akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

int b()
{
    
    long long  h, w;
    std::cin >> h >> w;
    
    long long ans = 0;
    
    if(w == 1 || h == 1)
    {
        ans = 1;
    }
    else
    {
        if(w % 2 == 0 || h % 2 == 0)
        {
            ans = h * w / 2;
        }
        else
        {
            ans = ((h * w) / 2) + 1;
        }
    }
    
    std::cout << ans;
    
    return 0;
    
}


int main(int argc, const char * argv[])
{
    b();
    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
struct state {
	int sx, sy, cost;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int R, H[2], W[2], sx[2], sy[2], a[2][509][509], cnt[2], b[2][250009], vis[509][36];
int dir[] = { 0, 1, 0, -1 };
int main() {
	while (scanf("%d", &R), R) {
		for (int i = 0; i < 2; i++) {
			scanf("%d%d%d%d", &W[i], &H[i], &sy[i], &sx[i]); sy[i]--, sx[i]--;
			for (int j = 0; j < H[i]; j++) {
				for (int k = 0; k < W[i]; k++) {
					reader(&a[i][j][k]);
				}
			}
			priority_queue<state> que; que.push(state{ sx[i], sy[i], -1 });
			memset(vis, 0, sizeof(vis));
			vis[sx[i]][sy[i] >> 5] |= 1 << (sy[i] & 31); cnt[i] = 1;
			while (!que.empty()) {
				state u = que.top(); que.pop();
				b[i][cnt[i]++] = a[i][u.sx][u.sy];
				for (int j = 0; j < 4; j++) {
					int tx = u.sx + dir[j], ty = u.sy + dir[j ^ 1];
					if (0 <= tx && tx < H[i] && 0 <= ty && ty < W[i] && !(vis[tx][ty >> 5] & (1 << (ty & 31)))) {
						a[i][tx][ty] = max(a[i][tx][ty], a[i][u.sx][u.sy]);
						vis[tx][ty >> 5] |= 1 << (ty & 31);
						que.push(state{ tx, ty, -a[i][tx][ty] });
					}
				}
			}
		}
		int ret = 2000000009;
		for (int i = 0; i <= H[0] * W[0]; i++) {
			int z = max(R - i, 0);
			if (z > H[1] * W[1]) continue;
			ret = min(ret, b[0][i] + b[1][z]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 7056
n=int(input())
A=[0]*(n+1)
B=[0]*(n+1)
i=0
mx=(1<<30)*-1
for v in list(map(int,input().split())):
	A[i+1] = v
	mx=max(mx,A[i+1])
	i+=1	

C=[0]*(mx+1)
for i in range(n):
	C[A[i+1]]+=1
for i in range(1,mx+1):
	C[i] += C[i-1]
for i in range(n,0,-1):
	B[C[A[i]]] = A[i]
	C[A[i]]-=1

st=str(B[1])
for i in range(2,n+1):
	st += ' ' + str(B[i])
print(st)



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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) (__gcd(a, b))
#define LCM(a, b) ((a)/GCD(a,b)*(b))
#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 1550555;
const int M = 5125;

ll powmod(int n, int k, int m){
    if (k == 0) return 1;
    ll x = powmod(n, k/2, m);
    x = x * x % m;
    if (k % 2 == 1) x = x * n % m;
    return x;
}

int popcount(int n){
    int z = 0;
    for (int i = 0; i < 31; i++){
        if (n & (1 << i)) z++;
    }
    return z;
}

int ff(int n){
    if (n == 0) return 0;
    int z = 0;
    while (n){
        n = n % popcount(n);
        z++;
    }
    return z;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;

    reverse(ALL(s));

    int popc = 0;
    for (int i = n-1; i >= 0; i--){
        if (s[i] == '1') popc++;
    }

    if (popc == 0){
        for (int i = n-1; i >= 0; i--){
            cout << 1 << endl;
        }
        return;
    }

    if (popc == 1){
        for (int i = n-1; i >= 0; i--){
            if (s[i] == '1'){
                cout << 0 << endl;
                continue;
            }
            s[i] = '1';
            if (s[0] == '1') cout << 2 << endl; else
                cout << 1 << endl;
            s[i] = '0';
        }
        return;
    }

    int mod1 = 0, mod2 = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '0') continue;
        mod1 += powmod(2, i, popc-1);
        mod2 += powmod(2, i, popc+1);
        mod1 %= (popc - 1);
        mod2 %= (popc + 1);
    }

    for (int i = n-1; i >= 0; i--){
        int ans = 1;
        if (s[i] == '0'){
            ll x = mod2 + powmod(2, i, popc+1);
            x %= popc + 1;
            x = (x + popc + 1) % (popc+1);
            ans += ff(x);
        } else {
            ll x = mod1 - powmod(2, i, popc-1);
            x %= popc - 1;
            x = (x + popc - 1) % (popc-1);
            ans += ff(x);
        }
        cout << ans << endl;
    }

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3776
from collections import deque
def bfs(sl, visited, sy, sx, gy, gx, h, w):
    q = deque([(sy,sx,0)])
    q_warp = deque([])
    visited[sy][sx] = 0

    while q:
        while q:
            y, x, d = q.popleft()
            if (y, x) == (gy, gx):
                return visited[gy][gx]
            for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                ny, nx = y+j, x+k
                if ny >= h or nx >= w or ny < 0 or nx < 0:
                    continue
                if sl[ny][nx] == '.' and (visited[ny][nx] == -1 or visited[ny][nx] > visited[y][x]):
                    visited[ny][nx] = visited[y][x]
                    q.appendleft((ny,nx,d))

            for j in range(-2,3):
                for k in range(-2,3):
                    ny, nx = y+j, x+k
                    if ny >= h or nx >= w or ny < 0 or nx < 0: continue
                    if sl[ny][nx] == '.' and visited[ny][nx] == -1:
                        visited[ny][nx] = visited[y][x] + 1
                        q.append((ny,nx,d))

    return -1


h, w = map(int, input().split()) 
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
sl = [list(input()) for _ in range(h)]
visited = [ [-1]*w for i in range(h)]
ans = bfs(sl,visited,ch-1,cw-1,dh-1,dw-1,h,w)
print(ans)

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vv(n, vector<int>());
  //map<int, set<int>> mp;

  int a, b;
  REP(i, m) {
    cin >> a >> b;
    vv[a-1].push_back(b);
    vv[b-1].push_back(a);
  }

  for(auto v : vv) {
    cout << v.size() << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val letter = sc.nextLine().split(" ")

    if (letter(0) < letter(1)) {
      println("<")
    } else if (letter(0).equals(letter(1))) {
      println("=")
    } else {
      println(">")
    }
  }
}

Measured memory_bytes: 25628
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

int main()
{
    const auto n = read<size_t>();
    auto as = reads<int64_t>(n+1);
    auto bs = reads<int64_t>(n);
    int64_t count = 0;
    for(int i = n-1; 0 <= i; --i)
    {
        int64_t killnext = min(as[i+1], bs[i]);
        as[i+1] -= killnext;
        bs[i] -= killnext;
        int64_t kill = min(as[i], bs[i]);
        as[i] -= kill;
        bs[i] -= kill;
        count += kill + killnext;
    }
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<int> > g;
vector<int> ord, low;
vector<bool> is_articulation;
vector<P> bridges;

void dfs(int u, int par, int &k){
    ord[u] = k;
    k++;
    low[u] = ord[u];
    int cnt = 0;
    for(auto v : g[u]){
        if(ord[v] == -1){
            cnt++;
            dfs(v, u, k);
            low[u] = min(low[u], low[v]);
            if(par!=-1 && ord[u] <= low[v]){
                is_articulation[u] = true;
            }
            if(ord[u] < low[v]){
                bridges.push_back(make_pair(u, v));
            }
        }
        else if(v != par)low[u] = min(low[u], ord[v]);
    }
    if(par == -1){
        is_articulation[u] = cnt >= 2;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    g.resize(n);
    ord.resize(n, -1);
    low.resize(n);
    is_articulation.resize(n, false);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int k = 0;
    dfs(0, -1, k);
    for(int i=0;i<n;i++){
        if(is_articulation[i]){
            cout << i << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5048
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <functional>
#include <string>
#include <cstdlib>
 
using namespace std;
 
int main()
{
    int a, b, c, d, ans;
    while(scanf("%d%d%d%d", &a, &b, &c, &d) != EOF)
        ans = min(min(min(d-c, b-c), min(b-a, d-c)), d-a), printf("%d\n", ans < 0 ? 0 : ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string A,B;
    cin >>A>>B;
    if(A.size()==B.size()){
        if(A==B){
            cout<<"EQUAL"<<endl;
        }else if(A>B){
            cout<<"GREATER"<<endl;
        }else{
            cout<<"LESS"<<endl;
        }
    }else if(A.size()>B.size()){
        cout<<"GREATER"<<endl;
    }else{
        cout<<"LESS"<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3608
n = int(input())
a = [0 for i in range(n)]

for z in range(1, int(n**0.5+1)):
    for y in range(1, int(n**0.5+1)):
        for x in range(1, int(n**0.5+1)):
            i = x*x + y*y + z*z + x*y + y*z + x*z
            if i <= n: a[i-1] += 1 

for i in range(n):
    print(a[i])


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

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	vector<vector<pair<int, int>>> xy( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
		for( int j = 0; j < A[i]; j ++ ) {
			int x, y;
			cin >> x >> y;
			x--;
			xy[i].push_back( make_pair( x, y ) );
		}
	}

	int ans = 0;
	for( int mask = 0; mask < 1 << N; mask++ ) {
		vector<int> s( N );
		int flag = 0;
		for( int i = 0; i < N; i++ ) {
			if( mask >> i & 1 ) {
				for( int j = 0; j < A[i]; j++ ) {
					int x, y;
					tie( x, y ) = xy[i][j];
					if( y ) {
						if (s[x] < 0 ) {
							flag = 1;
							break;
						}
						if ( !(mask >> x & 1) ) {
							flag = 1;
							break;
						}
						s[x] = 1;
					}
					else {
						if (s[x] > 0 ) {
							flag = 1;
							break;
						}
						if ( mask >> x & 1 ) {
							flag = 1;
							break;
						}
						s[x] = -1;
					}
				}
			}
			if( flag ) break;
		}
		if( flag == 0 ) {
			int t = __builtin_popcount( mask );
			ans = max( ans, t );
		}
	}

	cout << ans << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int long long
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

bool bl[1000010];
long long x[10000010], y[10000010], z[100000010];
signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n, a, b, cnt = 0, ans = 0;
   string s, v;

   cin >> a >> b;

   if (a == 1 && b == 1)
      cnt = cnt + 400000;
   if (a == 1)
      cnt = cnt + 300000;
   else if (a == 2)
      cnt = cnt + 200000;
   else if (a == 3)
      cnt = cnt + 100000;
   if (b == 1)
      cnt = cnt + 300000;
   else if (b == 2)
      cnt = cnt + 200000;
   else if (b == 3)
      cnt = cnt + 100000;

   cout << cnt << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b;

	scanf("%d %d", &a, &b);
	if(a < b){
		printf("a < b\n");
	} else if(a == b) {
		printf("a == b\n");
	} else {
		printf("a > b\n");
	}
	
	return 0;
}

Measured memory_bytes: 1008
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int N = s.length();
		HashMap<Character, Character> StoT = new HashMap<>(s.length(), 1);
		HashMap<Character, Character> TtoS = new HashMap<>(t.length(), 1);
		for (int i = 0; i < N; i++) {
			// First Observation for every character in S they can only map to one unique
			// character of T
			if (StoT.containsKey(s.charAt(i)) && StoT.get(s.charAt(i)) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
			// Second Observation for every character in T they can only map to one unique
			// character of S
			if (TtoS.containsKey(t.charAt(i)) && TtoS.get(t.charAt(i)) != s.charAt(i)) {
				System.out.println("No");
				return;
			}
			StoT.put(s.charAt(i), t.charAt(i));
			TtoS.put(t.charAt(i), s.charAt(i));
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 34356
n = int(input())

R = []

for i in range(n):
    R.append(int(input()))

minv = R[0]
maxv = R[1] - R[0]

for r in R[1:]:
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)

Measured memory_bytes: 17080
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

typedef long long ll;

const int CBRT = 3005;
const ll INF = 10000000000;

int n,ans,tot;
int prime[CBRT];

bool mark[CBRT];

map<ll,int> cnt;
map<ll,ll> match;

void init()
{
	ll LIM = pow(INF,1.0 / 3) + 1;
	for (int i = 2;i <= LIM;i++)
	{
		if (!mark[i])
			prime[++tot] = i;
		for (int j = 1;j <= tot && i * prime[j] <= LIM;j++)
		{
			mark[i * prime[j]] = true;
			if (i % prime[j] == 0)
				break;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	init();
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		ll a,spj;
		cin >> a;
		ll mat = 1,A = a;
		for (ll J = 1,j = prime[J];J <= tot && j * j * j <= a;j = prime[++J])
		{
			while (a % (j * j * j) == 0)
			{
				a /= j * j * j;
				A /= j * j * j;
			}
			if (a % (j * j) == 0)
			{
				a /= j * j;
				if (mat > INF / j)
				{
					mat = INF + 1;
					break;
				}
				mat *= j;
			}
			if (a % j == 0)
			{
				a /= j;
				if (mat > INF / j / j)
				{
					mat = INF + 1;
					break;
				}
				mat *= j * j;
			}
		}
		cnt[A]++;
		if (mat == INF + 1)
			continue;
		spj = pow(a,1.0 / 2);
		while (spj * spj < a)
			spj++;
		while (spj * spj > a)
			spj--;
		if (spj * spj == a)
		{
			a /= spj * spj;
			if (mat > INF / spj)
				continue;
			mat *= spj;
		}
		if (mat > INF / a / a)
			continue;
		mat *= a * a;
		match[match[mat] = A] = mat;
	}
	for (map<ll,int>::iterator i = cnt.begin();i != cnt.end();i++)
	{
		if ((*i).first == 1)
		{
			ans += (*i).second - 1;
			continue;
		}
		ll cur = min((*i).second,cnt[match[(*i).first]]);
		ans += cur;
		(*i).second -= cur;
		cnt[match[(*i).first]] -= cur;
	}
	cout << n - ans << endl;
	return 0;
}

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

int main(){
double N;
cin >> N;
  
vector<double> A(N);
for (double i = 0; i < N; i++){cin >> A.at(i);}

vector<double> B(N);
for (double i = 0; i < N; i++){B.at(i) = 1 / A.at(i);}
double ans = 0;
for (double i = 0; i < N; i++){ans += B.at(i);}

double ans2 = 0;  
ans2 = 1/ans;
cout << fixed << setprecision(7);
cout << ans2 <<endl;

  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 100010
#define MOD 1000000007
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
int x[M],y[M];
int cnt[M],z[M];
inline int Power(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%MOD;
		x=1ll*x*x%MOD;y>>=1;
	}
	return ret;
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		scanf("%d%d",&x[i],&y[i]);
	}
	rep(i,1,n)cnt[i]=1;
	z[1]=1;
	rep(i,1,m){
		z[y[i]]+=1ll*z[x[i]]*Power(cnt[x[i]],MOD-2)%MOD;
		if(z[y[i]]>=MOD)z[y[i]]-=MOD;
		z[x[i]]-=1ll*z[x[i]]*Power(cnt[x[i]],MOD-2)%MOD;
		if(z[x[i]]<0)z[x[i]]+=MOD;
		cnt[x[i]]--;
		cnt[y[i]]++;
	}
	int ans=0;
	rep(i,1,n)if(z[i]){
		++ans;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
N, *a = map(int, open(0).read().split())

ans = 0
r = 0
x_xor = 0
x_sum = 0

for l in range(N):
    while (r == l) or (r < N and x_xor ^ a[r] == x_sum + a[r]):
        x_xor ^= a[r]
        x_sum += a[r]
        r += 1

    ans += r - l
    x_xor ^= a[l]
    x_sum -= a[l]
    
print(ans)


Measured memory_bytes: 91172
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        inp.close();
        char ss[] = s.toCharArray();
        int N = 753;
        int ans = 1000000;
        int r = 0;
        for (int i = 0; i < ss.length - 2; i++) {
            r = sum(slice(ss, i, i+3));
            r = Math.abs(r - 753);
            if (r < ans) {
                ans = r;
            }
        }
        System.out.println(ans);
    }
    public static char[] slice(char arr[], int from, int to) {
        char res[] = new char[to - from + 1];
        int count = 0;
        for (int i = from; i < to; i++) {
            res[count] = arr[i];
            count++;
        }
        return res;
    }
    public static int sum(char arr[]) {
        String s = String.valueOf(arr).trim();
        int ans = Integer.parseInt(s);
        return ans;
    }
}

Measured memory_bytes: 21972
N=int(input())
ans_dist={}
for n in range(1,N+1):
    ans_dist[n]=0

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            a=x**2 + y**2 + z**2 + x*y + y*z + x*z
            if a <= N:
                ans_dist[a]+=1
            
for k in ans_dist.keys():
    print(ans_dist[k])

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

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

using namespace std;

int main() {
    string str;
    cin >> str;
    
    rep(i, 3) {
        if(str[i]==str[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

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

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

int main(){
    int n;
    cin >> n;
    int S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    int q;
    cin >> q;
    int T[q];
    for(int i = 0; i < q; i++){
        cin >> T[i];
    }

    int cnt = 0;
    for(int i = 0; i < q; i++){
        int k = lower_bound(S, S + n, T[i]) - S;
        if(0 <= k and k < n and S[k] == T[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n, x, m[100];
    scanf("%d%d", &n ,&x);
    int i;
    int minm = 1001;
    int minm_num = 0;
    int weight1 = 0;
    for (i=0; i<n; i++)
    {
        scanf("%d", &m[i]);
        weight1 += m[i];
        if (m[i] < minm) {
            minm = m[i];
            minm_num = i;
        }
    }
    int ans = n;
    int weight_all = weight1;
    i=1;
    while (weight_all <= x)
    {
        weight_all += m[minm_num];
        ans ++;
        i ++;
    }
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 128
S = gets.chomp
K = gets.to_i

ipos = 0
first = "1"
S.each_char do |c|
  if c != "1" then
    first = c
    break
  end
  ipos += 1
end

if ipos < K then
  print first, "\n"
else
  print '1', "\n"
end


Measured memory_bytes: 3836
k,n=map(int,input().split())
ls=list(map(int,input().split()))
sum_ls=ls[:n]
rest_ls=ls[n:]
tmp=sum(sum_ls)
mx=tmp
for i in range(k-n):
    first=ls[i]
    last=ls[i+n]
    tmp=tmp-first+last
    if mx<tmp:
        mx=tmp


print((mx+n)/2)

Measured memory_bytes: 71792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  ll l;
  cin >> l;
  vector<ll> a(l);
  rep(i, l) cin >> a[i];

  vector<vector<ll>> dp(l + 1, vector<ll>(5, INF));
  dp[0][0] = 0;
  rep(i, l) {
    rep(j, 1) chmin(dp[i + 1][0], dp[i][j] + a[i]);
    rep(j, 2) chmin(dp[i + 1][1], dp[i][j] + (a[i] ? a[i] % 2 : 2));
    rep(j, 3) chmin(dp[i + 1][2], dp[i][j] + (a[i] + 1) % 2);
    rep(j, 4) chmin(dp[i + 1][3], dp[i][j] + (a[i] ? a[i] % 2 : 2));
    rep(j, 5) chmin(dp[i + 1][4], dp[i][j] + a[i]);
  }
  ll ans = INF;
  rep(j, 5) chmin(ans, dp[l][j]);
  cout << ans << '\n';

  




  
  return 0;
}

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

struct StGate
{
  StGate() : 
    m_nPassLow(0), m_nPassHigh(0) { }

  int m_nPassLow;
  int m_nPassHigh;
};

void input(vector<StGate>& rvoGate)
{
  int  nPassSiz, nGateSiz;
  cin >> nPassSiz >> nGateSiz;
  rvoGate.resize(nGateSiz);

  for (StGate& roGate : rvoGate)
    cin >> roGate.m_nPassLow >> roGate.m_nPassHigh;
}

int countAlmightyPass(const vector<StGate>& cnrvoGate)
{
  int nAlmightyPassLow = 0;
  int nAlmightyPassHigh = 100001;

  for (StGate oGate : cnrvoGate)
  {
    nAlmightyPassLow  = max(nAlmightyPassLow,  oGate.m_nPassLow);
    nAlmightyPassHigh = min(nAlmightyPassHigh, oGate.m_nPassHigh);
  }
  return max(0, nAlmightyPassHigh - nAlmightyPassLow + 1);
}
  
int main()
{
  vector<StGate> voGate;

  input(voGate);
  cout << countAlmightyPass(voGate) << endl;

  return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i>>1) & 0x55555555);
    i = (i & 0x33333333) + ((i>>2) & 0x33333333);
    i = (i + (i>>4)) & 0x0f0f0f0f;
    i = i + (i>>8);
    i = i + (i>>16);
    return i & 0x3f;
}

typedef struct {
    string name;
    int i;
    int p;
} city;

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

    vector<city> c(n);

    for (int i = 0; i < n; ++i) {
        city city;
        city.i = i+1;
        cin >> city.name >> city.p;
        c[i] = city;
    }

    sort(c.begin(), c.end(), [](city c1, city c2) {
        if (c1.name != c2.name) return c1.name < c2.name;
        if (c1.p != c2.p) return c1.p > c2.p;
        return c1.i < c2.i;
    });

    for (int i = 0; i < n; ++i) {
        cout << c[i].i << endl;
    }
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

ll nc2(ll n){
	return n*(n-1)/2;
}


int main(void){

	int N; cin >> N;
	vector<int> A(N);
	REP(i,N) cin >> A[i];
	REP(i,N) A[i]--;
	vector<int> cnt(N);
	REP(i,N) cnt[A[i]]++;

	ll total = 0;
	REP(i,N){
		total += nc2(cnt[i]);
	}

	REP(i,N){
		ll ans = total;
		ans -= nc2(cnt[A[i]]);
		ans += nc2(cnt[A[i]]-1);
		cout << ans << endl;
	}
	


	return 0;

}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(b % a == 0){
        print(a+b);
    }else{
        print(b-a);
    }
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
D_list = np.array([_i() for _ in range(N)])
idx = np.argsort(D_list)
sorted_D = D_list[idx]
mapping = []
for j in idx:
    mapping.append(j+1)

# 解説を参考に実装
# Dのスコアが大きい方から小さい方へ伸びる有向エッジとみなす
# valueはノードから出ている有向エッジを切った場合の部分木の大きさ
nodes = [1] * N
ans = []
cost = [[0, 1] for _ in range(N)]
# 葉っぱから見て，[エッジにたどり着くまでのコスト, 自分も含めた子ノードの数]
for i in range(N-1, 0, -1):
    d = sorted_D[i]
    sub = nodes[i]
    target = d + 2*sub - N
    cand = np.searchsorted(sorted_D[:i], target)
    if (sorted_D[cand] != target) or (cand == i):
        print(-1)
        exit()
    else:
        ans.append((mapping[i], mapping[cand]))
        nodes[cand] += nodes[i]
        cost[cand][0] += (cost[i][0] + cost[i][1])
        cost[cand][1] += cost[i][1]

# 1番目のノードについてチェック
if cost[0][0] != sorted_D[0]:
    print(-1)
    exit()
else:
    for a in ans:
        print(a[0], a[1])


Measured memory_bytes: 48928
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type Element struct {
	parent, left, right *Element
	key                 int
}

// NewBinarySearchTree is constructor for BinarySearchTree
func NewBinarySearchTree() *BinarySearchTree {
	bstree := BinarySearchTree{
		root: nil,
	}
	return &bstree
}

// BinarySearchTree for int
type BinarySearchTree struct {
	root *Element
}

func (t *BinarySearchTree) inorderTreeWalk(p *Element) {
	if p == nil {
		return
	}

	if p.left != nil {
		t.inorderTreeWalk(p.left)
	}

	fmt.Print(" ", p.key)

	if p.right != nil {
		t.inorderTreeWalk(p.right)
	}
}

func (t *BinarySearchTree) inorderTreeWalk2(p *Element) string {
	if p == nil {
		return ""
	}

	return t.inorderTreeWalk2(p.left) +
		" " + strconv.Itoa(p.key) +
		t.inorderTreeWalk2(p.right)
}

func (t *BinarySearchTree) preorderTreeWalk(p *Element) {
	if p == nil {
		return
	}

	fmt.Print(" ", p.key)

	if p.left != nil {
		t.preorderTreeWalk(p.left)
	}

	if p.right != nil {
		t.preorderTreeWalk(p.right)
	}
}

func (t *BinarySearchTree) preorderTreeWalk2(p *Element) string {
	if p == nil {
		return ""
	}

	return " " + strconv.Itoa(p.key) +
		t.preorderTreeWalk2(p.left) +
		t.preorderTreeWalk2(p.right)
}

func (t *BinarySearchTree) insert(k int) {
	newElement := Element{
		left:  nil,
		right: nil,
		key:   k,
	}

	x := t.root
	var y *Element

	for x != nil {
		y = x
		if newElement.key < x.key {
			x = x.left
		} else {
			x = x.right
		}
	}
	newElement.parent = y
	if y == nil {
		t.root = &newElement
	} else if newElement.key < y.key {
		y.left = &newElement
	} else {
		y.right = &newElement
	}
}

func (t *BinarySearchTree) search(current *Element, k int) *Element {
	for current != nil && current.key != k {
		if k < current.key {
			current = current.left
		} else {
			current = current.right
		}
	}
	return current
}

func (t *BinarySearchTree) minimum(x *Element) *Element {
	for x.left != nil {
		x = x.left
	}
	return x
}

func (t *BinarySearchTree) maximum(x *Element) *Element {
	for x.right != nil {
		x = x.right
	}
	return x
}

func (t *BinarySearchTree) successor(x *Element) *Element {
	if x.right != nil {
		return t.minimum(x.right)
	}
	y := x.parent
	for y != nil && x == y.right {
		x = y
		y = y.parent
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	bstree := NewBinarySearchTree()

	nCommands := nextInt()
	for i := 0; i < nCommands; i++ {
		cmd := nextString()
		if cmd == "insert" {
			key := nextInt()
			bstree.insert(key)
		} else if cmd == "print" {
			// bstree.inorderTreeWalk(bstree.root)
			// fmt.Print("\n")
			fmt.Println(bstree.inorderTreeWalk2(bstree.root))
			// bstree.preorderTreeWalk(bstree.root)
			// fmt.Print("\n")
			fmt.Println(bstree.preorderTreeWalk2(bstree.root))
		}
	}
}



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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
     ll A,B;
    
    cin >>A>>B;
    if(A>9||B>9){
        cout << -1 << endl;
    }else{
        cout << A*B << endl;
    }
    
    //cout << N << endl;
    
    return 0;
}

Measured memory_bytes: 3624
fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1] // 'this' がリストに対応する
    this[index1] = this[index2]
    this[index2] = tmp
}

fun main (args:Array<String>) {
    // Point!! toMutableListでmutableにすることが重要。
    val list = readLine()!!.split(" ").map(String::toInt).toMutableList()

    // MutableになるとList内の値の書き換えが可能になる。
    list.swap(0,1)
    list.swap(0,2)
    var (a,b,c) = list.map(Int::toString)
    print("${a} ${b} ${c}")

}


Measured memory_bytes: 36204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int result = N * N * N;
            Console.WriteLine(result);
        }   
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  int n,x[9],i,m;
  scanf("%d",&n);
  for(i=0;i<9;i++)x[i]=0;
  for(i=0;i<n;i++){scanf("%d",&m);x[m/400<8?m/400:8]++;}
  m=0;for(i=0;i<8;i++)if(x[i])m++;
  printf("%d %d",m?m:1,m+x[8]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 1010
#define modn 1000000007
using namespace std;
int f[maxn][maxn],a[maxn],b[maxn],n,m,i,t1=1,t2=1,ans=1;
int getnum()
{
	int s=0;
	char c=getchar();
	for (;!isdigit(c);c=getchar());
	for (;isdigit(c);c=getchar())
		s=s*10+c-'0';
	return s;
}
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	n=getnum();
	m=getnum();
	for (i=1;i<=n;i++)
		a[i]=getnum();
	for (i=1;i<=m;i++)
		b[i]=getnum();
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+m+1,cmp);
	for (i=n*m;i;i--)
	{
		if ((t1<=n) && (a[t1]>i)) break;
		if ((t2<=m) && (b[t2]>i)) break;
		if ((a[t1]==i) && (b[t2]==i)) t1++,t2++;
			else if (a[t1]==i) t1++,ans=1LL*ans*(t2-1)%modn;
				else if (b[t2]==i) t2++,ans=1LL*ans*(t1-1)%modn;
					else ans=1LL*ans*((t1-1)*(t2-1)-(n*m-i))%modn;
	}
	if (i) printf("0");
		else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "delete" :
            list.delete( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*3);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 189432
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long[] array = new long[n + 1];
			
			array[0] = 2;
			array[1] = 1;
			
			for (int i = 2; i <= n; i++) {
				array[i] = array[i - 1] + array[i - 2];
			}
			
			System.out.println(array[n]);
		}
	}
}

Measured memory_bytes: 25556
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Sum {
  int num;
  ll s;
  multiset<int> ms;
  Sum(int num) : num(num),s(0) {}
  void add(int x) {
    if (ms.size() < num) {
      ms.insert(x);
      s += x;
    } else if (x < *--ms.end()) {
      s = s - *--ms.end() + x;
      ms.erase(--ms.end());
      ms.insert(x);
    }
  }
  ll sum() {
    if (ms.size() == num) return s;
    else return -1;
  }
};

bool cmp(const pii &a, const pii &b) {
  return a.second > b.second;
}
pii p[300000];
int N;

bool check(int n) {
  Sum sum(n);
  // cout << "n = " << n << endl;
  REP(i,N) {
    ll b = p[i].second;
    sum.add(p[i].first);
    ll s = sum.sum();
    // cout << p[i].first << " " << p[i].second << " " << s << endl;
    if (s == -1) continue;
    if (s <= b*n) return 1;
  }
  return 0;
}

int main() {
  cin >> N;
  REP(i,N) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p,p+N,cmp);
  int low = 0, high = N+1;
  while(low+1<high) {
    int mid = (low+high) / 2;
    if (check(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }
  cout << low << endl;
}

Measured memory_bytes: 17492
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int cnt = 0;
	string ans = "No";
	while(n--) {
		int d, dd; cin >> d >> dd;
		if(d == dd) {
			++cnt;
		} else {
			cnt = 0;
		}
		if(cnt == 3) {
			ans = "Yes";
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    string coff;
    cin >> coff;
    if(coff.at(2) == coff.at(3) && coff.at(4) == coff.at(5)){
        cout << "Yes" ;
    }else{
        cout << "No" ;
    }
}

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

#define UNCO if(x >= n){x = 0;}if(x < 0){x = n - 1;}if(y >= n){y = 0;}

int main() {
	int n, a, x, y;

	while (cin >> n) {
		if (n == 0) break;
		int s[15][15] = { 0 };
		a = n * n;
		x = y = n / 2 + 1; x--;
		
		for (int i = 1; i <= a; i++) {
			if (s[y][x] != 0) {
				y++, x--;
				UNCO
				s[y][x] = i;
			}
			else {
				s[y][x] = i;
			}

			y++, x++;
			UNCO
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				printf("%4d", s[i][j]);
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3144
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int,n)
	
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	//nums[i]の各数が何回2で割れるかを求める
	min := 1000000000
	for i := 0; i < n; i++ {
		cnt := 0
		for nums[i] % 2 == 0 {
			nums[i] /= 2
			cnt++
		}
		
		if cnt < min {
			min = cnt
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s;

bool check(char c)
{
	return c >= 'a' && c <= 'z';
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	
	if(s[0] != 'A' || !check(s[1]) || !check(s.back())){
		cout << "WA" << endl;
		return 0;
	}
	bool flag = false;
	for(int i = 2; i < (int)s.size()-1; i++){
		if(s[i] == 'C'){
			if(flag){
				cout << "WA" << endl;
				return 0;
			}
			flag = true;
		}
		else{
			if(!check(s[i])){
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	if(!flag) cout << "WA" << endl;
	else cout << "AC" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, arr[100005], coun[100005];
set<pi> s;
set<int> pos;

int main() {
	fastio; cin >> n;
	if (n == 2) {cout << -1; return 0;}
	FOR(i, 1, n) {
		cin >> arr[i];
		coun[arr[i]]++;
	}
	FOR(i, 1, n) {
		s.insert(pi(coun[i], i));
		pos.insert(i);
	}
	int no = -1;
	while (n) {
		if (n == 3) {
			vector<int> a; a.clear();
			for(auto it:pos) a.pb(it);
			do {
				bool ok = true; int nn = no;
				for(auto it:a) {
					if (nn == it) {ok = false; break;}
					nn = arr[it];
				}
				if (ok) {
					for(auto it:a) cout << it << " ";
					return 0;
				}
			} while (next_permutation(a.begin(), a.end()));

		}
		pi t = *(--s.end());
		int a = t.f, b = t.s;
		int cur = 0;
		if (a == n-1) cur = b;
		else {
			for (auto it:pos) {
				if (it != no) {
					cur = it;
					break;
				}
			}
		}
		cout << cur << " ";
		pos.erase(cur); s.erase(pi(coun[cur], cur));
		no = arr[cur]; n--;
		if (pos.find(no) != pos.end()) {
			s.erase(pi(coun[no], no));
			--coun[no];
			s.insert(pi(coun[no], no));
		}
	}
}


Measured memory_bytes: 11136
#include<stdio.h>




int main(void){
	
	int x,y,r,tmp;
	
	scanf("%d %d",&x,&y);
	
	
	
	if(x<y){
		tmp=x;
		x=y;
		y=tmp;
	}
	
	
	while(y>0)
	{
	r=x%y;
	x=y;
	y=r;	
	}
	
	printf("%d\n",x);
	return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  int res=6;
  res = res -A-B;
  cout << res << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	getInt()
	S := getString()

	fmt.Println(strings.Count(S, "ABC"))
}

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define LL long long
#define maxn 100010
using namespace std;
struct bkn
{
    int to,next;
}e[2*maxn];
int head[maxn],tot=0,sum[maxn],f[maxn],tt=-1,deep[maxn],ans=0;
void add(int a,int b)
{
    e[tot].to=b;
    e[tot].next=head[a];
    head[a]=tot++;
}
void dfs(int fa,int x,int s)
{
    int i;
    deep[x]=s;
    for (i=head[x];i!=-1;i=e[i].next)
    {
        int y=e[i].to;
        if (y==fa) continue;
        f[y]=x;
        dfs(x,y,s+1);
        sum[x]+=sum[y];
    }
    sum[x]++;
}
void get(int x,int n)
{
    int fa=f[x];
    if (deep[fa]==(deep[1]+deep[n])/2)
    {
        ans=sum[x];
        return;
    }
    get(fa,n);
}
int main()
{
    int n,i;
    memset(head,-1,sizeof(head));
    cin>>n;
    for (i=1;i<=n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        add(x,y);
        add(y,x);
    }
    dfs(0,1,1);
    get(n,n);
    if (ans>=n-ans) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 9600