akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

ll n, x;
vl width;
vl paty;

ll get_tabeta(int rank, ll taberu) {
    ll tabeta = 1;
    ll w = width[rank];
    // cout << rank << " " << taberu << endl;
    if (rank == 0) {
        if (taberu == 1) return 1;
        else {
            exit(1);
        }
    }
    if (taberu == 1) {
        return 0;
    } else if (taberu == (w / 2L) + 1L) {
        return 1L + paty[rank - 1];
    } else if (taberu == w) {
        return 1L + (2L * paty[rank - 1]);
    } else {
        if (taberu < (w / 2L) + 1L) {
            return get_tabeta(rank - 1L, taberu - 1L);
        } else {
            return 1L + paty[rank - 1] + get_tabeta(rank - 1L, taberu - 1L - width[rank - 1] - 1L);
        }
    }
    return tabeta;
}

int main() {
    cin >> n >> x;
    width.resize(n+1); paty.resize(n+1);
    paty[0] = 1; width[0] = 1;
    for (int i = 1; i <= n; i++) {
        width[i] = 3 + (2 * width[i - 1]);
        paty[i] = 1 + (2 * paty[i - 1]);
    }
    // rep(i, n+1) cout << i << " " << paty[i] << " " << width[i] << endl;
    // cout << "+++++++++++++" <<endl;
    cout << get_tabeta(n, x) << endl;

}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

int main(void)
{
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << (ab * bc) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
w=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        w[i].append((x,y))
ans=0
for i in range(1<<n):
    x="0"*15+bin(i)[2:]
    z=[int(i) for i in x[-n:]]
    f=1
    for p,q in enumerate(w):
        if z[p]==1:
            for r in q:
                if (z[r[0]-1]!=r[1]):
                    f=0
    if f:
        ans=max(ans,z.count(1))
print(ans)

Measured memory_bytes: 43500
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int a, b, maxnum = INT_MIN;
    cin >> a >> b;
    maxnum = a+b;
    maxnum = max(maxnum, a-b);
    maxnum = max(maxnum, a*b);
    cout << maxnum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef pair<int,int> Pt;
typedef pair<Pt,Pt> P;
#define fr first
#define sc second
int h,w,sx,sy,gx,gy,d[]={0,1,0,-1},Time[101][101],cnt;
bool used[101][101][1<<5];
int ldx[]={-1,-1,-1,0,1,1,1,0},ldy[]={-1,0,1,1,1,0,-1,-1};
int sdx[]={-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1};
int sdy[]={-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2};
char mas[101][101];
void BAD(int,int);
int bfs();
bool judge(int x,int y){ return ((x>=0&&x<h&&y>=0&&y<w)? true : false); }
int main(){
  cin >> w >> h;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) Time[i][j] = 1;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mas[i][j];
      if(mas[i][j] == 'S') sx = i,sy = j;
      else if(mas[i][j] == 'G') gx = i,gy = j;
      else if(mas[i][j] == '#') BAD(i,j);
      else if(mas[i][j] == 'M') mas[i][j] = cnt++;
    }
  }
  cout << bfs() << endl;
}

int bfs(){
  memset(used,false,sizeof(used));
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(Pt(0,sx),Pt(sy,0)));
  while(!que.empty()){
    P p = que.top();
    int t = p.fr.fr,px = p.fr.sc,py = p.sc.fr,BIT = p.sc.sc;
    que.pop();
    if(used[px][py][BIT])continue;
    used[px][py][BIT] = true;
    if(px == gx && py == gy && BIT ==(1<<cnt)-1 )return t;
    for(int i=0;i<4;i++){
      int nx = px + d[i],ny = py + d[3-i],bit = BIT;
      if(!judge(nx,ny)) continue;
      if(mas[nx][ny] == '#') continue;
      if(mas[nx][ny]>=0&&mas[nx][ny]<=10) bit |= 1<<mas[nx][ny];
      que.push(P(Pt(t+Time[px][py],nx),Pt(ny,bit)));
    }
  }
}
void BAD(int x,int y){
  for(int i=0;i<8;i++){
    int nx=x+ldx[i],ny=y+ldy[i];
    if(judge(nx,ny)) Time[nx][ny] = 3;
  }
  for(int i=0;i<16;i++){
    int nx=x+sdx[i],ny=y+sdy[i];
    if(judge(nx,ny)) Time[nx][ny] = max(Time[nx][ny],2);
  }
}

Measured memory_bytes: 1796
#include <stdio.h>
#include <string.h>
int N=1000;

int lcs(char X[],char Y[]){
    int c[N+1][N+1];
    int m=strlen(X);
    int n=strlen(Y);
    int maxl=0,i,o;
    for(i=1;i<=m;i++)
        c[i][0]=0;
    for(o=1;o<=n;o++)
        c[0][o]=0;
    for(i=1;i<=m;i++){
        for(o=1;o<=n;o++){
            if(X[i-1] == Y[o-1])
                c[i][o]=c[i-1][o-1]+1;
            else
                c[i][o]=c[i-1][o]>c[i][o-1]?c[i-1][o]:c[i][o-1];
            maxl=maxl>c[i][o]?maxl:c[i][o];
        }
    }
    return maxl;
}


int main(void){
    char line1[1001],line2[1001];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",line1,line2);
        printf("%d\n",lcs(line1,line2));
    }
    return 0;
}



Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rsort(a) sort(a.rbegin(), a.rend())
#define ins(r,p,x) r.insert(r.end(),p.begin(),p.begin()+x)

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  rsort(p);
  rsort(q);
  ins(r,p,x);
  ins(r,q,y);
  rsort(r);
  long long ans = 0;
  rep(i,x+y) ans += r[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2808
// cmod.cpp
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<pair<int, pair<int, int>>> vpp(m);
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		vpp[i].first = y;
		vpp[i].second.first = x-1;
		vpp[i].second.second = i;
	}
	int stadt[n];
	for( int i = 0; i < n; ++i ) stadt[i] = 0;
	sort( vpp.begin(), vpp.end() );
	vector<pair<int, pair<int, int>>> result(m);
	for( int i = 0; i < m; ++i ){
		result[i].first = vpp[i].second.second;
		result[i].second.first = vpp[i].second.first;
		result[i].second.second = stadt[vpp[i].second.first];
		stadt[vpp[i].second.first] += 1;
	}
	sort( result.begin(), result.end() );
	for( int i = 0; i < m; ++i ){
		printf("%06d", result[i].second.first+1);
		printf("%06d", result[i].second.second+1);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String X = scan.next();
        scan.close();
        int divizer = 0;
        for (int i = 0; i < X.length(); i++) {
            char c = X.charAt(i);
            divizer += Integer.parseInt(String.valueOf(c));
        }
        System.out.println(Integer.parseInt(X) % divizer == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 22996
n, m, l = map(int, input().split())
A, B = [], []
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    A.append([int(i) for i in input().split()])

for i in range(m):
    B.append([int(i) for i in input().split()])

B = list(zip(*B))

for i, line_A in enumerate(A):
    for j, line_B in enumerate(B):
        for x, y in zip(line_A, line_B):
            C[i][j] += x * y

for line in C:
    for i, x in enumerate(line):
        if i == l - 1:
            print(x)
        else:
            print(x, end=" ")



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

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

  int x = (n - 1) * (n - 2) / 2;
  if (k > x) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int, int>> ans;
  for (int i = 1; i < n; i++) {
    ans.emplace_back(i, n);
  }

  int c = x - k;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < i; j++) {
      if (c == 0) goto end_loop;
      ans.emplace_back(i, j);
      c--;
    }
  }
 end_loop:

  cout << ans.size() << endl;
  for (auto&& e : ans) {
    cout << e.first << " " << e.second << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int d[55];
int c[13]; // 時刻%12の個数をカウントする

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> d[i];
    c[0] = 1;
    rep(i, n) c[d[i]]++;

    vector<int> res;

    for(int bits = 0; bits < (1<<12); bits++){
        int tmp = 12;
        vector<int> v;
        v.push_back(24);
        if (c[0] >= 2) tmp = 0;
        else if (c[0] == 1) v.push_back(0);
        if (c[12] >= 2) tmp = 0;
        else if (c[12] == 1) v.push_back(12);

        for(int i = 1; i < 12; i++){
            if (c[i] >= 3) tmp = 0;
            else if (c[i] == 2) {
                v.push_back(i);
                v.push_back(24-i);
            }
            else if (c[i] == 1){
                if (bits&(1<<i)) v.push_back(24 - i);
                else v.push_back(i);
            }
        }
        sort(v.begin(), v.end());
        // for(auto e : v) cout << e << " ";
        // cout << endl;
        rep(i, v.size()-1) tmp = min(tmp, v[i+1]-v[i]);
        res.push_back(tmp);
    }

    cout << *max_element(res.begin(), res.end()) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;

int main(){
    ll N,M; cin>>N>>M;
    vector<P> ans;
    ll x=1, y=1+M;
    while(x<y){
        ans.pb(mp(x,y));
        x++; y--;
    }
    x=2+M, y=1+2*M;
    while(x<y){
        ans.pb(mp(x,y));
        x++; y--;
    }
    rep(i,M) cout<<ans[i].first<<' '<<ans[i].second<<endl;

}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,temp,mul=10,WholeNumber;
bool r=false;
cin>>a>>b;
temp=b;
while(true)
{
if(b/10!=0)
{
    b=b/10;
    mul=mul*10;
}
else
{
    break;
}
}
WholeNumber=(a*mul)+temp;
for(int i=1;i<10000;i++)
{
    if(WholeNumber==(i*i))
    {
        r=true;
        break;
    }
}
if(r==true)
{
    cout<<"Yes"<<endl;
}
else if(r==false)
{
    cout<<"No"<<endl;
}



}

Measured memory_bytes: 3596
#!/usr/bin/env python3

import math
def main():
    times = [input() for i in range(5)]

    # 1の位最小のものを求める
    mini_one = 10
    mini_one_index = 0
    for i, time in enumerate(times):
        one = int(time[len(time)-1])
        if mini_one > one and one > 0:
            mini_one = one
            mini_one_index = i

    all_time = 0
    for i, time in enumerate(times):
        if i == mini_one_index:
            all_time += int(time)
        else:
            one = int(time[len(time)-1])
            if one == 0:
                all_time += int(time)
            else:
                ten_time = (math.floor(int(time) / 10)+1) * 10
                all_time += ten_time

    print(all_time)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)[::-1]
a = []
ng = 9999999
for i in range(N-1):
    if i != ng:
        if A[i] == A[i+1]:
            a.append(A[i])
            ng = i+1
            if len(a) == 2:
                break

ans = 0
if len(a) == 2:
    ans = a[0] * a[1]
else:
    ans = 0

print(ans)


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

int main(){
    int a,b,total;
    total = 0;
    cin >> a >> b;
    for(int i = 0;i < 2;i++){
        if(a >= b){
            total += a;
            a--;
        }else{
            total += b;
            b--;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
        int n;
        cin>>n;
        vector<int> a(n),b(n);
        forn(i,0,n)
        cin>>a[i];
        forn(i,0,n)
        cin>>b[i];
        
        vector<int> p(n);
        for(int i=1;i<=n;i++)
        p[i-1]=i;
        int cnt=0,cnt1,cnt2;
        
        do{
            cnt++;
            bool flag=true;
            for(int i=0;i<n;i++){
                if(p[i]!=a[i]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cnt1=cnt;
            }
            flag=true;
            for(int i=0;i<n;i++){
                if(p[i]!=b[i]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cnt2=cnt;
            }    
        }while(next_permutation(p.begin(),p.end()));
        cout<<abs(cnt1-cnt2);
  }    
}    




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int N;
int l[523456],r[523456];
int nc[523456];
long long wos[523456];
long long mem[523456];

long long rec(int x,int d){
  if(x==N)return 0;
  auto lr=rec(l[x],d+1),rr=rec(r[x],d+1);
  nc[x]=nc[l[x]]+nc[r[x]];
  wos[x]=wos[l[x]]+nc[l[x]]+wos[r[x]]+nc[r[x]];
  return min({nc[l[x]]+wos[l[x]]+rr+1,
	nc[r[x]]+wos[r[x]]+lr+1,
	lr+rr+2+d});
}

int main(){
  cin>>N;
  for(int i=1;i<N;i++){
    cin>>l[i]>>r[i];
  }
  nc[N]=1;
  vector<pair<int,int> > v;
  v.emplace_back(0,1);
  for(int i=0;i<v.size();i++){
    int x=v[i].second;
    if(l[x]!=N){
      v.emplace_back(v[i].first+1,l[x]);
    }
    if(r[x]!=N){
      v.emplace_back(v[i].first+1,r[x]);
    }
  }
  for(int i=v.size()-1;i>=0;i--){
    int x=v[i].second;
    auto lr=mem[l[x]],rr=mem[r[x]];
    nc[x]=nc[l[x]]+nc[r[x]];
    wos[x]=wos[l[x]]+nc[l[x]]+wos[r[x]]+nc[r[x]];
    mem[x]=min({nc[l[x]]+wos[l[x]]+rr+1,
	  nc[r[x]]+wos[r[x]]+lr+1,
	  lr+rr+2+v[i].first});
  }
  cout<<mem[1]<<endl;
}

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

int main(){
 int a,b;
 cin >> a >> b;
 if(a!=1 &&b!=1){
     cout << 1 << endl;
 }else if(a!=2 && b!=2){
   cout << 2 << endl;     
 }else{
     cout << 3 << endl;
 }

   
    return 0;
}


Measured memory_bytes: 768
# coding: utf-8
a, b, c, d = [int(i) for i in input().split()]
c1 = d if c < d else c
d1 = c if c < d else d
while d1 != 0:
    e = d1
    d1 = c1 % d1
    c1 = e
e = int((c * d) / e)
a -= 1
cnt = (b - a) + int(b // e) - int(a // e) - int(b // c) + int(a // c) - int(b // d) + int(a // d)
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 300010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define db(x) cout << x << endl;
const int mod = 10e8+7;
const int eps = 1e-6;
const ld pi = 3.14159265358979;
using namespace std;
int a[maxn],b[maxn];
char s[maxn];
int c[maxn],si[maxn];
signed main()
{
	ios::sync_with_stdio(0);
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	ld x= h*30;
	ld y = m*5.5;
	ld p = fabs(x-y);
	printf("%.15Lf\n",sqrt(a*a+b*b-2*a*b*cos(p/180.0*pi)));
	return 0;
}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=2e15;
const int N=3e3+20;
ll n,s; 
ll calc(ll n,ll x)
{
	if(x>n)
		return n;
	else
		return calc(n/x,x)+n%x;
}
int main()
{
	while(cin>>n>>s)
	{
		ll pos=inf,res=inf;
		if(n<s)
		{
			puts("-1");
			continue;
		}
		if(n==s)
		{
			cout<<n+1<<endl;
			continue;
		}
		for(ll i=2;i*i<=n;i++)
		{
			if(calc(n,i)==s)
			{
				pos=i;
				break;
			}
		}
		for(ll i=1;i*i<n&&i<=s;i++)
		{
			ll q=s-i;
			if((n-q)%i==0)
			{
				ll b=(n-q)/i;
				if(b>i&&b>q)
					res=min(res,b);
			}
		}
		ll ans=min(pos,res);
		if(ans>=inf)
			ans=-1;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, *t, *x, *y, i;
    bool can = true;
    cin >> n;
    t = new int[n+1];
    x = new int[n+1];
    y = new int[n+1];
    for (i = 1; i <= n; i++)
        cin >> t[i] >> x[i] >> y[i];
    t[0] = x[0] = y[0] = 0;
    
    for (i = 0; i < n; i++) {
        int dx = x[i+1] - x[i];
        int dy = y[i+1] - y[i];
        int dt = t[i+1] - t[i];

        if (dx + dy > dt || (dx + dy - dt) % 2 != 0)
            can = false;
    }

    if (can)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N;
int a[55];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>a[i];
    while(1){
        int sum=0;
        int maxmum=-INF;
        for(int i=0;i<N;++i)maxmum=max(maxmum,a[i]);
        if(maxmum<=N-1)break;
        for(int i=0;i<N;++i)sum+=a[i]/N;
        for(int i=0;i<N;++i){
            int cost = sum - (a[i]/N) - (a[i]/N)*N;
            a[i]+=cost;
        }
        ans+=sum;
    }
    cout<<ans<<endl;
}


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

signed main(void)
{
	int n;	cin >> n;
	vector<int> v(n);
	int cnt;
	rep(i, n) cin >> v[i];

	cnt = 0;
	for(int i = 1; i < n - 1; i++)
	{
		if ((v.at(i - 1) <= v.at(i) && v.at(i) <= v.at(i + 1))\
				|| (v.at(i - 1) >= v.at(i) && v.at(i) >= v.at(i + 1)))
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, q, a[100009]; long long x;
int main() {
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	while(q--) {
		scanf("%lld", &x);
		int r = 0; long long ret = 0, sum = 0;
		for(int l = 0; l < n; l++) {
			while(r < n && sum + a[r] <= x) sum += a[r++];
			ret += r - l;
			sum -= a[l];
		}
		printf("%lld\n", ret);
	}
}

Measured memory_bytes: 3588
n=int(input())
B=list(map(int,input().split()))
flag=True
ans=[]
while flag and len(B):
    for i in range(len(B)-1,-1,-1):
        if B[i]==i+1:
            del B[i]
            ans.append(i+1)
            break
    else:
        flag=False
        break
if not flag:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        System.out.println((1 & a & b) == 0 ? "Even" : "Odd");
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
 
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8
 
#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
 
__int128 gcd(__int128 a, __int128 b) {		// ユークリッドの互除法
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
int main() {
	int n;
	cin>>n;
	vector<ll> t(n);
	REP(i,n) cin>>t[i];
	vector<__int128> ta(n);
	REP(i,n) ta[i]=t[i];
	__int128 res = 1;
	REP(i,n) {
		res=res*t[i]/gcd(res,t[i]);
	}
	ll ans = res;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
while (w, d = gets.split.map(&:to_i)).inject(:+) != 0 do
  front = Array.new
  side = Array.new
  gets.split.map(&:to_i).each do |i|
    front[i] = 0 if !front[i]
    front[i] += 1
  end
  gets.split.map(&:to_i).each do |i|
    side[i] = 0 if !side[i]
    side[i] += 1
  end
  front.collect!{|v| v ? v : 0}
  side.collect!{|v| v ? v : 0}
  answer = 0
  front.size.times do |i|
    answer += [front[i], side[i]].max * i
  end
  p answer
end

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

int main() {
	int n,d,r,t;
	cin>>n>>d;
	r=(d*2)+1;
	if(n%r==0)
	{
		cout<<n/r<<endl;
	}
	else
	{
		cout<<(n/r)+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, u, k, v, i, j, A[101][101];

  scanf("%d",&n);

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      A[i][j] = 0;
    }
  }
  
  for(i=1 ; i<=n ; i++){
    scanf("%d%d", &u, &k);
    for(j=1 ; j<=k ; j++){
      scanf("%d",&v);
      A[u][v] = 1;
    }
  }

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      if(j != 1)printf(" ");
      printf("%d",A[i][j]);
      if(j == n)printf("\n");
    }
  }
 

  return 0;
}



Measured memory_bytes: 2108
n=int(input())
# sum1=
arr=list(map(int,input().split()))
arr.sort()
arr.reverse()
from collections import deque 
st = deque()
for i in arr:
  st.append(i)
while(len(st)!=1):
    x=st.pop()
    y=st.pop()
    st.append((x+y)/2)
print(st.pop())


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int num = scanner.nextInt();
        
        int h = num / 3600;
        num %= 3600;
        
        int m = num / 60;
        num %= 60;
        
        int s = num;
        
        System.out.println(String.format("%1$s:%2$s:%3$s", h, m, s));
    }
}


Measured memory_bytes: 26472
# -*- coding: utf-8 -*-
"""
A - Beginning
https://atcoder.jp/contests/keyence2019/tasks/keyence2019_a

"""
import sys


def solve(numbers):
    if all([n in numbers  for n in '1974']):
        return 'YES'
    return 'NO'


def main(args):
    numbers = input()
    ans = solve(numbers)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> good(N);
    for(int i = 0; i < N; i++) cin >> good.at(i);
 
    int sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            sum += good.at(i) * good.at(j);
        }
    }
    cout << sum / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define FOR(i,x,n) for(ll i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << 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; }
#define LEAF ((ll)pow(2, 17)-1)
#define NUM ((ll)pow(2, 18)-1)
using P=pair<ll, ll>;
vector<P> seg(NUM, {(ll)pow(2,31)-1, 0});

void update(ll s, ll t, ll x, ll n, ll l, ll r, ll k){
    // prllf("%d, %d, %d\n", l ,r, k);
    if(r < s || t < l) {
        // pr("c"); 
        return;}
    if(l==r) {seg[k] = {x, n}; 
    // pr("a"); 
    return;}
    if(s<=l && r<=t) {seg[k] = {x, n}; 
    // pr("b");
     return;}
    ll mid = (l+r)/2;
    ll chl = 2*k+1, chr = 2*k+2;
    update(s, t, x, n, l, mid, chl);
    update(s, t, x, n, mid+1, r, chr);
}

ll find(ll i, P p){
    if(seg[i].second > p.second) p = seg[i];
    if(i==0) return p.first;
    return find((i-1)/2, p); 
}

int main()
{
    ll n, q; cin >> n >> q;
    ll c, s, t, x;
    rep(i, q){
        cin >> c;
        if(c==1){
            cin >> x;
            ll k = find(LEAF + x, {0, -1});
            pr(k);
        }else{
            cin >> s >> t >> x;
            update(s, t, x, i+1, 0, LEAF, 0);
        }
    }

    return 0;}


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

int main(){
    int mini = 10,num,ans = 0;
    vector<int> dish(5);
    cin >> dish[0] >> dish[1] >>dish[2] >>dish[3] >>dish[4];
    for(int i = 0;i < 5;i++){
        if(dish[i] % 10 != 0 && mini > dish[i] % 10){
            mini = dish[i] % 10;
            num = i;
        }
    }

    for(int i = 0;i < 5;i++){
        if(i == num)ans += dish[i];
        else{

            ans += ((dish[i] + 9) / 10 * 10);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int r, D, x;
	cin >> r >> D >> x;
	rep(i, 10) {
		x = r * x -D;
		cout << x << endl;
	}
	
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b;
  cin >> a >> b;

  cout << max(0, a - b * 2) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>

inline int min(const int &a, const int &b) {
	return a < b ? a : b;
}

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;
	
	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;
	
	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';
	
	return neg ? -ret : ret;
}

#define inf 2147483647

int n, m, mini[400005];

int find(int t, int l, int r, int x, int y) {
	if (x <= l && r <= y)
		return mini[t];
	int mid = (l + r) >> 1;
	if (y <= mid)
		return find(t << 1, l, mid, x, y);
	if (x > mid)
		return find(t << 1 | 1, mid + 1, r, x, y);
	else
		return min(
			find(t << 1, l, mid, x, mid),
			find(t << 1 | 1, mid + 1, r, mid + 1, y)
		);
}

void update(int t, int l, int r, int x, int y) {
	if (l == r)mini[t] = y;
	else {
		int mid = (l + r) >> 1;
		if (x <= mid)
			update(t << 1, l, mid, x, y);
		else
			update(t << 1 | 1, mid + 1, r, x, y);
		mini[t] = min(mini[t << 1], mini[t << 1 | 1]);
	}
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 0; i <= (n << 2); ++i)mini[i] = inf;

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		int x = nextInt();
		int y = nextInt();
		if (c)	// find(x, y)
			printf("%d\n", find(1, 1, n, x + 1, y + 1));
		else	// update(x, y)
			update(1, 1, n, x + 1, y);
	}

//	system("pause");
}

Measured memory_bytes: 5628
#include<stdio.h>
#include<string.h>
int main()
{
  int N,i,j,num0,num;
  char S[99];
  scanf("%s",&S);
  N=strlen(S);
  num0=0;
  num=0;
  for(i=0;i<N/2;i++)
  {
    if(S[i]==S[N-1-i])
    {
      num0+=1;
    }
  }
  for(j=0;j<N/4;j++)
      {
        if(S[j]==S[N/2-1-j])
        {
          num+=1;
        }
      }
 
  if(num0==N/2&&num==N/4)
  {
   printf("Yes");
  }
  else
  {
   printf("No");
  }
}
      
  

Measured memory_bytes: 128
def main():
     n,x=map(int,input().split())
     l = list(map(int,input().split()))
     d=0
     cnt=1
     for i in l:
          if d+i>x:
               break
          else:
               d+=i
               cnt+=1
     print(cnt)
     
if __name__=='__main__':
     main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,k,f,g;
    cin>>a>>b>>k;
    if(k>=a)

    {
        f=k-a;
        if(f>b)
            g=0;
        else{g=abs(f-b);}
        cout<<"0"<<" "<<g;
    }
    else if(k<a)
    {
        f=a-k;
        cout<<f<<" "<<b;
    }

}


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

#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define int long long int
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 500001
#define MAXL 20
#define INF 200001
#define mod 1000000007

bool possible(int x, vector<int> v, int k)
{
  int ans = 0;
  for (int i = 0; i < v.size(); i++)
  {
    if (v[i] > x)
    {
      int inc = v[i] / x;
      ans += inc;
    }
  }
  return ans <= k;
}
int bb(vector<int> v, int k)
{
  int l = 1, r = 1e9, m;
  while (l < r)
  {
    m = (l + r) >> 1;
    if (possible(m, v, k))
      r = m;
    else
      l = m + 1;
  }
  return l;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  cout << bb(v, k) << endl;
  return 0;
}


Measured memory_bytes: 7836
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <cassert>    // assert
#include <stdexcept>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

constexpr inline ll MOD = 998244353LL;
constexpr int max_n = 200000 + 9;

int n,m,k;
// vector<ll> dp(max_n);
// vector<ll> fact(max_n);
ll sum;
vector<ll> comb(max_n); // comb[i] = (n-1) C i

ll pw(ll base, int ex) {
    if (ex == 0)
    {
        return 1;
    }
    else if (ex & 1)
    {
        return pw(base, ex - 1) * base %MOD;
    }
    else
    {
        ll res = pw(base, ex / 2);
        return res * res %MOD;
    }
}

ll modinv(ll a) {
    return pw(a, MOD-2);
}

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin>>n>>m>>k;
    /*
    fact[0] = 1;
    REP(i, k + 1) { fact[i + 1] = fact[i] * (i + 1) % MOD; }
     */
    comb[0] = 1;
    REP(i, n-1) { comb[i+1] = comb[i] * (n-1-i) %MOD * modinv(i+1) %MOD; }

    REP(i, k + 1) {
        ll prod = m;
        prod = prod * comb[i] %MOD;
        prod = prod * pw(m - 1, n - 1 - i) %MOD;
        sum = (sum + prod) %MOD;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4696
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class A500YenCoins {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int K, X;
        cin >> K >> X;
        cout << (K * 500 >= X ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    A500YenCoins solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())

grid = np.zeros((N,N),np.int8)

grid[::2,::2] = 1
grid[1::2,1::2] = 1

grid[::6,1::6] = 1
grid[::6,5::6] = 1
grid[2::6,1::6] = 1
grid[2::6,3::6] = 1
grid[4::6,3::6] = 1
grid[4::6,5::6] = 1

grid[0,:] = 1
grid[-1,:] = 1
grid[:,0] = 1
grid[:,-1] = 1

grid[::2,::2] = 0
grid[1::2,1::2] = 0

x,y = np.where(grid==1)

print(len(x))
for cell in zip(x,y):
    print(*cell)



Measured memory_bytes: 19236
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;
    
    void solve() {
        ll n, sum = 0;
        cin >> n;
        ll a[n], b[n];
        rep(i, n) cin >> a[i];
        for(ll i = 0; i < n-1; i+=2) sum += (a[i] - a[i+1]);
        sum+=a[n-1];
        b[0] = sum;
        
        repA(i, 1, n-1) b[i] = 2*a[i-1] - b[i-1];
        rep(i, n) cout << b[i] << " ";

    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
inline int myabs(int a){return a<0?-a:a;}
int A[200005],B[200005];
int main(){
	int k,cx,cy,x,y,n,b,c,f1,f2,f3,t,i;
	scanf("%d%d%d",&k,&x,&y);
	if(!(k&1)&&((x^y)&1)){printf("-1");return 0;}
	if(myabs(x)+myabs(y)==k){printf("1\n%d %d",x,y);return 0;}
	if(x<0){x=-x;f1=1;}else f1=0;
	if(y<0){y=-y;f2=1;}else f2=0;
	if(x<y){f3=x;x=y;y=f3;f3=1;}else f3=0;
	n=2;t=cx=cy=0;while(k*n<x+y||(k&n&1)!=((x^y)&1))++n;
	if(n==3&&x+y<k){
		A[  1]=x;B[1]=x-k;
		A[  2]=x+((x-y+k)>>1);B[2]=(x+y-k)>>1;
		A[t=3]=x;B[3]=y;
//		printf("k=%d x=%d y=%d n=%d f1=%d f2=%d f3=%d\n",k,x,y,n,f1,f2,f3,b,c);
	}else{
		b=(n*k-x-y)>>1;
		c=(n*k-x+y)>>1;
//		printf("k=%d x=%d y=%d n=%d f1=%d f2=%d f3=%d b=%d c=%d\n",k,x,y,n,f1,f2,f3,b,c);
		while((k-cy)<=b) B[++t]=(cy-=k);
//		printf("cy=%d\n",cy);
		A[++t]=cx=k-(b+cy);B[t]=-b;
		while( k+cx <=x){A[++t]=cx+=k;B[t]=-b;}
		A[++t]=x;B[t]=cy=k+cx-(b+x);
//		printf("cy=%d\n",cy);
		while( k+cy <=y){A[++t]=x;B[t]=(cy+=k);}
	}
	if(f3)for(i=1;i<=t;++i){f3=A[i];A[i]=B[i];B[i]=f3;}
	if(f1)for(i=1;i<=t;++i)A[i]=-A[i];
	if(f2)for(i=1;i<=t;++i)B[i]=-B[i];
	printf("%d",t);
	for(i=1;i<=t;++i)printf("\n%d %d",A[i],B[i]);
	return 0;
}

Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
max_pay = x * a + y * b
i = 0
while (x - i)>=0 or (y - i)>=0:
    pay = max((x - i),0) * a + max((y - i),0) * b + c * i * 2
    #print(pay)
    max_pay = min(max_pay,pay)
    i += 1
print(max_pay)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    if (k == 1)
        cout << "0\n";
    else
        cout << n - k << '\n';

    return 0;
}


Measured memory_bytes: 256
import random
import numpy as np
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
s = np.array(s)
#print(s)
for i in range(26):
    print(i+1)
for i in range(26, d):
    print(s[i].argmax()+1)

Measured memory_bytes: 27408
#include <stdio.h>

int main(void){
        long long int x;
        long long int ans=0;
        scanf("%lld",&x);
        while(x-500>=0){
                x-=500;
                ans+=1000;
        }
        while(x-5>=0){
                x-=5;
                ans+=5;
        }
        printf("%lld\n",ans);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	} else if (N == 2) {
		cout << 2 << endl;
		return 0;
	}
	int sum = 0;
	int mx_score = -1;
	for (int i = 1; i < N; i++) {
		sum += i;
		if (sum >= N) {
			mx_score = i;
			break;
		}
	}
	int sum_score = 0;
	for (int i = mx_score; i >= 1; i--) {
		if (sum_score + i > N) {
			continue;
		} else {
			cout << i << endl;
			sum_score += i;
		}
	}
  return 0;
}

Measured memory_bytes: 3564
K, A, B = map(int,input().split())
if K < A+1 or B-A <= 2 :
    print(K+1)
else:
    t = (K - A - 1) //  2
    if (K - A - 1) % 2 != 0:
        ans = B + t * (B - A) + 1
    else:
        ans = B + t * (B - A)
    print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;


signed main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> p(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        p[i] = a + (h+1)*b;
    }
    SORT(p);
    int cnt[10] = {0};
    rep(i,n){
        for(int x = -1;x <= 1;x++){
            for(int y = -1;y <= 1;y++){
                int X = p[i]%(h+1);
                int Y = p[i]/(h+1);
                if(X+x <= 1 || X+x >= h || Y+y <= 1 || Y+y >= w) continue;
                int c = 0;
                auto a1 = lower_bound(p.begin(),p.end(),(X+x-1) + (h+1)*(Y+y-1));
                auto b1 = upper_bound(p.begin(),p.end(),(X+x+1) + (h+1)*(Y+y-1));
                int c1 = distance(a1,b1);
                auto a2 = lower_bound(p.begin(),p.end(),(X+x-1) + (h+1)*(Y+y));
                auto b2 = upper_bound(p.begin(),p.end(),(X+x+1) + (h+1)*(Y+y));
                int c2 = distance(a2,b2);
                auto a3 = lower_bound(p.begin(),p.end(),(X+x-1) + (h+1)*(Y+y+1));
                auto b3 = upper_bound(p.begin(),p.end(),(X+x+1) + (h+1)*(Y+y+1));
                int c3 = distance(a3,b3);
                cnt[c1+c2+c3]++;
                //cerr << X << " " << Y << " " << x << " " << y << " " << c1+c2+c3 << endl;
            }
        }
    }
    cout << (h-2)*(w-2) - cnt[1]-cnt[2]/2-cnt[3]/3-cnt[4]/4-cnt[5]/5-cnt[6]/6-cnt[7]/7-cnt[8]/8-cnt[9]/9 << endl;
    for(int i = 1 ;i <= 9;i++){
        cout << cnt[i]/i << endl;
    }

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1), ans(n);
  rep(i, n-1) cin >> b.at(i);
  ans.at(0) = b.at(0);
  for(int i = 1; i < n-1; i++) {
    ans.at(i) = min(b.at(i), b.at(i-1));
  }
  ans.at(n-1) = b.at(n-2); 
  cout << accumulate(all(ans), 0LL);
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/xpressive/xpressive_static.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
using namespace boost::xpressive;

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

  S.pop_back();
  boost::xpressive::smatch m;
  const sregex re = bos >> (s1 = +lower) >> s1;
  if (regex_search(S, m, re)) {
    cout << m.str().length() << endl;
  }
  return 0;
}


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

long N;
map<long, long> M;

int main(void) {

    cin >> N;
    for (long i = 1; i < N; i++) {
        long a; cin >> a;
        M[a]++;
    }

    for (long i = 1; i <= N; i++) {
        cout << M[i] << endl;
    }

    return 0;

}

Measured memory_bytes: 16048
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll white=0,red=0;
    ll ans=0,count=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        white++;
        else
        {
            red++;
        }
        
    }
    for(int i=0;i<red;i++)
    {
        if(s[i]=='W')
        count++;
    }
    ans=min(count,min(red,white));
    cout<<ans;


    
    return 0;
}

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

const int inf = 1e9;
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int ans=inf,t1,t2,t3,n;
    cin>>n;

    for(int i=1;i<=n/2;i++)
    {
        t1=i;   t2=n-i; t3=0;
        while(t1>0)
        {
            t3+=t1%10;
            t1/=10;
        }
        while(t2>0)
        {
            t3+=t2%10;
            t2/=10;
        }
        ans=min(ans,t3);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256