akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

a, b = A[0], A[1]
X = 0
for i in range(2, N):
    X ^= A[i]
S = a + b

M = 42
dp = [[[-1] * 2 for _ in range(2)] for _ in range(M + 1)]
dp[0][0][0] = 0
v = 1
for i in range(M):
    cs = S & 1
    cx = X & 1
    ca = a & 1
    for j in range(2):
        for k in range(2):
            if dp[i][j][k] == -1:
                continue
            for na in range(2):
                for nb in range(2):
                    # 条件②: A' ^ B' = X
                    if na ^ nb != cx:
                        continue
                    # 条件①: A' + B' = S
                    ns = na + nb + j
                    if ns & 1 != cs:
                        continue
                    
                    ni = i + 1
                    nj = 1 if ns >= 2 else 0
                    if na > ca:
                        nk = 1
                    elif na < ca:
                        nk = 0
                    else:
                        nk = k
                    
                    dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] + na * v)
    S >>= 1
    X >>= 1
    a >>= 1
    v <<= 1

ans = dp[M][0][0]
if ans <= 0:
    print(-1)
else:
    print(A[0] - ans)


Measured memory_bytes: 62668
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;

# define INF ((int)(1<<30))
# 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 TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12

template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int clamp(int a, int mi, int ma)
{
	return max(mi, min(a, ma));
}

int n, m;
int c[17];
int a[20002];
int memo[20002][256];

int dp(int now,int o)
{
	if (now > n)return 0;
	if (memo[now][o] != -1)return memo[now][o];
	int ans = INT_MAX;
	for (int i = 0; i < m; i++)
	{
		ans = min(ans, dp(now + 1, clamp(o + c[i], 0, 255)));
	}
	ans += (o - a[now])*(o - a[now]);
	return memo[now][o] = ans;
}

int main()
{
	
	while (cin >> n >> m&&n)
	{
		memset(memo, -1, sizeof memo);
		REP(i, m)cin >> c[i];
		REP(i, n)cin >> a[i+1];
		a[0] = 128;
		cout << dp(0,128) << endl;
	}
}

Measured memory_bytes: 24676
#!/usr/bin/env python3
#ABC75 B

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
ans = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            x = 0
            for k in range(8):
                nx = j+dx[k]
                ny = i+dy[k]
                if 0 <= nx < w and 0 <= ny < h:
                    if s[ny][nx] == '#':
                        x += 1
            ans[i][j] = str(x)
        else:
            ans[i][j] = '#'
for i in range(h):
    print(''.join(ans[i]))


Measured memory_bytes: 40048
#include<stdio.h>

#define LEN 1000

void swap(int *sx,int *sy){
  int tmp=*sx;
  *sx=*sy;
  *sy=tmp;
}

void bsort(int s[],int N){
  int tmp,i,j;
  for(i=0;i<N;i++)
    for(j=0;j<N-i-1;j++)
      if(s[j]>s[j+1])
	swap(&s[j],&s[j+1]);
}

int main(void){
  int N,K;
  scanf("%d %d",&N,&K);
  
  int p[LEN],i,sum=0;
  for(i=0;i<N;i++)
    scanf("%d",&p[i]);
  
  bsort(p,N);

  for(i=0;i<K;i++)
    sum+=p[i];
  
  printf("%d\n",sum);
  return 0;
}
    
  
  


Measured memory_bytes: 1708
# input
H, W = map(int, input().split())
s = [
    list(input())
    for i in range(H)
]

# check
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            continue
        else:
            check = []
            append = check.append

            if i - 1 >= 0:
                append(s[i - 1][j])
            if i + 1 < H:
                append(s[i + 1][j])
            if j - 1 >= 0:
                append(s[i][j - 1])
            if j + 1 < W:
                append(s[i][j + 1])

            if set(check) == {"."}:
                print("No")
                exit(0)
print("Yes")

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<long> dp(N+1);
  dp[0] = 0;
  
  for(int i=1; i<=N; i++){
    int order = log10(i)+1;
    if(order == 1)
    {
      dp[i] = dp[i-1] + 1;
      continue;
    }
    
    int B = i % 10;
    int T = i / pow(10,order-1);
    
    if(B == 0){
      dp[i] = dp[i-1];
    }else if (B < T){
      dp[i] = dp[i-1] + 2 * (pow(10.0, order-1)-1) / 9;
    }else if (B > T){
      dp[i] = dp[i-1] + 2 * (pow(10.0, order-2)-1) / 9;
    }else if (B == T){
      int maxOrderNum = (i - T*pow(10, order-1) -B) / 10+1;
      dp[i] = dp[i-1] + 2 *((pow(10.0, order-2)-1)/9 + 1) + 2 *maxOrderNum - 1; 
    }
  }
  
  cout << dp[N];
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
string  s;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> ai(n);
REP(i,n){
    cin >> ai[i];
}
SORT(ai);
  int ans=0;
REP(i,k){
    ans+=ai[i];
}
cout << ans;
}

Measured memory_bytes: 3628
#include <stdio.h>

int max(int a, int b){
    if(a > b)
        return a;
    else  
        return b;
}
int min(int a, int b){
    if(a < b)
        return a;
    else  
        return b;
}


int main(void){
    //input
    int N;  scanf("%d",&N);
    int A[N];
    int B[N-1];     
    for(int i = 0 ;i < N-1; i++){
        scanf("%d",&B[i]);
        }

    //cal
    int sum = 0;
    A[N-1]=B[N-2]; A[0]=B[0];
    if(N>4){
        for(int i = N-2; i>0; i--){
            A[i] = min(B[i], B[i-1]);
        }
        for(int i = 0; i < N; i++){
            sum += A[i];
        }
    }else if(N==2){
        sum = B[0]*2;
    }else{
        A[1] = min(B[0],B[1]);
        //A[2] = B[1];
        //printf("%d %d %d %d\n",A[0],A[1],A[2],A[3]);
        sum = A[0]+A[1]+A[2];
    }


    // for(int i = 0; i < N; i++){
    //     printf("%d ",A[i]);
    // }
    // printf("\n");

    //output
    printf("%d\n",sum);
}


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

int main(){
  int n,i,c,s;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  c=0;
  s=0;
  for(i=0;i<n;i++){
    if(i==n-1||a.at(i)!=a.at(i+1)){
      c=1-c;
      s += c;
      c=0;
    }else{
      c=1-c;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

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

  ll a,b,n;
  cin >> a >> b >> n;
  ll ansa, ansb ,ans;
  ll x=n;
  if (n>= b-1) x = b-1;
  ans = (a*x)/b - a*(x/b);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int x = scan.nextInt();
		
		if(x < a) {
			System.out.println("NO");
		}else if(x <= a + b) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 23764
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

x,y = map(int,input().split())
if (2*x - y)%3 == 0 and (2*y - x)%3 == 0 and (2*x - y) >= 0 and (2*y - x) >=0:
    a = (2*x - y)//3
    b = (2*y - x)//3
    c = cmb(a+b,a)
    print(c%(10**9 + 7))
else:
    print(0)

Measured memory_bytes: 46060
#include <iostream>
#include <vector>
using namespace std;
int solve(int s, int N, vector<int> &D, vector<int> t, int d){
  if(s == N || d == 0) return d;
  int x = D[s], y = (24-D[s])%24, d1 = d, d2 = d;
  for(int i = 0; i <= s; ++i){
    d1 = min(d1,min(abs(t[i]-x),24-abs(t[i]-x)));
    d2 = min(d2,min(abs(t[i]-y),24-abs(t[i]-y)));
  }
  vector<int> t1 = t, t2 = t;
  t1.push_back(x);
  t2.push_back(y);
  return max(solve(s+1,N,D,t1,d1), solve(s+1,N,D,t2,d2));
}

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; ++i) cin >> D[i];
  if(N > 35){
    cout << "0" << endl;
    return 0;
  }
  vector<int> init(1,0);
  cout << solve(0,N,D,init,24) << endl;
  return 0;
}


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

int main() {
	ll x, k, d;
	cin >> x >> d >> k;
	if (abs(x)/k > d) {
		cout << abs(x)-k*d << endl;
		// cout << "s" << endl;
		return 0;
	}
	if ((d-abs(x)/k)%2==0) {
		cout << abs(x)%k << endl;
		// cout << "b" << endl;
		return 0;
	} else{
		cout << abs(abs(x)%k-k) << endl;
		// cout << "a" << endl;
		return 0;
	}
	return 0;
}

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

int main() {
  ll n,k,c=0;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(ll i=0;i<n;i++)
  {
    if(a[i]>=k)
    {
c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int gr[100009];
int f[100009];
vector<int> v[100009];
void dfs(int x){
    f[x] = 1;
    for(auto i : v[x]){
        if(f[i]) continue;
        dfs(i);
        gr[x] ^= gr[i];

    }
    if(x > 1) gr[x] ++;
}
main(){
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >>x>> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1);
    if(gr[1] == 0) cout << "Bob"<< endl;
    else cout << "Alice"<<endl;
}


Measured memory_bytes: 11136
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(1,H+1):
        for j in range(1,W+1):
            if j==1 or i==1 or j==W or i==H:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()    



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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;}
 
int n;
vector<pair<int, bool> > edges[100001];
bool res[100001];
int cost[100001];

void solve(int p){

  REP(i, edges[p].size()){
    int np = edges[p][i].first;
    bool flag = edges[p][i].second;
    if(cost[np] >= 0) continue;
    if(flag){
      cost[np] = cost[p] + 1;
      solve(np);
    }else{
      cost[np] = cost[p];
      solve(np);
    }
  }
}

int main(){
  cin >> n;
  REP(i, n-1){
    int u, v;
    ll int w;
    cin >> u >> v >> w;
    bool flag = (w%2 == 1);
    edges[u-1].pb(mp(v-1, flag));
    edges[v-1].pb(mp(u-1, flag));
  }
  REP(i, n) cost[i] = -1;
  cost[0] = 0;
  solve(0);
  REP(i, n){
    cout << (cost[i]%2==0) << endl;
  }
}	
	
	

Measured memory_bytes: 8320
// @DateTime:    2020-04-27 16:37:23
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int a, b , c;
    cin >> a >> b >> c;
    cout << max(0,c-(a-b)) << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;

int calc(int x) {
	int ret;
	for (int i = 1; ; i++) {
		x -= i;
		if (x < 0) {
			ret = i - 1;
			break;
		}
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n;
	int ans = 0;
	for (i = 2; i * i <= n; i++) {
		int cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		ans += calc(cnt);
	}
	if (n > 1) ans++;
	cout << ans << endl;
	return 0;
}

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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            int z = s - i - j;
            if (z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main() {
  while (1) {
    char ch;
    scanf("%c", &ch);

    if (ch == '\n') {
      break;
    } else if (isupper(ch) != 0) {
      ch = tolower(ch);
    } else if (islower(ch) != 0) {
      ch = toupper(ch);
    }

    printf("%c", ch);
  }

  printf("\n");

  return 0;
}


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

const double INF = DBL_MAX;

int main(){
    int n;
    cin >> n;
    vector<int> s(n), d(n), v(n);
    for(int i = 0; i < n; i++)  cin >> s[i] >> d[i] >> v[i];
    vector<vector<double>> dp(n, vector<double>(1<<n, INF));
    vector<vector<int>> back(n, vector<int>(1<<n, -1));
    for(int i = 0; i < n; i++){
        dp[i][1<<i] = 0;
    }
    for(int s = 0; s < 1<<n; s++){
        for(int i = 0; i < n; i++){
            if(((s>>i)&1) == 0) continue;
            double w = 0;
            for(int k = 0; k < n; k++)  if((s>>k)&1)    w += v[k];
            w *= 20;
            for(int j = 0; j < n; j++){
                if((s>>j)&1)    continue;
                if(dp[j][s|(1<<j)] > dp[i][s] + abs(d[i]-d[j])/2000.0*(70+w)){
                    dp[j][s|(1<<j)] = dp[i][s] + abs(d[i]-d[j])/2000.0*(70+w);
                    back[j][s|(1<<j)] = i;
                }
            }
        }
    }
    vector<int> ans;
    int pos = -1, bit = (1<<n)-1;
    double tim = INF;
    for(int j = 0; j < n; j++){
        if(dp[j][(1<<n)-1] < tim){
            tim = dp[j][bit];
            pos = j;
        }
    }
    while(pos != -1){
        ans.push_back(s[pos]);
        int nbit = bit^(1<<pos);
        pos = back[pos][bit];
        bit = nbit;
    }
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < n; i++){
        cout << ans[i] << " \n"[i==n-1];
    }
    return 0;
}


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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l;
    cin >> l;
    long double ans = 0;
    long double edge = (long double)l/3;
    ans = edge*edge*edge;
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define pb push_back
#define mp make_pair



int main() {
	
	int n;
	cin >> n;
	int b[n+1];
	b[0] = 1e5+1;
	b[n] = 1e5+1;
	rep1(i,n-1) cin >> b[i];
		
		int ans = 0;
		for(int i =0;i<n;i++)
		   ans+=min(b[i],b[i+1]);
			  
			cout << ans <<endl;
			
	
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left  (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)

#define mod %
#define N 13
#define MOD (ll)(1e9 + 7)
#define test if(!true)

int cnt[100007][13];
int tmp[13];

int powerf(int a, int b)
{
	int ans = 1;
	while(b > 0)
	{
		if(b & 1)
		{
			ans = (ans * a) mod N;
		}

		a = (a * a) mod N;
		b = ( b >> 1);
	}
	return ans;
}

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

	cnt[0][0] = 1;
	int n = s.length();
	reverse(all(s));

	for(int i=1; i<=n; i++)
	{
		frt(j, 0, 13) tmp[j] = 0;

		if(s[i-1] != '?')
		{
			int val = (powerf(10, i-1) * (s[i-1]-'0')) mod N;
			frt(j, 0, 13)
				tmp[(val + j) mod N] = (tmp[(val + j) mod N] + cnt[i-1][j]) mod MOD;
			frt(j, 0, 13)	
			{
				cnt[i][j] = tmp[j];
				test cout << j << " : " << cnt[i][j] << "\n";
			}
			continue;
		}
		for(int d=0; d<10; d++)
		{
			int val = (powerf(10, i-1) * d) mod N;
			frt(j, 0, 13)
				tmp[(val + j) mod N] = (tmp[(val + j) mod N] + cnt[i-1][j]) mod MOD; 
		}

		frt(j, 0, 13)	
		{
			cnt[i][j] = tmp[j];
			test cout << j << " : " << cnt[i][j] << "\n";
		}
	}

	cout << cnt[n][5] << "\n";



    return 0;
}




Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
  int main() {
  string s;
  cin >> s;
  unordered_map<char, int> mp;
  rep(i, s.size()) {
    mp[s[i]]++;
  }
  bool b = true;
  if(mp['a'] != 1) b = false;
  if(mp['b'] != 1) b = false;
  if(mp['c'] != 1) b = false;
  yorn(b);
  return 0;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(true){
    C-=B;
    if(C<=0){
      cout << "Yes" << endl;
      return 0;
    }
    A-=D;
    if(A<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [usize; n],
        es: [(usize1, usize1); m]
    }
    let mut gs = vec![true; n];
    for &(a, b) in &es {
        if v[a] >= v[b] {
            gs[b] = false;
        }
        if v[a] <= v[b] {
            gs[a] = false;
        }
    }
    println!("{}", gs.iter().filter(|&&x| x).count());
}


Measured memory_bytes: 4424
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int  gcd( int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}



int main() {
    int n;
    int a[100010];
    cin>>n;
    REP(i,n) cin>>a[i];
    sort(a,a+n);
    int min_gcd=INF;
    int j=0;
    
    //
    for(int i=1;i<n;i++){
        int s=gcd(a[0],a[i]);
        if(s<min_gcd) {
            min_gcd=s;
            j=i;
            //cerr<<min_gcd<<endl;
        }
    }
    //a[0]を書き換えた時
    int tmp1=a[1];
    for(int i=1;i<n;i++){
        tmp1=gcd(tmp1,a[i]);
    }
    //それ以外
    a[j]=a[0];
    int ans=a[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<max(ans,tmp1)<<endl;
 
 
 
    return 0;
}

Measured memory_bytes: 640
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			//System.out.println("n = "+n);
			
			boolean[][] post = new boolean[5001][5001];
			ArrayList<Point> plist = new ArrayList<Point>();
			
			for(int i = 0; i < n; i++){
				String[] tmpArray = br.readLine().split(" ");
				int x = Integer.parseInt(tmpArray[0]);
				int y = Integer.parseInt(tmpArray[1]);
				post[y][x] = true;
				plist.add(new Point(x, y));
			}
			
			//Iterator<Point> it = plist.iterator();
			Point[] parray = plist.toArray(new Point[plist.size()]);
			
			int maxArea = 0;
			
			for(int i = 0; i < n - 1; i++){
				int x1 = parray[i].x;
				int y1 = parray[i].y;
				for(int j = i + 1; j < n; j++){
					int v1x = parray[j].x - x1;
					int v1y = parray[j].y - y1;
					
					int v2x = v1y*(-1);
					int v2y = v1x;
					
					int v3x = v1y;
					int v3y = v1x*(-1);
					
					//if((v1x + v2x)*(v1x + v2x) >= 15000000) System.out.println((v1x + v2x)*(v1x + v2x));
					
					if(inRange(x1 + v2x, y1 + v2y) && post[y1 + v2y][x1 + v2x]
							&& inRange(x1+v1x+v2x, y1 + v1y + v2y) && post[y1+v1y+v2y][x1+v1x+v2x]){
						//long tmpArea = (v1x + v2x)*(v1x + v2x) - Math.abs(2*v1x*v1y);
						int tmpArea = (int)Math.pow(Math.abs(v1x) + Math.abs(v2x), 2)- Math.abs(2*v1x*v1y);
						
						
						
						if(tmpArea > maxArea){
							maxArea = tmpArea;
							//System.out.println("Type 1 i = "+i+" j = "+j +" area = "+maxArea);
						}
					}
					
//					else if(inRange(x1 + v3x, y1 + v3y) && post[y1 + v3y][x1 + v3x]
//							&& inRange(x1+v1x+v3x, y1 + v1y + v3y) && post[y1+v1y+v3y][x1+v1x+v3x]){
//						//int tmpArea = (v1x + v3x)*(v1x + v3x) - Math.abs(2*v1x*v1y);
//						int tmpArea = (v1x + v3x)*(v1x + v3x) ;
//								
//						if(tmpArea > maxArea){
//							maxArea = tmpArea;
//							System.out.println("Type 2 i = "+i+" j = "+j +" area = "+maxArea);
//						}
//					}
				}
			}
			
			System.out.println(maxArea);
		}
	}
	
	static boolean inRange(int x, int y){
		if(x >= 0 && x <= 5000 && y >= 0 && y <= 5000){
			return true;
		}
		else {
			return false;
		}
	}

}

class Point{
	int x;
	int y;
	
	public Point(int x, int y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 124656
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
void warshall(vvl& d, vvi& es, map<pii, int>& cost){
    int N = es.size();
    d = vvl(N, vl(N, LINF));
    // d[i][j] : the shortest distance from i to j

    REP(i, N) d[i][i] = 0;
    REP(i, N) {
        for (int t : es[i]) {
            //d[i][t] = 1;
            //d[t][i] = 1;
            d[i][t] = cost[pii(i, t)];
            d[t][i] = cost[pii(t, i)];
        }
    }
    REP(k, N) {
        REP(i, N) {
            if (d[i][k] == INF) continue;
            REP(j, N) {
                if (d[k][j] == INF) continue;

                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
}

void get_permutation(vector<vs>& perm, vs a){
    sort(a.begin(), a.end());
    do {
        vs t;
        for (string s : a) t.push_back(s);
        perm.push_back(t);
    } while (next_permutation(a.begin(), a.end()));
}
#endif


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

    int N, M, R; cin >> N >> M >> R;
    vi r(R); 
    REP(i, R) {
        cin >> r[i];
        r[i]--;
    }
    vi A(M), B(M), C(M);
    REP(i,M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
    }

    vvi es(N);
    map<pii, int> cost;
    REP(i,M) {
        es[A[i]].push_back(B[i]);
        cost[pii(A[i], B[i])] = C[i];
        es[B[i]].push_back(A[i]);
        cost[pii(B[i], A[i])] = C[i];
    }

    vvl d;
    warshall(d, es, cost);

    vs sr;
    REP(i, R) sr.push_back(to_string(r[i]));

    vector<vs> perm;
    get_permutation(perm, sr);
    
    ll ans = LINF;
    for(vs ptn : perm) {
        ll sum = 0;
        int x = stoi(ptn[0]);
        for (int i = 1; i < ptn.size(); i++) {
            int nx = stoi(ptn[i]);
            sum += d[x][nx];
            x = nx;
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7608
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


N = INT()
S = input()

s1 = []
dic_s2 = defaultdict(int)

for x in product([0, 1], repeat=N):
	s1_red = ""
	s1_blue = ""
	s2_red = ""
	s2_blue = ""
	for i in range(N):
		if x[i]:
			s1_red += S[i]
			s2_red += S[N+i]
		else:
			s1_blue += S[i]
			s2_blue += S[N+i]

	s1.append((s1_red, s1_blue))
	dic_s2[(s2_blue[::-1], s2_red[::-1])] += 1

ans = 0
for x in s1:
	ans += dic_s2[x]

print(ans)


Measured memory_bytes: 271648
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int comps(const void *a, const void *b){return strcmp(a, b);}

int main(void){
	int n, i;
	char s[200000][11];
	int a[200000];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s", s[i]);
		a[i]=0;
	}
	qsort(s, n, 11, comps);

	int max=0;
	for(i=0; i<n; i++){
		int l=0, r=n-1, m;
		while(l<=r){
			m=(l+r)/2;
			if(comps(s[m], s[i])>=0) r=m-1; else l=m+1;
		}
		a[l]++;
		if(a[l]>max) max=a[l];
	}
	for(i=0; i<n; i++){
		if(a[i]==max) printf("%s\n", s[i]);
	}
	return 0;
}


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

int main() {
    vector<int> v;
    int N;
    cin >> N;
    for (int i = 0; i < N;i ++) {
        int n;
        cin >> n;
        v.push_back(n);
    }

    int a[100010] = {0};
    for (int i = 0; i < N; i++) {
        a[v[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < 100005; i++) {
        ans = max(a[i-1] + a[i] + a[i+1], ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1144
s=raw_input()
stack=[]
for i in xrange(len(s)):
    if len(stack)==0 or s[i]=="S":
        stack.append(s[i])
        continue
    if s[i]=="T":
        if stack[-1]=="S":
            stack.pop()
        else:
            stack.append(s[i])
print(len(stack))

Measured memory_bytes: 21812
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int arr[] = new int[n];
        for (int i = 0;i < n;++i){
            arr[i] = scanner.nextInt();
        }
        int c = 0;
        for (int i = 1;i < n;++i){
            if(arr[i - 1] == arr[i]){
                if(i + 1 == n){
                    ++c;
                }
                else{
                    arr[i] = 10001;
                    ++c;
                }
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,i,counter=0;
    long min=200001;
    cin>>n;

    for (int op=0;op<n;op++){
        cin>>i;
        if(i<=min){
            min = i;
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    if(n % 2 == 0)
    {
        REP(i, n)
        {
            if(a[i] != 2 * (i / 2) + 1)
            {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    else
    {
        if(a[0] != 0)
        {
            cout << 0 << endl;
            return 0;
        }
        FOR(i, 1, n)
        {
            if(a[i] != 2 * ((i + 1) / 2))
            {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    ll ans = 1;
    if(n % 2 == 0)
    {
        REP(i, n / 2)
        {
            ans *= 2;
            ans %= MOD;
        }   
    }
    else
    {
        REP(i, (n - 1) / 2)
        {
            ans *= 2;
            ans %= MOD;
        }  
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include<stdio.h>
#include <cstdio>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for(int i = 1;cin >> ch; i++){
    if(ch == '\\')S1.push(i);
    else if(ch == '/' && S1.size() > 0){
    int j = S1.top();S1.pop();
    sum += i - j;
    int a = i - j;
    while(S2.size() > 0 && S2.top().first > j){
    a += S2.top().second;S2.pop();
    }
    S2.push(make_pair(j, a));
    }
    }
    vector<int> ans;
    while(S2.size() > 0){ans.push_back(S2.top().second);S2.pop();}
    reverse(ans.begin(),ans.end());
    cout<< sum << endl;
    cout<< ans.size();
    for( int i = 0; i < ans.size(); i++){
    cout<< " ";
    cout<< ans[i];
    }
    cout << endl;
    return 0;
    }

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
    if (b == 0) return b;
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
 
int main() {
  ll n;
  cin >> n;
  vl a;
  inputv(a,n);
  vl l(n+1),r(n+1);
  l[0] = a[0];
  for(ll i=1; i<n; i++){
    l[i] = gcd(l[i-1], a[i]);
  }
  r[n-1] = a[n-1];
  for(int i=n-2; i>=0; i--){
    r[i] = gcd(r[i+1], a[i]);
  }
  ll ans = r[1];
  for(int i=1; i<n-1; i++){
    ans = max(ans, gcd(l[i-1], r[i+1]));
              }
  ans = max(ans, l[n-2]);
  cout << ans;          
  
 return 0;
}

Measured memory_bytes: 2676
n, k, q =map(int,input().split())
points = [k-q] * (n)
a = [0] * (q)

for i in range(q):
    a[i] = int(input())

for j in a:
    points[j-1] = points[j-1]+1

for l in points:
    if l >0:
        print('Yes')
    else:
        print('No')

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int n;
	cin >> n;
	vector<int> res(n + 1);
	for(int x = 1; x <= 100; x++) {
		for(int y = 1; y <= 100; y++) {
			for(int z = 1; z <= 100; z++) {
				if(x*x + y*y + z*z + x*y + y*z + z*x <= n)
					res[x*x + y*y + z*z + x*y + y*z + z*x]++;
			}
		}
	}
	for(int i = 0; i < n; i++)
		cout << res[i + 1] << '\n';
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a;
int main(void){
    cin>>n>>a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(1000*(10*i+5*j+(n-i-j))==a){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int time[] = new int[5];
        for (int i = 0; i < 5; i++) {
            time[i] = sc.nextInt();
        }

        int index = 0;
        int min = 9;

        for (int i = 0; i < 5; i++) {
            if (time[i] % 10 != 0) {
                if (min > time[i] % 10) {
                    min = time[i] % 10;
                    index = i;
                }
            }
        }

        for (int i = 0; i < 5; i++) {
            if (i != index) {
                if (time[i] % 10 != 0) {
                    time[i] = time[i] - (time[i] % 10) + 10;
                }
            }
        }

        int result = 0;

        for (int i = 0; i < 5; i++) {
            result = result + time[i];
        }

        System.out.println(result);
	}
}


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

const int maxn = 2010;
int n, sz[maxn], sum[maxn], f[maxn];
char s[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d %s", &n, s + 1);
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    int ans = INT_MAX;
    for (int i = 1; i <= n; i++) {
        function<void(int, int)> dfs = [&](int v, int fa) {
            int mx = sum[v] = f[v] = sz[v] = 0;
            sz[v] = s[v] - '0';
            for (int u : G[v]) if (u ^ fa) {
                dfs(u, v);
                sz[v] += sz[u], sum[v] += sum[u];
                if (sum[u] > sum[mx]) mx = u;
            }
            if (mx) {
                f[v] = f[mx];
                for (int u : G[v]) {
                    if (u ^ mx && u ^ fa) f[v] -= sum[u];
                }
                f[v] = max(0, f[v]);
            }
            sum[v] += sz[v], f[v] += sz[v];
        };
        dfs(i, 0);
        if (f[i] == sz[i] && !((sum[i] - sz[i]) & 1)) {
            ans = min(ans, (sum[i] - sz[i]) >> 1);
        }
    }
    printf("%d\n", ans == INT_MAX ? -1 : ans);
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	int w,h;
	char c[1010][1010];
	ll dp[1010][1010]={};
	cin>>h>>w;
	dp[0][0]=1;
	rep(i,0,h)rep(j,0,w){
		cin>>c[i][j];
		if(i==0&&j==0||c[i][j]=='#')continue;
		if(i==0){
			if(c[i][j]=='.')
				dp[i][j]=dp[i][j-1];
		}else if(j==0){
			if(c[i][j]=='.')
				dp[i][j]=dp[i-1][j];
		}else{
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%inf;
		}
	}
//	rep(i,0,h){
//		rep(j,0,w)cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	if(c[0][0]=='#')print(0);
	else print(dp[h-1][w-1]);
	return 0;
}
	

Measured memory_bytes: 9344
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func greater(a, b string) bool {
	if len(a) > len(b) {
		return true
	} else if len(a) < len(b) {
		return false
	}

	for i := 0; i < len(a); i++ {
		if a[i] > b[i] {
			return true
		} else if a[i] < b[i] {
			return false
		}
	}

	return false
}

func main() {
	a, b := next(), next()

	if greater(a, b) {
		fmt.Println("GREATER")
	} else if a == b {
		fmt.Println("EQUAL")
	} else {
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

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

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

	int X, N; cin >> X >> N;
	vector<bool> v(102, true);
	for (int i = 0; i < N; i++) {
		int k; cin >> k;
		v[k] = false;
	}
	if (v[X]) {
		cout << X << endl;
	}
	else {
		for (int i = 1; i < 100; i++) {
			if (v[X - i]) {
				cout << X - i << endl;
				return 0;
			}
			if (v[X + i]) {
				cout << X + i << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

void func(long long W, long long H, long long x, long long y){

    double ans = W*H/2.0;

    lli ans2 = 0;
    if(W%2==0 && H%2==0 && W/2==x && H/2==y)ans2=1;

    cout<<ans<<" "<<ans2<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    func(W, H, x, y);
    return 0;
}


Measured memory_bytes: 3852