akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
				using namespace std;
				#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
				#define pb push_back
				#define fe first
				#define se second
				#define endl "\n"
				#define int long long int 
				#define pii pair<int, int>
				#define PI 3.14159265358979323846
				const int N = 1e5 + 10;
			     int INF=1e9;
				int a,b,c,n;
				
				int v[N];
				
			  int dfs(int cur,int fa,int fb,int fc) {
				      if(cur==n) {
						    if(min({fa,fb,fc})>0) {
								   return  abs(fa-a)+abs(fb-b)+abs(fc-c);
								}
							else	
								return  INF;					     
						  }
						  
						int res0=dfs(cur+1,fa,fb,fc);
						int res1=dfs(cur+1,fa+v[cur],fb,fc)+10;
						int res2=dfs(cur+1,fa,fb+v[cur],fc)+10;
						int res3=dfs(cur+1,fa,fb,fc+v[cur])+10;
						
						return min({res0,res1,res2,res3});
			   }
			
			
			     void solve() {
					    cin>>n>>a>>b>>c;
					    
			
					    
					    for(int i=0;i<n;i++)  {
							   cin>>v[i];
							}
							
					  int tot=dfs(0,0,0,0);
					  cout<<tot-30;		
					    
					 
					 }	      	
					   

				int32_t  main() {
				  cool;
				  int t = 1;
				  while (t--)
					solve();

				  return 0;
				}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

struct unionfind {
  vector<int> A;

  unionfind(int n) : A(n, -1) {}

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (A[x] > A[y]) swap(x, y);
    A[x] += A[y];
    A[y] = x;
  }

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

int main() {
  int N, M;
  cin >> N >> M;
  unionfind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x - 1, y - 1);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) if (uf.find(i) == i) ans++;
  cout << ans << '\n';
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int ans=0,ind=0;
    while(ind<n){
        int c=a[ind],tmp=0;
        while(a[ind]==c&&ind<n){
            ind++;tmp++;
        }
        ans+=tmp/2;
        if(tmp==0) ind++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  i64 k;
  cin >> n >> k;
  vt<i64> a(n);
  rep(i, 0, n) cin >> a[i];

  if(k == 0) {
    i64 ans = 0;
    rep(i, 0, n) ans += a[i];
    return cout << ans << endl, 0;
  }

  string s = "";
  vt<i64> v;
  rep(i, 0, 63) {
    i64 num = 1ll << i;
    if(k & num) s += "1";
    else s += "0";
    v.push_back(num);
  }
  reverse(all(s));
  reverse(all(v));
  map<i64, i64> mp;
  rep(i, 0, v.size()) {
    mp[v[i]] = 0;
    rep(j, 0, n) {
      if(a[j] & v[i]) mp[v[i]]++;
    }
  }

  int l = s.size();
  vvt<i64> dp(l + 1, vt<i64>(2, -1));
  dp[0][0] = 0;
  rep(i, 0, l) {
    int d = s[i] - '0';
    rep(smaller, 0, 2) {
      rep(j, 0, (smaller ? 1 : d) + 1) {
        if(j == 0 && dp[i][smaller] >= 0) dp[i + 1][smaller || j < d] = max(dp[i + 1][smaller || j < d], dp[i][smaller] + v[i] * mp[v[i]]);
        else if(j == 1 && dp[i][smaller] >= 0) dp[i + 1][smaller || j < d] = max(dp[i + 1][smaller || j < d], dp[i][smaller] + v[i] * (n - mp[v[i]]));
      }
    }
  }
  cout << max(dp[l][0], dp[l][1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
struct S
{
    double x;
    double y;
};
bool cmp(S a,S b)
{
    return a.x<b.x;
}
int main()
{
    int q,h,s,d;
    double n;
    scanf("%d%d%d%d%lf",&q,&h,&s,&d,&n);
    S a[4];
    a[0].x=q*8,a[0].y=0.25;
    a[1].x=h*4,a[1].y=0.5;
    a[2].x=s*2,a[2].y=1;
    a[3].x=d,a[3].y=2;
    sort(a,a+4,cmp);
    ll ans=0;
    for(int i=0;i<4;i++)
    {
        if(n>=a[i].y)
        {
            ll p=n/a[i].y;
            if(a[i].y==0.25)
                ans+=p*(q);
            else if(a[i].y==0.5)
                ans+=p*h;
            else if(a[i].y==1)
                ans+=p*s;
            else
                ans+=p*d;
            n=n-p*a[i].y;

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


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265359

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
	int n;cin >> n;
	vector<int> A(n);
	vector<int> B(n);
	
	REP(i,n)cin >> A[i];
	REP(i,n)cin >> B[i];
	
	int ans = 0;
	
	REP(i,30)
	{
		vector<int> v(2*n);
		REP(j,n)
		{
			v[2*j] = B[j] % (1 << (i+1));
			v[2*j+1] = B[j] % (1 << (i+1)) + (1 << (i+1));
		}
		sort(ALL(v));
		int cou = 0;
		REP(j,n)
		{
			int	up = lower_bound(ALL(v),4*(1<<i) - (A[j]%(1<<(i+1)))) - v.begin();
			int lo = lower_bound(ALL(v),3*(1<<i) - (A[j]%(1<<(i+1)))) - v.begin();
			cou += up - lo;
			cou %= 2;
		}		
		ans |= (cou << i);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3428
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int[] H = IntStream.generate(s::nextInt).limit(N).toArray();
			int max = H[0];
			int ret = 1;

			for (int i = 1; i < N; i++) {
				if (max <= H[i]) {
					ret++;
					max = H[i];
				}
			}
			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 27092
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// wrap,pair
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

// pairをsecond基準で昇順sort
// sort(vector_name.begin(),vector_name.end(),compare_by_b);
bool compare_by_b(pair<int, int>a, pair<int, int>b) {
	if (a.second != b.second) return a.second < b.second;
	else return a.first < b.first;
}

// ----------------------------------------------------------------

int main(void) {

	int n;
	cin >> n;
	vector<pair<int, int> > work(n);
	REP(i, n) cin >> work[i].first >> work[i].second;

	sort(work.begin(),work.end(), compare_by_b);
	
	int sum = 0;
	REP(i, n) {
		sum += work[i].first;
		if (sum > work[i].second) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

using Edge = pair<int, ll>;
vector<vector<Edge>> G;
ll INF = 1e18;

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

  int V, E; cin >> V >> E;
  G.resize(V);
  vector<ll> d(V, INF);

  for (int i = 0; i < E; i++) {
    int a, b; cin >> a >> b; a--; b--;
    ll c; cin >> c;
    G[a].emplace_back(Edge(b, -c));
    // G[b].emplace_back(a);
  }

  d[0] = 0;
  for (int t = 0; t < V * 2; t++) {
    for (int i = 0; i < V; i++) {
      if (d[i] == INF) continue;
      for (auto e: G[i]) {
        if (d[e.first] > d[i] + e.second) {
          d[e.first] = d[i] + e.second;
          if (t == V -1) {
            d[e.first] = -INF;
          }
        }
      }
    }
  }

  if (d[V - 1] <= -INF) cout << "inf\n";
  else cout << -d[V - 1] << '\n';

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
#define db double
using namespace std;
inline ll read(){
	ll res=0,f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)) {res=(res<<1)+(res<<3)+(ch^48);ch=getchar();}
	return res*f;
}
const int N=1e6+5;
struct Vector{ll v;db t;}q[N];
ll t[N],v[N];
ll n,x,y,L;
int l,r;
inline void merge(Vector &a,Vector b){
	a.t=(a.t*a.v+b.t*b.v)/(a.v+b.v);
	a.v+=b.v;
}
int main(){
	n=read();L=read();
	l=1,r=0;
	for(int i=1;i<=n;i++){
		t[i]=read();v[i]=read();
		while(x+v[i]>L){
			ll del=min(q[l].v,x+v[i]-L);
			q[l].v-=del;
			x-=del,y-=del*q[l].t;
			if(!q[l].v) ++l;
		}
		q[++r].v=v[i];q[r].t=t[i];
		y+=v[i]*t[i],x+=v[i];
		while(l<r && q[r].t<q[r-1].t) merge(q[r-1],q[r]),--r;
        printf("%lf\n",(db)y/L);
	}
	return 0;
}

Measured memory_bytes: 29056
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] a = new long[3 * N];
    for(int i = 0; i < 3 * N; i++) {
      a[i] = sc.nextLong();
    }
    PriorityQueue<Long> pq = new PriorityQueue<Long>();
    long[] max = new long[N + 1];
    for(int i = 0; i < N; i++) {
      pq.add(a[i]);
      max[0] += a[i];
    }
    for(int i = 1; i < N + 1; i++) {
      pq.add(a[N + i - 1]);
      long m = pq.poll();
      max[i] = max[i - 1] + a[N + i - 1] - m;
    }

    PriorityQueue<Long> pq2 = new PriorityQueue<>(N, Collections.reverseOrder());
    long[] min = new long[N + 1];
    for(int i = 3 * N - 1; i > 2 * N - 1; i--) {
      pq2.add(a[i]);
      min[0] += a[i];
    }
    for(int i = 1; i < N + 1; i++) {
      pq2.add(a[2 * N - i]);
      long m = pq2.poll();
      min[i] = min[i - 1] + a[2 * N - i] - m;
    }

    long ans = (-1) * (long)Math.pow(10, 15);
    for(int i = 0; i < N + 1; i++) {
      ans = Math.max(ans, max[i] - min[N - i]);
    }
    System.out.println(ans);
  }
}

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

using namespace std;

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

    long *score = new long[N];
    memset(score, 0, sizeof(long) * N);

    for (int i = 0; i < Q; i++)
    {
        int player;
        cin >> player;
        score[player - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        if (K - Q + score[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    delete score;

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
  //  #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  //  #endif
    int a,b;
    cin>>a>>b;
    vector<int> v;
    ffor(i,1,2000)
    {
        double x=(double)i*0.08,y=(double)i*0.1;
      // cout<<x<<" "<<y<<endl;
        if((int)x==a&&(int)y==b) v.pb(i);
    }
   // cout<<"a "<<sz(v)<<endl;
    if(sz(v)==0) cout<<"-1";
    else cout<<v[0];
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define MAX 251

int main() {
	int i, k, n, pk, lk, rk;
	int A[MAX];

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &k);
		A[i] = k;
	}

	for (i = 1; i <= n; i++) {
		printf("node %d: ", i);
		printf("key = %d, ", A[i]);
		if (i != 1) {
			pk = i / 2;
			printf("parent key = %d, ", A[pk]);
		}
		lk = i * 2;
		if (lk <= n) {
			printf("left key = %d, ", A[lk]);
			rk = lk + 1;
			if (rk <= n) printf("right key = %d, ", A[rk]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>

using namespace std;

int main()
{
	int N, K, X, Y;
	int ans = 0;
	cin >> N >> K >> X >> Y;

	for (int i = 1;i <= N;i++)
	{
		if (i > K)ans += Y;
		else ans += X;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n;
 cin>>n;
 if(n<=9)
    cout<<n<<endl;
 else if(n>9 && n<=99)
    cout<<"9"<<endl;
 else if(n>99 && n<=999)
    cout<<n-99+9<<endl;
 else if(n>999 && n<=9999)
    cout<<"909"<<endl;
 else if(n>9999 && n<=99999)
     cout<<n-9999+909<<endl;
 else if(n==100000)
     cout<<"90909"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
#define pb push_back
const int maxn = 200005;
const ll mod = 1000000007;
ll f[maxn], n, m, A, B;
ll powmod(ll x, ll n)
{
	ll s = 1;
	while (n)
	{
		if (n & 1)
			s = (s * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return s;
}
ll C(ll n, ll m)
{
	ll a = f[n];
	ll b = (f[m] * f[n - m]) % mod;
	return (a * powmod(b, mod - 2)) % mod;
}
int main()
{
	f[0] = 1;
	for (ll i = 1; i < maxn; i++)
		f[i] = (f[i - 1] * i) % mod;
	cin >> n >> m >> A >> B;
		ll ans = 0;
		for (ll i = B + 1; i <= m; i++)
		{
			ll t = (C(i - 1 + n - A - 1, n - A - 1) * C(m - i + A - 1, m - i)) % mod;
			ans = (ans + t) % mod;
		}
		cout << ans << endl;
	return 0;
}

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

int main(){
   
    int N,C;cin>>N>>C;
    vector<vector<int>> point(C,vector<int>(C)),color(N,vector<int>(N));
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            cin>>point[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>color[i][j];
        }
    }
    vector<int> D(C,0),E(C,0),F(C,0);
    for(int i=0;i<C;i++){
        for(int a=0;a<N;a++){
            for(int b=0;b<N;b++){
                if((a+b)%3==0) D[i]+=point[color[a][b]-1][i];
                if((a+b)%3==1) E[i]+=point[color[a][b]-1][i];
                if((a+b)%3==2) F[i]+=point[color[a][b]-1][i];
            }
        }
    }
    int ans=1000000000;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            for(int k=0;k<C;k++){
                if(i!=j&&j!=k&&k!=i){
                    int sum=0;
                    sum+=(D[i]+E[j]+F[k]);
                    ans=min(ans,sum);
                }
            }
        }
    }
    if(N==1){
        for(int i=0;i<C;i++){
            ans=min(ans,point[color[0][0]-1][i]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n,d,x; cin>>n>>d>>x;
  rep(i,n){
    int a; cin>>a;
    x++;
    int j=1;
    while(j*a+1<=d){
      x++;
      j++;
    }
  }
  cout<<x<<endl;

  return 0;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)
    tmp = 0
    bar1 = 0
    bar2 = 0

    for a in A:
        if tmp == 0:
            tmp = a
        elif tmp == a:
            if bar1 > 0:
                bar2 = a
                print(bar1*bar2)
                exit()
            else:
                bar1 = a
                tmp = 0
        elif a < tmp:
            tmp = a

    print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <iostream>
//#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
  int N, K;
  long H[200000];

  vector<long> vec;

  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> H[i];
    vec.push_back(H[i]);
  }

  std::sort(vec.begin(), vec.begin() + N);

  if (N <= K) {
    cout << 0;
  } else {
    long monster = 0;
    for (int i = 0; i < (N - K); i++) {
      monster += vec[i];
    }
    cout << monster;
  }
  //
  // for (vector<long>::iterator i=begin(v); i != end(v); ++i) {
  //     cout << i << endl;
  //  }
/*
  std::sort(v.begin(), v.end(), std::greater<long>());
  cout << "after" << endl;

  for (vector<long>::iterator i=begin(v); i != end(v); ++i) {
      cout << i << endl;
   }
*/
  return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std ;
 
int main()
{   int n,d;
    cin>>n>>d;
    int x,y,cnt=0;
    while(n--)
    {
        cin>>x>>y;
        if(sqrt(pow(x,2)+pow(y,2))<=d){cnt++;}
    }
    cout<<cnt;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

ll cntA[100001], cntB[100001], cntC[100001], cntQ[100001];
string s;
ll a[4], res;

ll pw(ll x, ll y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a *= x;
			a %= mod;
		}
		x *= x;
		x %= mod;
		y /= 2;
	}
	return a;
}

int main() {
	cin >> s;
	for (int i = 0; i != s.size(); ++i) {
		cntA[i + 1] = cntA[i];
		cntB[i + 1] = cntB[i];
		cntC[i + 1] = cntC[i];
		cntQ[i + 1] = cntQ[i];
		if (s[i] == 'A')
			++cntA[i + 1];
		if (s[i] == 'B')
			++cntB[i + 1];
		if (s[i] == 'C')
			++cntC[i + 1];
		if (s[i] == '?')
			++cntQ[i + 1];
	}
	for (int i = 0; i != s.size(); ++i) {
		if (s[i] == 'B') {
			a[3] += cntA[i] * (cntC[s.size()] - cntC[i + 1]);
			a[3] %= mod;
			a[2] += cntA[i] * (cntQ[s.size()] - cntQ[i + 1]);
			a[2] %= mod;
			a[2] += cntQ[i] * (cntC[s.size()] - cntC[i + 1]);
			a[2] %= mod;
			a[1] += cntQ[i] * (cntQ[s.size()] - cntQ[i + 1]);
			a[1] %= mod;
		}
		if (s[i] == '?') {
			a[2] += cntA[i] * (cntC[s.size()] - cntC[i + 1]);
			a[2] %= mod;
			a[1] += cntA[i] * (cntQ[s.size()] - cntQ[i + 1]);
			a[1] %= mod;
			a[1] += cntQ[i] * (cntC[s.size()] - cntC[i + 1]);
			a[1] %= mod;
			a[0] += cntQ[i] * (cntQ[s.size()] - cntQ[i + 1]);
			a[0] %= mod;
		}
	}
	res += a[3] * pw(3, cntQ[s.size()]);
	res %= mod;
	res += a[2] * pw(3, cntQ[s.size()] - 1);
	res %= mod;
	res += a[1] * pw(3, cntQ[s.size()] - 2);
	res %= mod;
	res += a[0] * pw(3, cntQ[s.size()] - 3);
	res %= mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3584
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;
  REP(i, s.size()) {
    if(i%2==0) {
      cout << s[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 512
// atcoder/abc047/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w, n;
  while (cin >> w >> h >> n) {
    const int N = 100 + 5;
    int g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, 1);
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        g[i][j] = 0;
      }
    }
    for (int _ = 0; _ < n; ++_) {
      int I, J, a;
      cin >> J >> I >> a;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          g[i][j] = g[i][j] || (a == 1 && J > j);
          g[i][j] = g[i][j] || (a == 2 && J <= j);
          g[i][j] = g[i][j] || (a == 3 && I > i);
          g[i][j] = g[i][j] || (a == 4 && I <= i);
        }
      }
    }

    cout << count(&g[0][0], &g[N - 1][N - 1] + 1, 0) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input()) 
A = [int(i) for i in input().split()] 

r = 0
d = {}
pass_list = []
for a in A:
    if a in pass_list:
        r += 1
        continue
    r += 1
    if a in d:
        d[a] += 1
        if d[a] == a:
            r -= a
            pass_list.append(a)
    else:
        d[a] = 1
        if d[a] == a:
          r -= a
          pass_list.append(a)

print(r)

Measured memory_bytes: 18168
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N);RV(neko,N);
  i8t mn=999999,mx=0;
  i8t cmn=0,cmx=0;
  for(i8t a:neko){
    if(a<mn){
      mn=a;
      cmn=1;
    }else if(a==mn)cmn++;
    if(a>mx){
      mx=a;
      cmx=1;
    }else if(a==mx)cmx++;
  }

  if(mx-mn>1){P("No");return 0;}

  if(mx==mn){
    P(mx*2<=N||N-1==mx?"Yes":"No");
  }else{
    P(cmx>=2&&mx>=cmn+1&&mx<=cmn+cmx/2?"Yes":"No");
  }
  return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    for(int i = 0; i < n; i++){
        cin >> H[i];
    }

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

    int mini = 1e9;
    for(int i = 0; i < n - k + 1; i++){
        mini = min(mini, H[i + k - 1] - H[i]);
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 768
n = int(input())+1
a = list(map(int, input().split()))
m_node = [1]*n
node = 0
total = 0

if n == 1:
    if a[0] != 1:
        print("-1", end="")
        exit()
    else:
        print("1", end="")
        exit()

for i in range(1, n):
    m_node[i] = (m_node[i-1] - a[i-1])*2
    if m_node[i] <= 0:
        print("-1", end="")
        exit()
for i in reversed(range(n)):
    if a[i] > m_node[i]:
        print("-1", end="")
        exit()
    node = min((node+a[i]), m_node[i])
    total += node

print(total, end="")


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string str;

int main(){
    cin >> str;
    int i = str.size();
    while (true) {
        if (i == 0) break;
        if (i-6 >= 0) {
            if (str.substr(i-6,6) == "eraser") {
                i -= 6;
                continue;
            }
        }
        if (i >= 7) {
            if (str.substr(i-7,7) == "dreamer") {
                i -= 7;
                continue;
            }
        }
        if (i >= 5) {
            if (str.substr(i-5,5) == "erase") {
                i -= 5;
                continue;
            }
            if (str.substr(i-5,5) == "dream") {
                i -= 5;
                continue;
            }
        }
        puts("NO");
        return 0;
    }
    puts("YES");
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int fac[MAXN], inv[MAXN], two[MAXN], itwo[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int getc(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void init(int n) {
	fac[0] = two[0] = itwo[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = 1ll * fac[i - 1] * i % P;
		two[i] = 2ll * two[i - 1] % P;
		itwo[i] = (P + 1ll) / 2 * itwo[i - 1] % P;
	}
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
int n, m, nw[MAXN], lft[MAXN];
//nw : P(No White Left)
//lft : Cnt(Both Left)
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(m);
	init(n + m), lft[0] = 1;
	for (int i = 1; i <= n + m; i++) {
		nw[i] = nw[i - 1], lft[i] = 2ll * lft[i - 1] % P;
		update(nw[i], 1ll * itwo[i] * getc(i - 1, m - 1) % P);
		if (i >= n) update(lft[i], P - getc(i - 1, n - 1));
		if (i >= m) update(lft[i], P - getc(i - 1, m - 1));
		writeln((nw[i - 1] + 1ll * itwo[i] * lft[i - 1]) % P);
	}
	return 0;
}

Measured memory_bytes: 6912
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = "CODEFESTIVAL2016"
print(sum(x!=y for x, y in zip(S, T)))


Measured memory_bytes: 5148
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    if(b-a+1<=2*k){
        for (int i = a; i <= b;i++)
            cout << i << endl;
    }
    else{
        for (int j = a; j <= a + k - 1;j++)
            cout << j << endl;
        for (int l = b - k + 1; l <= b;l++)
            cout << l << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=input()

#1-indexed
bit=[ 0 for i in range(N+1) ]
bit[0]=None

#BIT
def add(x,w):
	while x<=N:
		bit[x]+=w
		x+=x&(-1*x)

def bitsum(x):
	s=0
	while 0<x:
		s+=bit[x]
		x-=x&(-1)*x
	return s

def search(wa):
	if wa<=0: return 0
	if bitsum(N)<wa: return N+1
	r=N
	l=0
	while r-l!=1:
		m=(l+r)/2
		if bitsum(m)<wa:
			l=m
		else:
			r=m	
	return r


#0-indexed
A=map(int, sys.stdin.readline().split())
# 配列のAの数字の位置を1-indexedで格納。例 B[8]=1 は、Aで数字8が配列Aの1番目（1-indexed)にあることを示す
B=[ 0 for i in range(N+1) ]
for i,a in enumerate(A):
	B[a]=i+1

ans=0
x=N
add(B[x],1)

#大きい数字から順番に、その数字が2番目に大きい数字として何回カウントされることがあるかをカウント
for x in range(N-1,0,-1):
	cur_p=B[x]	#current position
	cur_v=bitsum(cur_p)
	l1=search(cur_v)
	l2=search(cur_v-1)
	r1=search(cur_v+1)
	r2=search(cur_v+2)
	#print "l2,l1,r1,r2 :: ",l2,l1,r1,r2
	#print "ans+=( (",l1-l2,")*(",r1-cur_p,")+(",cur_p-l1,")*(",r2-r1,") )*",x
	#(左に自分より大きい数字がある場合＋右に自分より大きい数字がある場合)*自分の数字
	ans+=( (l1-l2)*(r1-cur_p)+(cur_p-l1)*(r2-r1) )*x
	#数字をBITに追加
	add(B[x],1)

print ans


Measured memory_bytes: 51928
#include<cstdio>
#include<algorithm>
using namespace std;
const long long MAXN=1005,MAXM=1005,MAXK=1005,MOD=1000000007;

long long gcd(long long a,long long b)
{return b==0?a:gcd(b,a%b);}
long long powmod(long long a,long long b)
{
	long long ret=1;
	while(b)
	{
		if(b&1LL)
			ret=(1LL*ret*a)%MOD;
		a=(1LL*a*a)%MOD;
		b>>=1LL;
	}
	return ret;
}

struct Edge
{
	long long v,id;
	Edge *nxt;
}E[MAXM*2],*adj[MAXN],*ecnt=E;
void AddEdge(long long u,long long v,long long id)
{
	ecnt->v=v;ecnt->id=id;
	ecnt->nxt=adj[u];
	adj[u]=ecnt++;
	ecnt->v=u;ecnt->id=id;
	ecnt->nxt=adj[v];
	adj[v]=ecnt++;
}

long long ans=1,powk[MAXK],inv[MAXK],fac[MAXK],ifac[MAXK];
long long N,M,K;
long long dfc,dfn[MAXN],low[MAXN],top;
bool vis[MAXM],mk[MAXN];
Edge *stk[MAXM];

void tarjan(long long u)
{
	dfn[u]=++dfc;
	low[u]=dfn[u];
	for(Edge *p=adj[u];p;p=p->nxt)
		if(!vis[p->id])
		{
			long long v=p->v;
			vis[p->id]=true;
			stk[++top]=p;
			if(dfn[v]==0)
			{
				tarjan(v);
				low[u]=min(low[u],low[v]);
				if(low[v]>=dfn[u])
				{
					long long tmp=0,cnt=0;
					bool flag=false;
					for(long long i=top;stk[i+1]!=p&&i>0;i--)
					{
						if(mk[stk[i]->v])
							flag=true;
						mk[stk[i]->v]=true;
						cnt++;
					}
					if(flag)
						tmp=fac[cnt+K-1]*ifac[cnt]%MOD*ifac[K-1]%MOD;	
					else
					{
						for(long long i=0;i<cnt;i++)
							tmp=(tmp+powk[gcd(cnt,i)])%MOD;
						tmp=(tmp*inv[cnt])%MOD;
					}
					
					ans=ans*tmp%MOD;
					do
					{
						mk[stk[top]->v]=false;
						top--;
					}while(stk[top+1]!=p);
				}
			}
			else
				low[u]=min(low[u],dfn[v]);
		}
}

int main()
{
	scanf("%lld%lld%lld",&N,&M,&K);
	powk[0]=1;fac[0]=1;ifac[0]=1;inv[0]=1;
	for(long long i=1;i<1000;i++)
	{
		powk[i]=powk[i-1]*K%MOD;
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=powmod(i,MOD-2);
		ifac[i]=powmod(fac[i],MOD-2);
	}
	for(long long i=1;i<=M;i++)
	{
		long long u,v;
		scanf("%lld%lld",&u,&v);
		AddEdge(u,v,i);
	}
	for(long long i=1;i<=N;i++)
		if(!dfn[i])
			tarjan(i);
	printf("%lld\n",ans);
	
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> masme(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> masme[i][j];
    }
  }
  vector<bool> yoko(H, false);
  vector<bool> tate(W, false);

  for (int i = 0; i < H; i++) {
    bool black = false;
    for (int j = 0; j < W; j++) {
      if (masme[i][j] == '#') {
        black = true;
        break;
      }
    }
    if (!black) yoko[i] = true;
  }

  for (int i = 0; i < W; i++) {
    bool black = false;
    for (int j = 0; j < H; j++) {
      if (masme[j][i] == '#') {
        black = true;
        break;
      }
    }
    if (!black) tate[i] = true;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (yoko[i] || tate[j]) continue;
      cout << masme[i][j];
    }
    if (!yoko[i]) cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,h[200000];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    int sum=0;
    for(int i=0;i<n-k;i++)
        sum+=h[i];
    cout<<sum<<endl;
}


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

using namespace std;

int n;
vector<int> p;
int main(void) {
  cin >> n;
  p = vector<int>(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) p[i]--;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (p[i] == i && p[i+1] == i+1) {
      p[i] = i+1;
      p[i+1] = i;
      ans++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == i) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
_input = input().split(" ")
_A = int(_input[0])
_B = int(_input[1])
_C = int(_input[2])

if _A < _B:
  if _A < _C and _C < _B:
    print("Yes")
  else:
    print("No")
else:
  if _B < _C and _C < _A:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()

    N, M = len(S), len(T)
    ans = []

    for i in range(N - M + 1):
        ok = True
        s = list(S)
        for j in range(M):
            if S[i + j] == '?':
                s[i + j] = T[j]
            elif S[i + j] != T[j]:
                ok = False
                break
        if ok:
            ans.append(''.join(s).replace('?', 'a'))

    if ans:
        ans.sort()
        print(ans[0])
    else:
        print('UNRESTORABLE')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62120
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[200001],i;
	long long sum=0,sum2=0;
	sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		sum%=1000000007;
	}
	for(i=0;i<n;i++){
		sum-=a[i];
		if(sum<0){
			sum+=1000000007;
		}
		sum2+=a[i]*sum%1000000007;
		sum2%=1000000007;
	}
	printf("%lld\n",sum2);
	return 0;
}

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

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

int main()
{
    int A;
    int num5 = 0;
    int num7 = 0;
    rep(i, 3){
        cin >> A;
        if(A == 5)
            num5++;
        if(A == 7)
            num7++;
    }
    cout << (num5 == 2 && num7 == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
while 1:
	N = input()
	if N == 0: break
	M = [map(int,raw_input().split()) for i in range(N+1)]
	K = set(M[-1][1:])
	a = -1
	for i in range(N):
		if set(M[i][1:]) >= K:
			if a != -1:
				a = -1
				break
			a = i + 1
	print a

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

int main() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>>M(r, vector<int>(c));
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> M.at(i).at(j);
        }
    }
    vector<int>a;
    for(int i=0; i<c; i++){
        int ttl=0;
        for(int j=0; j<r; j++){
            ttl+=M.at(j).at(i);
        }
        a.push_back(ttl);
    }
    M.push_back(a);


    for(int i=0; i<r+1; i++){
        int x = accumulate(M.at(i).begin(), M.at(i).end(), 0);
        M.at(i).push_back(x);
    }
for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            cout << M.at(i).at(j);
            if(j<c) cout << " " ;
        }
       cout << endl;
    }

    
    return 0;
}




Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) {
        ll a,b; cin >> a >> b;
        A[i] = a + b;
        B[i] = a - b;
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    ll ans = 0;
    ans = max(ans,A.back() - A[0]);
    ans = max(ans,B.back() - B[0]);
    cout << ans << '\n';
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    string T = "";
    int count = 0; //何文字目かを記録する変数

    while(true) {
        //cout << S[count] << endl;
        if (S.size() - (count) < 10) { //最後の単語の処理
            //cout << "final roop" << endl;
            if (S.size() - (count) == 5) {  //最後の単語が5文字
                if (S[count] == 'd') T += "dream";
                else T += "erase";
            } else {
                if (S[count] == 'd') T += "dreamer";
                else T += "eraser";
            }
            //cout << T << endl;
            break;  //ループ脱出
        }


        if (S[count] == 'd') {  //dream or dreamer
            if (S[count + 5] == 'd') {
                T += "dream"; //dream かつ 次が dream or dreamer
                count += 5;
                continue;
            } else if (S[count + 7] == 'a') {
                T += "dream"; //dream かつ 次が erase or eraser
                count += 5;
                continue;
            } else {
                T += "dreamer";    //dreamer
                count += 7;
                continue;
            }

        } else if (S[count] == 'e') {   //erase or eraser
            if (S[count + 5] == 'd') {
                T += "erase";   //erase かつ 次が dream or dreamer
                count += 5;
                continue;
            } else if (S[count + 7] == 'a') {
                T += "erase";   //erase かつ 次が erase or eraser
                count += 5;
                continue;
            } else {
                T += "eraser";  //eraser
                count += 6;
                continue;
            }
        }
        //cout << T << endl;
        break;
    }

    if (S == T) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

char s[10];

int n, m;

int main(){
	while(~scanf("%d %d", &n, &m)){
		for(int i=1; i<=n; i++){
			for(int j=0; j<m; j++){
				scanf("%s", s);
				if(strcmp(s, "snuke") == 0){
					printf("%c%d\n", j+'A', i);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    rep(i,s.size())cout<<"x";
}

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

int main(){
	int people,days,remainingCount;
	std::cin >> people >> days >> remainingCount;
	int originalCount = remainingCount;
	int person_consumingDuration[people];
	for(int i=0;i<people;i++)std::cin >> person_consumingDuration[i];

	for(int i=0;i<people;i++){
		for(int j=1;j<=days;j+=person_consumingDuration[i])
			originalCount += 1;
	}

	std::cout << originalCount << std::endl;
	return 0;
}


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

int main()
{
  int N;
  int ans = 0;
  
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
		ans += d.at(i) * d.at(j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
  let stdin = stdin();
  let line = stdin.lock().lines().next().unwrap().unwrap();

  let mut args = line.split_whitespace().map(|str| str.parse::<i32>().unwrap());
  let w = args.next().unwrap();
  let h = args.next().unwrap();
  let x = args.next().unwrap();
  let y = args.next().unwrap();
  let r = args.next().unwrap();

  if x < r || y < r || x + r > w || y + r > h {
    println!("No");
  } else {
    println!("Yes");
  }
}



Measured memory_bytes: 5028
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
const long long mod = 1000000007;
long long n, m, ans;

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

  cin >> n >> m;
  ans = 0;
  if (abs(n-m) <= 1) {
    ans = 1;
    for (int i = 0; i < n; i++) {
      ans = (ans*(n-i)) % mod;
    }

    for (int i = 0; i < m; i++) {
      ans = (ans*(m-i)) % mod;
    }

    if (n == m) {
      ans = (ans*2) % mod;
    }
  }

  cout << ans;

  return 0;
}

//n*(m-1)*(n-1)


Measured memory_bytes: 256
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 200005

ll a[ma],b[ma];

int main()
{
    ll n,i,j;
    while(cin>>n)
    {
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            b[a[i]]=i;
        }
        ll cn=0;
        ll pre=0;
        ll max1=0;
        for(i=1;i<=n;i++)
        {
            if(b[i]>pre)
            {
                pre=b[i];
                cn++;
            }
            else
            {
                pre=b[i];
                cn=1;
            }
            max1=max(max1,cn);
        }
        cout<<n-max1<<endl;
    }
    return 0;
}


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

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  else return gcd(b, a%b);
}

void solve() {
  ll a, b;
  cin >> a >> b;
  ll t = gcd(a, b);
  vector<ll> v;
  v.push_back(1);
  for(ll i = 2; i * i <= t; i++) {
    if(t % i != 0) continue;
    v.push_back(i);
    while(t % i == 0) {
      t /= i;
    }
  }
  if(t != 1) v.push_back(t);
  cout << v.size() << endl;
}

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, k;
    cin >> n >> k;

    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }
    int conn_max = (n-1)*(n-2)/2;
    int m = n-1 + (conn_max - k);
    cout << m << endl;
    for(int i=2;i<=n;i++) cout << "1 " << i << endl;
    for(int i=2;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(k == conn_max) return 0;
            cout << i << " " << j << endl;
            k++;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int A, B; cin >> A >> B;
	vi v = {1, 2, 3};
	each(i, v) {
		if (i != A && i != B) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256