akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    string s;
    int dp[2][10][10][2];
    while(cin >> s && s != "#"){
        int n = s.size();
        rep(i, 2)rep(j, 10)rep(k, 10)rep(l, 2) dp[i][j][k][l] = MAX;
        dp[0][0][2][0] = dp[0][0][2][1] = 0;
        rep(i, n){
            rep(j, 10)rep(k, 10){
                int t = s[i]-'1';
                if(j%3 <= t%3){
                    chmin(dp[1][j][t][1], dp[0][j][k][0]);
                    chmin(dp[1][j][t][1], dp[0][j][k][1]+1);
                }
                if(t%3 <= k%3){
                    chmin(dp[1][t][k][0], dp[0][j][k][1]);
                    chmin(dp[1][t][k][0], dp[0][j][k][0]+1);
                }
            }

            rep(j, 10)rep(k, 10)rep(l, 2){
                dp[0][j][k][l] = dp[1][j][k][l];
                dp[1][j][k][l] = MAX;
            }
        }

        int ans = MAX;
        rep(j, 10)rep(k, 10)rep(l, 2) chmin(ans, dp[0][j][k][l]);
        printf("%d\n", ans);
    }
}


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

const double ep = 1e-10;

int main() {
    int a, b, c, d, e, f, A, B, C;
    double x, y;
    while(cin >> a >> b >> c >> d >> e >> f) {
        A = c*e - b*f;
        B = a*f - c*d;
        C = a*e - b*d;
        x = (double)A/C; y = (double)B/C;
        if(x>-ep && x<ep) x = 0.0;
        if(y>-ep && y<ep) y = 0.0;
        printf("%.3f %.3f\n", x, y);
    }
}


Measured memory_bytes: 3124
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final int[] WEIGHT =
		{512, 256, 128, 64, 32, 16, 8, 4, 2, 1};

	public static void main(String[] args) {
		 while(sc.hasNext()) { //??\?????¶?????°?????????
			 //??\???????????¨???
			 int num = sc.nextInt();
			 int[] ans = new int[WEIGHT.length];
			 Arrays.fill(ans, 0);

			 for(int $ = 0; $ < WEIGHT.length; $++) {
				 if(num >= WEIGHT[$]) {
					 ans[$] = WEIGHT[$];
					 num -= WEIGHT[$];
				 }
			 }

			 Arrays.sort(ans);

			 for(int $ = 0; $ < WEIGHT.length; $++) {
				 if($ == 9) {
					 System.out.println(ans[$]);
				 } else if(ans[$] != 0) {
					 System.out.print(ans[$] + " ");
				 }
			 }
		}

	}

}

Measured memory_bytes: 26076
#include <stdio.h>

void swap_int(int *a, int *b) {
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(int argc, char *argv[]) {
  int a[3], i, j;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  for (i = 0; i < 3; i++) {
    /* printf("%d %d %d\n", a[0], a[1], a[2]); */
    for (j = i; j < 3; j++) {
      if (a[i] > a[j]) {
        swap_int(&a[i], &a[j]);
      }
    }
  }

  for (i = 0; i < 2; i++) {
      printf("%d ", a[i]);
  }
  printf("%d\n", a[2]);

  return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << min({P+Q, P+R, Q+R}) << endl;
}


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

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

	vector<int> weight(N);

	for (int i = 0; i < N; i++)
	{
		cin >> weight.at(i);
	}

	int ans = 1e9;
	for (int i = 0; i < N; i++)
	{
		int l = 0;
		int r = 0;
		for (int j = 0; j < i; j++)
		{
			l += weight.at(j);
		}
		for (int j = i; j < N; j++)
		{
			r += weight.at(j);
		}
		ans = min(ans, abs(l - r));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

def f(x):
  amari = x % 4
  if amari == 0:
    return x
  elif amari == 1:
    return x ^ (x-1)
  elif amari == 2:
    return x ^ (x-1) ^ (x-2)
  elif amari == 3:
    return 0
    
    
A = f(a-1)
B = f(b)


print(A^B)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl p(n);
  rep(i,n)cin>>p[i];
  ll ans=0;
  vector<bool>ok(n,false);
  rep(i,n){
    if(i>=1&&i+1==p[i]&&ok[i-1]==true){
      continue;
    }
    else if(i+1==p[i]){
      ok[i]=true;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector< pair<int,int> >e[100010];
int vis[100010];
int dis[100010];

int dfs(int u)
{
    int s,t;
    vis[u]=1;
    vector<pair<int,int> >::iterator iter;
    for(iter=e[u].begin();iter!=e[u].end();iter++)
    {
        s=iter->first;
        t=iter->second;
//    cout<<"s="<<s<<endl;
//    cout<<"t="<<t<<endl;
//    cout<<endl;
    if(!vis[s])
    {
        dis[s]=dis[u]+t;
        if(!dfs(s)) return false;
    }
    else if((dis[u]+t)!=dis[s]) return false;
    }
     return true;
}

int main()
{
    memset(vis,0,sizeof(vis));
    int n,m;
    int u,v,w;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&u,&v,&w);
        e[u].push_back(make_pair(v,w));
        e[v].push_back(make_pair(u,-w));
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            if(!dfs(i))
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 11392
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//ld dis(ll a,ll b,ll c,ll d){return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;}

int main(){
	ll n,m,x ;
	cin >> n >> m >> x ;
	vll c(n) ;
	vvll d(n,vll(m)) ;
	for(int i=0;i<n;i++){
		cin >> c.at(i) ;
		for(int j=0;j<m;j++){
			cin >> d.at(i).at(j) ;
		}
	}
	ll ans = INF ;
	for(int i=0;i<(1<<n);i++){
		bitset<15> bit(i) ;
		bool ok = true ;
		for(int j=0;j<m;j++){
			ll sum = 0 ;
			for(int k=0;k<n;k++){
				if(bit[k]){
					sum += d.at(k).at(j) ;
				}
			}
			if(sum<x) ok = false ;
		}
		if(ok){
			ll sub = 0 ;
			for(int j=0;j<n;j++){
				if(bit[j]){
					sub += c.at(j) ;
				}
			}
			ans = min(ans,sub) ;
		}
	}
	cout << (ans==INF?-1:ans) << endl ;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
const int N=2e5+10;
int a[N],n,vis[N],t;
long long k;
int dfs(int v,int p){
	if(vis[v]){
		t=v;
		return vis[p]-vis[v]+1;
	}
	vis[v]=vis[p]+1;
	return dfs(a[v],v);
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	int f=dfs(1,0);
	if(k<vis[t]-1){
		int s=1;
		for(int i=0;i<k;i++) s=a[s];
		cout<<s;
		return 0;
	}
	k-=vis[t]-1;
	k%=f;
	int s=t;
	for(int i=0;i<k;i++) s=a[s];
	cout<<s<<"\n";	
	return 0;
}


Measured memory_bytes: 5208
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  string s;
  cin >> s;
  bool ex[26];
  fill(ex,ex+26,false);
  for(int i=0;i<s.size();i++){
    ex[s[i]-'a'] = true;
  }

  for(int i=0;i<26;i++){
    if(!ex[i]){
      cout << char(i + 'a') << endl;
      return 0;
    }
  }

  cout << "None" << endl;
  return 0;
}


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


int main()
{
   int n,i=0,max=0,sum=0;
 int a[11];
scanf("%d",&n);
   for(i=0;i<n;i++)
    {
       scanf("%d",&a[i]);
        sum+=a[i];


    }

   for(i=0;i<n;i++)
   {
       if (a[i]>max)
        max=a[i];

   }
   printf("%d",sum-max/2);




return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> b = a;
    sort(b.begin(), b.end());
    map<int, ll> memo;
    for (int i = 0; i < n; i++) {
        memo[b[i]] = b.end() - upper_bound(b.begin(), b.end(), b[i]);
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = 0; j < i; j++) {
            cnt += (a[j] > a[i]);
        }
        ll hoge = ((K - 1) * memo[a[i]] % MOD + 2 * cnt) * K % MOD * ((MOD + 1) / 2) % MOD;
        (ans += hoge) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
//
// A - One Card Poker
//

#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A == 1) A = 14;
    if (B == 1) B = 14;
    cout << (A > B ? "Alice" : (A < B ? "Bob" : "Draw")) << endl;
}

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

using namespace std;

int main() {
	int h, w;
	string a[8], ans = "Possible";
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			int c = 0, r = 0, d = 0, l = 0, u = 0;
			if (a[y][x] == '#')c = 1;
			if (y+1 < h || x+1 < w) {
				if (x + 1 < w && a[y][x + 1] == '#')r = 1;
				if (y + 1 < h && a[y + 1][x] == '#')d = 1;
				if (c && !(r^d))ans = "Impossible";
			}
			if (y > 0 || x > 0) {
				if (x - 1 >= 0 && a[y][x - 1] == '#')l = 1;
				if (y - 1 >= 0 && a[y - 1][x] == '#')u = 1;
				if (c && !(l^u))ans = "Impossible";
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int h, w, dd[] = {0, 1, 0, -1, 0};
	cin >> h >> w;
	auto inside = [&](int a, int b) {
		return 0 <= a && a < h && 0 <= b && b < w;
	};
	string s[h];
	for (auto &t : s) {
		cin >> t;
	}
	pair<int, int> pp[h][w];
	int dist[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = -1;
		}
	}
	queue<pair<int, int>> q;
	q.push({0, 0});
	dist[0][0] = 0;
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x + dd[i], ny = y + dd[i + 1];
			if (!inside(nx, ny) || s[nx][ny] == '#' || (0 <= dist[nx][ny] && dist[nx][ny] <= dist[x][y] + 1)) {
				continue;
			}
			dist[nx][ny] = dist[x][y] + 1;
			pp[nx][ny] = {x, y};
			q.push({nx, ny});
		}
	}
	if (dist[h - 1][w - 1] < 0) {
		cout << -1 << endl;
		return 0;
	}
	{
		pair<int, int> now(h - 1, w - 1);
		while (now != make_pair(0, 0)) {
			int x = now.first, y = now.second;
			int nx = pp[x][y].first, ny = pp[x][y].second;
			s[x][y] = s[nx][ny] = 'n';
			now = {nx, ny};
		}
	}
	int count = 0;
	for (auto &t : s) {
		cerr << t << endl;
		for (auto &c : t) {
			if (c == '.') {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
//typedef long long ll;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
ll i_7=1;
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat a,mat b){/*行列aと行列bの積*/
    mat c(a.size(),vec(b[0].size()));
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b[0].size();j++){
            for(int k=0;k<a[0].size();k++){
                c[i][j]=mod(c[i][j]+a[i][k]*b[k][j]);
            }
        }
    }
    return c;
}
ll pow(ll a,ll p){
    ll res=1;
    rep(i,1,p)res=res*a;
    return res;
}

mat pow(mat a,ll n){/*行列aのn乗*/
    mat b(a.size(),vec(a.size()));
    for(int i=0;i<a.size();i++){
        b[i][i]=1;
    }
    while(n>0){
        if(n&1)b=mul(b,a);
        a=mul(a,a);
        n>>=1;
    }
    return b;
}
//////////////////////////////////////////
int main(){
    //最後にタバイチョウに直す
    ll l,a,d;cin>>l>>a>>d>>i_7;
    ll S=1;
    ll num[20];for(int i=0;i<=19;i++)num[i]=0;
    num[19]=l;
    for(int t=1;t<=18;t++){
        if(pow((ll)10,t)<=a)continue;
        ll ok=l,ng=-1;
        
        while(abs(ok-ng)>1){
            ll mid=(ok+ng)/2;
            if(a+(mid)*d>=pow((ll)10,t-1))ok=mid;
            else ng=mid;
        }
         
        num[t]=ok;
    }
    /*
    for(int i=0;i<=19;i++){
        cout<<i<<" "<<num[i]<<endl;
    }*/
  
    ll ans=0;
    for(int t=18;t>=1;t--){
        if(num[t]==num[t+1])continue;
        mat B(3,vec(1));
        B={{a+(num[t])*d},{a+(num[t])*d},{1}};
        mat A(3,vec(3));
        A={ {po(10,t),1,d},
            {0,1,d},
            {0,0,1}};
        ll n=num[t+1]-num[t];
        A=pow(A,n-1);
        B=mul(A,B);
        Add(ans,mod(B[0][0]*S));
        S=mod(S*(ll)po(10,n*t));
        //cout<<ans<<" ";
    }
    cout<<mod(ans)<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
def bfs(x):
  from collections import deque
  dist = [INF] * (H * W)
  dist[x] = 0
  stack = deque([(0, x)]) #
  while stack:
    v, s = stack.popleft() #
    for w, g in graph[s]:
      if dist[g] > v + w:
        dist[g] = v + w
        stack.append((dist[g], g)) #
  return dist

H, W = map(int, input().split())
S = [input() for _ in range(H)]

INF = 10**15
graph = [[] for _ in range(H * W)]
 
for i in range(H):
  for j in range(W):
    for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
      if 0 <= ni < H and 0 <= nj < W and S[ni][nj] != "#":
        graph[W * i + j].append((1, W * ni + nj))

answer = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      continue
    else:
      dist = bfs(i * W + j)
      for ii in range(H * W):
        if dist[ii] != INF:
          answer = max(answer, dist[ii])
      
print(answer)

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

int main() {
	int n;
	cin >> n;
	vector<long long> x, y;
	long long a, b, i, j,k,l;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		x.push_back(a);
		y.push_back(b);
	}
	/*	for (int i = 0; i < n; i++) {
			cout << x[i] << y[i] << endl;
		}
	*/	
	long long p, q;
	int point = 0, maxpoint = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i == j) continue;
			else{
				p = x[i] - x[j];
				q = y[i] - y[j];
			}
			for (k = 0; k < n; k++) {
				for (l = 0; l < n; l++) {
					if (k == l) continue;
					else if ((x[k] + p) == x[l] && (y[k] + q) == y[l]) {
						point++;
					}
				}
			}		
			if (point > maxpoint) {
				maxpoint = point;
			}
			point = 0;
		}
	}

	cout << n - maxpoint;
	return 0;
}


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

long long int a, b, c, d;

long long int func(long long int n){
  long long int ret = 0;
  long long int lcm = c * d;
  lcm /= __gcd(c, d);
  ret += n / c;
  ret += n / d;
  ret -= n / lcm;
  cerr << ret << endl;
  return ret;
}

int main(){
  cin >> a >> b >> c >> d;
  long long int range = b - a + 1;
  long long int antidiv = func(b) - func(a - 1);
  cout << range - antidiv << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int tail[100010];
bool pan(long long x)
{
    long long sum = 0;
    for(int i = 1;i<=n;++i)
    {
        long long t = (long long)tail[i]-x*b;
        if(t>0)
        {
            sum+=(long long)ceil(t*1.0/(a-b));
            if(sum>x||sum<0)
                return false;
        }
    }
    return true;
}
int main()
{
        scanf("%d%d%d",&n,&a,&b);
        int imax = 0;
        for(int i = 1;i<=n;++i)
        {
            scanf("%d",&tail[i]);
            imax = max(imax,tail[i]);
        }
        long long l = 0,r = imax;
        long long mid;
        while(l<r)
        {

            mid = l+r>>1;
            //cout<<"l: "<<l<<" r: "<<r<<" mid: "<<mid<<'\n';
            if(pan(mid)) r = mid;
            else l = mid + 1;
        }
        cout<<r<<'\n';
}


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

namespace ABC138D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NQ = ReadInt();
            int N = NQ[0];
            int Q = NQ[1];

            Edges = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                Edges[i] = new List<int>();
            }
            for (int i = 0; i < N - 1; i++)
            {
                var input = ReadInt();
                Edges[input[0] - 1].Add(input[1] - 1);
                Edges[input[1] - 1].Add(input[0] - 1);
            }

            points = new int[N];
            for (int i = 0; i < Q; i++)
            {
                var input = ReadInt();
                points[input[0] - 1] += input[1];
            }

            Accessed = new int[N];
            DFS(0, 0);

            Console.WriteLine(string.Join(" ", points));
            Console.ReadKey();
        }

        static int[] points;
        static List<int>[] Edges;
        static int[] Accessed;
        static void DFS(int v, int count)//0から始まる番号
        {
            if (Accessed[v] == 1) return;
            Accessed[v] = 1;

            points[v] += count;
            count = points[v];

            foreach (var e in Edges[v])
            {
                DFS(e, count);
            }
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 75100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int a[6];
		for(int i=1;i<=5;i++){
			cin>>a[i];
			if(a[i]==0){
				cout<<i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

	class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            
            String s = sc.next();
            String SS = s+s;
            String str = sc.next();
            	if(SS.contains(str)){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
        }
    }


Measured memory_bytes: 26256
def isPrime(x):
    if x < 0:
        return False
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    i = 3
    while i * i <= x:
        if x % i == 0:
            return False
        i += 2
    return True


if __name__ == '__main__':
    n = int(input())
    cnt = 0
    for i in range(n):
        x = int(input())
        if isPrime(x):
            cnt += 1
    print(cnt)


Measured memory_bytes: 5616
#include<stdio.h>
int main(){
    int n,i,st[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&st[i]);
    }
    for(i=n-1;i>0;i--){
        printf("%d ",st[i]);
    }
    printf("%d\n",st[0]);
    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,w,n;
  cin >> h >> w >> n;

  vll a(n);
  REP(i, n)
    cin >> a[i];

  vector<vll> ans(h, vll(w));
  ll cur = 0;
  ll x,y;
  REP(i, h){
    REP(j, w){
      x = i;
      if(x%2 == 0)
        y = j;
      else
        y = w-1-j;
      ans[x][y] = cur+1;
      a[cur]--;
      if(a[cur]==0)
        cur++;
    }
  }

  REP(i, h){
    REP(j, w-1)
      cout << ans[i][j] << " ";
    cout << ans[i][w-1] << endl;
  }




  
  
}


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

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    n++;

    ll sum(0);
     rep(i, 1, n)
     { 
        rep(j, 1, n)
         {
            if (i % 2 == 0 && j % 2 == 1)
                sum++;
                //cout << i << ' ' << j << endl, sum++;   

            //if (j % 2 == 0 && i % 2 == 1)
            //    cout << i << ' ' << j << endl, sum++;   
         }
     }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
	int		n, ai, min, max;
	long	sum;

	scanf("%d", &n);
	scanf("%d", &ai);
	min = ai;
	max = ai;
	sum = ai;
	for (int i = 1; i < n; i++)
	{
		scanf("%d", &ai);
		if (ai < min)
			min = ai;
		if (ai > max)
			max = ai;
		sum += ai;
	}
	printf("%d %d %ld\n", min, max, sum);
	return (0);
}





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

int main() {
  long long a,b,k; cin >> a >> b >> k;
  if(a>=k) cout << a-k << " " << b << endl;
  else if(a+b>=k) cout << 0 << " " << (a+b)-k << endl;
  else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

//  nCk の組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

signed main(){
  int N,ans=0;
  cin >> N;
  int A[5]={};
  rep(i,N){
    string s;
    cin >> s;
    if(s[0]=='M') A[0]++;
    else if(s[0]=='A') A[1]++;
    else if(s[0]=='R') A[2]++;
    else if(s[0]=='C') A[3]++;
    else if(s[0]=='H') A[4]++;
  }
  sort(A,A+5);
  reverse(A,A+5);
  int c=0;
  rep(i,5) if(A[i]!=0) c++;
  if(c<3){
    cout << 0 << endl;
    return 0;
  }
  foreach_comb(c, 3, [&](int *X) {
  //  cout << X[0] << " " << X[1] << " " << X[2] << endl;
    ans+=A[X[0]]*A[X[1]]*A[X[2]];
  });
  cout << ans << endl;
  return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var dict = new Dictionary<int, int>();
            var set = new HashSet<int>();
            for (var i = 0; i < N; i++)
            {
                if (dict.ContainsKey(A[i]))
                    dict[A[i]]++;
                else
                    dict[A[i]] = 1;

                set.Add(A[i]);
            }

            var stack = new Stack<int>();
            foreach (var d in dict.Where(z => z.Value >= 2))
                stack.Push(d.Value);

            while (stack.Count > 1)
            {
                var diff = Math.Abs(stack.Pop() - stack.Pop());
                if (diff == 0) continue;
                stack.Push(diff + 1);
            }

            var isOk = true;
            if (stack.Count == 1)
            {
                var tmp = stack.Pop();
                if (tmp % 2 == 0) isOk = false;
            }

            Console.WriteLine(isOk ? set.Count : set.Count - 1);
        }
    }
}


Measured memory_bytes: 30688
#include <cstdio>

int main(){
    int r,c,sum;
    int a[100][100];
    scanf("%d%d",&r,&c);
    for(int i = 0;i < r;i++){
        for(int j = 0;j < c;j++){
            scanf("%d",&a[i][j]);    
        }
    }
    
    for(int i = 0;i < r;i++){
        sum = 0;
        for(int j = 0;j < c;j++){
            printf("%d ",a[i][j]);
            sum += a[i][j];
        }
        printf("%d\n",sum);
    }
    
    int sum2 = 0;
    for(int i = 0;i < c;i++){
        sum = 0;
        for(int j = 0;j < r;j++){
            sum += a[j][i];
        }
        sum2 += sum;
        printf("%d ",sum);
    }
    printf("%d\n",sum2);

    return 0;
}


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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  int s1=1;
  int s2=2+M;
  int r1=M;
  int r2=M-1;
  
  for(int i=0; i<M; i++){
    int &s = (i % 2 ==0) ? s1 : s2;
    int &r = (i % 2 ==0) ? r1 : r2;
    cout << s << " " << s+r << endl;
    ++s;
    r = r -2;
  }
  return 0;
}

Measured memory_bytes: 3640
K = int(input())


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        #        tmp, r = divmod(tmp, 10)
        r = tmp % 10
        tmp //= 10
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#define INF 40
using namespace std;

char map[102][102];
int h, w;
int ans;
char tree;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void dfs(int x,int y)
{
	int nx, ny;
	map[x][y] = '.';
	for (int i = 0;i < 4;i++)
	{
		nx = x + dx[i];
		ny = y + dy[i];
		if (map[nx][ny] == tree && nx >= 0 && nx < h && ny >= 0 && ny < w)
		{
			dfs(nx, ny);
		}
	}
	return;
}

int main()
{
	while (~scanf("%d%d",&h,&w))
	{
		getchar();
		ans = 0;
		if (h == 0 && w == 0) break;
		for (int i = 0;i < h;i++)
		{
			for (int j = 0;j < w;j++)
			{
				scanf("%c", &map[i][j]);
			}
			getchar();
		}

		for (int i = 0;i < h;i++)
		{
			for (int j = 0;j < w;j++)
			{
				if (map[i][j] == '#' || map[i][j] == '*' || map[i][j] == '@')
				{
					tree = map[i][j];
					dfs(i, j);
					ans++;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

#define For(k,i) for(int i=0;i<k;i++)

using namespace std;
using ll = long long;

int main() {
    int ans = 0;
    int h,w,n;
    cin >> h >> w >> n;
    int ma = max(h,w);
    int mi = min(h,w);
    float a = ceil((float)n/(float)ma); 
    cout << a;
}


Measured memory_bytes: 256
import math
from decimal import Decimal

A, B, H, M = map(int,input().split())

cos = math.cos(math.radians(Decimal(360.0*(H/12.0+M/(12*60)-M/60.0))))
C = Decimal(A**2 + B**2 - 2.0*A*B*cos)**Decimal('0.5')

print(C)

Measured memory_bytes: 10348
#include <bits/stdc++.h>
#define INT long long
#define oo (int)(1e9)+1
using namespace std;

char x, y;

int main()
{
    ios::sync_with_stdio(false);
    cin>>x>>y;
    if( x > y ) cout<<">"<<endl;
    else if( x < y ) cout<<"<"<<endl;
    else cout<<"="<<endl;
}


Measured memory_bytes: 256
def calc(sum,cnt,len)
  k = (len*2 -cnt + 1)
  return k * cnt / 2 - sum
end

s = gets.chomp
len,sum,cnt,ans = 0,0,0,0
i = 0
while i < s.length
  if s[i] == "A"
    len += 1
    sum += len
    cnt += 1
  elsif s[i] == "B"
    if s[i+1] != "C"
      ans += calc(sum,cnt,len)
      len,sum,cnt = 0,0,0
    else
      len += 1
      i += 1
    end
  else
    ans += calc(sum,cnt,len)
    len,sum,cnt = 0,0,0
  end
  #p [i,len,cnt,sum,ans]
  i += 1
end
ans += calc(sum,cnt,len)
p ans

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  int ans = 0;
  while(true){
    bool flag = false;
    for(int i = 0; i < N; i++){
      if(A[i] % 2 != 0){
        flag = true;
      }
    }
    
    if(flag){
      break;
    }
    
    for(int i = 0; i < N; i++){
      A[i] /= 2;
    }
    
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,m,X,Y;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	int x[n],y[m];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(int j=0;j<m;j++)
	{
		scanf("%d",&y[j]);
	}
	int xmax=-101,ymin=101;
	for(int k=0;k<n;k++)
	{
		if(x[k]>=xmax)
		{
			xmax=x[k];
		}
	}
	if(X>=xmax)
	{
		xmax=X;
	}
	
	for(int l=0;l<m;l++)
	{
		if(y[l]<=ymin)
		{
			ymin=y[l];
		}
	}
	if(Y<=ymin)
	{
		ymin=Y;
	}
	
	int abs=ymin-xmax;
	if(abs>0)
	{
		printf("No War");
	}
	else
	{
		printf("War");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll M=1e9+7;
const ll mxx=1e5+7;
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;   
    x%=p;    
    while(y>0) 
    { 
        if(y&1)res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p; 
    } 
    return res; 
} 

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 
 
ll ncr(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 

    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}

int main()
{
    ll n;
    cin>>n;
    if(n==1)cout<<0;
    else 
    cout<<(power(10,n,M)-2ll*power(9,n,M)+power(8,n,M)+5ll*M)%M;

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <cmath>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int compar(const void * b, const void* a)
{
	return (*(int*)a - *(int*)b );
}

template<typename T> bool chmax(T& a, const T& b)
{
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main()
{
	string S;
	string t;
	cin >> S;
	
	int len = S.length();
	long sum = 0;
	for (int b = 0; b < (1<<len-1);b++) {
		t = "";
		long n = S[0] - '0';
		t += S[0];
		for (int i = 0; i < len - 1; i++) {
			if (b & (1 << i)) {
				n += S[i+1] - '0';
				t += "+";
			} else {
				n -= S[i+1] - '0';
				t += "-";
			}
			t += S[i+1];
		}
		if (n == 7) {
			cout << t << "=7" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const int N=1e6+6;
ll a[N],bs[1000];
void ins(ll x){
    rep(i,0,100)
        if (x>>i&1){
            if (bs[i]) x^=bs[i];
            else bs[i]=x,x=0;
            if (!x) return;
        }
}
bool query(ll x){
    rep(i,0,100)
        if (x>>i&1){
            if (bs[i]) x^=bs[i];
            else return true;
            if (!x) return false;
        }
    return false;
}
int main(){
    int T; scanf("%d",&T);
    while (T--){
        int n; scanf("%d",&n);
        rep(i,1,n) scanf("%lld",&a[i]);
        static char s[N]; scanf("%s",s);
        rep(i,0,100) bs[i]=0; bool f=false;
        per(i,n,1)
            if (s[i-1]=='0') ins(a[i]);
            else if (s[i-1]=='1'&&query(a[i])){ f=true; break; }
        if (!f) printf("0\n");
        else printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
template<typename T = int>T in() { T x; cin >> x; return x; }
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()
int main()
{
	int n = in();
	int n_copy = n;
	int sum = 0;
	while (n != 0)
	{
		sum += n % 10;
		n /= 10;
	}
	cout << (n_copy%sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 

void solve()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    int ans=0;
    for(int i=0;i<n;i++){

        ans=ans^v[i];
    }


      

    

    

   
    for(int i=0;i<n;i++){
       
         v[i]=ans^v[i];
        cout<<v[i]<<" ";
    }



return;


}

int32_t main()
{
    IOS;
    solve();
    return 0;
}

Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<int> v;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int cnt=0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            v.push_back(cnt);
        }
    }
    if(n!=1){
        v.push_back(1);
    }
    ll ans=0;
    for(ll x:v){
        ll cnt=1;
        while(cnt*(cnt+1)/2<=x){
            cnt++;
        }
        ans+=cnt-1;
    }
    cout << ans << endl;
}

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

int main(){
	int n, m, l, i, j, k;
	cin >> n >> m >> l;
	long int a[n][m], b[m][l], c[n][l];
	for(i = 0; i <= n-1; i++){
		for(j = 0; j <= m-1; j++){
			cin >> a[i][j];
		}
	}
	for(i = 0; i <= m-1; i++){
		for(j = 0; j <= l-1; j++){
			cin >> b[i][j];
		}
	}
	
	for(i = 0; i <= n-1; i++){   
		for(j = 0; j <= l-1; j++){
			c[i][j] = 0;
		}
	}
	
	for(i = 0; i <= n-1; i++){
		for(j = 0; j <= l-1; j++){
			for(k = 0; k <= m-1; k++){
				c[i][j] += a[i][k]*b[k][j];
			}
		}
	}
	
	for(i = 0; i <= n-1; i++){
		for(j = 0; j <= l-2; j++){
			cout << c[i][j] << ' ';
		}
		cout << c[i][l-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1392
/*
17D8101031C 杉山　祥吾 ID:keisei334 C++
*/

#include <iostream>

using namespace std;

#define N 1000000
int a[N],b[N];

int binarySearch(int key,int n){
  int left = 0;
  int right = n;
  while(left < right){
    int mid = (left + right) / 2;
    if(a[mid] == key){
      return 1;
    }else if(key < a[mid]){
      right = mid;
    }else left = mid + 1;
  }
  return 0;
 }

int main(){
  int n,q,count=0;
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  cin>>q;
  for(int i=0;i<q;i++){
    cin>>b[i];
  }

  for(int i=0;i<q;i++){
    count+=binarySearch(b[i],n);
  }

  cout<<count<<"\n";

  return 0;
}

/*実行結果

*/



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, check = 0;
  cin >> A >> B;
  for (int i = 1; i <= 1250; i++) {
    if (10*B <= i && i < 10*(B + 1)) {
      int a, b;
      if (A%2 == 0) {
        a = 0, b = 1;
      }
      else {
        a = 1; b = 0;
      }
      if ((25*A + a)/2 <= i && i < (25*(A + 1) + b) /2) {
        cout << i << endl;
        check = 1;
        break;
      }
    }
  }
  if (check == 0) {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9 + 7;
	int N,M;
	int[] a,b,c;
	int[][] D;
	public void solve() {
		N = nextInt();
		M = nextInt();

		D = new int[N][N];
		for(int i = 0;i < N;i++)for(int j = 0;j < N;j++)if(i == j)D[i][j] = 0;else D[i][j] = INF;

		a = new int[M];
		b = new int[M];
		c = new int[M];
		for(int i = 0;i < M;i++){
			a[i] = nextInt()-1;
			b[i] = nextInt()-1;
			c[i] = nextInt();

			D[a[i]][b[i]] = c[i];
			D[b[i]][a[i]] = c[i];
		}

		for(int k = 0;k < N;k++)for(int i = 0;i < N;i++)for(int j = 0;j < N;j++)D[i][j] = Math.min(D[i][j],D[i][k] + D[k][j]);

		int ans = M;
		for(int i = 0;i < M;i++){
			boolean flag = false;
			for(int j = 0;j < N;j++)if(D[j][a[i]] + c[i] == D[j][b[i]])flag = true;
			if(flag)ans--;
		}
		out.println(ans);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 9640
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String count = sc.next();
		long ans = 0;
		Map<String, Long> map = new HashMap<String, Long>();

		for (int i = 0; i < Integer.parseInt(count); i++) {
			char[] ary = sc.next().toCharArray();
			Arrays.sort(ary);
			String c = 	new String(ary);
				if (map.containsKey(c)) {
					ans = ans + map.get(c);
					map.put(c, map.get(c) + 1);
				} else {
					map.put(c, (long) 1);
				}
			}

		System.out.println(ans);
	}

}

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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (((int)log10(i) + 1) % 2 == 1) {
			ans += 1;
		}
	}
	
	cout << ans << endl;
}

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

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

    int ac = 0,wa = 0,tle = 0,re = 0;

    vector<string> S(N);
    for(auto& x: S){
        cin >> x;
        if(x == "AC"){
            ac++;
        }
        else if(x == "WA"){
            wa++;
        }
        else if(x == "TLE"){
            tle++;
        }
        else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 6408
#include<cstdio>
#include<algorithm>
#define maxn 200005
#define D 20
#define INF 2147483647
using namespace std;
int n,v,x[maxn],vis[maxn],maxv[maxn],cnt[D],l[D][maxn],r[D][maxn],f1[maxn*5],f2[maxn*5],ans[maxn];
int upfind(int i,int pos)
{
	pos++;
	int p=upper_bound(l[i]+1,l[i]+cnt[i]+1,pos)-l[i]-1;
	if(p<=0) return pos;
	return max(r[i][p],pos-1);
}
int lowfind(int i,int pos)
{
	pos--;
	int p=lower_bound(r[i]+1,r[i]+cnt[i]+1,pos)-r[i];
	if(p>cnt[i]) return pos;
	return min(l[i][p],pos+1);
}
int main()
{
	scanf("%d%d",&n,&v);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	x[0]=-INF,x[n+1]=INF;
	int log2;
	for(log2=0;(1<<log2)<=v;log2++);
	for(int lg=0;lg<=log2;lg++)
	{
		int d=v/(1<<lg);
		cnt[lg]=l[lg][1]=1;
		for(int i=1;i<=n;i++)
		{
			r[lg][cnt[lg]]=i;
			if(x[i+1]-x[i]>d) l[lg][++cnt[lg]]=i+1;
		}
		cnt[lg]--;
	}
	if(cnt[0]>log2+1)
	{
		for(int i=1;i<=n;i++) printf("Impossible\n");
		return 0;
	}
	int S=(1<<(log2+1));
	for(int s=0;s<S;s++) f1[s]=0,f2[s]=INF;
	f2[0]=n+1;
	for(int s=0;s<S;s+=2)
		for(int i=0;i<=log2;i++)
		{
			if(!(s&(1<<i))) continue;
			f1[s]=max(f1[s],upfind(i,f1[s-(1<<i)]));
			f2[s]=min(f2[s],lowfind(i,f2[s-(1<<i)]));
		}
	for(int i=1;i<=cnt[0];i++)
	{
		int ln=l[0][i],rn=r[0][i];
		for(int s1=0;s1<S;s1+=2)
		{
			int s2=S-s1-2;
			int lp=f1[s1],rp=f2[s2];
			if(lp>=ln-1&&rp<=rn+1) { ans[i]=true; break; }
		}
	}
	for(int i=1,pos=1;i<=n;i++)
	{
		printf("%s\n",ans[pos]?"Possible":"Impossible");
		if(x[i+1]-x[i]>v) pos++;
	}
}


Measured memory_bytes: 43264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) out("Bad");
    else out("Good");
}

Measured memory_bytes: 256
import numpy as np
N, ma, mb = map(int, input().split())
abc = tuple(map(int, input().split()) for _ in range(N))

inf = 10000
dp = np.full((401, 401), inf, dtype=int)
dp[0][0] = 0

for a, b, c in abc:
    for i in range(400, a - 1, -1):
        dp[i][b:] = np.minimum(dp[i][b:], dp[i - a][: - b] + c)

ans = inf
x = 1

while True:
    Ma = x * ma
    Mb = x * mb
    if Ma > 400 or Mb > 400:
        break
    ans = min(ans, dp[Ma][Mb])
    x += 1

ans = -1 if ans >= inf else ans
print(ans)


Measured memory_bytes: 13660
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
  return 0;
}

Measured memory_bytes: 256