akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ivec a(9);
  REP(i, 9) cin >> a[i];
  int n;
  cin >> n;
  ivec b(n);
  REP(i, n) cin >> b[i];
  bool ok = false;

  vector<bool> ans(9, false);
  REP(i, n) {
    REP(j, 9) {
      if (a[j] == b[i]) {
         ans[j] = true;
      }
    }
  }

  if (ans[0] && ans[1] && ans[2]) ok = true;
  else if (ans[3] && ans[4] && ans[5]) ok = true;
  else if (ans[6] && ans[7] && ans[8]) ok = true;
  else if (ans[0] && ans[4] && ans[8]) ok = true;
  else if (ans[2] && ans[4] && ans[6]) ok = true;
  else if (ans[0] && ans[3] && ans[6]) ok = true;
  else if (ans[1] && ans[4] && ans[7]) ok = true;
  else if (ans[2] && ans[5] && ans[8]) ok = true;

  print((ok ? "Yes" : "No"));
  return 0;
}

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

int main() {
  string a, b, s;
  cin >> a >>b;
  s = a+b;
  int n = stoi(s);
  rep (i,1000) {
    if (n == i*i) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
    ll x,y,ans=0;
    cin >> x >> y;
    if(x>=y){
      ans+=x;
      x--;
    }else{
      ans+=y;
      y--;
    }
  
    if(x>=y){
      ans+=x;
      x--;
    }else{
      ans+=y;
      y--;
    }
  
  cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,m,n,ans=0;cin>>m>>n;
	
	if(m==2){
		int ki=0,gu=0;
		for(i=0;i<n;i++){
			int a;cin>>a;
			if((a+i)%2==0){ki++;}
			else{gu++;}
		}
		cout<<min(ki,gu)<<endl;
	}else{
		int mae=0;
		for(i=0;i<n;i++){
			int a;cin>>a;
			if(mae==a){a=0;ans++;}
			mae=a;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3100
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int cnt = 0;
		for(int i=0;i<S.Length;i++) cnt += S[i] == T[i] ? 0 : 1;
		Console.WriteLine(cnt);
	}
	String S,T;
	public Sol(){
		S = rs();
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> g[200000];
vector<bool> visit(200000);
vector<int> root;
int last = -1;

void dfs(int v) {
  visit[v] = true;
  root.push_back(v);
  for (auto u : g[v]) {
    if (visit[u]) {
      last = u;
      return;
    } else {
      dfs(u);
    }
  }
}

int main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
    g[i].push_back(a[i]);
  }
  dfs(0);
  vector<int> root2;
  bool f = false;
  for (int i = 0; i < root.size(); ++i) {
    if (!f && root[i] == last) {
      f = true;
      root2.push_back(root[i]);
    } else if (f) {
      root2.push_back(root[i]);
    }
  }
  if (k < root.size()) {
    cout << root[k] + 1 << endl;
  } else {
    k -= root.size();
    k %= root2.size();
    cout << root2[k] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 28568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin>>a[i];
    }
    
    vector<int> bucket(100009, 0);
    for (int i=0; i<N; i++) {
        bucket[a[i]]++;
        bucket[a[i]+1]++;
        bucket[a[i]+2]++;
    }
    
    int ans=0;
    for (int i=0; i<100009; i++) {
        if (ans<bucket[i]) {
            ans=bucket[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
    stack<int> S;
    int a, b, x;
    string s;

    while ( cin >> s ) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        } else if (s[0] == '-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        } else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3148
import java.util.*;
class Main{
	static String rev(String a){
		String ret="";
		for(int i=a.length()-1;i>=0;i--)ret+=a.charAt(i);
		return ret;
	}
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		for(int i=0;i<a;i++){
			String str=s.next();
			HashMap<String,Integer> map=new HashMap<String,Integer>();
			int ret=0;
			for(int j=1;j<str.length();j++){
				String s1=str;
				String s2=str.substring(0,j)+rev(str.substring(j));
				String s3=rev(str.substring(0,j))+str.substring(j);
				String s4=rev(str.substring(0,j))+rev(str.substring(j));
				String s5=str.substring(j)+str.substring(0,j);
				String s6=str.substring(j)+rev(str.substring(0,j));
				String s7=rev(str.substring(j))+str.substring(0,j);
				String s8=rev(str.substring(j))+rev(str.substring(0,j));
				if(!map.containsKey(s1)){
					ret++;
					map.put(s1,1);
				}
				if(!map.containsKey(s2)){
					ret++;
					map.put(s2,1);
				}
				if(!map.containsKey(s3)){
					ret++;
					map.put(s3,1);
				}
				if(!map.containsKey(s4)){
					ret++;
					map.put(s4,1);
				}
				if(!map.containsKey(s5)){
					ret++;
					map.put(s5,1);
				}
				if(!map.containsKey(s6)){
					ret++;
					map.put(s6,1);
				}
				if(!map.containsKey(s7)){
					ret++;
					map.put(s7,1);
				}
				if(!map.containsKey(s8)){
					ret++;
					map.put(s8,1);
				}
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 1000

using namespace std;

int N, ans, cnt, sum;
bool flg;

int main() {
	int d[52];
	cin >> N ;
	rep(i, N) cin >> d[i];

	rep(i, N) {
		repk(j, i+1, N) {
			ans += d[i] * d[j];
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int N,cou;
	cou = 1;
	cin >> N;
	vint H(N);
	for (int i = 0; i < N; i++)cin >> H[i];
	for (int i = 1; i < N; i++) {
		int jur = 0;
		for (int j = 0; j < i; j++) {
			if (H[j] > H[i])jur = 1;
		}
		if (jur == 0)cou++;
	}
	cout << cou << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include <cmath>

int main(int argc, char const *argv[]) {

  // std::cout << (2^3) << '\n';
  // std::cout << std::pow(2,3) << '\n';


  std::string S;
  std::cin >> S;

  std::string ichi = "1";

  long long K;
  std::cin >> K;

  std::string ans;
  int startfrom = 0;

  while (1) {

    if (S[startfrom] == ichi[0]) {
      K += -1;

      if (K == 0) {
        ans = S[startfrom];
        break;
      }
    }else{
      ans = S[startfrom];
      break;
    }
    startfrom ++;

    // if (S2 > 1) {
    //   ans = S2;
    //   break;
    // }else{
    //   K += -1;
    //   S = S - std::pow(10, keta1);
    //   if (K == 0) {
    //     ans = 1;
    //     break;
    //   }
    // }

  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
//#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define MOD 998244353
#define SIZE 1024

ll N,X;
ll POW[11];
ll dp[2][505][512],table[505][512];


int main(){

	POW[0] = 1;
	for(int i = 1; i <= 10; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld %lld",&N,&X);

	int CURRENT = 0,NEXT = 1;

	for(int i = 0; i <= X; i++){
		for(int k = 0; k < POW[9]; k++){
			dp[CURRENT][i][k] = 0;
			dp[NEXT][i][k] = 0;
		}
	}

	for(int i = 0; i <= X; i++){
		table[i][0] = 1;
	}

	dp[CURRENT][0][0] = 1;

	for(int loop = 0; loop < N; loop++){

		for(int a = 0; a <= X; a++){
			for(int b = 0; b < POW[9]; b++){
				dp[NEXT][a][b] = table[a][a^b];
			}
		}

		for(int a = 0; a <= X; a++){
			for(int b = 0; b < POW[9]; b++){
				if(a == 0){

					table[a][b] = dp[NEXT][a][b];
				}else{

					table[a][b] = table[a-1][b]+dp[NEXT][a][b];
				}
				table[a][b] %= MOD;
			}
		}
		swap(CURRENT,NEXT);
	}

	ll ans = 0;
	for(int i = 0; i <= X; i++){

		ans += dp[CURRENT][i][X];
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli pre[MaxN],pot[MaxN];
	void solve(){
		lli N,i,j,l,r,numero,res=0;
		string numb;
		cin>>numb;
		N=numb.size();
		numero=0;
		pot[0]=1;
		pre[0]=1;
		for(i=1;i<=N;i++){
			pot[i]=pot[i-1]*10;
			pot[i]=pot[i]%2019;
		}
		for(i=0;i<N;i++){
			numero=numero+(pot[N-i-1]*(numb[i]-'0'));
			numero=numero%2019;
			res+=pre[numero];
			pre[numero]+=1;
			//cout<<numero<<" ";
		}
		cout<<res;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 4812
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;


int main(void){
  //入力
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}


Measured memory_bytes: 256
# 2019-11-10 20:23:41(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    info = [[int(x) for x in sys.stdin.readline().split()] for _ in range(n)]
    
    # 基準を決める
    for i in range(n):
        if info[i][2] >= 1:
            x0, y0, h0 = info[i][0], info[i][1], info[i][2]
            break
    # else: すべてのhは h = 0

    for x in range(101):
        for y in range(101):
            H = h0 + abs(x - x0) + abs(y - y0)
            for i in range(n):   # 中心(x, y, H)が条件を満たしているか確認する
                h = max(H - abs(x - info[i][0]) - abs(y - info[i][1]), 0)
                if h != info[i][2]: #　本当に中心なら同じ値になるはず
                    break     # そうでないならこれは正しくない
            else:  # 全ての座標に対して条件を満たしていたなら
                res = [x, y, H]
                for i in range(3):
                    res[i] = str(res[i])
                print(' '.join(res))
                sys.exit() # 中心は一意に決まるので見つかったらそれ以上調べる必要ない
    
            

if __name__ == "__main__":
    main()

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 200111, inf = 1000111222;

bool from1[max_n];
bool ton[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    int n, m, from, to;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> from >> to;
        if (from == 1) {
            from1[to] = true;
        }
        if (to == n) {
            ton[from] = true;
        }
    }
    for (int i = 2; i < n; ++i) {
        if (from1[i] && ton[i]) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}




Measured memory_bytes: 640
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstdlib>

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

using namespace std;

const int INF=1<<29;

struct P{ int x,y,cost; };

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		int B[100][100];
		int sx,sy,gx,gy;
		int lastdgt=0;
		vector<P> dgt[10010];
		rep(i,h) rep(j,w) {
			char ss[16]; scanf("%s",ss);
			if(!isdigit(ss[0])) B[i][j]=0;
			else sscanf(ss,"%d",&B[i][j]);

			if(ss[0]=='S') sx=j, sy=i;
			if(ss[0]=='G') gx=j, gy=i;
			if(isdigit(ss[0])){
				dgt[B[i][j]].push_back((P){j,i,INF});
				lastdgt=max(lastdgt,B[i][j]);
			}
		}
		dgt[    0    ].push_back((P){sx,sy,0});
		dgt[lastdgt+1].push_back((P){gx,gy,INF});

		rep(k,lastdgt+1){
			rep(i,dgt[k].size()) rep(j,dgt[k+1].size()) {
				P p=dgt[k][i],q=dgt[k+1][j];
				dgt[k+1][j].cost=min(q.cost,p.cost+abs(q.x-p.x)+abs(q.y-p.y));
			}
		}
		printf("%d\n",dgt[lastdgt+1][0].cost);
	}

	return 0;
}

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

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[2] == a[1] + a[0]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    A=(A<B)?B-A:A-B;
    for(LL m=0;m<N;m++)
        if(C*(N-1-m)-m*D<=A&&A<=D*(N-1-m)-m*C){
            cout<<"YES"<<endl;
            return 0;
        }
    cout<<"NO"<<endl;
     return 0;
}

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

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

using namespace std;

int main(){
	int n,m; cin>>n>>m;
	vector<pair<int,int>> I[30];
	rep(i,n){
		int s,t,c; cin>>s>>t>>c; c--;
		I[c].emplace_back(s,t);
	}

	rep(c,m){
		sort(I[c].begin(),I[c].end());

		vector<pair<int,int>> J;
		int k=I[c].size();
		rep(i,k){
			if(i==k-1 || I[c][i].second!=I[c][i+1].first)
				J.emplace_back(I[c][i]);
			else
				I[c][i+1].first=I[c][i].first;
		}
		I[c]=J;
	}

	int sum[100002]={};
	rep(c,m) for(auto J:I[c]) {
		sum[J.first]++;
		sum[J.second+1]--;
	}
	rep(i,100001) sum[i+1]+=sum[i];

	cout<<*max_element(sum,sum+100002)<<endl;

	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

ll N ;
map<ll, stack<ll> > match;
vector<ll> former;


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

    cin >> N ;
    rep(i, N){
        rep(j, N-1){
            ll inp; cin >> inp;
            inp --;
            match[i].push(inp);
        }
    }

    ll ans = 0;
    rep(i, N){
        former.pb(i);
    }
    
    while(former.size() != 0){
        ans ++;
        map<ll, bool> used;
        vector<ll> nxt;
        
        rep(i, former.size()){
            ll player1 = former[i];
            if(match[player1].empty()) continue;
            ll player2 = match[player1].top();
            
            if(used[player1] or used[player2] ) continue;
            
            if(match[player2].top() == player1){
                nxt.pb(player1); nxt.pb(player2);
                used[player1] = true; used[player2] = true;
                
                match[player1].pop(); match[player2].pop();
            }
        }
        former.clear();
        rep(i, nxt.size()) former.pb(nxt[i]);
    }
    
    rep(i, N){
        if(match[i].size() != 0){
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << ans-1 << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 9088
N, A, B, C, D = map(int, input().split())

p = N%A
q = N%C
r = N//A
s = N//C

if p == 0 and q == 0:
    t = B * r
    u = D * s
    if t > u:
        print(u)
    else:
        print(t)
elif p !=0 and q == 0:
    t = B * (r+1)
    u = D * s
    if t > u:
        print(u)
    else:
        print(t)
elif p == 0 and q != 0:
    t = B * r
    u = D * (s+1)
    if t > u:
        print(u)
    else:
        print(t)
else:
    t = B * (r+1)
    u = D * (s+1)
    if t > u:
        print(u)
    else:
        print(t)


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

int main(){
    int n,m;cin>>n>>m;
    int r[50];
    for(int i=0;i<n;i++){
        r[i]=0;
    }
    for(int j=0;j<m;j++){
        int a,b;
        cin>>a>>b;
        r[a-1]+=1;
        r[b-1]+=1;
    }
    for(int i=0;i<n;i++){
        cout<<r[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,i,j,k;
    int mat[100][100]={{}};
    int ve[100]={};
    cin>>n>>m;
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            cin>>mat[i][j];
        }
    }
    for(j=0; j<m; j++)
    cin>>ve[j];
    for(i=0; i<n; i++){
        int x=0;
        for(j=0; j<m; j++)
        x+=mat[i][j]*ve[j];
        cout<<x<<endl;
    }
    return 0;
}

    


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#define N 100001

using namespace std;

int main(void) {
	int i, j, sum = 0, num, l, r;
	vector<int> p(N, true);
	p[0] = 0;
	p[1] = 0;
	for (i = 2; i < N; i++) {
		while (i < N && !p[i])
			i++;
		for (j = i << 1; j < N; j += i)
			p[j] = false;
	}
	for (i = 1; i <= N >> 1; i++) {
		if (p[i] && p[(i << 1) - 1])
			sum++;
		p[i] = sum;
	}
	cin >> num;
	for (i = 0; i < num; i++) {
		scanf("%d%d", &l, &r);
		l >>= 1;
		r = (r + 1) >> 1;
		printf("%d\n", p[r] - p[l]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > 0 && a < 10 && b > 0 && b < 10)
	{
		cout << a * b << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 603;

i64 n, m;

vector<i64> e[MAXN];
double dp[MAXN];
pair<double, double> de[MAXN][MAXN];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;
    for (i64 i = 0; i < m; i++) {
        i64 u, v;
        cin >> u >> v;
        e[u].push_back(v);
    }

    for (i64 i = n - 1; i > 0; i--) {
        double z = 1.0 / e[i].size();
        for (auto t : e[i]) {
            dp[i] += z * (dp[t] + 1);
        }
    }

    for (i64 j = 1; j < n; j++) {
        for (i64 i = n - 1; i > 0; i--) {
            //if (i > j) {
            if(0) {
                de[j][i].second = dp[i];
            }
            else if (i == j) {
                de[j][i].first = 1.0;
            }
            else {
                double z = 1.0 / e[i].size();

                de[j][i].second += 1.0;
                for (auto t : e[i]) {
                    de[j][i].first += z * de[j][t].first;
                    de[j][i].second += z * de[j][t].second;
                }
            }
        }
    }

    /*
    cerr << dp[1] << endl;
    for (i64 j = 1; j < n; j++) {
        double t = de[j][1].first * dp[j] + de[j][1].second;
        cerr << "de[" << j << "][1] = " << t << endl;
    }
    */

    double R = dp[1];
    for (i64 j = 1; j < n; j++) {
        if (e[j].size() < 2) {
            continue;
        }

        vector<double> te;
        for (auto t : e[j]) {
            te.push_back(dp[t]);
        }
        sort(te.begin(), te.end(), greater<double>());

        double ej = 1.0;
        double z = 1.0 / (e[j].size() - 1);
        for (i64 i = 1; i < te.size(); i++) {
            ej += z * te[i];
        }

        double r = de[j][1].first * ej + de[j][1].second;
        R = min(R, r);
    }

    cout << R << endl;

    return 0;
}

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

int main(){
    int a,b,v,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    
    if(a==b){
        cout << "YES" << endl;
        return 0;
    }
    if(v<=w) {
        cout << "NO" << endl;
        return 0;
    }
    int d = abs(a-b);
    int x = v-w;
    int t2 = d/x;
    // cout << d << " " << x << " " << t2 << endl;
    if(d%x != 0) t2++;
    if(t2 <= t){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    let mut ret = 0;
    for i in 0..s.len() {
        if s[i] == '+' {
            ret += 1;
        } else {
            ret -= 1;
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 305;
const ll LINF = 1e18 + 5;
int n, a[3];
double dp[N][N][N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++) 
 	{
 		int x;
 		cin >> x;
 		a[x-1]++;
 	}
 	dp[0][0][0] = 0;
 	for(int i=0; i<=n; i++)
 	{
 		for(int j=0; j<=n-i; j++)
 		{
 			for(int k=0; k<=n-i-j; k++)
 			{
 				if(!i && !j && !k) continue;
 				int x = i + j + k;
 				if(i) dp[i][j][k] += dp[i-1][j+1][k]*i/x;
 				if(j) dp[i][j][k] += dp[i][j-1][k+1]*j/x;
 				if(k) dp[i][j][k] += dp[i][j][k-1]*k/x;
 				dp[i][j][k] += n*1.0/x;
 			}
 		}
 	}
 	cout << fixed << setprecision(12) << dp[a[2]][a[1]][a[0]];
	return 0;
}


Measured memory_bytes: 219520
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
#define reps(i,s,N) for(LL i=s;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

std::string O, E;

int main()
{
	in >> O >> E;
	int seek = 0;
	rep(i, O.length() + E.length())
	{
		if (i % 2 == 0)
		{
			out << O[seek];
		}
		else
		{
			out << E[seek];
		}
		seek = (i+1) / 2;
	}
	out << std::endl;
	return 0;
}

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

int main() {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3 ;
    cout << (char)(s1[0]+'A'-'a') << (char)(s2[0]+'A'-'a') << (char)(s3[0]+'A'-'a') << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

ll w[110], v[110];
vector<int> V[4];

int main()
{
	int N, W;
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
	ll base = w[0];
	for (int i = 0; i < N; i++) {
		V[w[i] - base].push_back(v[i]);
	}
	for (int i = 0; i < 4; i++) {
		sort(V[i].rbegin(), V[i].rend());
	}
	ll ans = 0;
	for (int i = 0; i <= V[0].size(); i++) {
		for (int j = 0; j <= V[1].size(); j++) {
			for (int k = 0; k <= V[2].size(); k++) {
				for (int l = 0; l <= V[3].size(); l++) {
					ll value = 0;
					ll weight = 0;
					weight += i * base;
					weight += j * (base + 1);
					weight += k * (base + 2);
					weight += l * (base + 3);
					if (weight > W) continue;
					//cout << i << " " << j << " " << k << " " << l << endl;
					for (int q = 0; q < i; q++) value += V[0][q];
					for (int q = 0; q < j; q++) value += V[1][q];
					for (int q = 0; q < k; q++) value += V[2][q];
					for (int q = 0; q < l; q++) value += V[3][q];
					ans = max(ans, value);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 2*1e5;

vector<int>adj[N];
int vis[N];
int sz = 0;
int cnt = 0;

void dfs(int u)
{
	vis[u] = 1;
	cnt++;
	sz = max(sz,cnt);
	for(int v : adj[u])
	{
		if(!vis[v])
		{
			dfs(v);
		}
	}
}

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	int n,m,u,v;
	cin>>n>>m;
	
	forn(i,m)
	{
		cin>>u>>v; u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	int ans = 0;

	forn(i,n)
	{
		if(!vis[i])
		{
			cnt = 0;
			dfs(i);
		}
	}

	cout<<sz<<endl;

	return 0;
}

Measured memory_bytes: 21584
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

void solve()
{
	ll n, w;
	cin >> n >> w;
	ll val[n + 1], wei[n + 1];
	for (ll i = 1; i <= n; ++i)
	{
		cin >> wei[i];
		cin >> val[i];
	}
	ll dp[n + 1][w + 1];
	for (ll i = 0; i <  w + 1; ++i)dp[0][i] = 0;
	for (ll i = 0; i <  n + 1; ++i)dp[i][0] = 0;
	for (ll i = 1; i <= n; ++i)
	{
		for (ll j = 1; j <= w; ++j)
		{
			if (wei[i] > j)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - wei[i]]);
		}
	}
	cout << dp[n][w] << endl;
}

int main()
{
	fast
	ll t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 79232
#include<iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    int sum = 0;
    char hoge[5];
    sprintf(hoge, "%d", a);
    for(int b = 0; b<4; b++){
        if(hoge[b] == '2'){
            sum++;
        }
    }
    cout << sum;
}

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

int main() {
    vector<int> r(4);
    vector<int> b(2);
    rep(i, 4) {
        cin >> r.at(i);
    }
    rep(i, 2) {
        cin >> b.at(i);
    }
    sort(r.rbegin(), r.rend());

    int ans = 0;
    rep(i, 3) {
        ans+= r.at(i);
    }
    ans += max(b.at(0), b.at(1));
    cout << ans << endl;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	int k , t ;
	cin >> k >> t;
	vector<int> a(t);
	rep(i,t) cin >> a[i];
	SORT(a);
	int M = a[t-1] ; 
	int sum = 0 ;
	rep(i,t-1){
		sum += a[i] ;
	}
	int ans = max(0 , M - sum  - 1);
	cout << ans << endl;
}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    priority_queue<int> A;
    REP(i,N){
        int a; cin >> a;
        A.push(a);
    }

    REP(i,M){
        int a = A.top(); A.pop();
        A.push(a/2);
    }
    
    ll ans = 0;
    while(A.size()>0){
        int a = A.top(); A.pop();
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3880
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		// code to read values
		// code to call required method
		// code to display the result
		// System.out.println(Math.ceil(2.5));
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++){
			arr[i] = sc.nextInt();
		}
		//System.out.println(arr[0]);
		
		Arrays.sort(arr);
		//System.out.println(arr[0]);
		int sum = 0;
		for(int i=0; i<k; i++){
			sum += arr[i];
			//System.out.println(arr[0]);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 30176
#include <iostream>
const int INF = 1000 * 1000 * 1000;
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = INF;
    int curAns = 0;
    for(int i = 0; i < s.size(); i++)
        curAns += s[i] != '#';
    ans = curAns;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '#')
            curAns++;
        else
            curAns--;
        ans = min(ans , curAns);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 char a,b;
 cin >> a>> b;
 if(a=='H'&&b=='H'){
     cout << 'H' << endl;
 }else if(a=='D'&&b=='D'){
     cout << 'H' << endl;
 }else{
     cout << 'D' << endl;
 }
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    ll r;
    cin >> r;
    cout << r * r << endl;
   


    return 0;

}

Measured memory_bytes: 3540
import sys
import math
import copy
import numpy as np




def MinPrime(N, Prime):
    Max = math.ceil(math.sqrt(N))
    Min = Prime+1
    if(N%2 ==0):
        return 2


    Dev = 2
    if(Min%2==0):
        Min += 1
    for Num in range(Min, Max+1, Dev):
        if(N%Num == 0):
            return Num
    return N

def estimatePow(N, Prime):

    Pow = 0
    N_bef = N
    while(N%Prime==0):
        Pow+= 1
        N //= Prime
    # print(N_bef, N, Pow, Prime)
    return [Pow, N]

def estimateTimes(Pow):
    Times = math.floor(math.sqrt(Pow))
    Sum = (1+Times) * Times /2


    while(True):
        Sum *= (Times+2)/Times
        if(Pow < Sum):
            return Times
        Times += 1
    return Times
def calcOperateionTimes(N):
    Prime = 1
    Times = 0
    #Primes = seachPrimeNum(N)
    while(N > 1):
        # Prime = MinPrime(N, Prime)
        Prime= MinPrime(N, Prime)
        Pow_N = estimatePow(N, Prime)
        N = Pow_N[1]
        Times += estimateTimes(Pow_N[0])
    return Times

if(__name__ == "__main__"):

    N = int( input().strip() )



    Times = calcOperateionTimes(N)
    print(Times)


Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

const ll INF = 1e11;
using P = pair<ll, ll>;

int main(void){
    int n;
    cin >> n;
    vector<P> v(n);
    rep(i,n){
        ll x,l;
        cin >> x >> l;
        v[i] = {x+l, x-l};
    }
    sort(all(v));
    int cnt = 0;
    ll r = -INF;
    rep(i,n){
        if (r <= v[i].second) {
            r = v[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main (void)
{
  int w , a ,b ,temp;
  scanf("%d %d %d",&w,&a,&b);
  
  if(a>b){
    temp = a;
    a = b;
    b =temp;
  }
  
  if((b-(w+a))>0){
    printf("%d",b-(w+a));
  }
  else{
    printf("0");
  }
  return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<p64> a(n);
    for (i64 i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(all(a));

    i64 cnt = 0;
    for (i64 i = 0; i < n; i++) {
        if (abs(a[i].second - i) % 2) cnt++;
    }
    cout << cnt / 2 << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int n;
int act[3][100005];
int dp[100005][3];

// dp[i][j] = max happiness from 0 to i if jth act is done on day i

int rec(int d, int a)
{
    if (dp[d][a] != -1)
        return dp[d][a];

    if (d == 0)
    {
        dp[d][a] = act[a][0];
        return dp[d][a];
    }

    dp[d][a] = act[a][d] + max(rec(d - 1, (a + 1) % 3), rec(d - 1, (a + 2) % 3));
    return dp[d][a];
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> act[0][i] >> act[1][i] >> act[2][i];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            dp[i][j] = -1;

    int ans = max(rec(n - 1, 0), rec(n - 1, 1));
    ans = max(ans, rec(n - 1, 2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val S = sc.next

    val z = S.count(_ == '0')
    (Array(z, S.length - z).min * 2).toString
  }
}


Measured memory_bytes: 31336
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int main(){

    int a , b, k;

    scanf("%d%d%d", &a, &b, &k);

    int cnt = 0; //見つかった数
    for (int i=110; i >= 1; i--){

        if (a % i == 0 && b % i  == 0){
            cnt++;
            if(cnt == k){
                cout << i <<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 888
import sys
X = int(input())
# for i in range(1000):
#     for j in range(1000):
#         a = i ** 2
#         b = j ** 2
#         c = i * j
#         if (i - j) * (a * (a ** 2 + c + b) + b * (c + b)) == X:
#             print(i,j)
#             sys.exit()
#         elif (i + j) * (a * (a ** 2 - c + b) + b * (-c + b)) == X:
#             print(i,-j)
#             sys.exit()

for i in range(-118,120):
    for j in range(-118,120):
        if i ** 5 - j ** 5 == X:
            print(i,j)
            sys.exit()


Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
const int N=1e5+100;
ll a[N];
int pwmod(int a, int n, int mod)
{
ll ret = 1;
while (n)
{
if (n & 1) ret = ret * a % mod;
a = a * a % mod;
n >>= 1;
}
return ret;
}
main()
{
ll n;
string ans="";
scanf("%lld",&n);
while(n){
    n--;
    ans+=char('a'+n%26);
    n/=26;
}
reverse(ans.begin(),ans.end());
printf("%s",ans.c_str());
}


Measured memory_bytes: 3784
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

A.unshift(0)
B = Array.new(N + 1)
N.downto(1){|i|
  w = A[i]
  c = 2
  while(c * i <= N) do
    w ^= B[c * i]
    c += 1
  end
  B[i] = w
}

puts B.count{|b| b == 1}
(1..N).each{|i|
  printf("#{i} ") if B[i] == 1
}
printf("\n")


Measured memory_bytes: 21644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
 
signed main()
{
    int n, m;
    cin >> n >> m;
    std::vector<int> s(n);
    std::vector<int> t(m);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    std::vector<int> sumarray(n, 0);
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3660
n=int(input())
s={}
for i in range(n):
  sw=input()
  if sw in s.keys():
    s[sw]+=1
  else:
    s[sw]=1
m=int(input())
for i in range(m):
  t=input()
  if t in s.keys():
    s[t]-=1
print(max(s.values()) if max(s.values())>0 else 0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, K; cin >> N >> K;
    string S;
    while (N) {
        S.push_back('0' + N % K);
        N /= K;
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 256