akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <cstdio>
#include <string>
#include<cmath>
using namespace std;
int a[100005];
int b[100005];
int c[100005];
int main(){
int n;
long long sum=0,sum1=0;
cin>>n;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
	sum=sum+a[i];
}
c[1]=0;
for(int i=2;i<n;i=i+2)
{
	c[i+1]=c[i-1]+2*(a[i]-a[i-1]);
}
c[2]=c[n]+2*(a[1]-a[n]);
for(int i=3;i<n;i=i+2)
{
	c[i+1]=c[i-1]+2*(a[i]-a[i-1]);
}

for(int i=1;i<=n;i++)
{
	sum1=sum1+c[i]; 
}
int ave=(sum-sum1)/n;
b[1]=ave;
for(int i=1;i<=n;i++)
{
	b[i]=b[1]+c[i];
}
for(int i=1;i<=n;i++)
{
	cout<<b[i]<<" ";
}


    return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) throws IOException {
		try (AtCoderReader ar = new AtCoderReader()) {
			System.out.println(ar.nextLine().replaceFirst("2017", "2018"));
		}
	}

	public static class AtCoderReader implements AutoCloseable {
		private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public final String[] nextStringArray() throws IOException {
			return this.nextLine().split(" ");
		}

		public final Stream<String> nextStream() throws IOException {
			return Arrays.stream(this.nextStringArray());
		}

		public final IntStream nextIntStream() throws NumberFormatException, IOException {
			return this.nextStream().mapToInt(Integer::parseInt);
		}

		public final int[] nextIntArray() throws IOException {
			return this.nextIntStream().toArray();
		}

		public final int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextLine());
		}

		public final int nextInt(int radix) throws NumberFormatException, IOException {
			return Integer.parseInt(nextLine(), radix);
		}

		public final long nextBits() throws NumberFormatException, IOException {
			return Long.parseLong(nextLine().replaceAll(" ", ""), 2);
		}

		public final String nextLine() throws IOException {
			return this.br.readLine();
		}

		@Override
		public final void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 21332
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		final int INF = 1000000;
		char[][] s = new char[H][];
		for(int i=0; i<H; i++)
			s[i] = sc.next().toCharArray();
		
		int[][][] dp = new int[H][W][2];
		
		for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				Arrays.fill(dp[i][j], INF);
		
		if(s[0][0]=='.') {
			dp[0][0][0]=0;
		} else {
			dp[0][0][1]=1;
		}
		
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				if(i+1<H) {
					if(s[i+1][j]=='.') {
						dp[i+1][j][0] = Math.min(dp[i+1][j][0], dp[i][j][0]);
						dp[i+1][j][0] = Math.min(dp[i+1][j][0], dp[i][j][1]);
					} else {
						dp[i+1][j][1] = Math.min(dp[i+1][j][1], dp[i][j][1]);
						dp[i+1][j][1] = Math.min(dp[i+1][j][1], dp[i][j][0]+1);
					}
				}
				if(j+1<W) {
					if(s[i][j+1]=='.') {
						dp[i][j+1][0] = Math.min(dp[i][j+1][0], dp[i][j][0]);
						dp[i][j+1][0] = Math.min(dp[i][j+1][0], dp[i][j][1]);
					} else {
						dp[i][j+1][1] = Math.min(dp[i][j+1][1], dp[i][j][1]);
						dp[i][j+1][1] = Math.min(dp[i][j+1][1], dp[i][j][0]+1);
					}
				}
			}
		}
		
		System.out.println(Math.min(dp[H-1][W-1][0], dp[H-1][W-1][1]));
		
		sc.close();
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(360/gcd(x,360));
	}
	static int gcd(int a,int b) {
		if(b==0) return a;
		return gcd(b,a%b);
	}
}


Measured memory_bytes: 35584
x = gets
y = x.split
z = []

if y[0].to_i <= y[1].to_i

  if y[0].to_i <= y[2].to_i
    z[0] = y[0]
    if y[1].to_i <= y[2].to_i
      z[1] = y[1]
      z[2] = y[2]
    else
      z[1] = y[2]
      z[2] = y[1]
    end
  end

elsif y[0].to_i <= y[2].to_i
  z[0] = y[1]
  z[1] = y[0]
  z[2] = y[2]
elsif y[1].to_i <= y[2].to_i
  z[0] = y[1]
  z[1] = y[2]
  z[2] = y[0]
else
  z[0] = y[2]
  z[1] = y[1]
  z[2] = y[0]
end

puts z[0].to_s + " " + z[1].to_s + " " + z[2].to_s



Measured memory_bytes: 6872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int value;
		for(int i = 1;(value = Integer.parseInt(in.readLine())) != 0;i++){
			System.out.printf("Case %d: %d%n",i,value);
		}
	}
}

Measured memory_bytes: 46892
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = M.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto st = new SegmentTree(N+1);
    A.sort!"a[1] < b[1]";
    int ans = 0;

    foreach (a; A) {
        auto l = a[0];
        auto r = a[1];
        if (st.sum(l, r-1) > 0) {
            continue;
        }
        st.add(r-1, 1);
        ans += 1;
    }

    ans.writeln;
}

class SegmentTree {
    int[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new int[](size);
    }

    void add(int pos, int num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, int num, int i, int left, int right) {
        table[i] += num;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
    }

    int sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    int sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                sum(pl, pr, i*2+1, left, (left+right)/2) +
                sum(pl, pr, i*2+2, (left+right)/2+1, right);
    }
}


Measured memory_bytes: 12668
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

tmp = input().split()

H = [0]*N
Flag = [1]*N

for h in range(N):
    H[h] = int(tmp[h])

for i in range(M):
    tmp = input().split()
    A = int(tmp[0])-1
    B = int(tmp[1])-1
    if H[A] < H[B]:
        Flag[A] = 0
    if H[A] > H[B]:
        Flag[B] = 0
    if H[A] == H[B]:
        Flag[A] = 0
        Flag[B] = 0

print(sum(Flag))

Measured memory_bytes: 20928
#include <iostream>

using namespace std;

int main(){    
    int N;

    cin >> N;

    for(int i = 1; i <= 9; i++){
        if(N%i == 0 && N/i <= 9){
            cout << "Yes" << endl;
            exit(0);
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    Mtx = list(map(int, input().split()))
    
    showMtx(Mtx)
    for i in range(1,n):
        for j in range(i,0,-1):
            if Mtx[j] < Mtx[j-1]:
                Mtx[j-1], Mtx[j] = Mtx[j], Mtx[j-1]
            else:
                break
            # print(i, j, sep=', ')
        showMtx(Mtx)
                

def showMtx(Mtx):    
    q = len(Mtx)
    for i in range(q):
        if i != q - 1:
            print(Mtx[i], sep=' ', end=' ')
        else:
            print(Mtx[i])



if __name__ == '__main__':
    main()



Measured memory_bytes: 5972
#include <iostream>
using namespace std;

long ref(long i, long j){
    if(i%j==0) return j*(2*i/j-1);
    else return 2*j*(i/j)+ref(j, i%j);
}

int main() {
	long N, X; cin >> N >> X;
	cout << N+ref(X, N-X) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    FOR(i,1,n+1){
        if(i<n-i){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii              pair <ull,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 100010
#define psz 20
using namespace std;

ll w[maxl+3],val[maxl+3],n,w1,dp[110][maxl+2];

ll Dp(ll pos, ll weight)
{
    if(weight < 0LL) return -val[pos-1];
    if(weight == 0LL) return 0LL;
    if(pos == n) return 0LL;

    if(dp[pos][weight] != -1LL) return dp[pos][weight];
    ll max1=0LL,max2=0LL;

    max1 = val[pos]+Dp(pos+1LL,weight-w[pos]);
    max2= Dp(pos+1,weight);

    return dp[pos][weight]=max(max1,max2);
}

int main()
{
    scanf("%lld %lld",&n,&w1);
    memset(dp,-1,sizeof dp);
    for(int i=0; i<n; i++)
        scanf("%lld %lld",&w[i],&val[i]);

    printf("%lld\n",Dp(0LL,w1));

    return 0;
}

Measured memory_bytes: 86400
#include <iostream>
#include <algorithm>
using namespace std;

int p,q,a,n,b[10];
int search(int step, int mul){
    if(step>n){
        return 0;
    }
    
    int ret=0;
    for(int i=b[step-1]; i*mul<=a; i++){
        b[step] = i;
        int ev=0;
        for(int j=1; j<=step; j++){
            ev += mul*i*q/b[j];
        }
        if(ev == mul*i*p){
            ret++;
        }else if(ev > mul*i*p){
            continue;
        }else{
            ret += search(step+1, i*mul);
        }
    }
    return ret;
}

int main(){
    b[0]=1;
    while(1){
        cin >> p >> q >> a >> n;
        if(p==0) break;

        int ans = search(1,1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void)
{
    int N, i, count=0, min = 200002;
    int P[200001];

    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%d",&P[i]);
    }

    //自分より左側にある数の中で自分よりも小さいものが存在しない場合にカウントする
    for(i=0; i<N; i++){
        if(min > P[i]){
            count++;
            min = P[i];
        }
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

int main () {
  int a, b, c, d, N;
  cin >> a >> b >> c >> d >> N;
  vector<long> x = {4*a, 2*b, c}, y = {8*a, 4*b, 2*c, d};
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  long p = x.at(0), q = y.at(0);
  long ans;
  if (N%2 == 0) ans = q*(N/2);
  else ans = q*(N/2)+p;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for ( ll i = 1; i * i <= n; ++i ) {
        if ( n % i != 0 ) continue;
        if ( n / i - 1 <= i ) break;
        ans += n / i - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  string ans;
  for (int i=0; i < 3;i++) {
    if (n.at(i) == '7') {
      ans = "Yes";
      break;
    }
    else {
      ans = "No";
    }    
  }  
  cout << ans << endl;  
  return 0;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    set<ll> c;
    for(int i = 1; i*i <= sum; i++){
        if(sum % i == 0){
            c.insert(i);
            c.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x : c){
        ll need;
        vector<ll> r(n);
        rep(i,n) r[i] = a[i] % x;
        sort(r.begin(), r.end());
        ll tot = 0;
        rep(i,n) tot += r[i];
        int l = n - tot/x;
        need = 0;
        rep(i,l) need += r[i];
        if(need <= k) ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    ll W, H;
    cin >> W >> H;
    vector<pair<int,int>> cost;
    for(int i=0; i<W; i++){
        int p;  cin >> p;
        cost.push_back({p,0});
    }
    for(int i=0; i<H; i++){
        int p;  cin >> p;
        cost.push_back({p,1});
    }

    sort(cost.begin(), cost.end());
    W++;  H++;
    ll ans = 0;
    for(auto p:cost){
        if(p.second==0){
            ans += p.first*H;
            W--;
        }else if(p.second==1){
            ans += p.first*W;
            H--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	int a,b;cin>>a>>b;
	int mini=min(a,b);
	int maxi=max(a,b);
	for(int i=0;i<maxi;++i)
	{
		cout<<mini;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main (void) {
	int N, K;
	std::cin >> N >> K;
	std::string S;
	std::cin >> S;
	
	std::vector<int> cntVecT;
	if (S[0] == '0') {
		cntVecT.push_back(0);
	}
	
	int cnt = 0;
	char prev = S[0];
	for (char c : S) {
		if (c != prev) {
			cntVecT.push_back(cnt);
			cnt = 0;
		}
		prev = c;
		++cnt;
	}
	cntVecT.push_back(cnt);
	
	if (S[S.size() - 1] == '0') {
		cntVecT.push_back(0);
	}
	
	int range = K * 2 + 1;
	int max = 0;
	
	if (range >= cntVecT.size()) {
		for (int cnt : cntVecT) {
			max += cnt;
		}
	} else {	
		for (int i = 0; i < cntVecT.size() - range + 1; i += 2) {
			int sum = 0;
			for (int j = 0; j < range; ++j) {
				sum += cntVecT[i + j];
			}
			if (max < sum) {
				max = sum;
			}
		}
	}
	
	std::cout << max << std::endl;
	
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t n, sum = 0, ans = 0;
    cin >> n;
    vector<int64_t> a(n);
    map<int64_t, int64_t> cnt;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) cnt[0]++;
        sum += a[i], cnt[sum]++;
    }
    for (auto& elm : cnt) {
        if (elm.second >= 1)
            ans += elm.second * (elm.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17044
x1,y1,x2,y2 = map(int, input().split())
x3 = x2 -(y2-y1)
y3 = y2 +(x2-x1)
x4 = x2 -(y2-y1)-(x2-x1)
y4 = y2 +(x2-x1)-(y2-y1)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
n, q = map(int, input().split())

ab_list = [list(map(int, input().split())) for i in range(n-1)]
ab_list = sorted(ab_list)

ans = [0 for i in range(n)]

for i in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

for ab in ab_list:
    ans[ab[1]-1] += ans[ab[0]-1]

print(*ans)

Measured memory_bytes: 66724
N=int(input())

alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

a="a"

def dfs(n):
  if n == 1:
    return["a"]

  if n == 2:
    return["aa","ab"]
  else:
    characters = alphabets[0:n]
    result = []
    for r in dfs(n-1):#n=3の時は["aa","ab"]
      done = False
      for char in characters:#"a","b","c",,,
        if char in r:#char="a" が r="aa"に入っていたら
          result.append(r + char)#("aa"+"a"="aaa")
        else:#入っていないなら
          if not done:#もしdone=Falseなら
            result.append(r + char)#"aab"
            done =True
          else:
            break
    return result

print("\n".join(dfs(N)))

Measured memory_bytes: 12936
#include <bits/stdc++.h>
using namespace std;


int main(){
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

	int a,b,c;
	cin >> a >> b >> c;
	if(a!=b || a!=c){
		cout << "No";
	}
	else{
		cout << "Yes";
	}


	


 
 
	
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();

        int[][] points = new int[N][D];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                points[i][j] = sc.nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < N - 1; i++) {
            for (int j = i + 1; j < N; j++) {

                int sum = 0;
                for (int k = 0; k < D; k++) {
                    sum += Math.pow(points[i][k] - points[j][k], 2);
                }
                double distance = Math.sqrt(sum);
                int distanceInt = (int)distance;
                if (distance == distanceInt) {
                    ans++;
                }
            }
        }
        System.out.print(ans);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 21972
# ABC080C - Shopping Street
import sys
input = sys.stdin.readline

from itertools import product

def main():
    N = int(input())
    F = tuple(tuple(map(int, input().split())) for _ in range(N))
    P = tuple(tuple(map(int, input().split())) for _ in range(N))
    ans = []
    for b in tuple(product((0, 1), repeat=10))[1:]:
        cnt = 0
        for f, p in zip(F, P):
            opening = sum(b[i] == 1 and b[i] == f[i] for i in range(10))
            cnt += p[opening]
        ans += [cnt]
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	auto A = vector<int>(n);
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		A[i] = x;
	}
	sort(revAll(A));
	ll p = 0, comfort = A[0];
	for(int i = 2; i < n; i++){
		if(i%2 == 0){
			p++;
		}
		comfort += A[p]; 
	}
	cout << comfort << "\n";
}

Measured memory_bytes: 3940
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll nums[59];
vector<pii> ans;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    
    ll mx=0,idx=-1;
    rep(i,N){
        if(abs(mx)<abs(nums[i])) mx=nums[i],idx=i;
    }
    
    if(mx>=0){
        rep(i,N-1){
            while(nums[i]>nums[i+1]){
                nums[i+1]+=nums[idx];
                ans.push_back({idx,i+1});
                if(nums[i+1]>nums[idx]){
                    idx=i+1;
                }
            }
        }
    }else{
        for(int i=N-1;i>0;i--){
            while(nums[i-1]>nums[i]){
                nums[i-1]+=nums[idx];
                ans.push_back({idx,i-1});
                if(nums[i-1]<nums[idx]){
                    idx=i-1;
                }
            }
        }
    }
    
    cout1(ans.size())
    for(auto p:ans){
        cout2(p.first+1,p.second+1)
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
 	int a,b,c;
  cin >> a >> b >> c;
  	if (a<= c && c <= b)
      cout << "Yes" << endl;
 else if (a >= c && c >= b)
   cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)

int main(){
	int n;
	while(cin>>n,n){
		vector<map<int,int> > v(n);
		// cout<<-1<<endl;
		rep(i,n){
			int m;
			cin>>m;
			rep(j,m){
				int t;
				cin>>t;
				v[i][t]=1;
			}
		}
		int r;
		cin>>r;
		// cout<<r<<endl;
		vector<int> s(r);
		rep(i,r){
			cin>>s[i];
		}
		int ans=0;
		bool f2=false;

		rep(i,n){
			bool f=true;
			rep(j,s.size()){
				if(v[i][s[j]]==1);
				else{
					f=false;
					// cout<<"hoge\n";
					break;
				}
			}
			if(f){
				if(ans==0){
					ans=i+1;
				}
				else{
					f2=true;
					break;
				}
			}
		}
		if(f2||ans==0) cout<<-1<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

double dp[3005][3005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		double p;
		cin >> p;
		for(int j = 0; j < i; j++){
			dp[i][j + 1] += dp[i - 1][j] * p;
			dp[i][j] += dp[i - 1][j] * (1 - p);
		}
	}
	double res = 0.0;
	for(int i = (n / 2) + 1; i <= n; i++) res += dp[n][i];
	cout << setprecision(10) << res << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 68992
#include <cstdio>
typedef long long ll;
char str[15]; 
inline bool query(ll x)
{
	printf("? %lld\n", x);
	fflush(stdout); 
	scanf("%s", str); 
	return str[0] == 'Y'; 
}
int main()
{
	ll x = 1e9, ans; 
	while (!query(x))
		x /= 10; 
	if (x == 1e9)
	{
		ans = 1; 
		while (!query(ans + 1))
			ans *= 10; 
	}
	else
	{
		int l = x, r = x * 10 - 1; 
		while (l <= r)
		{
			int m = l + r >> 1; 
			if (query((ll)m * 10))
			{
				ans = m; 
				r = m - 1; 
			}
			else
				l = m + 1; 
		}
	}
	printf("! %lld\n", ans);
	return 0; 
}


Measured memory_bytes: 504
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;

int main(){
   
    ll n;
    cin>>n;
    ll ans=0;
    vector<ll> v;
    
    rep(i,n){
        ll a;
        cin>>a;
        v.push_back(a);
    }
    vector<int> s;
    
    for(ll i=0;i<n;i++){
        if(v[i]==i+1&&v[i+1]==i+2){
            ans++;
            i=i+1;
        }else if(v[i]==i+1){
            ans++;
        }
       
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1400
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
A.push(0)
A.unshift(0)
sum = 0
balance = Array.new(N,0)
1.upto(A.length-1) do |n|
	sum += (A[n-1]-A[n]).abs
	if n<balance.length+1
		balance[n-1] = (A[n-1]-A[n+1]).abs-((A[n-1]-A[n]).abs+(A[n]-A[n+1]).abs)
	end
end
balance.each do |b|
	p b+sum
end

Measured memory_bytes: 17932
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int a,b;

int main(){
    cin>>a>>b;
    cout<<6-a-b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  int N = int(s.size());
  vector<int> d(N+1);
  int ten = 1;
  for (int i = N-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % 2019;
    d[i] = (d[i+1]+a) % 2019;
    ten *= 10; ten %= 2019;
  }
  vector<int> cnt(2019);
  ll ans = 0;
  for (int i = N; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    VVI mas(N, VI(5));
    REP(i, N)REP(j, 5) {
        scanf("%d", &mas[i][j]);
    }
    int ans = 0;
    while (true) {
        bool Flag = false;
        REP(i, N)REP(j, 3) {
            int def = mas[i][j];
            if (def == 0) continue;
            int renzoku = 0;
            bool f = false;
            for (int k = j + 1; k < 5; k++) {
                if (def != mas[i][k]) {
                    renzoku = k - j;
                    break;
                }
                if (k == 4) f=true; 
            }
            if (f) renzoku = 5 - j;
            if (renzoku >= 3) {
                Flag = true;
                ans += def * renzoku;
                for (int k = j; k < j + renzoku; k++) {
                    mas[i][k] = 0;
                }
            }
        }
        if (!Flag) break;
        REP(_, N + 10) {
            FOR(i, 1, N) {
                REP(j, 5) {
                    if (mas[i][j] == 0) {
                        mas[i][j] = mas[i - 1][j];
                        mas[i - 1][j] = 0;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int lcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) {
    return a;
  } else {
    return lcd(b, a % b);
  }
}


int main() {
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; ++i) {
    cin >> B[i];
  }
  int result = B[0];
  for (int i = 1; i < N - 1; ++i) {
    result += min(B[i - 1], B[i]);
  }
  result += B[N - 2];
  cout << result << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n = int(input())
a = [int(_) for _ in input().split()]
left, right, ans = ([0], [0], 0)

for i in range(n):
    left.append(fractions.gcd(left[i], a[i]))
    right.append(fractions.gcd(right[i], a[n-i-1]))

for i in range(n):
    g = fractions.gcd(left[i], right[n-i-1])
    if ans < g:
        ans = g

print(ans)


Measured memory_bytes: 16060
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
ans=0
for A in range(1,N):
    ans+=(N-1)//A
print(ans)

Measured memory_bytes: 68028
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_N (1000000)
#define MAX_Q (75)
#define SIZE_BUF (30)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  char S[MAX_N + 2], buf[SIZE_BUF];
  int N, Q;
  int ks[MAX_Q];
  scanf("%d", &N);
  fgets(buf, SIZE_BUF, stdin);
  fgets(S, MAX_N + 2, stdin);
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++)
    scanf("%d", &ks[i]);

  // count number of ms up to each index
  int acc_num_ms[MAX_N + 1];
  acc_num_ms[0] = 0;
  for (int i = 1; i <= N; i++)
    acc_num_ms[i] = acc_num_ms[i - 1] + (S[i - 1] == 'M' ? 1 : 0);

  // solve for each k
  for (int q = 0; q < Q; q++) {
    const int k = ks[q];
    int num_ds = 0;
    long num_dm_pairs = 0, ans = 0;
    // look through each character
    for (int i = 0; i < N; i++) {
      // check for out of range ds and remove if them
      // only one element becomes invalid at a time
      if (i >= k && S[i - k] == 'D') {
        num_dm_pairs -= acc_num_ms[i] - acc_num_ms[i - k + 1];
        num_ds--;
      }

      // check the current character and act accordingly
      if (S[i] == 'D') {
        // update num_dm_pairs
        num_ds++;
      } else if (S[i] == 'M') {
        // update num_dm_pairs
        num_dm_pairs += num_ds;
      } else if (S[i] == 'C') {
        // increment number of triplets
        ans += num_dm_pairs;
      }
    }
    printf("%ld\n", ans);
  }
  
  return 0;
}


Measured memory_bytes: 4992
#include <cstdio>

int main(void)
{
    int a, b, c, num=0;
    scanf("%d %d %d", &a, &b, &c);
    for(int i=a; i<=b; i++)
        if((c%i) == 0) num++;
    printf("%d\n", num);

    return 0;
}


Measured memory_bytes: 2760
s = input()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

pair<int, int> segment[maxn];
int N;
pair<int, int> p[maxn];
int suffix[maxn];

signed main(void){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define L first
#define R second
	cin >> N;
	int a = 0, b = suffix[N+1] = 1e9+5;
	for (int i=1; i<=N; ++i){
		cin >> segment[i].L >> segment[i].R;
		a = max(a, segment[i].L);
		b = min(b, segment[i].R);
	}
	int ans = 0;
	for (int i=1; i<=N; ++i){
		ans = max(ans, max(0, b-a+1) + segment[i].R - segment[i].L + 1);
		p[i] = mp(max(0, segment[i].R - a + 1), max(0, b - segment[i].L + 1));
	}
	sort(p+1, p+1+N); reverse(p+1, p+1+N);
	for (int i=N; i>=1; --i)
		suffix[i] = min(suffix[i+1], p[i].second);
	for (int i=1; i<N; ++i)
		ans = max(ans, p[i].fi + suffix[i+1]);
	cout << ans << '\n';
#undef L
#undef R
}


Measured memory_bytes: 2176
n = int(input())
h = str(input())
h = list(h)
h2 = []
def mojiretu(n, h):
    h2.append(h[0])
    for i in range(1, len(h)):
            if h[i] != h[i - 1]:
                h2.append(h[i])
    return len(h2)
print(mojiretu(n,h))

Measured memory_bytes: 4652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
void sor(vel &v) {
	sort(v.begin(), v.end());
}
int ser(vel &v, int tan) {
	int si = v.size() - 1;
	if (tan == v[si]) {
		return si;
	}
	int lo = 0;
	int up = si;
	while (up - lo > 1) {
		int mi = (lo + up) / 2;
		if (v[mi] <= tan) {
			lo = mi;
		}
		else {
			up = mi;
		}
	}
	return lo;
}
signed main() {
	int n, m;
	cin >> n >> m;
	vvvel ma(2, vvel(n+1, vel(m+1, 0)));
	string ss, tt;
	cin >> ss >> tt;
	vel s(n, 0);
	vel t(m, 0);
	for (int i = 0; i < n; i++) {
		if (ss[n - 1 - i] == 'I') {
			s[i] = 1;
		}
	}
	for (int i = 0; i < m; i++) {
		if (tt[m - 1 - i] == 'I') {
			t[i] = 1;
		}
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i > 0) {
				if (ma[(s[i - 1] + 1) % 2][i - 1][j] != 0 or s[i-1]==1) {
					ma[s[i - 1]][i][j] = ma[(s[i - 1] + 1) % 2][i - 1][j] + 1;
				}
			}
			if (j > 0) {
				if (ma[(t[j - 1] + 1) % 2][i][j - 1] != 0 or t[j - 1] == 1) {
					mmax(ma[t[j - 1]][i][j], ma[(t[j - 1] + 1) % 2][i][j - 1] + 1);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			mmax(ans, ma[1][i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 96896
#define pb push_back
#define ll long long
#define maxn 30000000
#include <bits/stdc++.h>
using namespace std;

int arr[1000006], dp[1000006], n, k;

int rec(int pos){
    if(dp[pos] != -1) return dp[pos];
    if(pos >= n) return 0;
    int res = INT_MAX;
    for(int i=1;i<=k;i++){
        if(pos+i <= n){
            res = min(res, abs(arr[pos] - arr[pos+i]) + rec(pos+i) );
        }
    }
    return dp[pos] = res;
}


int main() {
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    cout << rec(1) << endl;


    return 0;
}


Measured memory_bytes: 11008
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	if (n == 0)
		cout << 1 << endl;
	if (n == 1)
		cout << 2 << endl;
	if (n == 2)
		cout << 1 << endl;
	if (n >=3)
		cout << 0 << endl;
}

Measured memory_bytes: 3104
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let (_n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    // 数値テーブル
    let a = read::<usize>();
    let mut min = 9999999;
    for x in &a {
        if *x < min {
            min = *x;
        }
    }

    let mut count = 0;
    for x in &a {
        if *x != min {
            count += 1;
        }
    }
    let ans = if count % (k - 1) == 0 {
        count / (k - 1)
    } else {
        count / (k - 1) + 1
    };

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W;

    while(1) {
        cin >> H >> W;
        if (H == 0 && W == 0) break ;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i != 0) && (i != H -1) && (j != 0) && (j != W - 1))  {
                    cout << '.';
                } else {
                    cout << '#';    
                }
                
            }
            cout << "\n";
            
            
        }
        cout << endl;
    }
    
    // cout << min << " " << max << " " << sum << endl;
    
    
    return 0;
}

Measured memory_bytes: 1152
//file_name:ABC64_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);



    int ans = a*100+b*10+c;
    if(ans%4==0)yn

    //cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n = input()
d = set()
pre = ""
for i in range(n):
    s = raw_input()
    if s in d:
        print "No"
        exit()
    if pre == "" or pre[-1] == s[0]:
        d.add(s)
        pre = s
    else:
        print "No"
        exit()
print "Yes"

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int x,a,b;
    cin>>x;
    a=x%100;
    b=x/100;
    if(a<=b*5) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int k,s;
  cin>>k>>s;
  int count=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0&&s-i-j<=k)  count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
int s[31]={};
for(int i=0;i<28;i++)
{
int h;
cin>>h;
s[h]=1;
}
for(int i=1;i<31;i++)
{
if(s[i]==0)cout<<i<<endl;
}
return 0;
}

Measured memory_bytes: 1164