akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int sl=s.length(),tl=t.length();
    int dp[sl+1][tl+1];
    for(int i=0;i<=s.length();i++){
    	for(int j=0;j<=t.length();j++){
    		dp[i][j]=0;
    	}
    }
    for(int i=0;i<s.length();i++){
    	for(int j=0;j<t.length();j++){
    		if(s[i]==t[j]){
    			dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
    		}
    		else{
    			int tmp=max(dp[i+1][j],dp[i][j+1]);
    			dp[i+1][j+1] = max(dp[i+1][j+1],tmp);
    		}
    		dp[i][j+1] = max(dp[i][j+1],dp[i][j]);
    		dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
    	}
    }
    /*for(int i=0;i<=s.length();i++){
    	for(int j=0;j<=t.length();j++){
    		cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    	}
    }*/
    //cout<<dp[s.length()][t.length()]<<endl;
    int index = dp[s.length()][t.length()];
    char lcs[index+1];
    lcs[index]='\0';
    int i=sl,j=tl;
    while(i>0 && j>0){
    	if(s[i-1]==t[j-1]){
    		lcs[index-1]=s[i-1];
    		i--;j--;index--;
    	}
    	else if (dp[i-1][j] > dp[i][j-1]){
         	i--; 
    	}
		else{
		 	j--; 
		}
    }
    cout<<lcs;
    return 0;
}

Measured memory_bytes: 73980
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,k;
    cin>>n>>k;
    vl p(n), q(n,0);
    FOR(i,0,n){
        cin>>p[i];
    }
    FOR(i,0,k){
        q[k-1]+=(p[i]+1);
    }
    LL mx=q[k-1],idx=k-1;
    FOR(i,k,n){
        q[i]=q[i-1]+p[i]-p[i-k];
        if(mx<q[i]){
            mx=q[i];
            idx=i;
        }
    }
    cerr<<1.*mx/2<<endl;
    if(mx&1){
        cout<<mx/2<<".5"<<endl;
    }else{
        cout<<mx/2;
    }


}


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

typedef long long LL;

LL a, b, c, d, t;

int main() {
	cin>>a>>b>>c>>d>>t;
	if((b - d)*t < abs(a - c)) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return 0;
}

Measured memory_bytes: 3636
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
template<class T> void MIN(T& a, const T& b) { a = min(a, b); }
template<class T> void MAX(T& a, const T& b) { a = max(a, b); }

#define MULTITEST 1
#include <atcoder/all>

using namespace atcoder;

void solve() {
    int N, M, A, B;
    R(N, M, A, B);

    W(floor_sum(N, M, A, B));
}

int main() {
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int A = sc.nextInt()-1;
		int B = sc.nextInt()-1;
		int C = sc.nextInt()-1;
		int D = sc.nextInt()-1;
		char[] s = sc.next().toCharArray();
		boolean ok = true;
		int ff = can(s, A, C);
		int ss = can(s, B, D);
		if (ff == 0 || ss == 0) ok = false;
		if (D < C) {
			if (ss < 2) ok = false;
		}
		out.println(ok ? "Yes" : "No");
		
		out.flush();
	}
	
	static int can(char[] s, int from, int to) {
		boolean ok = false;
		for (int i = from; i <= to; i++) {
			if (i+1 <= to && s[i] == '#' && s[i+1] == '#') return 0;
			if (i-1 >= 0 && i+1 < s.length && s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') ok = true;
		}
		return ok ? 2 : 1;
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    int n,m;
    int n1=10,n2=10,n3=10;
    cin >> n >> m;
    int output = 0;
    for (int i = 0; i < m; i++){
        int k,l;
        cin >> k >> l;
        if(k==1&&n1!=10&&n1!=l){
            output = -1;
        }else if(k==1){
            n1=l;
        }else if(k==2&&n2!=10&&n2!=l){
            output = -1;
        }else if(k==2){
            n2=l;
        }else if(k==3&&n3!=10&&n3!=l){
            output = -1;
        }else if(k==3){
            n3=l;
        }
    }
    if(n!=1&&n1==0){
        output = -1;
    }
    if(n1==10&&n==1){
        n1=0;
    }else if(n1==10&&n!=1){
        n1=1;
    }
    if(n2==10){
        n2=0;
    }
    if(n3==10){
        n3=0;
    }
    
    if(output == -1){
    }else{
        if(n == 1){
            output = n1;
        }else if(n == 2){
            output = 10* n1 + n2;
        }else {
            output = 100*n1 + 10*n2 + n3;
        }
    }
    cout << output << endl;
}

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

#define MAX 100000
#define INF (1<<29)

vector<int> G[MAX];
list<int> out; //やるべき仕事の順番に入ってるリスト
bool V[MAX]; //仕事が完了したかどうかを示す配列
int N; //仕事の数
int indeg[MAX]; //ノードiに入ってくる有向辺の数

void bfs(int s) {
  queue<int> q;
  q.push(s); //最初のノードをキューに入れる
  V[s] = true;

  while (!q.empty()) {
    int u = q.front(); q.pop();
    out.push_back(u);

    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i]; //隣接するノード
      indeg[v]--;
      if (indeg[v] == 0 && !V[v]) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for (int i = 0; i < N; i++) {
    indeg[i] = 0;
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      int v = G[i][j];
      indeg[v]++;
    }
  }

  for (int u = 0; u < N; u++) {
    if (indeg[u] == 0 && !V[u]) bfs(u);
  }

  for (auto it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for (int i = 0; i < N; i++) { V[i] = false; }

  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();

  return 0;
}



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

typedef long long ll;
using namespace std;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll ops = floor(N/(A+B));

    ll sol = A * ops;
    ll rem = N % (A+B);

    cout << sol + min(A, rem) << endl;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout<<"Bad"<<endl;
        return 0;
    }
    cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ci const int&	
using namespace std;
const int m=1e7;
int n,a[110],p[210],sz,ip[m+10],pr[m+10],p1[210],p2[210],nw[210],n1,n2,pn;
vector<int>t[210];
bool Match(ci x){
	for(int i=nw[x]+1;i<t[x].size();++i)if(!p2[t[x][i]]||Match(p2[t[x][i]]))return p2[t[x][i]]=x,nw[x]=i,true;
	return false;
}
int main(){
	ip[1]=1;
	for(int i=2;i<=m;++i){
		if(!ip[i])pr[++sz]=i;
		for(int j=1;j<=sz&&i*pr[j]<=m;++j){
			ip[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	scanf("%d",&n),a[0]=-1,sz=0,ip[2]=1;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		if(a[i]-1!=a[i-1])p[++sz]=a[i],a[i]&1?++n1:++n2;
		if(a[i]+1!=a[i+1])p[++sz]=a[i]+1,a[i]&1?++n2:++n1;
	}
	for(int i=1;i<=sz;++i)for(int j=i+1;j<=sz;++j)if(!ip[p[j]-p[i]])p[i]&1?t[i].push_back(j):t[j].push_back(i);
	for(int i=1;i<=sz;++i)if(p[i]&1)nw[i]=-1,pn+=Match(i);
	printf("%d",pn+2*(n1-pn>>1)+2*(n2-pn>>1)+3*(n1-pn&1));
	return 0;
}

Measured memory_bytes: 43648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    string a;
    cin >> a;
    if(a[0]==a[1]&&a[1]==a[2])cout << "Yes" << endl;
    else if(a[1]==a[2]&&a[2]==a[3])cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
// Ver19.03
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    int p;
    scanf("%d", &p);
    if (p != i + 1)
      cnt++;
    if (cnt > 2)
    {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int N, K;
vector<int>A;

int main()
{
	
	cin >> N;
	cin >> K;

	A = vector<int>(N + 1);
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		sum += A[i];
	}

	set<int> sumcd;
	int s = 2;
	while ( s * s <= sum) {
		if (sum % s == 0) {
			sumcd.insert(s);
			sumcd.insert(sum/s);
		}
		s++;
	}
	sumcd.insert(sum);

	int ans = 1;
	for (auto it = sumcd.rbegin(); it != sumcd.rend(); it++) {
		int g = *it;
		vector<int>remainder_list;
		for (int i = 1; i <= N; i++) {
			int r = A[i] % g;
			if (r>0) {
				remainder_list.push_back(r);
			}
		}
      
      	sort(remainder_list.begin(), remainder_list.end());

		int p = 0;
		int m = (int)remainder_list.size()-1;
		int libra = 0;
		int k = 0;
		while (p <= m && k <= K) {
			if (libra <= 0) {
				libra += remainder_list[p];
				k += remainder_list[p];
				p++;
			}
			else{
				libra += -g + remainder_list[m];
				m--;
			}
		}

		if (k <= K) {
			ans = g;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int R;
  
  cin >> N >> R;
  
  if (N >= 10) {
    cout << R;
  }
  
  else {
    R = R + 100 * (10 - N );
    cout << R;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <memory.h>

using namespace std;

#define INF 0x3f3f3f3f

int dist[1005][1005]; 
int goal[55];
char map[1005][1005];
int w, h, n;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int ans;

int bfs(int x, int y)
{
    int sx = x;
    int sy = y;
    int res = 0;
    memset(goal, 0, sizeof(goal));
	for(int i = 1; i <= 10; ++i)
	{
		memset(dist, 0x3f, sizeof(dist));
	    dist[sy][sx] = 0;
        //map[sy][sx] = '.';
        queue<P> q;
        q.push(P(sx, sy));
        P tmp;
        while(!q.empty())
        {
            tmp = q.front();
            q.pop();
            if(map[tmp.second][tmp.first] == '0'+i)
            {
                goal[i] = dist[tmp.second][tmp.first];
                sy = tmp.second;
                sx = tmp.first;
        	    ans += dist[tmp.second][tmp.first];
		    }    
            for(int i = 0; i < 4; ++i)
            {
                int tx = tmp.first + dx[i];
                int ty = tmp.second + dy[i];
                if(tx >= 0 and tx < w and ty >= 0 and ty < h and map[ty][tx] != 'X' and dist[ty][tx] == INF)
                {    
			    	q.push(P(tx, ty));
			    	dist[ty][tx] = dist[tmp.second][tmp.first] + 1;
			    } 
            }
        }
        res += goal[i];
	}
    return res;
}

int main()
{
    cin>>h>>w>>n;
    int sx = 0, sy = 0;
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
        {
            cin>>map[i][j];
            if(map[i][j] == 'S')
            {
                sx = j;
                sy = i;
            }
        }
			
    cout<<bfs(sx, sy)<<endl;
}



Measured memory_bytes: 7972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	int map[];

	void run() {
		int n = sc.nextInt();
		sc.nextLine();
		
		map = new int[n + 1];
		int q0 = query(0);
		map[n] = q0;
		if (q0 == 0) {
			return;
		}
		rec(0, n);

	}

	int query(int pos) {
		if (map[pos] == 0) {
			System.out.println(pos);
			System.out.flush();
			String s = sc.nextLine();
			switch (s) {
			case "Male":
				map[pos] = 1;
				break;
			case "Female":
				map[pos] = -1;
				break;
			}
		}
		return map[pos];
	}

	void rec(int left, int right) {

		int ll = query(left);
		int rr = query(right);

		int mid = (right + left) / 2;
		int mm = query(mid);
		if(mm == 0){
			return;
		}

		int len1 = mid - left;
		int len2 = right - mid;
		
		boolean leftMustContain = ((len1 % 2) == 0) ^ (ll == mm);
		boolean rightMustContain = ((len2 % 2) == 0) ^ (mm==rr);

		if (leftMustContain && rightMustContain) {
			if (len1 < len2) {
				rec(left, mid);
			} else {
				rec(mid, right);
			}
		} else if (leftMustContain) {
			rec(left, mid);
			return;
		} else if (rightMustContain) {
			rec(mid, right);
			return;
		} else {
			rec(left, mid);
			rec(mid, right);
		}
	}
}


Measured memory_bytes: 24260
#include<bits/stdc++.h>
using namespace std;
# define PI           3.14159265358979323846
int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
map<int,int> mp;
  for(int i=0;i<n;i++){
    mp[i]=0;}
  for(int i=0;i<n-1;i++){
  cin>>vec[i];
  mp[vec[i]]++;
}
for( auto i : mp){
  if(mp.find( i.first+1)!=mp.end()){
     cout<<mp[i.first+1]<<"\n";
  }else
  cout<<"0\n";
}
}


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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

int main() {
  int x;
  cin >> x;
  
  cout << (x == 0 ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************

int main(void) {

	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for(auto & a: A) {
		cin >> a;
	}

	vector<int> dp(K + 1, 0);
	dp[0] = -1;

	FOR(i, 1, K+1) {
		bool flag = true;
		for (auto& a : A) {
			if (i < a) continue;
			if (dp[i - a] != -1) continue;

			dp[i] = a;
			flag = false;
			break;
		}
		if (flag) dp[i] = -1;
	}

	if (dp[K] != -1) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    vi vec(4);
    REP(i,4){
        vec[i]=stoi(st.substr(i,1));
        cerr<<vec[i]<<endl;
    }
    REP(i,2){
        REP(j,2){
            REP(k,2){
            int sum=vec[0];
            if(i)sum+=vec[1];
            else sum-=vec[1];
            if(k)sum+=vec[3];
            else sum-=vec[3];
            if(j)sum+=vec[2];
            else sum-=vec[2];
            if(sum==7){
                    cout<<vec[0]<<(i?'+':'-')<<vec[1]<<(j?'+':'-')<<vec[2]<<(k?'+':'-')<<vec[3]<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    G = [[] for _ in range(N)]
    for i in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        G[A].append(B)
        G[B].append(A)

    ans = 0
    for i in range(N):
        good = True
        for p in G[i]:
            if not H[i] > H[p]:
                good = False
        ans += 1 if good else 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29444
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	vector<int> P;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		P.push_back(p);
	}

	sort(P.begin(), P.end());

	int total = 0;
	for (int i = 0; i < K; i++) {
		total += P[i];
	}
	cout << total << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int main() {
  int64_t N,ans=0,k=1; cin>>N;
  N--;
  while(k<=N){
    ans+=(N/k);
    k++;
  }
  cout<<ans;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n,s;cin>>n>>s;
  ll i;
  ll ans=-1;
  if(s==n)ans=n+1;
  ll upper=n;
  ll lower=n+1;
  ll now=1;
  while(now*now<n)
  {
    upper=lower-1;
    lower=n/(now+1)+1;
    ll ups=now+n%upper;
    ll los=now+n%lower;
    if(upper==lower)
    {
      if(ups==s)ans=upper;
    }
    else
    {
      ll dis=(los-ups)/(upper-lower);
      if(s<=los&&s>=ups&&(s-ups)%dis==0)
      {
        ll num=(s-ups)/dis;
        ans=upper-num;
      }
    }
    now++;
  }
  for(i=lower;i>=2;i--)
  {
    int count=0;
    ll left=n;
    while(left>0)
    {
      count+=left%i;
      left/=i;
    }
    if(count==s)
    {
      ans=i;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 1; i <= S.size(); i++) {
    	for (int j = 0; j < S.size() - i + 1; j++) {
    		bool ACGT = true;
    		for (int k = 0; k < i; k++) {
    			if (S.at(j + k) != 'A' && S.at(j + k) != 'C' && S.at(j + k) != 'G' && S.at(j + k) != 'T') {
    				ACGT = false;
    			}
    		}
    		if (ACGT) ans = i;
    	}
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y; cin>>x>>y;

    if (y % 2) {
        cout<<"No"<<endl;
        return 0;
    }
    if (2 * x <= y && 4 * x >= y) {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3644
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

int n;
long long a[101010];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n;

	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i & 1) sum -= a[i] * 2;
		else sum += a[i] * 2;
	}

	sum /= 2;
	cout << sum;
	for (int i = 1; i < n; i++) {
		sum = a[i - 1] * 2 - sum;
		cout << ' ' << sum;
	}
	cout << '\n';

	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 1e5 + 10;
const int M_MAX = 1e5 + 10;
vector<int> G[N_MAX];
vector<int> tree[N_MAX];
vector<int> d(N_MAX,0);

class UnionFind{
  private:
    vector<int> Parent;
  public:
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    int find(int x){
      if(Parent[x]<0)return x;
      return Parent[x] = find(Parent[x]);
    }

    int size(int x){
      return -Parent[find(x)];
    }

    bool unite(int x, int y){
      x = find(x);
      y = find(y);
      if(x==y)return false;

      if(x<y)swap(x,y);
      Parent[x] += Parent[y];
      Parent[y] = x;
      return true;
    }

    bool same(int x, int y){
      return find(x) == find(y);
    }
};


void dfs(int cur,int pare){
  for(int &e : tree[cur]){
    if(e == pare)continue;
    dfs(e,cur);
  }
  if(pare!=-1){
    if(d[cur]&1){
      cout << cur SP pare << endl;
      ++d[cur];
    }else{
      cout << pare SP cur << endl;
      ++d[pare];
    }
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  rep(i,M){
    int x,y;cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if(M&1){
    cout << -1 << endl;
    return 0;
  }

  //全域木を作る
  set<PII> st;
  queue<int> que;
  que.push(1);
  UnionFind uni = UnionFind(N+1);
  while(uni.size(1) != N){
    int x = que.front();que.pop();
    for(int &e : G[x]){
      if(uni.same(e,x))continue;
      uni.unite(e,x);
      que.push(e);
      tree[x].push_back(e);
      tree[e].push_back(x);
      st.insert(PII(x,e));
    }
  }

  //木以外の辺を適当につける
  rep(x,N){
    for(int &e :G[x]){
      if(st.count(PII(e,x)) || st.count(PII(x,e)))continue;
      st.insert(PII(e,x));
      cout << e SP x << endl;
      ++d[e];
    }
  }

  //木の辺をつける
  dfs(1,-1);
  return 0;
}


Measured memory_bytes: 20224
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[0] > '1' || (s[0] == '0' && s[1] == '0') || (s[0] == '1' && s[1] > '2')) {
        if (s[2] > '1') {
            cout << "NA" << endl;
            return;
        } else if (s[2] < '1') {
            if (s[3] == '0') {
                cout << "NA" << endl;
                return;
            } else {
                cout << "YYMM" << endl;
                return;
            }
        } else {
            if (s[3] <= '2') {
                cout << "YYMM" << endl;
                return;
            } else {
                cout << "NA" << endl;
                return;
            }
        }
    } else {
        if (s[2] > '1') {
            cout << "MMYY" << endl;
            return;
        } else if (s[2] < '1') {
            if (s[3] == '0') {
                cout << "MMYY" << endl;
                return;
            } else {
                cout << "AMBIGUOUS" << endl;
                return;
            }
        } else {
            if (s[3] <= '2') {
                cout << "AMBIGUOUS" << endl;
                return;
            } else {
                cout << "MMYY" << endl;
                return;
            }
        }        
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int n;
string s;
set<int> r[10];

bool can(int a, int b, int c) {
	if(r[a].empty()) return false;

	int i = *r[a].begin();

	auto it = r[b].upper_bound(i);
	if(it == r[b].end()) return false;

	int j = *it;
	auto jt = r[c].upper_bound(j);
	if(jt == r[c].end()) return false;
	return true;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> s;
	rep(i,0,n) {
		int c = s[i] - '0';
		r[c].insert(i);
	}
	int ret = 0;
	rep(i,0,10) rep(j,0,10) rep(k,0,10) {
		if(can(i,j,k)) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin>>N;
     vector<int> W(N);
   for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  int ans =1000000000;
  for (int i = 0; i < N; i++) {
  int S1=0;
  int S2=0;
  for (int j = 0; j < i; j++) {
  S1 += W[j];
  }
  for (int j = i; j < N; j++) {
 S2 += W[j];
}
   ans= min(ans,abs(S1-S2));
  }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  ll int x;
  cin>>x;
  vector<ll int> y(2);
  y[0]=1;
  y[1]=x;
  rep(i,2,ceil(sqrt(x))+1){
    if(x%i==0){
      y.push_back(i);
      y.push_back(x/i);
    }
  }
  if(y.size()%2){
    cout<<(sqrt(x)-1)*2;
  }else{
    asort(y);
    cout<<y[y.size()/2-1]+y[y.size()/2]-2;
  }
    
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w, d;
  cin >> h >> w >> d;
  
  int a;
  vector<pair<int, int>> x(h * w);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a;
      x.at(a - 1) = make_pair(i, j);
    }
  }
  
  vector<int> y(h * w, 0);
  for(int i = 0; i < h * w; i++){
    if(i < d) continue;
    y.at(i) = y.at(i - d) + abs(x.at(i).first - x.at(i - d).first) + abs(x.at(i).second - x.at(i - d).second);
  }
  
  int q;
  cin >> q;
  
  int l, r;
  for(int i = 0; i < q; i++){
    cin >> l >> r;
    cout << y.at(r - 1) - y.at(l - 1) << '\n';
  }
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		int len = S.length();
		String h1 = S.substring(0, (len - 1) / 2);
		String h2 = S.substring(((len + 3) / 2) - 1, len);

		if (isPalindrome(S) && isPalindrome(h1) && isPalindrome(h2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static boolean isPalindrome(String s) {
		int n = s.length();
		for (int i = 0; i < n / 2; i++) {
			if (s.charAt(i) != s.charAt(n - i - 1)) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

#define vin(v, N) for (long long i = 0; i < N; i++) cin >> v.at(i)
#define lin(n) long long n; cin >> n
#define chin(x) char x; cin >> x;
#define sin(s) string s; cin >> s;
#define vlin(v, N) vector<long long> v(N); for (long long i = 0; i < N; i++) cin >> v.at(i)

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

bool board[8][8];

bool check(vector<int> ind){
    for(int i = 0; i < 8; ++i){
        for(int j = i+1; j < 8; ++j){
            if(abs(ind[i] - ind[j]) == j - i) return false;
        }
    }
    return true;
}

void setup(){
    for(int i = 0; i < 8; ++i){
        for(int j = 0; j < 8; ++j){
            board[i][j] = false;
        }
    }
}

int main(){
    int N;
    cin >> N;
    int r[N], c[N];
    for(int i = 0; i < N; ++i) cin >> r[i] >> c[i];

    vector<int> ind(8);
    for(int i = 0; i < 8; ++i) ind[i] = i;
    do{
        setup();
        bool ok = true;
        for(int i = 0; i < N; ++i){
            if(ind[r[i]] != c[i]) ok = false;
        }
        if(!ok) continue;
        for(int i = 0; i < 8; ++i) board[i][ind[i]] = true;
        if (check(ind)){
            for(int i = 0; i < 8; ++i){
                for(int j = 0; j < 8; ++j){
                    if(board[i][j]) cout << 'Q';
                    else cout << '.';
                }
                cout << endl;
            }
            return 0;
        }
    } while (next_permutation(ind.begin(), ind.end()));
    return 0;
}



Measured memory_bytes: 3164
import Data.List

erst :: Int->([Int],[Int])->[Int]
erst nmax (tosearch, primes)
    | x*x >= nmax  = sort $ primes' ++ tosearch'
    | otherwise    = erst nmax (tosearch', primes')
    where
        x = head tosearch
        tosearch' = [n|n<-(tail tosearch),(n`mod`x)/=0]
        primes' = primes ++ [x]

nmax = 104729 :: Int -- 10000th prime
primes = erst nmax (filter odd [3..nmax], [2])

s :: Int->Int
s n = sum $ take n primes

solve :: String->IO ()
solve str = do
    let n = read str :: Int
    if n==0 then return () else print (s n) 

main :: IO ()
main = do
    str <- getContents
    mapM_ solve $ lines str

Measured memory_bytes: 6368
#include<stdio.h>
int cmp(const void *a,const void *b){
  return *(int*)a-*(int*)b;}
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a+1==c)
    printf("1\n");
  else
    printf("0\n");

  return 0;}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<string> name[5];
    map<char, int> mp;
    mp['M'] = 0; mp['A'] = 1; mp['R'] = 2; mp['C'] = 3; mp['H'] = 4;

    int N; cin >> N;
    rep(i, N){
        string S; cin >> S;
        if(S[0] == 'M' || S[0] == 'A' || S[0] == 'R' || S[0] == 'C' || S[0] == 'H'){
            name[mp[S[0]]].push_back(S);
        }
    }
    ll ans = 0;
    for(int i = 0; i < 5; i++){
        ll a = name[i].size();
        for(int j = i+1; j < 5; j++){
            ll b = name[j].size();
            for(int k = j+1; k < 5; k++){
                ll c = name[k].size();
                ans += a*b*c;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5748
s = input()

def judge(s):
    l = int((len(s)-1)/2)
    if len(s)%2 == 1:
        if s[:l] == s[l+1:][::-1]:
            return True
        else:
            return False
    else:
        if s[:l+1] == s[l+1:][::-1]:
            return True
        else:
            return False

def main(s):
    l = int((len(s)-1)/2)
    frag1 = judge(s)
    frag2 = judge(s[:l])
    frag3 = judge(s[l+1:])
    if frag1 and frag2 and frag3:
        return 'Yes'
    else:
        return 'No'
      
print(main(s))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Func<int, int> Grow = GetFormula(input[0], input[1]);
            int MO = input[2];
            for(int i = 0; i < 10; i++)
            {
                MO = Grow(MO);
                Console.WriteLine(MO);
            }
        }

        static Func<int,int> GetFormula(int r, int d)
        {
            return new Func<int, int>((x) => r * x - d);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int dig=0,n1=n;
	while(n1>0)
	{
		n1/=10;
		dig++;
	}
	if(dig==1)
		cout<<n;
	if(dig==2)
		cout<<9;
	if(dig==3)
		cout<<n-99+9;
	if(dig==4)
		cout<<909;
	if(dig==5)
		cout<<n-9999+909;
	if(dig==6)
		cout<<90909;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    cout << n / 2 + n % 2 << endl;
}


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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
 
using namespace std;

int32_t main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n){
        cin >> v[i];
    }

    vector<int> s;
    s.pb(0);
    REP(i, n){
        s.pb(s[i]+v[i]);
    }
    s.pb(INF);

    SORT(s);

    int cnt=1, ans=0;
    REP(i, n+2){
        if(s[i]==s[i+1]){
            cnt++;
        }
        else{
            ans+=(cnt*(cnt-1))/2;
            cnt=1;
        }
    }

    cout << ans << endl;
}



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

int main(){
  int n;
  cin >> n;

  while(n--){
    int score = 0;
    int out = 0;
    int first = 0, second = 0, third = 0;

    while(out != 3){
      string s;
      cin >> s;

      if(s == "HIT"){
        score += third;
        third = second;
        second = first;
        first = 1;
      }
      else if(s == "OUT"){
        out++;
      }
      else{
        score += first + second + third + 1;
        first = second = third = 0;
      }
    }

    cout << score << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    int n;
    cin>>n;
    
    int wk = ceil(n/1.08);
 
    if((int)(wk*1.08)==n)
        cout<<wk<<endl;
    else
        cout<<":("<<endl;
    

    return 0;
}  

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


def F(num):
    ans = 0
    for n in str(num):
        ans += int(n)
    return ans


min_num = 10**9
for A in range(1, N):
    B = N - A
    num = F(A) + F(B)
    if num < min_num:
        min_num = num
print(min_num)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        long ans = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, a[i]);
            ans += max - a[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59864
s = input()
ans = ""
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans = str(i+1) + " " + str(i+2)

if ans != "":
	print(ans)
	exit(0)

for i in range(len(s)-2):
	if s[i] == s[i+2]:
		ans = str(i+1) + " " + str(i+3)

if ans == "":
	print("-1 -1")
else:
	print(ans)

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    bool flag = s.size() % 2 == 0;
    if(flag){
        for(int i=0;i<(int)s.size();i+=2){
            if(s[i] != 'h' || s[i+1] != 'i')flag = false;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

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

string o, e;

int main() {
  cin >> o >> e;
  rep (i, o.size()+e.size()) {
    if (i % 2 == 0) {
      cout << o[i/2];
    } else {
      cout << e[(i-1)/2];
    }
  }
  cout << endl;
  return 0;
}


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

int main()
{
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256