akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC075C
{
    class Program
    {
        static int INFTY = 0x30000000;

        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = int.Parse(bufs[0]);
            int M = int.Parse(bufs[1]);

            int[] a = new int[M];
            int[] b = new int[M];

            int[,] cost = new int[N, N];

            for (int i = 0; i < M; i++)
            {
                bufs = Console.ReadLine().Split(' ');
                a[i] = int.Parse(bufs[0]) - 1;
                b[i] = int.Parse(bufs[1]) - 1;
            }

            // END Initialize

            int res = 0;

            for (int cut = 0; cut < M; cut++)
            {
                // Cost Reset
                for (int i = 0; i < N; i++)
                {
                    cost[i, i] = 0;
                    for (int j = i + 1; j < N; j++)
                    {
                        cost[i, j] = cost[j, i] = INFTY;
                    }
                }

                for (int m = 0; m < M; m++)
                {
                    if(m != cut)
                    {
                        cost[a[m], b[m]] = cost[b[m], a[m]] = 1;
                    }
                }
                // END Cost Reset

                // WF Method
                for (int k = 0; k < N; ++k)
                {
                    for (int i = 0; i < N; ++i)
                    {
                        for (int j = 0; j < N; ++j)
                        {
                            int wc = cost[i, k] + cost[k, j];
                            if (wc < cost[i, j])
                            {
                                cost[i, j] = wc;
                            }
                        }
                    }
                }

                // Check
                bool disconnected = false;

                for (int i = 0; i < N; i++)
                {
                    for (int j = i + 1; j < N; j++)
                    {
                        if (cost[i, j] >= INFTY)
                        {
                            disconnected = true;
                        }
                    }
                }

                if (disconnected)
                {
                    res++;
                }

            }


            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11200
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for(int i=0;i<n;i++){
		cout << s[i] << t[i];
	}
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void p(vector<int> A){
    rep(i,A.size()){
        cout << A[i] << " ";
    }
    cout << "\n";
}

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    cout << a*min(b-1,n)/b << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m;
int a[505][505];
int cnt;
struct p{
	int x1,y1,x2,y2;
}nd[250005];
int tp;
int main(){
	int i,j;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	n=read(),m=read();
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++) a[i][j]=read();
	for(i=1;i<=n;i++)
		for(j=1;j<m;j++)
			if(a[i][j]%2)
				nd[++tp]=(p){i,j,i,j+1},a[i][j]--,a[i][j+1]++;
	for(i=1;i<n;i++)
		if(a[i][m]%2)
			nd[++tp]=(p){i,j,i+1,j},a[i][j]--,a[i+1][j]++;
	printf("%d\n",tp);
	for(i=1;i<=tp;i++) 
	printf("%d %d %d %d\n",nd[i].x1,nd[i].y1,nd[i].x2,nd[i].y2);
	return 0;
}

Measured memory_bytes: 6708
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

ll extGCD(ll a,ll b,ll &x,ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}

ll iter_squ(ll a,ll p,ll m){
  if(p==0LL) return 1LL;
  if(p%2LL==0){
    ll t = iter_squ(a, p/2LL, m);
    return (t*t)%m;
  }
  return (a * iter_squ(a, p-1,m))%m;
}

int main() {
  ll n,a,b;cin>>n>>a>>b;
  ll out = iter_squ(2LL,n,mod) - 1LL;
  ll comb_a,comb_b,comb=1LL;
  for(ll i=1LL;i<=b;++i){
    comb *= (n-i+1LL);
    comb %= mod;
    ll x,y;
    extGCD(i,mod,x,y);
    x = (x%mod + mod)%mod;
    comb *= x;
    comb %= mod;
    if(i==a) comb_a = comb;
    if(i==b) comb_b = comb;
  }
  out -= comb_b;
  if(out<0)out+=mod;
  out -= comb_a;
  if(out<0)out+=mod;
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 1001001001;
  rep(i, s.size()-t.size()+1){
    int add = 0;
    rep(j, t.size()){
      if(s.at(i+j) != t.at(j)) add++;
    }
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
    int n;
    vector<int> a;
    while(cin >> n && n) {
        a.resize(n);
        REP(i, n) cin >> a[i];
        int ans = numeric_limits<int>::max();
        sort(a.begin(), a.end());
        REP(i, n-1) ans = min(ans, a[i+1]-a[i]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3144
#include<iostream>

int main(){
	using namespace std;
	int n;
	cin >> n;
	int happy[n][3];
	int dp[n+1][3][3];
	for(int a = 0;a < n;a++){
		for(int b = 0;b < 3;b++){
			cin >> happy[a][b];
		}
	}
	for(int a = 0;a < 3;a++){
		for(int b = 0;b < 3;b++){
			dp[0][a][b] = 0;
		}
	}
	for(int a = 0;a < 3;a++){
		dp[1][a][0] = happy[0][0];
		dp[1][a][1] = happy[0][1];
		dp[1][a][2] = happy[0][2];
	}
	for(int a = 2;a <= n;a++){
		for(int b = 0;b < 3;b++){
			for(int c = 0;c < 3;c++){
				if (b == c) dp[a][b][c] = 0;
				else{
					dp[a][b][c] = max(dp[a-1][0][b],max(dp[a-1][1][b],dp[a-1][2][b])) + happy[a-1][c];
				}
			}
		}
	}
	int ans = 0;
	for(int a = 0;a < 3;a++){
         for(int b = 0;b < 3;b++){
         	ans = max(ans,dp[n][a][b]);
		 }
	}
	cout <<ans;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs (vector<int> A){
    if(A.size() == n+1){
        //calc score
        int now = 0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main() {
cin >> n >> m >> q;
a = b = c = d = vector<int> (q);

rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];

dfs(vector<int> (1,1));//長さ1，要素１
 cout << ans << endl;
return 0;

}


Measured memory_bytes: 3644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A, B; cin >> A >> B;
    cout << A*B << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	int N,M,ans,tmp;
	cin >> N >> M;
	vector<int> A(N);
	tmp = 0;
	ans = 0;

	rep(i, N) {
		cin >> A[i];
		tmp += A[i];
		
	}

	rep(i, N) {
		if (A[i] * 4 * M >= tmp) ans++;
	}
	
	if (ans < M)cout << "No";
	else cout << "Yes";
	


	
}

Measured memory_bytes: 256
#include<cstdio>
long long f(long long x) {
    long long res = 0;
    if (x % 2 == 0) {
        res = x;
    }
    if ((x + 1) / 2 % 2 == 0) {
        res ^= 1;
    }
    return res;
}
int main()
{
  long long a , b , res;
//  freopen("xor.in" , "r" , stdin);
//  freopen("xor.out" , "w" , stdout);
  scanf("%lld%lld" , &a , &b);
  printf("%lld" , (f(a - 1) ^ f(b)));

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int maxn=INT_MIN;
int main()
{
	int a[51];
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}sort(a+1,a+n+1);int sum=0;
	for(int i=n;i>=n-k+1;i--){
		sum+=a[i];
	}cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> tiii;
 
vector<tiii> v;
int n; 
 
ll memo[1007][10007];
 
 
 
ll solve(int p, int w) {
	if(w >= 10007) return 0;
	if(p == n) {
		return 0;
	}
 
	ll & st = memo[p][w];
 
	if(st == -1) {
		int we, s, x;
		tie(we, s, x) = v[p];
		st = max(
			s >= w? x + solve(p+1, w + we) : (ll) -1e15,
			solve(p+1, w)
		);
	}
	return st;
}
 
int main() {
	memset(memo, -1, sizeof memo);
	ios::sync_with_stdio(0); cin.tie(0);
 
	cin >> n;
 
	for(int i = 0; i < n; i++) {
		int w, s, x; cin >> w >> s >> x;
		v.eb(w, s, x);
	}
 
	sort(v.rbegin(), v.rend(), [&](tiii aux1, tiii aux2) {
		int w1, s1, x1; tie(w1, s1, x1) = aux1;
		int w2, s2, x2; tie(w2, s2, x2) = aux2;
 
		return w1 + s1 > w2 + s2;
	});	
 
	cout << solve(0, 0) << '\n';
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,sum=0;
    cin>>n>>m;
    vector<int>a(n);
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	sum=accumulate(a.begin(),a.end(),0);
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]*(4*m)>=sum){
			c++;
		}
	}
	if(c>=m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool P[1000001];
int a[3] = {2,3,5};

void init()
{
	for( int i = 0;i < 1000001;i++ ) P[i] = false;
	P[1] = true;
	for( int i = 1;i < 1000001;i++ ){
		if( P[i] ){
			for( int j = 0;j < 3;j++ ) if( i * a[j] < 1000001 ) P[i * a[j]] = true;
		}
	}
}

int main(int argc, char const* argv[])
{
	init();
	int m,n;

	while( cin >> m >> n && m != 0 ){
		int count = 0;
		for( int i = m;i <= n;i++ ) if( P[i] ) count++;
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
x=int(input())

if 400 <= x <= 599:
  print('8');
elif 600 <= x <= 799:
  print('7')
elif 800 <= x <= 999:
  print('6')
elif 1000 <= x <= 1199:
  print('5')
elif 1200 <= x <= 1399:
  print('4')
elif 1400 <= x <= 1599:
  print('3')
elif 1600 <= x <= 1799:
  print('2')
else:
  print('1')


Measured memory_bytes: 9128
#include <stdio.h>

int main()
{
  int n, y, i, b, t, j, number=0;
  double money,r,best;
  while(1)
    {
      best=1;
      scanf("%d", &n);
      if( n == 0 ) break;
      scanf("%d", &y);
      
      for( i = 0; i < n; i++ )
	{ 
	  money=1;
	  scanf("%d%lf%d", &b, &r, &t);
	  if( t == 1 ){
	    money =(double) 1 + y * r / 100;
	  }else if( t == 2){
	    for( j = 0; j < y; j++ ){
	      money *= (double)1 + (r / 100);
	    }
	  }
	  
	  if( best < money )
	    {
	      best = money;
	      number = b;
	    }
	}
      printf("%d\n", number);
    }
  return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b;
    cin >> a >> b;
    // 処理
    // 出力
    cout << (a > b ? a - 1 : a) << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

ll solve(ll level, ll layer) {
    if(level == 0) return 1;
    ll len = (1LL << (level + 1)) - 3;
    ll num = (1LL << level) - 1;
    if(layer <= 1) return 0;
    if(layer <= 1 + len) return solve(level - 1, layer - 1);
    if(layer == 2 + len) return num + 1;
    if(layer <= 2 + len + len) return num + 1 + solve(level - 1, layer - (2 + len));
    return num * 2 + 1;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n;
    ll x;
    cin >> n >> x;
    cout << solve(n, x) << endl;

    return 0;
}

Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

	char a;
	cin >> a;
	if(a>='a'){
		cout << 'a';
	}
	else{
		cout << "A";
	}

	return 0;
}  


Measured memory_bytes: 3608
from collections import deque

N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
q = deque()
damage = 0
result = 0
for x, h in XH:
    while q:
        if x <= q[0][0]:
            break
        damage -= q.popleft()[1]
    h -= damage
    if h <= 0:
        continue
    c = (h + A - 1) // A
    result += c
    damage += c * A
    q.append((x + 2 * D, c * A))
print(result)


Measured memory_bytes: 66368
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N, a = 0;
  ci(N);
  int n = N;
  wh(n > 0){
    a += n % 10;
    n = n / 10;
  }
  if(N % a == 0){
    co("Yes");
  }
  else{
    co("No");
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int former=0,counter=0;
    for(int i=0;i<n;i++){
        if(former==d[i]){
            continue;
        }
        counter++;
        former=d[i];
    }
    cout << counter << endl;
}



Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x,'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x,'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x,'x') # rev => int(res, 16)
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    s = IS()
    n = len(s)
    s = s[::-1]
    cb_num = 0
    a_num = 0
    cnt = 0
    i = 0
    while i < n:
        if cb_num == 0:
            if s[i:i+2] == 'CB':
                cb_num += 1
                i += 2
                continue
        if s[i:i+2] == 'CB':
            cb_num += 1
            i += 2
        elif s[i] == 'A':
            cnt += cb_num
            i += 1
        else:
            cb_num = 0
            i += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4236
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
M = 10 ** 9 + 7

def power(x, n)
    return 1 if n == 0
    (n.odd? ? x : 1) * power(x ** 2 % M, n / 2) % M
end

com = Array.new(n, 0)
com[k-1] = 1
k.upto(n-1) {|i| com[i] = com[i-1] * i * power(i-k+1, M-2) % M}

ans = 0
0.upto(n-k) {|i| ans -= a[i] * com[n-i-1]}
(k-1).upto(n-1) {|i| ans += a[i] * com[i]}
p ans % M

Measured memory_bytes: 12668
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
using namespace std;
using ll = long long;
vector<ll> v;
vector<ll> w;
vector<vector<ll>> memo;
ll solve(ll n, ll k)
{
    if(n<0) return 0;
    ll best = -1;  
    if(memo[n][k]!=-1) return memo[n][k];
    if(k-w[n]>=0){
        best = max(best, solve(n-1,k-w[n])+v[n]);
    }
    best = max(best, solve(n-1,k));
    
    memo[n][k]=best;
    return best;
}

void max_self(ll& a, ll b){
    a = max(a,b);
}

int main(){
    int n, W;
    scanf("%d%d",&n,&W);
    vector<ll> dp(W+1); //0...W까지 저장하자
    //dp[i]는 무게가 i일때 최대의 value를 출력한다.
    for(int item=0;item<n;item++){
        int weight, value;
        scanf("%d %d",&weight, &value);
        for(int weight_alredy=W-weight;weight_alredy>=0;weight_alredy--){
            max_self(dp[weight_alredy+weight], dp[weight_alredy]+value);
        }
    }
    ll ans = 0;
    for(int i =0;i<=W;i++){
        max_self(ans, dp[i]);
    }
    printf("%lld",ans);
    return 0;
} 

int main2() //재귀로 풀기..
{
    ll n, W;
    scanf("%lld %lld", &n, &W);
    v.resize(n + 1);
    w.resize(n + 1);
    memo.resize(n + 1, vector<ll>(W+1, -1));
    for (ll i = 0; i < n; i++)
    {
        scanf("%lld %lld", &w[i], &v[i]);
    }
 
    //solve 는 n번째 물건이고 무게가 W일때..
    cout << solve(n, W);

 
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
      ll n;
      cin>>n;
      ll A[n+5];
      ll sum=0;
     map<ll,ll> m;
     for(int i=0;i<n;i++){
       cin>>A[i];
       sum+=A[i];
       m[A[i]]++;
        }
  ll q;
  cin>>q;
  while(q--)
  {
    ll b,c;
    cin>>b>>c;
    ll ans=sum-m[b]*b+c*m[b];
    m[c]+=m[b];
    m[b]=0;
    cout<<ans<<endl;
    sum=ans;
     
    
  }
}


Measured memory_bytes: 10152
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int n;

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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


int main() {
	ll N;
	std::cin >> N;

	vector<map<ll, ll>> dic(N+1);
	rep(i, 1, N) {
		ll a, b, c;
		std::cin >> a >> b >> c;
		dic[a][b] = c;
		dic[b][a] = c;
	}

	ll Q, K;
	std::cin >> Q >> K;

	vll cost(N+1, 999999999999999);
	cost[K] = 0;
	vector<bool> isVisited(N + 1, false);
	priority_queue<pair<ll, ll>> pq;
	pq.push({ 0,K });
	while (!pq.empty()) {
		if (!isVisited[pq.top().second]) {
			isVisited[pq.top().second] = true;
			ll c = pq.top().first;
			ll pos = pq.top().second;
			pq.pop();

			for (auto itr = dic[pos].begin(); itr != dic[pos].end(); itr++) {
				if (c + itr->second < cost[itr->first]) {
					cost[itr->first] = c + itr->second;
					pq.push({ cost[itr->first],itr->first });
				}
			}
		}
	}

	rep(i, 0, Q) {
		ll x, y;
		std::cin >> x >> y;
		std::cout << cost[x] + cost[y] << endl;
	}


	return 0;
}


Measured memory_bytes: 20976
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

int main(){
  string s; cin >> s;
  int ans = 0;
  int n = s.size();
  rep(i, 0, n){
    int tmp = 0;
    rep(j, i, n){
      if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T'){
        ans = max(ans, tmp);
        i = j;
        break;
      }else{
        tmp++;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
     


Measured memory_bytes: 636
import java.util.*;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();   //the number of monster
    int A = sc.nextInt();   //the number of limit of deathblow
    long count  = 0;
    Integer[] H = new Integer[N];   //the HP of monster
    for(int i = 0;i < N;i++){
      H[i] = sc.nextInt();
    }
    Arrays.sort(H, Collections.reverseOrder());
    if(A > 0){
      for(int i = A;i < N;i++){
        count += H[i];
      }
    }else {
      for (int i = 0; i < N; i++) {
        count += H[i];
      }
    }
    System.out.println(count);
  }
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void func_to_create(){
    uint32_t A, B;
    cin >> A >> B;
    cout << A * B << endl;
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3640
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll K;
    cin >> K;

    if (K % 2 == 0 || K % 5 == 0)
    {
        cout << "-1" << endl;
        return 0;
    }

    ll L = K % 7 == 0 ? (9 * K / 7) : (9 * K);

    ll M = 10 % L;
    FOR(i, 1, L)
    {
        if (i >= 2)
            M = (M * 10) % L;

        if (M == 1)
        {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    for(int i=0;i<7;i++){
        int a,b;
        cin>>a>>b;
        cout<<a-b<<endl;
    }
}


Measured memory_bytes: 3180
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      StringBuilder sb = new StringBuilder();
      boolean flag = false;
      if(n == 1) 
          flag = true;
      while(--n >= 1) {
        long res = n % 26;
        sb.append((char)((res) % 26 + 'a'));
        n /= 26 ;
        if(n == 1) 
          flag = true;
      }
      if(flag)
      sb.append('a');
      System.out.println(sb.reverse().toString());
  }
}

Measured memory_bytes: 35852
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vi h(n); rep(i,n) cin >> h[i];
  sort(all(h));
  int ans = INF;
  rep(i,n-k+1) chmin(ans,h[i+k-1]-h[i]);
  cout << ans;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 main() {
    ll n,k;
    cin >> n >> k;
    ll res = 0;
    for (long long i = k; i <= n+1; ++i) {
        res = (res + ((n*2-i+1) * i / 2) -(i * (i-1) / 2)+ 1) % MOD;
    }
    cout << res%MOD << endl;
    return 0;
}

Measured memory_bytes: 3632
f6=list(map(int,input().split()))
t=[0]*6
cmd=input()
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
for c in cmd:
    for i in range(6):
        t[i]=f6[r[c][i]]
    f6,t=t,f6
print(f6[0])


Measured memory_bytes: 5600
# ABC136 C-City Savers
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0

for i in range(n):
    a_t=min(b[i],a[i])
    ans+=a_t
    b[i]-=a_t
    b_t=min(a[i+1],b[i])
    a[i+1]-=b_t
    ans+=b_t
print(ans)

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

vector<int> outendl(vector<int> v) {
    // rep(i, 0, v.size()) cout << v[i] << " "; cout << endl;
    return v;
}

int dist(vector<int> a, vector<int> b) {
    int d = 0;
    for (int i = 0; i < a.size(); i++) {
        if (b[i] != a[i]) {
            int j = i;
            while (b[i] != a[j] && j < a.size()) j++;
            if (j >= a.size()) return 10000;
            // cout << "[" << j << "]" << " ";
            // rep(k, 0, a.size()) {
            //     if (k == j) cout << "(";
            //     cout << a[k];
            //     if (k == j) cout << ")";
            //     cout << " "; 
            // }
            // cout << endl;
            for (int k = j - 1; k >= i; k--) {
                swap(a[k], a[k + 1]);
                d++;
            }
        }
            // cout << i <<  "," << d << ": "; outendl(a);
    }
    return d;
}

vector<int> gen(vector<int> p, int init) {
    vector<int> res;
    for (int x : p) {
        rep(i, 0, x) res.push_back(init);
        init ^= 1;
    }
    return outendl(res);
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, m; cin >> n >> m;
    vector<int> bits(n), perm(m);
    rep(i, 0, n) cin >> bits[i];
    rep(i, 0, m) cin >> perm[i];

    int d1 = dist(bits, gen(perm, 1));
    int d2 = dist(bits, gen(perm, 0));
    cout << min(d1, d2) << endl;
}


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

int main(void)
{
    int N;
    cin >> N;
    int tmp = N;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (4 * i + 7 * j == N)
            {
                cnt++;
            }
        }
    }
    if (cnt > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ABC,ARC,AGC,R;
int main () {
	cin >> R;
	if (R<1200) {
		cout << "ABC" << endl;
	} else if (R<2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
 

using namespace std;

int main() {
  int N;
  cin>>N; 
  vector<int> d(N);  
  vector<int>a(100010);
  rep(j,N){
    cin>>d.at(j);
    a.at(d.at(j))++;
  }
  int ans=a.at(0)+a.at(1)+a.at(2);
  int ch=ans;
  rep(i,100000){
    ch=ch+a.at(i+3)-a.at(i);
    ans=max(ans,ch);
    
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int n,a,b,i,ret=0;
  string s;
  cin >> n;
  cin >> s;
  int w[n]={};
  if(s[0]=='W')w[0]=1;
  for(i=1;i<n;i++){
    w[i]=w[i-1];
    if(s[i]=='W')w[i]++;
  }
  ret = n-1-(w[n-1]-w[0]);
  for(i=1;i<n;i++){
    int x;
    x=w[i-1]+n-i-1-w[n-1]+w[i];
    ret = min(ret,x);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
#define pii pair<int,int>
int main(){
    ll a;
    cin >> a;
    string ans =  "";
    while(a>0){
        ans = char('a' + (a-1)%26) + ans;
        a=(a-1)/26;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k, l;
	int ans;
		
	while(scanf("%d", &n) != EOF){
		ans = 0;
			for(i = 0; i < 10; i++){
				for(j = 0; j < 10; j++){
					for(k = 0; k < 10; k++){
						for(l = 0; l < 10; l++){
							if(i + j + k + l == n){ ans += 1; }
						}
					}
				}
			}
			
			printf("%d\n", ans);
		}
		return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Splitting Pile
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	sum1 := make([]int, N)
	var temp int
	for i := 0; i < N; i++ {
		a[i] = nextInt()
		temp += a[i]
		sum1[i] = temp
	}

	sum2 := make([]int, N)
	temp = 0
	for i := N - 1; 0 <= i; i-- {
		temp += a[i]
		sum2[i] = temp
	}

	var x, y, abs int
	var ans int = 100000000000
	for i := 0; i < N-1; i++ {
		x = sum1[i]
		//y = sum[N-1] - x
		y = sum2[i+1]
		abs = int(math.Abs(float64(x - y)))
		if ans > abs {
			ans = abs
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7676
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(i64);
    let a = get!(Vec<i64>);
    let b = get!(Vec<i64>);

    // k=0, 1, ..., について、bの各要素の下k桁の値をソートしておく
    let mut C = (0..30).map(
        |k| {
            let mut c = b.iter().map(|x|
                x & ((1 << k) - 1)
            ).collect::<Vec<_>>();
            c.sort();
            c
        }
    ).collect::<Vec<_>>();

    // a, bのk桁目同士の和と(k-1)桁目までの和に関する繰り上がりを求め、
    // 解のk桁目を求める
    let ans = (0..30).map(
        |k| (
            (
                (
                    if N % 2 == 0 {
                        0
                    } else {
                        a.iter()
                        .chain(b.iter())
                        .filter(|&x| x & (1 << k) > 0)
                        .count()
                    }
                    as i64
                ) +
                a.iter()
                    .map(
                        |x| {
                            let mut ok = N;
                            let mut ng = -1;
                            let m = (1 << k) - (x & ((1 << k) - 1));
                            while (ok - ng) > 1 {
                                let mid = (ok + ng) / 2;
                                if C[k][mid as usize] >= m {
                                    ok = mid;
                                } else {
                                    ng = mid;
                                }
                            }
                            N - ok
                        }
                    ).sum::<i64>()
            ) % 2
        ) << k
    ).sum::<i64>();

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


Measured memory_bytes: 70256
N = int(input())
h = list(map(int, input().split()))
mx = h[0]
cnt = 0
for i in range(N):
    if mx < h[i]:
        mx = h[i]
    elif mx-h[i] > 1 :
        cnt += 1
if cnt > 0:
    print("No")
else:
    print("Yes")

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

int main(void){
  int n;cin >> n;
  int house[4][3][10];
  rep(i,4){//huose
    rep(j,3){//floor
      rep(k,10){//room
        house[i][j][k] = 0;
      }
    }
  }
  rep(i,n){
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    house[b-1][f-1][r-1] += v;
  }
  rep(i,4){//huose
    rep(j,3){//floor
      rep(k,10){//room
        cout << " " << house[i][j][k];
      }
      cout << endl;
    }
    if(i != 3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int H, W;
	int i, j;

	

	while (1)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if ((i + j) % 2 == 0) {
					cout << '#';
					continue;
				}
				cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}

	

	return (0);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f,g;
    while(cin>>a>>b>>d)
    {

        if(a%b==0)
        {
            c=(double)a/b;
        }
        else
        {
            c=(double)a/b;
            c++;
        }
        cout<<c*d<<endl;
    }





    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int i, j, N, b;
    vector<vector<int>> bingo(3, vector<int>(3));
    vector<vector<bool>> find(3, vector<bool>(3));
    rep(i, 3) {
        rep(j, 3) cin>>bingo[i][j];
    }
    cin>>N;
    vector<int> bs(N);
    rep(i, N) {
        cin>>b;
        rep(i, 3) {
            rep(j, 3) {
                if (b == bingo[i][j]) find[i][j] = true;
            }
        }
    }
    bool res = false;
    rep(i, 3) {
        if (find[i][0] && find[i][1] && find[i][2]) res = true;
        if (find[0][i] && find[1][i] && find[2][i]) res = true;
    }
    if (find[0][0] && find[1][1] && find[2][2]) res = true;
    if (find[0][2] && find[1][1] && find[2][0]) res = true;
    if (res) cout<<"Yes"<<endl;
    else cout<<"No"<<endl; 
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
H = [int(input()) for i in range(n)]

def ok(x):
    t = 0
    for i in range(n):
        h = H[i]
        res = h-b*x
        if res <= 0:
            continue
        else:
            if res%(a-b) == 0:
                t += res//(a-b)
            else:
                t += res//(a-b)+1
    if t <= x:
        return True
    else:
        return False

l = 0
r = 10**10
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 51928
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  int n;
  //std::cin >> n;
  std::string s;
  std::string::iterator it;
  std::cin >> s;

  std::string ans;
  for (it = s.begin(); it != s.end(); it++) {
    int distance = std::distance(s.begin(), it);
    if (distance % 2 == 0) {
      ans.push_back(*it);
    }
  }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INFTY 1000000001

int cnt;

void merge(vector<int> &A,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    vector<int> L(n1+1);
    vector<int> R(n2+1);
    for(int i=0;i<n1;i++){
        L[i]=A[left+i];
    }
    for(int i=0;i<n2;i++){
        R[i]=A[mid+i];
    }
    L[n1]=R[n2]=INFTY;
    
    int i=0,j=0;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }
        else{
            A[k]=R[j];
            j++;
        }
    }
}

void mergeSort(vector<int> &A,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

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

    cnt=0;
    mergeSort(A,0,n);
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        cout<<A[i];
    }
    cout<<endl<<cnt<<endl;
}


Measured memory_bytes: 6812
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <queue>
using namespace std;

char ma[1005][1005];int vis[1005][1005];
int w,h,n;

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

struct node
{
    int x,y,time;
};
node start;

void bfs(char ed)
{
    queue<node> que;
    que.push(start);
    vis[start.x][start.y]=1;
    while(!que.empty())
    {
        node no=que.front();
        que.pop();
        for(int i=0;i<4;i++)
        {
            int x=no.x+dx[i];
            int y=no.y+dy[i];
            if(vis[x][y]||x>=h||x<0||y>=w||y<0||ma[x][y]=='X')
                continue;
            if(ma[x][y]==ed)
            {
                start.x=x;
                start.y=y;
                start.time=no.time+1;
                return ;
            }
            vis[x][y]=1;
            node no1;
            no1.x=x;no1.y=y;no1.time=no.time+1;
            que.push(no1);
        }
    }
}

int main()
{
    while(~scanf("%d %d %d", & h, & w, & n))
    {
        for(int i=0;i<h;i++)
        {
            scanf("%s",&ma[i]);
            for(int j=0;j<w;j++)
                if(ma[i][j]=='S')
                {
                    start.x=i;
                    start.y=j;
                    start.time=0;
                }

        }
            for(int i=0;i<n;i++)
            {
                memset(vis,0,sizeof(vis));
                bfs(i+'1');
            }

            printf("%d\n",start.time);
    }
    return 0; 
}

Measured memory_bytes: 8204
from collections import Counter

N = int(input())
a = list(map(lambda x:min(int(x)//400,8),input().split(" ")))
c = Counter(a)
s = 0
for i in [0,1,2,3,4,5,6,7]:
    s += (c[i] and 1)
l = max(1,s)
m = max(1,s+c[8])
print(str(l)+" "+str(m))

Measured memory_bytes: 3316
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m,a,k;
	cin>>n>>m;
	int like[m];
	fill(like,like+m,0);
	rep(i,n){
		cin>>k;
		rep(j,k){
			cin>>a;
			like[a-1]++;
		}
	}
	int ans=0;
	rep(i,m)if(like[i]==n)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256