akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int offset=100;
int dist[6][210][210];
bool obs[210][210];

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

typedef tuple<int,int,int,int> state;

int main(void){
	int sx,sy,gx,gy;
	cin >> sx >> sy >> gx >> gy;
	int n;
	cin >> n;
	rep(i,n){
		int x,y;
		cin >> x >> y;
		obs[x+offset][y+offset]=true;
	}
	int lx,ly;
	cin >> lx >> ly;
	rep(i,6)for(int x=-lx;x<=lx;++x)for(int y=-ly;y<=ly;++y)
		dist[i][x+offset][y+offset]=inf;

	dist[0][sx+offset][sy+offset]=0;
	priority_queue<state,vector<state>,greater<state>> q;
	q.push(state{0,0,sx,sy});
	while(!q.empty()){
		int cost,t,x,y;
		tie(cost,t,x,y)=q.top();q.pop();
		int p=abs(x*y*t)%6;
		rep(i,7){
			int nx=x+dx[abs(x)&1][i],ny=y+dy[abs(x)&1][i],ncost=cost+(i!=p);
			if(nx<-lx||lx<nx||ny<-ly||ly<ny) continue;
			if(obs[nx+offset][ny+offset]) continue;
			if(dist[(t+1)%6][nx+offset][ny+offset]>ncost){
				dist[(t+1)%6][nx+offset][ny+offset]=ncost;
				q.push(state{ncost,(t+1)%6,nx,ny});
			}
		}
	}
	int ans=inf;
	rep(i,6) ans=min(ans,dist[i][gx+offset][gy+offset]);

	if(ans==inf)
		cout << -1 << endl;
	else
		cout << ans  << endl;
	return 0;
}

Measured memory_bytes: 2360
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string w;
	cin>>w;
	int a,i,j,n,b[123]={0};
	n=w.size();
	for(i=0;i<n;i++)
	{
		a=w[i]-0;
		b[a]++;
	}
	for(i=97;i<123;i++)
	{
		if(b[i]%2!=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) { cin >> s[i]; }
  vector<bool> r(h, false), c(w, false);
  REP(i, h) {
    REP(j, w) {
      if (s[i][j] == '#') {
        r[i] = true;
      }
    }
  }

  REP(j, w) {
    REP(i, h) {
      if (s[i][j] == '#') {
        c[j] = true;
      }
    }
  }

  REP(i, h) {
    if (!r[i]) {
      continue;
    }
    REP(j, w) {
      if (c[j]) {
        cout << s[i][j];
      }
    }
    cout << "\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;


//const int MOD=(ll)1e10+7;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
ll n,m,h,w;
string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>m;
  if(n==1 && m==1)cout<<1<<endl;
  else if(n==1){
    cout<<m-2<<endl;
  }
  else if(m==1){
    cout<<n-2<<endl;
  }else{
    cout<<(n-2)*(m-2)<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
    return 0;
}






Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO  
  const int nax = 1e4 + 7;
  string s; cin >> s;
  int x, y, necc = 0; cin >> x >> y;
  vector<int> disp[2];
  vector<vector<bool>> hori, verti;

  for(int ins = 0, cons = 0, turn = 1, fst = true; ins <= SZ(s); ++ins){
    if(ins == SZ(s) || s[ins] == 'T'){
      if(fst){
        necc = cons;
        fst = false;
        cons = 0;
        continue;
      }
      disp[turn].PB(cons);
      turn = !turn;
      cons = 0;
    }else cons++;
  }

  int X = SZ(disp[0]), Y = SZ(disp[1]);
  hori.resize(X + 1); verti.resize(Y + 1);

  for(int pos = 0; pos <= X; ++pos) hori[pos].resize(2 * nax, false);
  for(int pos = 0; pos <= Y; ++pos) verti[pos].resize(2 * nax, false);

  hori[0][necc + nax] = true;
  verti[0][0 + nax] = true;

  for(int pos = 0; pos < X; ++pos){
    for(int t = -8000; t <= 8000; ++t){
      if(hori[pos][t + nax]){
        hori[pos + 1][t - disp[0][pos] + nax] = true;
        hori[pos + 1][t + disp[0][pos] + nax] = true;
      }
    }
  }

  for(int pos = 0; pos < Y; ++pos){
    for(int t = -8000; t <= 8000; ++t){
      if(verti[pos][t + nax]){
        verti[pos + 1][t - disp[1][pos] + nax] = true;
        verti[pos + 1][t + disp[1][pos] + nax] = true;
      }
    }
  }
  
  if(hori[X][x + nax] && verti[Y][y + nax]) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 20096
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int n, m;
  cin >> n >> m;
  vector<int> col(n, 0);
  vector<int> ans(n, -1);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (ans[p] != -1) continue;
    if (s == "AC") {
      ans[p] = col[p];
    } else {
      col[p]++;
    }
  }
  int count = 0;
  int error = 0;
  for (int a : ans) {
    if (a != -1) {
      count++;
      error += a;
    }
  }
  printf("%d %d\n", count, error);
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <limits>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
const int MAX = 700000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans=modpow(2,n,MOD);
  ans--;
  COMinit();
  ll j=n;
  ll i=n;
  ll aaa=a;
  ll bbb=b;
  ll aa=1;
  ll bb=1;
  while(aaa){
    aa*=i;
    aa%=MOD;
    aaa--;
    i--;
  }
  while(bbb){
    bb*=j;
    bb%=MOD;
    bbb--;
    j--;
  }
  aa=aa*(finv[a])%MOD;
  bb=bb*finv[b]%MOD;
  ans=(ans-aa-bb)%MOD;
    COUT((ans+MOD)%MOD);
}
  


Measured memory_bytes: 16640
a=int(input()) # 500
b=int(input()) # 100
c=int(input()) # 50
x=int(input())
sum = []
count = 0

for i in range(0, a+1):
    asum = 500 * i
    for i in range(0, b+1):
        bsum = 100 * i
        for i in range(0, c+1):
            csum = 50 * i
            sum.append(asum + bsum + csum)

for i in sum:
    if i == x:
        count += 1

print(count)


Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b;
    cin >> a >> b;
	
  	if(a <= 8 && b <= 8){
      cout << "Yay!" << endl;
    }
  	else{
      cout << ":(" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    vector <string> s;
    while(n--){
        string a;
        cin >> a;
        s.push_back(a);
    }
    sort(s.begin(), s.end());
    for(auto it : s) cout << it;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+9;
int ent[MAXN],sai[MAXN],tree[4*MAXN],n,q,cnt=0, lz[4*MAXN];
vector<int> v, val, G[MAXN];

void dfs(int u, int p){
	v.push_back(u);
	ent[u] = cnt;
	for(int i=0; i<(int)G[u].size(); i++){
		int viz = G[u][i];
		if(viz==p)continue;
		cnt++;
		dfs(viz, u);
	}
	sai[u] = cnt;
}
void refresh(int idx, int l, int r){
	tree[idx] += (r-l+1)*lz[idx];
	if(l!=r){
		int fe = 2*idx;
		int fd = fe+1;
		lz[fe] += lz[idx];
		lz[fd] += lz[idx];
	}
	lz[idx] = 0;
}
void upt(int idx, int l, int r, int ql, int qr, int vi){
	refresh(idx, l, r);
	if(l>qr || r<ql)return;
	if(l>=ql && r<=qr){
		lz[idx] += vi;
		return;
	}
	int fe = 2*idx;
	int fd = fe+1;
	int m = (l+r)/2;
	upt(fe, l, m, ql, qr, vi);
	upt(fd, m+1, r, ql, qr, vi);
	refresh(fe, l, m);
	refresh(fd, m+1, r);
	tree[idx] = tree[fe] + tree[fd];
}
int query(int idx, int l, int r, int pos){
	refresh(idx, l, r);
	if(l>pos || r<pos)return 0;
	if(l==r)return tree[idx];
	int fe = 2*idx;
	int fd = fe+1;
	int m = (l+r)/2;
	return query(fe, l, m, pos) + query(fd, m+1, r, pos);
}
int main(){
	scanf("%d %d", &n, &q);
	for(int i=1; i<n; i++){
		int ai,bi; scanf("%d %d", &ai, &bi);
		G[ai].push_back(bi);
		G[bi].push_back(ai);
	}
	dfs(1, -1);
	for(int i=1; i<=q; i++){
		int vi, xi;
		scanf("%d %d", &vi, &xi);
		upt(1, 0, cnt, ent[vi], sai[vi], xi);
	}
	for(int i=1; i<=n; i++){
		printf("%d ", query(1, 0, cnt, ent[i])); 
	}
}


Measured memory_bytes: 31480
import numpy as np

L, R = (int(i) for i in input().split()) 

l = L%2019
r = R%2019
answer = 0

if l-r < 0 and R - L < 2018:
    for i in range(r-l):
        for j in range(r-l-i):
            k = i + l
            m = j + l + i + 1
            if i == 0 and j == 0:
                answer = (k*m)%2019
            if answer >= (k*m)%2019:
                answer = (k*m)%2019
print(answer)

Measured memory_bytes: 12500
N = int(input())
A = list(map(int, input().split()))
even = 0
odd = 0
for i in range(N):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1
if odd % 2 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
typedef long long LL;

int n, m, c[15][15], tmp[15];
int f[15][33000], g[33000], sum;
int i, j, k, u, v, d, t;

int main()
{
    scanf("%d%d", &n, &m);
    memset(f, -0x3f, min(sizeof(f), sizeof(f[0])*(n+1)));
    for(i = 1; i <= m; ++i)
    {
        scanf("%d%d%d", &u, &v, &d);
        --u; --v;
        sum += d;
        c[u][v] = c[v][u] = d;
    }
    t = 1 << n;
    f[0][1] = 0;
    for(i = 1; i < t; ++i)
    {
    	int cnt = 0;
    	for(u = 0, k = i; k > 0; ++u, k >>= 1)
    		if (k & 1) tmp[cnt++] = u;
    	for (j = 0; j < cnt; ++j)
    	{
    		u = tmp[j];
    		for (k = j + 1; k < cnt; ++k)
    			g[i] += c[u][tmp[k]];
		}	
	}
    for(i = 1; i < t; ++i)
    {
        for(u = 0; u < n; ++u)
	        if (((i >> u) & 1) && f[u][i] >= 0)
	        {
	        	k = (t - 1) ^ i;
	            for(j = k; j; j = (j - 1) & k) // Ã¶¾Ù²¹¼¯µÄËùÓÐ×Ó¼¯ 
	                f[u][i | j] = max(f[u][i | j], f[u][i] + g[j | (1 << u)]);
	        }
        for(u = 0; u < n; ++u)
	        if (((i >> u) & 1) && f[u][i] >= 0)
	            for(v = 0; v < n; ++v)
	            	if (!((i >> v) & 1) && c[u][v])
	            		f[v][i | (1 << v)] = max(f[v][i | (1 << v)], f[u][i] + c[u][v]);
    }
    printf("%d\n", sum - f[n - 1][t - 1]);
    return 0;
}

Measured memory_bytes: 2304
import sys

sys.setrecursionlimit(50000)

n, m = (int(i) for i in input().strip().split(" "))
xs = []
ys = []
zs = []
for i in range(n):
    a, b, c = (int(i) for i in input().strip().split(" "))
    xs.append(a)
    ys.append(b)
    zs.append(c)

k=0

ar=[]
for i in range(n):
    ar.append(xs[i]+ys[i]+zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(xs[i]+ys[i]-zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(xs[i]-ys[i]+zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(-1*xs[i]+ys[i]+zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(xs[i]-ys[i]-zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(-xs[i]+ys[i]-zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(-xs[i]-ys[i]+zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t

ar=[]
for i in range(n):
    ar.append(-xs[i]-ys[i]-zs[i])
ar.sort(reverse=True)
t=sum(ar[:m])
if t>k:
    k=t
print(k)



Measured memory_bytes: 73752
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int ans = m * 1900 + (n - m) * 100;
	for (int i = 0; i < m; i++) {
		ans *= 2;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

struct aaa{
  string s;
  int p;
  int idx;
};

bool sortaaa(aaa a, aaa b) {
  if (a.s != b.s) {
    return a.s < b.s;
  } else if (a.p != b.p) {
    return a.p > b.p;
  } else {
    return a.idx > b.idx;
  }
}

void solve()
{
  int n; cin>>n;
  vector<aaa> t;
  for (int i=0; i<n; i++) {
    aaa a;
    string s;
    int p;
    a.idx = i+1;
    cin>>s>>p;
    a.s = s;
    a.p = p;
    t.push_back(a);
  }
  sort(t.begin(),t.end(), sortaaa);
  for (int i=0; i<n; i++) {
    cout << t[i].idx << endl;
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[200005];

int main(void)
{
	cin >> n;
	for(llint i = 0; i < n; i++) cin >> a[i];
	
	for(llint i = 0; i < n; i++){
		if(i < a[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	llint p = 0, ans = 0;
	for(llint i = n-1; i >= 0; i--){
		if(p < a[i]){
			ans += a[i];
			p = a[i];
		}
		else if(p > a[i]){
			cout << -1 << endl;
			return 0;
		}
		p--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#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 cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 6;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

inline void putints(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));
	putchar(' ');
}

inline void putintrep(int N, int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	rep(j, N) {
		for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));
		putchar(' ');
	}
}


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


	int K, N;
	K = getint();
	N = getint();

	if (K == 1) {
		rep(i, (N + 1) / 2) {
			putchar('1');
			putchar(' ');
		}
	}
	else if (K % 2) {
		ll A[13];
		*A = 1;
		ll S = K / 2 + 1;
		int doko;
		rep(i, 13) {
			if (S >= N / 2) {
				doko = i;
				break;
			}
			*(A + i + 1) = *(A + i) * K + 1;
			S += *(A + i + 1) * (K / 2) + 1;
		}
		ll kazu = S - N / 2;
		putintrep(N - doko - 1, (K + 1) / 2);
		for (int i = doko; i >= 0; i--) {
			if (kazu == 0) break;
			kazu--;
			int kari = kazu / *(A + i);
			kazu -= kari * *(A + i);
			putints(kari + 1);
		}
	}
	else {
		putints(K / 2);
		putintrep(N - 1, K);
	}

	Would you please return 0;
}

Measured memory_bytes: 2304
<?php
fscanf(STDIN, "%d", $n);
for ($i=1; $i<=9; $i++) {
  for ($j=1; $j<=9; $j++) {
    $kuku[] = $i * $j;
  }
}
if (in_array($n, $kuku)) {
  echo 'Yes';
} else {
  echo 'No';
}

Measured memory_bytes: 4604
def fib3(n)
  return 2 if n == 0
  return 1 if n == 1
  fib1 = 2
  fib2 = 1
  (n - 1).times do
    fib3 = fib1 + fib2
    fib1 = fib2
    fib2 = fib3
  end
  fib2
end

n = gets.to_i
puts fib3(n)

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
char grid[1005][1005];
int dp[1005][1005];

int main()
{
//	cut here before submit 
//	freopen ("testcase.square_searching", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		memset (grid, 0, sizeof (grid ) );
		memset (dp, 0, sizeof (dp ) );
		rep (i, n ){
			rep (j, n ){
				scanf (" %c", &grid[i][j] );
			} // end rep
		} // end rep

		dp[0][0] = (grid[0][0] == '*' ? 0 : 1 );
		for (int i = 1; i < n; i++ ){
			dp[i][0] = (grid[i][0] == '*' ? 0 : 1 );
		} // end for
		for (int j = 1; j < n; j++ ){
			dp[0][j] = (grid[0][j] == '*' ? 0 : 1 );
		} // end for
		for (int i = 1; i < n; i++ ){
			for (int j = 1; j < n; j++ ){
				dp[i][j] = (grid[i][j] == '*' ? 0 : min (dp[i-1][j-1], min (dp[i-1][j], dp[i][j-1] ) ) + 1 );
			} // end for
		} // end for
		
		int res = 0;
		rep (i, n ){
			rep (j, n ){
				res = max (res, dp[i][j] );
			} // end for
		} // end for
		printf ("%d\n", res );
	} // end loop

		
	return 0;
}

Measured memory_bytes: 6128
#include <iostream>
#include<stdlib.h>
#include <math.h>
using namespace std;
int main() {
        string R;
        cin >> R;
        int k = 0;
        if(R[0]!='A'||R[1]<'a'){
            cout << "WA";
        }
        
        else {for(int i = 2;i<(R.length()-1);i++){
            if(R[i]=='C'){
                k++;
            }
            else{if(R[i]<'a'){
                k = 0;
                break;
            }}
        }
        if(R[R.length()-1]<'a'){
            k = 0;
        }
    if(k==1){
        cout << "AC";
    }
    else{
          cout << "WA";
    }
        }

        return 0;
}

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

class Edge
{
public:
	int from, to, cost;
	Edge(){}
};

const int INF = 999999999;
int d[1000];
Edge e[2000];
int V, E, r;
bool flag;

int main()
{
	cin >> V >> E >> r;
	for (int i = 0; i < E; i++)
	{
		cin >> e[i].from >> e[i].to >> e[i].cost;
	}

	fill(d, d + V, INF);
	d[r] = 0;

	for (int i = 0; i < V; i++)
	{
		flag = true;
		for (int j = 0; j < E; j++)
		{
			if (d[e[j].from] != INF && d[e[j].to] > d[e[j].from] + e[j].cost)
			{
				flag = false;
				d[e[j].to] = d[e[j].from] + e[j].cost;
			}
		}
		if (flag) break;
		if (i == V - 1)
		{
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}

	for (int i = 0; i < V; i++)
	{
		if (d[i] == INF)
		{
			cout << "INF" << endl;
			continue;
		}
		cout << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
unittest
{
	assert( [ "5 2", "1 4", "2 5" ].solve == 1 );
	assert( [ "9 5", "1 8", "2 7", "3 5", "4 6", "7 9" ].solve == 2 );
	assert( [ "5 10", "1 2", "1 3", "1 4", "1 5", "2 3", "2 4", "2 5", "3 4", "3 5", "4 5" ].solve == 4 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto abs = new long[ 2 ][ m ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	abs.sort();
	
	auto ans = 0L;
	auto bm = long.max;
	foreach( ab; abs )
	{
		if( bm <= ab[ 0 ] )
		{
			ans++;
			bm = ab[ 1 ];
		}
		else
		{
			bm = min( bm, ab[ 1 ] );
		}
	}
	ans++;
	return ans;
}


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

int main() {
  int H1,M1,H2,M2,K,ans=0,minute=0; cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << 60*(H2-H1) + (M2-M1) -K << endl;
}

Measured memory_bytes: 3632
class Coodinate (object):
    """Coodinate object
    This class contains infomation about the coodinates.
    Each instance can have up to 3-dimensional(x,y,z) space coodinates.
    
    params
    ------------------------------
    x : int or floot ,default 0
    y : int or floot ,default 0
    z : int or floot ,default 0


    This class have following methods.
    ------------------------------
    distance : Calculate the straight-line distance between 2 points in Euclidean space.
    midpoint : Calculate the midpoint(halfway) between 2 points.
    manhattan_distance : Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.
    """

    def __init__(self,x=0,y=0,z=0):
        self.x=x
        self.y=y
        self.z=z


    def __str__(self):
        if self.z==0:
            if self.y==0:
                return "( {} )".format(self.x)
            else :
                return "( {} , {} )".format(self.x,self.y)
        else:
            return "( {} , {} , {} )".format(self.x,self.y,self.z)    


    def distance(self,other):
        """Calculate the straight-line distance between 2 points in Euclidean space.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        distance : floot

        """
        x_diff_sq=(self.x-other.x)**2
        y_diff_sq=(self.y-other.y)**2
        z_diff_sq=(self.z-other.z)**2
        return (x_diff_sq + y_diff_sq +z_diff_sq)**0.5
    

    def midpoint(self,other):
        """Calculate the midpoint(halfway) between 2 points.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        midpoint : tupul
        
        """
        x_midpoint=(self.x+other.x)/2
        y_midpoint=(self.y+other.y)/2
        z_midpoint=(self.z+other.z)/2
        if self.z == other.z ==0 :
            if self.y == other.y==0:
                return(x_midpoint)
            else:
                return(x_midpoint,y_midpoint) 
        return(x_midpoint,y_midpoint,z_midpoint)

    def manhattan_distance(self,other):
        """Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        manhattan_distance : floot

        """

        x_diff_abs=abs(self.x - other.x)
        y_diff_abs=abs(self.y - other.y)
        z_diff_abs=abs(self.z - other.z)
        return(x_diff_abs + y_diff_abs + z_diff_abs)

# AtCoder Beginner Contest 086
# C - Traveling

N=int(input())

T=0
now=Coodinate()

for i in range (N):
    t, x, y =map(int,input().split())
    time =t-T
    location = Coodinate(x,y)
    destination = Coodinate.manhattan_distance(location,now)
    if time >= destination and time%2==destination%2:
        T=t
        now=location
    else :
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 9268
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
using namespace std;
const int N=5010;
int n,st1[N],st2[N],tp1,tp2,l1,l2;
char s[N],t[N];
int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	scanf("%d%s%s",&n,s,t);
	l1=strlen(s),l2=strlen(t);
	for(int i=1;i<l1;i++){
		if(s[i]!=s[i-1])st1[++tp1]=i;
	}
	st1[tp1+1]=n;
	for(int i=1;i<l2;i++){
		if(t[i]!=t[i-1])st2[++tp2]=i;
	} 
	st2[tp2+1]=n;
	int ans = 1e9;
	for(int i=-tp2;i<=tp1+1;i++){
		if((s[0]==t[0])^(!((i-1)&1)))continue;
		int now=0;
		for(int j=-n;j<=n;j++){
			int p1 = min(max(i + j - 1 , 0) , tp1+1 ) , p2 = min(max(j , 0) , tp2+1 );
			now += abs(st1[p1] - st2[p2]);
		}
		ans = min(ans ,now);
	}
	cout<<ans<<endl;
	return 0;
}//by tkys_Austin;


Measured memory_bytes: 256
L=lambda:map(int,input().split())
n,m,c=L()
b=list(L())
a=[list(L()) for _ in range(n)]
ans=0
for code in a:
    Sum=0
    for a_elm, b_elm in zip(code, b):
        Sum += a_elm*b_elm
    Sum += c
    if Sum>0:ans += 1
print(ans)

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

int a[200000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  if (count(a, a + n, 1) == 0) {
    cout << -1 << endl;
    return 0;
  }
  
  int cnt = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == cnt) ++cnt;
  }
  cout << n - (cnt - 1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    vector<vector<int>> sums(N);
    for (int j = 1; j < N; j++) {
        for (int i = 0; (i < j && L[i] != L[j]); i++) {
            sums[j].push_back(L[i] + L[j]);
        }
    }
    int result = 0;
    for (int k = 2; k < N; k++) {
        for (int j = 1; (j < k && L[j] != L[k]); j++) {
            if (sums[j].size() == 0) {
                continue;
            }
            int left = 0;
            int right = sums[j].size() - 1;

            int lg = sums[j].size();
            while (left <= right) {
                int mid = (left + right) / 2;

                int sumval = sums[j][mid];
                if (sumval > L[k]) {
                    lg = min(mid, lg);
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            result += sums[j].size() - lg;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3624
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 19260817
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline LL Scan(){
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=100005;
///Code begin..................................................................

LL a[100];

int main ()
{
    int n;
    scanf("%d",&n);
    a[0]=2; a[1]=1;
    FOR(i,2,n) a[i]=a[i-1]+a[i-2];
    printf("%lld\n",a[n]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> v,w;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n;
    x=0;
    ll A[n];
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            p=A[i]*A[j];
            x+=p;
        }
    }
    cout<<x;
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

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

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

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
  int n;
  cin >> n;
  if(n == 3 || n == 5 || n == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main(){
  int n;
  int t[20][20];

  while(cin >> n, n){
    int x = n / 2, y = n / 2 + 1;
    int cnt = 0;

    memset(t, -1, sizeof(t));

    while(cnt < n * n){
      if(n <= x)      x = 0;
      else if(x < 0)  x = n - 1;
      else if(n <= y) y = 0;
      else if(y < 0)  y = n - 1;
      else if(t[y][x] != -1){
        x--;
        y++;
      }
      else{
        t[y][x] = cnt + 1;
        x++;
        y++;
        cnt++;
      }
    }

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

Measured memory_bytes: 1192
import sys
input = sys.stdin.readline
 
N = int(input())
d = list(map(int, input().split()))
P = 0
 
for i in range(N - 1):
    if d[i] == 0:
        continue
    for j in range(i + 1, N):
        if d[j] == 0:
            continue
        P += d[i] * d[j]
print(P)

Measured memory_bytes: 38512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
char a[51][51];
int main()
{
	int n,i,j,m;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)cin>>a[i][j];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			if(a[i][j]=='#')cout<<a[i][j];
			else if(a[i][j]=='.')
			{
				int sum=0;
				if(a[i+1][j]=='#')sum++;
				if(a[i][j+1]=='#')sum++;
				if(a[i+1][j+1]=='#')sum++;
				if(a[i-1][j]=='#')sum++;
				if(a[i][j-1]=='#')sum++;
				if(a[i+1][j-1]=='#')sum++;
				if(a[i-1][j+1]=='#')sum++;
				if(a[i-1][j-1]=='#')sum++;
				cout<<sum;
			}
		cout<<endl;
	}
		
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> works(N);
    for (int i = 0; i < N; ++i) cin >> works[i].second >> works[i].first;
    sort(works.begin(), works.end());
    ll time = 0;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        time += works[i].second;
        if (time > works[i].first) {
            flag = true;
            break;
        }
    }
    if (flag) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

using namespace std;

int main() {
	unsigned long edit = 0b0;
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			edit = edit << 1;
			count++;
		}
		else if (s[i] == '1') {
			edit = edit << 1;
			edit |= 0b1;
			count++;
		}
		else {
			if (count > 0) {
				edit = edit >> 1;
				count--;
			}
		}
	}

	for (int i = count; i > 0; i--) {
		if (edit & edit & (1 << (i - 1))) {
			cout << '1';
		}
		else {
			cout << '0';
		}
	}
	
	cout << endl;

}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let x: i64 = read();
  let mut ans = (0, 0);
  let n = 100_00;
  let mut v = vec![0; 2 * n];
  for i in 0..2*n {
    v[i] = pow(i as i64 - n as i64, 5);
  }
  //println!("{:?}", v);

  for a in 0..n {
    let tb = pow(a as i64, 5) - x;
    if let Some(b) = v.binary_search(&tb).ok() {
      println!("{} {}", a, b as i64 - n as i64);
      return
    }
    //println!("{} {} {:?}",a, tb,  v.binary_search(&tb));
  }
}


fn pow(x: i64, n: usize) -> i64 {
  let mut res = 1;
  for i in 0..n {
    res *= x;
  }
  res
}

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

struct Node{
	int x, y, z;
	bool operator < (const Node &A) const{
		if (x != A.x) return x > A.x;
		return y > A.y;
	}
}a[100010], b[100010];

int vis[100010];

int main(){
	int n;
	scanf("%d", &n);
	long long sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; i++){
		scanf("%d%d", &a[i].x, &a[i].y);
		sum1 += a[i].x, sum2 += a[i].y;
		a[i].z = i;
		b[i].x = a[i].x + a[i].y, b[i].y = i;
	}
	sort(b, b + n);
	long long ans = 0;
	for (int i = 0; i < n; i++){
		ans += (i & 1 ? -1 : 1) * b[i].x;
	}
	printf("%lld\n", (ans + sum1 - sum2) / 2);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int n;
	scanf("%d", &n);
	std::bitset<10> f[n];
	REP(i, 0, n){
		REP(j, 0, 10){
			getchar();
			if(getchar()%2) f[i].set(j);
			else f[i].reset(j);
		}
	}
	
	int p[n][11];
	REP(i, 0, n) REP(j, 0, 11) scanf("%d", &p[i][j]);

	int c[n], ans = -1e9;
	REP(i, 1, 1<<10){
		memset(c, 0, 4*n);
		REP(j, 0, 10) if((i>>j)&1) {
			REP(I, 0, n) if(f[I][j]) {
				c[I]++;
			}
		}
		int tmp = 0;
		REP(I, 0, n) tmp += p[I][c[I]];
		if(ans<tmp) ans = tmp;
	}

	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
int p[maxn], q[maxn];
int val[2][maxn << 2];

inline int min(int x, int y) { return p[x] < p[y] ? x : y; }

void build(int now, int L, int R) {
	if(L == R) return val[L & 1][now] = min(val[L & 1][now], L), void();
	int M = (L + R) >> 1;
	build(now << 1, L, M);
	build(now << 1 | 1, M + 1, R);
	for(int i = 0; i < 2; i ++)
		val[i][now] = min(val[i][now << 1], val[i][now << 1 | 1]);
}

int query(int now, int L, int R, int l, int r, int o) {
	if(l > r or l > R or r < L) return 0;
	if(l <= L and R <= r) return val[o][now];
	int M = (L + R) >> 1;
	return min(query(now << 1, L, M, l, r, o), query(now << 1 | 1, M + 1, R, l, r, o));
}

int n;
struct Range {
	int l, r, p;
	Range(int l, int r): l(l), r(r), p(query(1, 1, n, l, r, l & 1)) { }
};
bool operator < (Range x, Range y) { return p[x.p] > p[y.p]; }

int main() {
read(n);
	for(int i = 1; i <= n; i ++)
		read(p[i]);
	p[0] = 1000000000;

	build(1, 1, n);

	std::priority_queue<Range> qu;
	qu.push(Range(1, n));

	int qp = 0;
	while(!qu.empty()) {
		Range rg = qu.top();
		qu.pop();
		if(rg.l > rg.r) continue;

		int p1 = rg.p;
		int p2 = query(1, 1, n, p1, rg.r, !(p1 & 1));

		q[++ qp] = p[p1];
		q[++ qp] = p[p2];

		qu.push(Range(rg.l, p1 - 1));
		qu.push(Range(p1 + 1, p2 - 1));
		qu.push(Range(p2 + 1, rg.r));
	}

	for(int i = 1; i <= n; i ++)
		printf("%d ", q[i]);
	puts("");
}


Measured memory_bytes: 12272
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include<climits>
using namespace std;


//初期化O(n log n) 区間最小値クエリO(1)
class SparseTableRMQ{
	int maxlog;
	std::vector<int> a;
	std::vector<char> log;
	std::vector<int> M;
public:
	SparseTableRMQ(){}
	void build(const std::vector<int> &a){
		this->a=a;
		int n=a.size();
		log.resize(n+1);
		log[0]=0;
		for(int i=1,a=0;i<=n;i++){
			if((1<<a+1)<i)a++;
			log[i]=a;
		}
		maxlog=log[n]+1;
		M.resize(n*maxlog);
		for(int i=0;i<n;i++)M[i*maxlog]=i;
		for(int j=1;1<<j<=n;j++){
			for(int i=0;i+(1<<j)-1<n;i++){
				int n=M[i*maxlog+j-1];
				int m=M[(i+(1<<j-1))*maxlog+j-1];
				M[i*maxlog+j] = a[n]<a[m]?n:m;
			}
		}
	}
	int query(int i,int j)const{//[i,j)の最小値
		int k=log[j-i];
		int n=M[i*maxlog+k];
		int m=M[(j-(1<<k))*maxlog+k];
		return a[n]<a[m]?n:m;
	}
};

class LCA{
	vector<int> eulertour;
	vector<int> vertex;
	SparseTableRMQ rmq;
	//RMQ rmq;
	void dfs(const vector<int> edge[],int n,vector<int> &depth,int d,int u){
		eulertour[u]=vertex.size();	
		vertex.push_back(u);
		depth.push_back(d);
		for(int i=0;i<edge[u].size();i++){
			dfs(edge,n,depth,d+1,edge[u][i]);
			vertex.push_back(u);
			depth.push_back(d);
		}
	}
public:
	LCA(const vector<int> edge[],int n,int root):eulertour(n){
		vector<int> depth;
		dfs(edge,n,depth,1,root);
		vertex.push_back(root);
		depth.push_back(0);
		rmq.build(depth);
	}
	int query(int u,int v)const{
		if(u==v)return u;
		if(eulertour[u]>eulertour[v])swap(u,v);
		return vertex[rmq.query(eulertour[u], eulertour[v])];
	}
};


vector<int> edge[100000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k,v;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>v;
			edge[i].push_back(v);
		}
	}
	LCA lca(edge,n,0);
	int q,u,v;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>u>>v;
		cout<<lca.query(u,v)<<endl;
	}
	return 0;
}

Measured memory_bytes: 26220
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val iobuf = readLine.split(" ").head.split("").filterNot(_ == "").zipWithIndex.filter(_._2 % 2 == 0).map(_._1).mkString
    println(iobuf)
  }
}


Measured memory_bytes: 42032
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n , m , t , ans = 0 ,sum = 1;
int main()
{

        cin >> n >> m ;

        while ( sum < m)
        {
            ans++;
            sum += (n - 1 );
        }
        cout <<ans   ;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int H,W,i,j;
  while(1){
      scanf("%d%d",&H,&W);
      if(H==0&&W==0) break;
      
      for(i=1;i<=H;i++){
	for(j=1;j<=W;j++){
	  
	  if(i==1||j==1||j==W||i==H){
	    
	    printf("#");
	  
	  }else{
	    
	    printf(".");
	  
	  }
	  
	}
	
	  printf("\n");
      }
      printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1000
#coding=UTF-8

# 基本的に N=1 seq=[K] であれば簡単だった
# 全体では毎回 N減って N-1増えるのできっと収束する
# もし、2本立てると

# 7 7
# 5 8
# 6 6
# 4 7
# 5 5
# 3 6
# 4 4
# 2 5
# 3 3
# 1 4
# 2 2
# 0 3
# 1 1 done! の12回

# f(0,0)=0
# f(1,1)=0
# f(2,2): -> 0,3 -> 1,1 =2
# f(3,3): -> 1,4 -> 2,2 + f(2,2) = 4
# f(4,4): -> 2,5 -> 3,3 + f(3,3) = 6
# f(5,5): -> 3,6 -> 4,4 + f(4,4) = 8 ...

# f(A,A)=(A-1)*2 (A>=1)

# f(2,2,2)=0
# f(3,3,3): -> 0,4,4 -> 1,1,5 -> 2,2,2 =3
# K=1のときは
#  3,0 -> 1,1 ok (非負)

# N=50にするのがつよそう
# 最大の余りは49なので
# 49個が1回ずつ殴られるパターン
# L+50-48 L+50-48 ... L+50-48 L-49 が49回後には
# L L L ... となる
# これが合法手になるのはL>=49のときである

# f([49]*50)=0
# f([50]*50)= 50 + f([49]*50)=50
# f([L]*50)=50*(L-49) (for L >= 49)

# K=50*(10**16)-1 では
# L-49=10**16-1
# L=10**16+48
# L+50-48=10**16 + 50 ok
K=int(input())
print(50)
L=K//50+49
amari=K%50
ansstr=''
#extra amari times
for idx in range(0,50,1):
    if idx < amari:
        ansstr+=str(L+50-(amari-1))+' '
    else:
        ansstr+=str(L-amari)+' '

print(ansstr[0:len(ansstr)-1])



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

Graph g;
vector<int> ans;
void dfs(int v, int p = -1) {
    for (int u : g[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 23552
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), s;
  rep(i, n) cin >> a[i];
  s = a;
  sort(s.begin(), s.end());
  multiset<int> st;
  for (int i = 0; i < n; i+=2)
    st.insert(s[i]);
  int ans = 0;
  for (int i = 0; i < n; i+=2) {
    if (st.find(a[i]) == st.end())
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int meke_comb(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int fact(int n){
//   int ans;
//   if(n==1 || n == 0) return 1;
//   ans = n*fact(n-1);
//   return ans;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }




int main(){
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout <<  x2 + y1 - y2 << " " <<  y2 + x2 - x1 << " " <<  x1 + y1 - y2 <<" " << y1 + x2 - x1 << endl;
}



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

using namespace std;

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

class UF {
public:
	int n; vector<int> a;
	UF(int n) : n(n), a(n, -1) {}
	int find(int x) {
		return a[x] < 0 ? x : (a[x] = find(a[x]));
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (a[x] > a[y]) swap(x, y);
		a[x] += a[y];
		a[y] = x;
		n--;
		return true;
	}
	int size(int x) {
		return -a[find(x)];
	}
};

int main() {
	int n, m; scanf("%d%d", &n, &m);
	UF uf(n);
	FOR(i, m) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		uf.unite(a, b);
	}
	int ans = 0;
	FOR(i, n) if (uf.find(i) == i) {
		if (uf.size(i) == 1) ans++;
		else ans--;
	}
	cout << abs(ans) << endl;
}

Measured memory_bytes: 3172