akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

ll A[100002], B[100002];
bool active[100002];

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

    ll total = 0;
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
        if(A[i] <= K){
            total += B[i];
            active[i] = true;    
        }else{
            active[i] = false;
        }
    }

    ll logk = 0, K_copy = K;
    while(K_copy > 0){
        logk++;
        K_copy >>= 1;
    }

    ll ans = 0;
    for(int i=logk - 1;i>=0;i--){
        if((K>>i)&1){
            ll ans_cand = total;
            for(int j=0;j<N;j++){
                if(active[j] && ((A[j]>>i)&1) == 1){
                    ans_cand -= B[j];
                }
            }
            ans = max(ans, ans_cand);
        }else{
            for(int j=0;j<N;j++){
                if(((A[j]>>i)&1) == 1 && active[j]){
                    total -= B[j];
                    active[j] = false;
                }
            }
        }
    }
    ans = max(ans, total);

    cout << ans << endl;

    return 0;
}

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll ans = 0;
    if((b-a)%2==0){
        ans = (b-a) / 2;
    }else{
        ans = min(a-1, n-b) + 1 + (b-a-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
a=input().split()
N=int(a[0])
M=int(a[1])
M_list=input().split()
Flag=True
item_list=[]
for item in M_list :
	item_list.append(int(item))
    
if N<sum(item_list):
	print('-1')
else :
	for item in item_list :
		N-=item
	print(N)

Measured memory_bytes: 68164
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
b_sum=sum(b)
c_sum=0

for i in range(N-1):
    if a[i]== a[i+1]-1:
        c_sum += c[a[i]-1]

print(b_sum + c_sum)


Measured memory_bytes: 3060
from collections import deque
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
count = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p-1]+=x
q = deque([0])
flag = [False]*N
while q:
    v = q.pop()
    flag[v] = True
    for e in G[v]:
        if flag[e]:
            continue
        count[e]+=count[v]
        q.append(e)
print(' '.join(list(map(str, count))))
    

Measured memory_bytes: 123892
import std.stdio, std.algorithm, std.string, std.array, std.conv;

void main(){
  int n = readln.strip.to!int;
  foreach(_; 0..n){
    auto a = readln.strip.split.map!(to!int).array.sort;
    auto sq = (int x) => x * x;
    writeln(sq(a[0]) + sq(a[1]) == sq(a[2]) ? "YES" : "NO");
  }
}

Measured memory_bytes: 2384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=987654323;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,c,i,ans=0;cin>>n>>c;
	vector<llint>x(n);
	vector<llint>v(n);
	for(i=0;i<n;i++){cin>>x[i]>>v[i];}
	vector<llint>zugo(n);//時計周り,行ったきり
	vector<llint>hago(n);
	llint gen=0,mae=0,wa=0;
	for(i=0;i<n;i++){
		wa+=v[i];wa-=x[i]-mae;
		maxeq(gen,wa);
		maxeq(zugo[i],gen);
		mae=x[i];
	}
	gen=0,mae=c,wa=0;
	for(i=n-1;i>=0;i--){
		wa+=v[i];wa-=mae-x[i];
		maxeq(gen,wa);
		maxeq(hago[i],gen);
		mae=x[i];
	}
	gen=0,mae=0,wa=0;
	for(i=0;i<n;i++){
		maxeq(ans,gen+hago[i]);
		wa+=v[i];wa-=(x[i]-mae)*2;
		maxeq(gen,wa);
		maxeq(zugo[i],gen);
		mae=x[i];
	}
	gen=0,mae=c,wa=0;
	for(i=n-1;i>=0;i--){
		maxeq(ans,gen+zugo[i]);
		wa+=v[i];wa-=(mae-x[i])*2;
		maxeq(gen,wa);
		maxeq(hago[i],gen);
		mae=x[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

//ワーシャルフロイド法、全点対最短路
//実装例
const int INFTY=(numeric_limits<int>::max())/2;
//d[u][v]は辺uvのコスト、ただし存在しないときINFTY,d[i][i]=0

void warshall_floyd(int V,vector<vector<int>> &d){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j)//目的地の頂点
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}




void solve(){
  int n,m;
  ll l;
  cin>>n>>m>>l;
  vector<vector<int>>d(n,vector<int>(n,INFTY)),d2(n,vector<int>(n,INFTY));
  rep(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      d[a][b]=c;
      d[b][a]=c;
  }
  warshall_floyd(n,d);
  for(int i=0;i<n;++i){
      for(int j=0;j<n;++j){
          if(d[i][j]<=l)d2[i][j]=1;//2点間の距離がl以下の時だけパスでつなぐ=燃料補給なしで進める距離
      }
  }
  warshall_floyd(n,d2);
  int q;
  cin>>q;
  while(q--){
      int s,t;
      cin>>s>>t;
      s--;t--;
      if(d2[s][t]>=INFTY)cout<<-1<<"\n";
      else cout<<d2[s][t]-1<<"\n";
  }
 return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int P=1e9+7;
ll L,R;
int num[71],len,mi[71];
int dp[71][2][2][2];
int dfs(int x,bool fl1,bool fl2,bool fl3){
	if(x==0)return fl1;
	if(dp[x][fl1][fl2][fl3]!=-1)return dp[x][fl1][fl2][fl3];
	int up=fl2?1:num[x],res=0;
	if(fl3||mi[x]==0)res=(res+dfs(x-1,fl1,num[x]|fl2,fl3))%P;
	if(up){
		res=(res+dfs(x-1,1,fl2,fl3|(mi[x]^1)))%P;
		if(fl1&&(fl3||mi[x]==0))res=(res+dfs(x-1,1,fl2,fl3))%P;
	}
	dp[x][fl1][fl2][fl3]=res;
	return res;
}
int Solve(ll x,ll y){
	while(x){
		num[++len]=x&1;
		x>>=1;
	}
	int tot=0;
	while(y){
		mi[++tot]=y&1;
		y>>=1;
	}
	return dfs(len,0,0,0);
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld%lld",&L,&R);
	printf("%d\n",Solve(R,L));
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int[][] t = new int[n][n+1];
		for (int i=0; i<n; i++) {
			for (int j=0; j<=n; j++) {
				t[i][j] = in.nextInt();
			}
		}

		// trace(t);

		int[] dp = new int[1<<n];
		Arrays.fill(dp,Integer.MAX_VALUE/2);
		dp[0] = 0;

		// trace(dp);

		for (int i=0; i<n; i++) {
			for (int j=0; j<1<<n; j++) {
				if (Integer.bitCount(j) != i) continue;
				if (dp[j] == Integer.MAX_VALUE/2) continue;

				for (int k=0; k<n; k++) {
					if ((j>>k&1) == 1) continue;
					int d = t[k][0];
					for (int l=0; l<n; l++) {
						if ((j>>l&1) == 1) {
							d = Math.min(d,t[k][l+1]);
						}
					}
					dp[(j|1<<k)] = Math.min(dp[(j|1<<k)],dp[j] + d);
				}
			}
		}

		// trace(dp);

		out.println(dp[(1<<n)-1]);

		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 43480
// abc130_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  int x, a;
  cin >> x >> a;
  cout << ((x < a) ? 0 : 10) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,num)for(int i=0;i<(num);++i)
#define vi vector<int>

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    int N,X,t,i;
    vi xs;
    cin>>N>>X;
    for (i = 0;i < N; i++) { 
        cin>>t;
        xs.push_back(t);
    }
    xs.push_back(X);
    sort(xs.begin(),xs.end());
    vi diff;
    int ans = xs[1]-xs[0];
    for(i=2;i<=N;i++){
        ans = gcd(ans, xs[i]-xs[i-1]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 892
nums = [int(e) for e in input().split()]
n = nums[0]
k = nums[1]
a = [int(e) for e in input().split()]

town = 1
count = 0
visit = [0] * n

i = 0
while i < k:
    count += 1
    i = i+1
    next_town = a[town-1]
    if visit[town-1] > 1:
        k = (k-i)%(count-1)
        i = 0
    elif visit[town-1] == 0:
        count = 0
    visit[town-1] += 1
    town = next_town

print(town)


Measured memory_bytes: 32328
#include <stdio.h>

int main(void) {
	int h, m, s;
	int h1, m1, s1;
	int h2, m2, s2;
	int sum_s;
	int tmp1, tmp2;

	while(1) {
		scanf("%d %d %d", &h, &m, &s);

		if(h == -1 && m == -1 && s == -1)
			break;

		sum_s = (h * 3600 + m * 60 + s);
		tmp1 = 3600 * 2 - sum_s;
		tmp2 = tmp1 * 3;

		h1 = tmp1 / 3600;
		m1 = (tmp1 - 3600 * h1) / 60;
		s1 = tmp1 - 3600 * h1 - 60 * m1;

		h2 = tmp2 / 3600;
		m2 = (tmp2 - 3600 * h2) / 60;
		s2 = tmp2 - 3600 * h2 - 60 * m2;

		printf("%02d:%02d:%02d\n", h1, m1, s1);
		printf("%02d:%02d:%02d\n", h2, m2, s2);
	}

	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int h,w;
vector<string> v(1001);
ll dp[1001][1001];
bool vis[1000][1000];
ll find(int i,int j)
{
    vis[i][j] = 1;
    if(j < w - 1 && v[i][j + 1] == '.')
    {
        if(dp[i][j + 1] || vis[i][j + 1]){
            dp[i][j] += dp[i][j + 1];
        }
        else{
            dp[i][j] += find(i,j + 1);
        }
        dp[i][j] %= mod;
    }
    if(i < h - 1 && v[i + 1][j] == '.')
    {
        if(dp[i + 1][j] || vis[i + 1][j]){
            dp[i][j] += dp[i + 1][j];
        }
        else{
            dp[i][j] += find(i + 1,j);
        }
        dp[i][j] %= mod;
    }
    return dp[i][j];
}
int main()
{
    cin >> h >> w;
    for(int i = 0; i < h; ++i)
        cin >> v[i];
    dp[h - 1][w - 1] = 1;
    cout << find(0,0) % mod;
    return 0;
}

Measured memory_bytes: 10240
n = int(input())
S = [input() for _ in range(n)]
d = {}
m = 0
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    m = max(m, d[s])

sd = sorted(d.items(), key=lambda x: x[1], reverse=True)
ans = []
for k, v in sd:
    if v != m:
        break
    ans.append(k)

for a in sorted(ans):
    print(a)


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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a) {return a;}

template<typename T, typename... Args>
T Max(T a, Args... args){ return a > Max(args...)? a : Max(args...);}

template<typename T>
T Min(T a) {return a;}

template<typename T, typename... Args>
T Min(T a, Args... args){ return a < Min(args...)? a : Min(args...);}


//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a; n/=2;
    }
    return result;
}

ll mod_expo(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    if(n)
        cout << "0\n";
    else
        cout << "1\n";

    cerr << "time = " << clock() << " ms" << '\n';
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m;
  while(cin>>n>>m,n){
    vector<Int> a(n);
    for(Int i=0;i<n;i++) cin>>a[i];
    Int ans=0;

    set<Int> s;
    s.emplace(0);
    for(Int i=0;i<n;i++){
      if(i){
	s.emplace(a[i-1]);
	a[i]+=a[i-1];
      }
      a[i]%=m;
      chmax(ans,a[i]);
      if(s.upper_bound(a[i])!=s.end()){
	Int k=*s.upper_bound(a[i]);
	chmax(ans,(a[i]+m-k)%m);
      }
    }

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




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

using namespace std;

#define MAXN 55555
int arr[MAXN];

void Eratosthenes(){
  for(int i = 0; i < MAXN; i++){
    arr[i] = 1;
  }
  for(int i = 2; i * i < MAXN; i++){
    if(arr[i]){
      for(int j = 0; i * (j + 2) < MAXN; j++){
        arr[i *(j + 2)] = 0;
      }
    }
  }
}

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  Eratosthenes();
  for (int i = 11; i < MAXN; i++) {
    if (arr[i] && i % 5 == 1) {
      if (cnt) {
        cout << " ";
      }
      cout << i;
      cnt++;
      if (cnt == N) {
        cout << endl;
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    cout << (n % 500 <= a ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

vector<int> search(int a, int b, int n){
    vector<int> ans;
    if(n == 0){
        ans.push_back(a);
        ans.push_back(b);
        return ans;
    }
    int m = (1<<n);
    if((a&m)&&(b&m)){
        vector<int> tmp = search(a-m, b-m, n-1);
        vector<int> tmp1 = search(a-m, tmp[1], n-1);
        ans.push_back(a);
        for(int i = 0; i < tmp1.size(); i++) ans.push_back(tmp1[i]);
        for(int i = 1; i < tmp.size(); i++) ans.push_back(tmp[i]+m);
    }else if((!(a&m))&&(!(b&m))){
        vector<int> tmp = search(a, b, n-1);
        vector<int> tmp1 = search(a, tmp[1], n-1);
        ans.push_back(a);
        //cout << m << endl;
        for(int i = 0; i < tmp1.size(); i++) ans.push_back(tmp1[i]+m);
        for(int i = 1; i < tmp.size(); i++) ans.push_back(tmp[i]);
    }else if(a&m){
        int a_;
        if(a-m == 0) a_ = m+1;
        else {
            for(int i = 0; i <= n; i++){
                if(a&(1<<i)){
                    a_ = a-(1<<i);
                    break;
                }
            }
        }
        vector<int> tmp = search(a-m, a_-m, n-1);
        vector<int> tmp1 = search(a_-m, b, n-1);
        for(int i = 0; i < tmp.size(); i++) ans.push_back(tmp[i]+m);
        for(int i = 0; i < tmp1.size(); i++) ans.push_back(tmp1[i]);
    }else{
        int a_;
        if(a == 0) a_ = 1;
        else {
            for(int i = 0; i <= n; i++){
                if(a&(1<<i)){
                    a_ = a-(1<<i);
                    break;
                }
            }
        }
        vector<int> tmp = search(a, a_, n-1);
        vector<int> tmp1 = search(a_, b-m, n-1);
        for(int i = 0; i < tmp.size(); i++) ans.push_back(tmp[i]);
        for(int i = 0; i < tmp1.size(); i++) ans.push_back(tmp1[i]+m);
    }
    return ans;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int cnta = 0;
    int cntb = 0;
    for(int i = 0; i < N; i++){
        int m = (1<<i);
        if(A&m) cnta++;
        if(B&m) cntb++;
    }
    if(cnta%2 == cntb%2) cout << "NO" << endl;
    else{
        vector<int> ans = search(A, B, N-1);
        cout << "YES" << endl;
        for(int i = 0; i < ans.size()-1; i++){
            cout << ans[i] << ' ';
        }
        cout << ans[ans.size()-1] << endl;
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> vec(N);
  for(int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    ++vec.at(a-1);
    ++vec.at(b-1);
  }
  
  for(int i=0; i<N; i++) cout << vec.at(i) << endl;
}

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

using namespace std;

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

void mergesort(int A[], int left, int right, int& cnt){
	int mid;
	if (left+1 < right){
		mid = int((left+right)/2);
		mergesort(A,left,mid,cnt);
		mergesort(A,mid,right,cnt);
		merge(A,left,mid,right,cnt);
	}
}

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

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

	mergesort(A, 0, n, cnt);

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


	return 0;
}


Measured memory_bytes: 6912
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        Long [] a = new Long[n];
        TreeMap<Long, Integer> map = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            map.put(a[i], map.getOrDefault(a[i], 0) + 1);
        }
        int res = 0;
        while (!map.isEmpty()) {
            Long x = map.firstKey();
            long rem = (Long.highestOneBit(x) << 1) - x;
            if (map.containsKey(rem) && rem == x) {
                res += map.get(x) / 2;
                map.remove(x);
            } else if (map.containsKey(rem)) {
                map.put(rem, map.get(rem) - 1);
                if (map.get(rem) == 0) map.remove(rem);
                map.put(x, map.get(x) - 1);
                if (map.get(x) == 0) map.remove(x);
                ++res;
            } else {
                map.remove(x);
            }
        }
        out.println(res);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

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

int main() {
  string Ans = "No";  // 回答：

  int N; cin >> N; // 商品数
  int M; cin >> M; // 選択数
  int S=0;        // 総得票数
  int B=0;        // 最低得票数
  int C=0;        // 最低得票数以上の商品数
  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
    S += A.at(i);
  }
  if ( S%(4*M) == 0 ) { B = S/(4*M);}
  else { B = S/(4*M) + 1;}
  rep(i,N){
    if( A.at(i) >= B ) { C++; }
  }
  if ( C >= M ) { Ans = "Yes";}
  cout << Ans << endl;
}


Measured memory_bytes: 256
using C=System.Console;using System.Linq;class P{static void Main(){C.Write(string.Concat(Enumerable.Range(0,99).Select(i=>C.ReadLine().Split(' ').Select(int.Parse).ToArray()).TakeWhile(p=>p[0]+p[1]!=0).Select(p=>string.Join("\n",Enumerable.Range(0,p[0]).Select(j=>new string(Enumerable.Range(0,p[1]).Select(i=>(i+j)%2==0?'#':'.').ToArray())).ToArray())+"\n\n").ToArray()));}}

Measured memory_bytes: 9888
// 6/23 解き直し
#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>;
using Graph = vector<vector<int>>;

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

    vector<vector<P>> states(N);

    rep(i, N) {
        int a;
        cin >> a;

        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            states[i].push_back({x, y});
        }
    }

    // cout << "here?" << endl;

    int res = 0;

    rep(div, 1<<N) {
        bool be = true;
        vector<int> honests(N, -1);
        int num = 0;

        rep(i, N) {
            if (div>>i&1) {
                // i人目が正直なら
                // cout << "1";  // << endl;
                num += 1;

                for (auto p : states[i]) {
                    // if (honests[p.first] == -1) {
                    //     honests[p.first] = p.second;
                    // } else {
                    //     if (honests[p.first] != p.second) {
                    //         be = false;
                    //         break;
                    //     }
                    // }
                    // printf("p.first, second = %d, %d\n", p.first, p.second);
                    // printf("div>>p.first&1=%d\n", div>>p.first&0);

                    if ((div>>p.first&1 && p.second!=1) || !(div>>p.first&1) && p.second==1) {
                        // cout << "here?2" << endl;
                        be = false;
                        break;
                    }
                }

            } else {
                // cout << "0";  // << endl;
            }
            
        }
        // cout << endl;

        if (be) {
            res = max(res, num);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3616
N = int(input())
As = list(map(int,input().split()))
ans = 1
if 0 in As:
    print(0)
    exit(0)
for i in range(N):
    ans*=As[i]
    if ans > 1000000000000000000:
        print("-1")
        exit(0)
print(ans)

Measured memory_bytes: 21780
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int c[200] = {};

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, k){
		int d; scanf("%d", &d);
		REP(j, d){
			int a; scanf("%d", &a);
			c[a]++;
		}
	}
	int ans = 0;
	FOR(i, 1, n+1) if(c[i]==0) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int n, m, a[105];

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

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

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

    double p = sum / (4. * m);

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

    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int t, x;
    scanf("%d %d", &t, &x);
    printf("%.15lf", (double)t / x);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, a, ans = 0, cnt, s, t;
  scanf("%lld", &n);
  vector<ll> x[n];
  vector<bool> b[n];
  bool flg[n], used[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    for(j = 0; j < a; ++j) {
      scanf("%lld%lld", &s, &t);
      x[i].push_back(--s), b[i].push_back(t);
    }
  }
  for(j = 1; j < (1 << n); ++j) {
    cnt = 0;
    bool tmp = true;
    for(i = 0; i < n; ++i) used[i] = false;
    for(i = 0; i < n; ++i) if((j >> i) & 1) {
      cnt++;
      for(k = 0; k < x[i].size(); ++k) {
        if(used[x[i][k]] && flg[x[i][k]] != b[i][k]) {
          tmp = false;
          break;
        }
        if((!b[i][k] && ((j >> x[i][k]) & 1)) || (b[i][k] && !((j >> x[i][k]) & 1))) {
          tmp = false;
          break;
        }
        used[x[i][k]] = true, flg[x[i][k]] = b[i][k];
      }
      if(!tmp) break;
    }
    if(tmp && ans < cnt) ans = cnt;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
long long a,b;
  cin>>a>>b;
  long long ans=0;

for(long long i=22;i<=b;i++){
  long long l=i/10;
  long long r=i%10;
  if(l*r<=a && r>1) ans++;
  }
  
  cout<<ans<<endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    int* a = new int[n+1];

    for (int i = 1; i <= n; ++i) {
        int t; cin >> t;
        a[t] = i;
    }
    
    for (int i = 1; i <= n; ++i) cout << a[i] << " ";

    return 0;
}

Measured memory_bytes: 1280
def solve():
    N = int(input())
    t_p = 0
    x_p = 0
    y_p = 0
    for i in range(1, N+1):
        t, x, y = map(int, input().split())
        #　時間的に可能かどうか。
        if (t - t_p) < abs(x - x_p) + abs(y - y_p):
            print('No')
            exit()
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t%2==0 and (x+y)%2==1) or (t%2==1 and (x+y)%2==0):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y
    print('Yes')


if __name__ == '__main__':
    solve()



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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var d = new int[4, 2];
            for(string input; (input = Console.ReadLine()) != null;) { 
                for(var e = input.Split().Select(double.Parse).Select(q => q < 0.2 ? 3 : q < 0.6 ? 2 : q < 1.1 ? 1 : 0).Concat(new [] {0}).ToArray(); e[2] < 2; ++d[e[e[2]], e[2]++]);
            }
            for(int i = 0;i < 4; Console.WriteLine("{0} {1}", d[i, 0], d[i++ , 1]));
        }
    }
}

Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int S,h,m,s,a;
    cin>>S;
    h=S/3600;
    a=S%3600;
    m=a/60;
    s=a%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}



Measured memory_bytes: 3120
#標準入力
j = int(input())
for _ in range(j):
    a = int(input())
    b = int(input())
    
    #aとbの和を計算
    num = a + b
    
    #桁数を調べ81以上であればoverflowを出力する
    num1 = [c for c in str(num)]
    if len(num1) > 80:num = "overflow"
    else:pass
    print(num)


Measured memory_bytes: 5596
X, N = map(int, input().split())
p = list(map(int, input().split()))

if X not in p:
    print(X)
else:
    for i in range(100):
        if (X - (i + 1)) not in p:
            print(X - (i + 1))
            break
        elif (X + (i + 1)) not in p:
            print(X + (i + 1))
            break
        


Measured memory_bytes: 9048
import java.util.Scanner;

public class Main {

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

		double a = sc.nextInt();
		double b = sc.nextInt();
		double h = sc.nextInt();
		double m = sc.nextInt();

		double angle_h = (30 * h) + 0.5 * m;
		double angle_m = 6 * m;
		double angle = 0;

		if(angle_h < angle_m) {
			angle = angle_m - angle_h;
		}else {
			angle = angle_h - angle_m;
		}

		double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b *Math.cos(Math.toRadians(angle)));

		System.out.println(ans);

	}

}


Measured memory_bytes: 35988
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>

using namespace std;
typedef long long ll;

const int maxn=6e5;
int num[13];
int a[13][maxn];
int b[13][maxn];
int p[13];
int n,t;
char ch;
int s;
char ss[maxn];

void init()
{
    num[0]=1;
    for(int i=1;i<13;i++)num[i]=num[i-1]*3;
    for(int i=1;i<13;i++){
        for(int j=0;j<num[i-1];j++){
            a[i][j]=0;
            a[i][j+num[i-1]]=1;
            a[i][j+2*num[i-1]]=2;
            b[i][j]=0;
            b[i][j+num[i-1]]=0;
            b[i][j+2*num[i-1]]=0;
        }
    }
}

void add(int x,int p)
{
    if(x>n)return;
    if(b[x][p]!=s){
        if((s-b[x][p])%2==1){
            if(a[x][p]==1)a[x][p]=2;
            else if(a[x][p]==2)a[x][p]=1;
        }
        b[x][p]=s;
    }
    a[x][p]+=1;
    if(a[x][p]==3){
        a[x][p]=0;
        add(x+1,p);
        add(x+1,p+num[x]);
        add(x+1,p+2*num[x]);
    }
}

void pp()
{
    for(int i=1;i<=n;i++){
        for(int j=0;j<num[i];j++){
            if(b[i][j]!=s){
                if((s-b[i][j])%2==1){
                    if(a[i][j]==1)a[i][j]=2;
                    else if(a[i][j]==2)a[i][j]=1;
                }
            }
            b[i][j]=s;
            //cout<<a[i][j];
        }
        //cout<<endl;
    }
}
void pp2()
{
    for(int i=1;i<=n;i++){
        for(int j=0;j<num[i];j++){
            if(b[i][j]!=s){
                if((s-b[i][j])%2==1){
                    if(a[i][j]==1)cout<<2;
                    else if(a[i][j]==2)cout<<1;
                    else cout<<0;
                }
                else cout<<a[i][j];
            }
            else cout<<a[i][j];
        }
        cout<<endl;
    }
}
int main() {
    cin>>n;
    cin>>ss;
    t=strlen(ss);
    init();
    for(int i=0;i<t;i++){
        ch=ss[i];
        if(ch=='S')s++;
        else {
            add(1,0);
            add(1,1);
            add(1,2);
        }
    }
    pp();
    for(int i=0;i<num[n];i++){
        int ans=0;
        for(int i=1;i<=n;i++){
            ans+=a[i][p[i]]*num[i-1];
            p[i]+=1;
            if(p[i]==num[i])p[i]=0;
        }
        cout<<ans<<' ';
    }
    return 0;
}

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

def main():
    N, P = map(int, input().split())
    a = list(map(int, input().split()))
    all_even = True
    for i in range(N):
        if a[i]&1:
            all_even = False
            break
    if all_even:
        if P:
            print(0)
        else:
            print(pow(2, N))
    else:
        print(pow(2, N-1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define PI 3.141592
#define pb push_back

int main(){
    //入力
    int N,C;
    cin >> N >> C;
    vector<vint> D(C,vint(C));
    rep(i,C) rep(j,C) cin >> D[i][j];
    vector<vint> c(N,vint(N));
    rep(i,N) rep(j,N) cin >> c[i][j];

    vector<vint> change(3,vint(C));
    rep(i,3){
        rep(j,C){
            rep(a,N) rep(b,N){
                if((a+b)%3==i) change[i][j]+=D[c[a][b]-1][j];
            }
        }
    }
    
    int ret=-1;
    rep(i,C) rep(j,C) rep(k,C) {
        if(i!=j && j!=k && k!=i){
            int cost=change[0][i]+change[1][j]+change[2][k];
            if(ret==-1){
                ret=cost;
            }else{
                ret=min(ret,cost);
            }
        }
    }

    cout << ret << endl;
}


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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int n; cin >> n;
	vector<int> v;
	if(n == 0){
		v.pb(0);
	}else{
		while(abs(n) > 0){
			if(n % 2 == 0){
				v.pb(0);
				n = (-n) / 2;
			}else{
				v.pb(1);
				n = (-n+1) / 2;
			}
		}
	}
	int len = v.size();
	Rrep(i, len){
		cout << v[i];
	}
	cout << "\n";
	return 0;
}

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int min_K = 0;
    int max_K = (N-1)*(N-2)/2;
    if (K >= min_K and K <= max_K)
    {
        int M = N*(N-1)/2 - K;
        cout << M << endl;
        for (int i = 2; i <= N; i++)
        {
            cout << 1 << " " << i << endl;
        }
        int count = N;
        for (int i = 2; i < N; i++)
        {
            if (count > M)
                break;
            for (int j = i+1; j <= N; j++)
            {
                if (count > M)
                    break;
                cout << i << " " << j << endl;
                count++;
            }
        }
    }
    else
    {
        cout << -1 << endl;
    }
    
}

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

int main(){
  int h,w; cin>>h>>w;
  vector<string> s(h+2, "");
  for(int i=1; i<h+1; ++i){
    string t; cin>>t;
    s[i]="."+t+".";
  }
  for(int i=0; i<w+2; ++i){
    s[0]+=".";
    s[h+1]+=".";
  }

  bool ans=true;
  for(int i=1; i<h+1; ++i){
    for(int j=1; j<w+1; ++j){
      if(s[i][j]=='#' && s[i-1][j]=='.' && s[i][j-1]=='.' && s[i+1][j]=='.' && s[i][j+1]=='.'){
        ans=false;
        break;
      }
    }
  }

  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main()
{
	long long h, w;
	int n;
	std::map<std::pair<int, int>, int> num;
	scanf("%lld%lld%d", &h, &w, &n);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		for (int x = -1; x <= 1; x++)
		{
			for (int y = -1; y <= 1; y++)
			{
				if (a + y >= h || a + y <= 1 || b + x >= w || b + x <= 1) continue;
				num[{b + x, a + y}]++;
			}
		}
	}
	long long table[10]{(h - 2) * (w - 2)};
	for (auto& e: num)
	{
		table[e.second]++;
		table[0]--;
	}
	for (int i = 0; i < 10; i++) printf("%lld\n", table[i]);

	return 0;
}

Measured memory_bytes: 56448
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    long max = 1000000000000000000L;
    long ans = 1;
    boolean of = false;
    for(int i=0; i<N; i++) {
      long A = sc.nextLong();
      if(A==0) {
        ans = 0;
        of = false;
        break;
      }
        long Amax = max/ans;
        if(A>Amax) {
          of = true;
        } else {
          ans *= A;
        }
      }
    System.out.println(of? -1 : ans);

    sc.close();
  }
}


Measured memory_bytes: 49036
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main() {
  int n;
  cin >> n; 
  int four = 0;
  int two = 0;
  int others = 0;

  rep(i,n){
    int temp;
    cin >> temp;
    if(temp % 4 == 0)four++;
    else if(temp % 2 == 0)two++;
    else others++;
  }

  string ans = "No";

  if(two == n)ans = "Yes";
  else if(n % 2 == 0){
    if(four >= others)ans = "Yes";
  }
  else{
    if(four >= others - 1)ans = "Yes";
  }
  cout << ans << endl;
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
int memo[100001];

int rec(int n){
    if (n == 0) return 0;
    if (memo[n] != -1) return memo[n];

    int res = n;

    for (int pow6 = 1;pow6 <= n;pow6*=6) res = min(res,rec(n-pow6)+1);
    for (int pow9 = 1; pow9 <= n; pow9*=9) res = min(res,rec(n-pow9)+1);
    
    return memo[n] = res;
}

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < 100001;i++) memo[i] = -1;
    
    cout << rec(n) << endl;
    

    return 0;

}


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

int a[10];

int main()
{
    for(int i=0;i<10;i++)
    {
        cin>>a[i];
    }
    sort(a, a+10);
    cout<<a[9]<<endl<<a[8]<<endl <<a[7]<<endl;

    return (0);
}

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

# 約数
# O(N**0.5)
def yakusu(N):
    ret = [[], []]
    for i in range(1, int(N ** 0.5)+1):
        if N % i == 0:
            ret[0].append(i)
            if i ** 2 != N:
                ret[1].append(N//i)
    return ret[0] + ret[1][::-1]

ans = 0
for a in yakusu(N):
    if a == 1: continue
    
    if N % a == 0:
        b = N
        while b % a == 0:
            b //= a
        if (b-1) % a == 0:
            ans += 1
print(ans + len(yakusu(N-1)) - 1)

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

if N%2==0:
    S=N+1
else:
    S=N

ans=[]

for i in range(1,N+1):
    for j in range(i+1,N+1):
        if not i+j==S:
            ans.append([i,j])
print(len(ans))
for a,b in ans:
    print(a,b)


Measured memory_bytes: 9540
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5,M=1e6;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int head[N],nxt[M],to[M],w[M],tot=1;
int a[N];
int cur[N],dep[N],q[N],S,T;
inline void link(int a,int b,int _w) {
	to[++tot]=b,nxt[tot]=head[a],head[a]=tot,w[tot]=_w;
	to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
}
inline bool bfs() {
	int i,k,l,r;
	for (i=S;i<=T;i++) dep[i]=0;
	for (l=0,dep[q[r=1]=T]=1;l!=r;)
		for (i=head[k=q[++l]];i;i=nxt[i])
			if (w[i^1]&&!dep[to[i]])
				dep[q[++r]=to[i]]=dep[k]+1;
	return dep[S];
}
inline LL dfs(int k,LL low) {
	if (k==T) return low;
	LL s=0,x;
	for (int &i=cur[k];i;i=nxt[i])
		if (w[i]&&dep[to[i]]==dep[k]-1)
			if (x=dfs(to[i],min(low-s,(LL)w[i]))) {
				s+=x,w[i]-=x,w[i^1]+=x;
				if (s==low) return s;
			}
	return s;
}

int main()
{
	int n=gi(),i,j;LL ans=0;
	S=0,T=n+1;
	for (i=1;i<=n;i++)
		if ((a[i]=gi())>0)
			link(S,i,a[i]),ans+=a[i];
		else if (a[i])
			link(i,T,-a[i]);
	for (i=1;i<=n;i++)
		if (a[i]<0)
			for (j=i*2;j<=n;j+=i)
				if (a[j]>0)
					link(j,i,oo);
	
	while (bfs()) {
		for (i=S;i<=T;i++) cur[i]=head[i];
		ans-=dfs(S,OO);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(j%2==1)
	    {
	      if(i%2==1)printf("#");
	      else printf(".");
	    }
	  else 
	    {
              if(i%2==1)printf(".");
	      else printf("#");
	    }
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long int ;
 
 
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
 
    ll n;
    string s;
 
    cin >> n >> s;

    for(auto&& c : s){
        c = ((c - 'A' + n) % 26 )+ 'A';
    }

    cout << s << endl;
 
    return 0;
}

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

// https://atcoder.jp/contests/abc125/tasks/abc125_b
namespace BResale
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var n = int.Parse(Console.ReadLine());
            var values = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var costs = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var profits = values.Zip(costs, (v, c) => v - c).ToArray();
            var maxProfit = profits.Where(x => x > 0).Sum();

            // 解答の取得
            Console.WriteLine(maxProfit);
        }
    }
}


Measured memory_bytes: 13396
import numpy as np
from scipy.sparse.csgraph import shortest_path
 
H, W, *t = map(int, open(0).read().split())
c = np.array(t[:100]).reshape((10, 10))
A = np.array(t[100:])
print(int(np.sum(shortest_path(c)[:, 1][A[A >= 0]])))

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, B[105];
bool used[105];
int ans[105], cnt[105];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> B[i];
  }

  for (int i = 0; i < N; i++){
    cnt[0] = used[0];
    for (int j = 1; j < N; j++){
      cnt[j] = cnt[j - 1];
      if (used[j]) cnt[j]++;
    }

    for (int j = N - 1; j >= 0; j--){
      if (used[j]) continue;
      if (cnt[j] + 1 == B[j]){
        ans[i] = B[j];
        used[j] = true;
        break;
      }
    }

    if (ans[i] == 0){
      cout << -1 << endl;
      return 0;
    }
  }

  for (int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3596