akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
    
using namespace std;

int main(void){
    int x, n, w=0;
    cin >> x >> n;
    map<int, int> q{};
    for (int i=0; i<n; i++) {
        int t;
        cin >> t;
        q[t] = 1;
    }
    while(1) {
        if(!q[x+w] && !q[x-w]) {
            w = min(w, -w);
            break;
        } else if(!q[x+w]) {
            break;
        } else if(!q[x-w]) {
            w *= -1;
            break;
        }
        w++;
    }
    cout << x+w << endl;
    return 0;
}


Measured memory_bytes: 3632
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define zhfs main
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 1; i <= n; i++)
char a[57][57], b[57][57];
int zhfs()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", a[i]);
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%s", b[i]);
	}
	for (int i = 0; i + m - 1 < n; i++)
	{
		for (int j = 0; j + m - 1 < n; j++)
		{
			bool eq = true;
			for (int x = 0; x < m; x++)
			{
				for (int y = 0; y < m; y++)
				{
					if (b[x][y] != a[x + i][y + j]) eq = false;
				}
			}
			if (eq)
			{
				cout << "Yes" << endl;
				re 0;
			}
		}
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
    ll D;cin>>D;
    vector<int> c(26);rep(i,26)cin>>c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D)rep(j,26) cin>>s[i][j];
    rep(i,D) cout<<(i+1)%26+1<<endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
        cin>>n;
		if(n>=2)
		{
			long long a=2,b=1,t;
			for(int i=2;i<=n;i++)
			{
				t=a+b;
				a=b;
				b=t;
			}
			cout<<t<<endl;	
		}
		else if(n==1)printf("1\n");  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<long> p(a);
    vector<long> q(b);
    vector<long> r(c);
    rep(i,a) cin >> p.at(i);
    rep(i,b) cin >> q.at(i);
    rep(i,c) cin >> r.at(i);
    sort(all(p));
    sort(all(q));
    sort(all(r));
    p.push_back(1e9+1);
    q.push_back(1e9+1);
    long pi = a - x;
    long qi = b - y;
    long ri = c;
    for (int i=c-1; i>=0; i--){
        if(p.at(pi) > q.at(qi)){
            if(q.at(qi) < r.at(i)){
                qi++;
                ri=i;
            }
        }else{
            if(p.at(pi) < r.at(i)){
                pi++;
                ri=i;
            }
        }
    }
    long ans = 0;
    for(int i = pi;i<a;i++){
        ans += p.at(i);
    }
    for(int i = qi;i<b;i++){
        ans += q.at(i);
    }
    for(int i = ri;i<c;i++){
        ans += r.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int gcd(int x, int y) {
	int temp;
	if (x < y)swap(x, y);
	while (y) {
		temp = y;
		y = x % y;
		x = temp;
	}
	return x;
}
int main() {
	int N, ans; cin >> N;
	vector<int> A(N);

	rep(i, N) {
		cin >> A[i];
		if (i > 0)ans = gcd(ans, A[i]);
		else ans = A[i];
	}
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <algorithm>

constexpr char EAST = 'E';
constexpr char WEST = 'W';

int solve(const std::string & s) {
  auto ans = std::count_if(s.begin(), s.end(), [](const char c) { return c == EAST; });
  auto n { ans };

  for(int i = 0; i < s.length(); ++i) {
    if(s[i] == EAST) {
      --n;
    }
    if(s[i - 1] == WEST) {
      ++n;
    }
    ans = std::min(ans, n);
  }

  return ans;
}

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

  std::string s;
  std::cin >> s;

  std::cout << solve(s) << std::endl;
  return 0;
}


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

using namespace std;

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

    int n, med;
    cin >> n;
    int arr[n], neww[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i], neww[i] = arr[i];

    sort(neww, neww + n);
    med = neww[n / 2 - 1];

    for (int i = 0; i < n; i++)
        cout << (arr[i] <= med ? neww[n / 2] : neww[n / 2 - 1]) << '\n';

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;

int main(){
	long long x,y;
	cin >> x >> y;
	long long cnt=1;
	while(1){
		if(x>y){
			cnt--;
			break;
		}
		if(x==y){
			break;
		}
		x=x*2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
let fd [| x; y |] =
    [| for i in [ 0 .. x ] do
        yield 2 * i + 4 * (x - i) |]
    |> Array.filter (fun a -> a = y)
    |> Array.length
    |> fun x -> if x > 0 then "Yes" else "No"

//for i in [| [| 3; 8 |]; [| 2; 100 |]; [| 1; 2 |] |] do fd i |> printfn "%s"

[<EntryPoint>]
let main argv =
    let input = stdin.ReadLine().Split(' ') |> Array.map int
    fd input |> printfn "%s"
    0

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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin>>a>>b;
  if(a>2*b)
  {
    cout<<a-2*b<<endl;
  }
  else
  {
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 3540
#import random
import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)
#t=[None]*d
  for i in range(d):
    s[i]=list(map(int,input().split()))
  s=np.array(s)
#for i in range(d):
#  t[i]=int(input())-1
  for j in range(d):  
    #rand = np.random.randint(26, size = 10) 
    #print(np.argmax(s[j])+1)
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
    
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  #r_i+=1
  #print(r_i)
  """
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
#r0=t
  """
    
  testc=(90,80,85,75,70,65,60,55,50,45,40,35,30)
  for l in testc:
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    rand = np.random.randint(100, size = d) 
    for j in range(d):  
    #print(np.argmax(s[j])+1)
      r_i=r0[j]
      cd=c*cm
      if rand[j]>l:
        r_i=np.argmax(cd)
      r1[j]=r_i
      for k in range(26):
        cm[k]+=1
      cm[r_i]=0
      
    score1=0
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    for j in range(d):
      r0_j=r1[j]
        #print(score1)
      score1+=s[j][r0_j]
      for k in range(26):
        cm[k]+=1
        cm[r0_j]=0
      cd=c*cm
      #print(cm)
      score1+=-np.sum(cd)
      #print(score0)
      #print(score1)
      if score1>score0:
        r0=r1
        score0=score1
    
  
  for j in range(d):  
    print(r0[j]+1) 
 
main()

Measured memory_bytes: 27648
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <unordered_map>
#include <cstring>
#include <vector>

using namespace std ;

#define int long long 
#define endl "\n" 

const int N = 1e4 + 5 ;
const int M = 102 ;
const int mod = 1e9 + 7 ; 

int dp[N][M][2] , a[N] ;
int n , d ; 

int fun( int ind , int rem , int Isless)
{
     if(ind == n ) 
     {
        return (rem == 0 );
     }
     int &ans = dp[ind][rem][Isless] ;
     if(ans != -1 ) return ans ;
     ans = 0 ;
     if(Isless==0)
     {
         for(int i = 0 ; i <= a[ind] ; i ++ )
         {
             ans = ans + fun(ind+1,(rem+i)%d , (Isless|(i<a[ind])));
             ans%=mod ;
         }
     }
     else 
     {
         for( int i = 0 ; i <= 9 ; i++ )
         {
             ans =  ans + fun(ind+1,(rem+i)%d , Isless);
             ans%=mod ;
         }
     }
     return ans ;
}


int32_t main()
{
     /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin) ;
     freopen("output.txt","w",stdout) ;
     #endif*/ 
     memset(dp,-1,sizeof(dp));
     string s ;
     cin >> s >> d ;
     n = s.size() ;
     for(int i = 0 ; i< n ; i++ )
     {
         a[i] = s[i]-'0' ;
     }
     int ans = fun(0,0,0) ;
     ans -= 1 ;
     ans = (ans + mod) %mod ;
     cout<<ans<<endl;

}


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

int main()
{
  int x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;

  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x3 - (x2 - x1);
  y4 = y3 - (y2 - y1);

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int n, m;
pair<int,int> a[100005];

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> a[i].second >> a[i].first;
    sort(a, a + n);
    reverse(a, a + n);

    set<int> s;
    for(int i = 1; i <= m; ++i)
        s.insert(i);

    int c = 0;
    for(int i = 0; i < n; ++i) {
        auto it = s.lower_bound(a[i].second);
        if(it != s.end())
            c += a[i].first, s.erase(it);
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

void solve(){

    ll n;
    cin >> n;
    n= n%10;

    if(n==2||n==4||n==5||n==7||n==9){
        cout << "hon" << endl;
    }
    else if (n==3){
        cout << "bon" << endl;
    }
    else{
        cout << "pon" << endl;
    }

}

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define M 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int n, m; cin >> n >> m;
	vector<ll> x(n + 1), y(m + 1);
	vector<ll> sumx(n + 1), sumy(m + 1);
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		sumx[i] = sumx[i - 1] + x[i];
		sumx[i] %= DIV;
	}

	for (int i = 1; i <= m; i++) {
		cin >> y[i];
		sumy[i] = sumy[i - 1] + y[i];
		sumy[i] %= DIV;
	}

	ll X = 0;
	for (int j = 1; j <= n; j++) {
		X += ((j - 1) * x[j]) % DIV - sumx[j - 1] + DIV;
		X %= DIV;
	}

	ll Y = 0;
	for (int p = 1; p <= m; p++) {
		Y += ((p - 1) * y[p]) % DIV - sumy[p - 1] + DIV;
		Y %= DIV;
	}

	cout << (X * Y) % DIV << endl;
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,count,k=0;
    cin>>n;
    for (i=15;i<=n;i++)
    {
        count=0;
        if (i%2!=0)
        {
            for (j=1;j<=i;j++)
            {
                if (i%j==0)
                    count++;
            }
        }
        if (count==8)
            k++;
    }
    cout<<k<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
 
 
int main() {
  ll X, Y;
  cin >> X >> Y;
 
  string ans = "No";

  for (ll i = 0; i <= X; i++) {
    for (ll j = 0; j <= X; j++) {
      if ((2*i + 4*j) == Y && (i+j) == X) ans = "Yes";
    }
  }

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

Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define fr first
#define sc second
P seg[1<<18];
int n;
void update(int id,int pt){
  int k = id + n - 1;
  seg[k].fr += pt;
  seg[k].sc = -id;
  while(k != 0){
    k = ( k - 1 ) / 2;
    seg[k] = max(seg[2*k+1],seg[2*k+2]);
  }
}
void init(int size) {
  n = 1;
  while(n < size) n *= 2;
  for(int i = 0 ; i < size ; i++ ) update(i,0);
}
int main(){
  int N,R,L;
  scanf("%d %d %d",&N,&R,&L);
  init(N);
  int mostid = 0 , now = 0 , sum[100000] = {};
  for(int i = 0 ; i < R ; i++ ){
    int d,t,x;
    scanf("%d %d %d",&d,&t,&x);
    update(d-1,x);
    sum[mostid] += t - now;
    now = t;
    mostid = -seg[0].sc;
  }
  sum[mostid] += L - now;
  int rec = 0;
  for(int i = 0 ; i < N ; i++) if( sum[rec] < sum[i] ) rec = i;
  printf("%d\n",rec+1);
}

Measured memory_bytes: 3476
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int op(int a, int b){
   return max(a,b);
}
int e(){
   return (int)(0);
}
segtree<int,op,e> seg(300001);
int main() {
   int n,k;cin>>n>>k;
   rep(i,n){
      int a;cin>>a;
      seg.set(a,seg.prod(max(0,a-k),min(300001,a+k+1))+1);
   }
   cout<<seg.all_prod()<<endl;
}

Measured memory_bytes: 8324
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    if(N % K == 0){
        cout << "0" << endl;
        exit(0);
    }
    cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int N, M;
int mod = 1000000007;

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

    //N>=M
    if(M>N) swap(N, M);
    if(N > M+1) {
        cout << 0 << endl;
        return 0;
    }
    lng ans = 1;
    FOR(i, 1, M) {
        ans *= i;
        ans %= mod;
    }
    FOR(i, 1, N) {
        ans *= i;
        ans %= mod;
    }
    if(N == M) {
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
using namespace std;

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

#define max_n 100

string S, T;


int main() {

	cin >> S >> T;

	int ans = 0;
	rep(i,3)
	{
		if(S.at(i)==T.at(i))ans++;
	}
	
	

	cout << ans <<endl;

	return 0;	
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var lc, rc int
        var s string
        fmt.Scanf("%s", &s)
        for i := 0; i < len(s); i++ {
                if i % 2 == 0 {
                        if int(s[i]) - int('0') != 0 {
                                lc++
                        } else {
                                rc++
                        }
                } else {
                        if int(s[i]) - int('0') != 0 {
                                rc++
                        } else {
                                lc++
                        }
                }
        }
        if lc > rc {
                fmt.Println(rc)
        } else {
                fmt.Println(lc)
        }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

tuple<int, int, string> era[1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0) break;
    REP(i, N) {
      string en;
      int eby, wy;
      cin >> en >> eby >> wy;
      era[i] = make_tuple(wy - eby + 1, wy, en);
    }

    REP(_, Q) {
      int q;
      cin >> q;
      bool flag = true;
      REP(i, N) {
	int es, ee;
	string en;
	tie(es, ee, en) = era[i];
	if (es <= q && q <= ee) {
	  cout << en << ' ' << q - es + 1 << endl;
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << "Unknown" << endl;
      }
    }
  }			    
  return 0;
}

Measured memory_bytes: 3236
#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())

vector<int> Eratosthenes(ll n) {
  vector<int> res(n + 1);
  REP(i, n + 1) { res[i] = i; }
  res[0] = res[1] = 1;
  for (ll i = 2; i * i <= n; i++)
    if (res[i] == i) {
      for (ll j = 2; i * j <= n; j++)
        if (res[i * j] == i * j) res[i * j] = i;
    }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<int> isPrime = Eratosthenes(1e6 + 10);
  map<ll, ll> cnt;

  ll g = 0;
  REP(i, n) { cin >> a[i]; }
  REP(i, n) { g = gcd(g, a[i]); }

  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  REP(i, n) {
    ll t = a[i];
    while (t > 1) {
      ll u = isPrime[t];
      cnt[u]++;
      while (t % u == 0) {
        t /= u;
      }
    }
  }

  for (auto& p : cnt) {
    if (p.second >= 2) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 19884
import math
def A():
    N, M = map(int, input().split())
    if N == 1 == M:
        print(0)
        return
    ans = 0
    if N > 1:
        ans += math.factorial(N)//(2*(math.factorial(N-2)))
    if M > 1:
        ans += math.factorial(M)//(2*(math.factorial(M-2)))
    print(ans)

def B():
    S = input()
    if not S:
        print('No')
        return
    # for i in range(len(S)//4):
    #     # print(S[i], S[len(S)//2-i-1], S[len(S)//2+i+1], S[-i-1])
    #     if not (S[i] == S[(len(S)-1)//2-i-1] == S[(len(S)+3)//2+i-1] == S[-i-1]):
    #         print('No')
    #         return
    for i in range(len(S)):
        if not S[i] == S[len(S)-i-1]:
            print('No')
            return
    for i in range((len(S)-1)//2):
        if not S[i] == S[(len(S)-1)//2-i-1]:
            print('No')
            return
        if not S[(len(S)+3)//2+i-1] == S[len(S)-i-1]:
            print('No')
            return
    print('Yes')
B()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v;
    v.pb(-99999);
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x);
    }
    ll ans[n+1];
    ms(ans) ;
    for(ll i = n ; i >= 1; --i){
        if(i > (n/2)){
            ll ai = v[i] ;
            if(ai % 2 == 0){
                ans[i] = 0 ;
            }
            else ans[i] = 1;
        }
        else {
            ll ai = v[i] ;
            ll sum = 0 ;

            ll j = 2*i ;
            ll cnt = 2 ;
            while(j <= n){
               // cout << " i is " << i << " j is " << j << el ;
                sum = sum + ans[j] ;
                ++cnt ;
                j = cnt * i ;
            }
            ll foo = sum - ai ;
            ll res = abs(foo ) ;
            //cout << " foo is " << foo << " res is " <<res << el;
            if(res % 2 == 0){
                ans[i] = 0 ;
            }
            else if(res % 2 == 1){
                ans[i] = 1 ;
            }
        }
    }
    ll ziz = 0 ;
    forn(i , 1 , n ){
       if(ans[i] == 1){
        ++ziz ;
       }
    }
    cout << ziz << el ;
    if(ziz == 0){
        ro ;
    }
    else{
        forn(i , 1 , n ){
          if(ans[i] == 1){
            cout << i << " " ;
          }
        }
    }
    cout << el ;
    ro;
}































Measured memory_bytes: 4080
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int dp[3][100002];//dp[i][j]=j日目まで処理、最後はプランi
  cin >> dp[0][0] >> dp[1][0] >> dp[2][0];
  for (int i = 1; i < N; i ++) {
    int a, b, c;
    cin >> a >> b >> c;
    dp[0][i] = a + max(dp[1][i - 1], dp[2][i - 1]);
    dp[1][i] = b + max(dp[0][i - 1], dp[2][i - 1]);
    dp[2][i] = c + max(dp[0][i - 1], dp[1][i - 1]);
  }
  cout << max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1])) << endl;
}

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

int main()
{
  ll n,sum=0;
  cin>>n;
  ll k=n-1;
 for(ll i=1;i<n;i++)
 {
   ll k=(n-1)/i;
   sum+=k;
 }
 cout<<sum<<endl;

}




Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		System.out.println(3*n*n);
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                Console.WriteLine(string.Join("apple", line.Split(new []{"peach"}, StringSplitOptions.None).Select(ToPeach).ToArray()));
            }
        }

        static string ToPeach(string s)
        {
            return s.Replace("apple", "peach");
        }
    }
}

Measured memory_bytes: 6440
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>     
#include<algorithm>
#define ll long long
using namespace std;
#define hengheng main()
#define mem(a,b) memset(a,b,sizeof(a))
int x[1000];
int main()
{
	int n,m,t,k,i,j; ll sum;
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	k=min(a,b);
	t=1;
	for(i=k;i>=1;i--)
	{
		if(a%i==0&&b%i==0)
		{
			x[t]=i;
			t++;
		}
	}
	printf("%d\n",x[c]);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 15;
bool cut[15];
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int n = s.size();
	long long ans = 0;
	for(int i = 0;i < n; ++i)
	{
		//cut into i + 1 pieces
		memset(cut,0x00,sizeof(cut));
		for(int j = n - 1;j >= n - i; --j)
		{
			cut[j] = 1;
		}
		do{
			if(cut[0])
			{
				continue;
			}
			long long ret = 0;
			for(int j = 0;j < n; ++j)
			{
				if(cut[j])
				{
					ans += ret;
					ret = 0ll;
				}
				ret = ret * 10 + s[j] - '0';
			}
			ans += ret;
			// cout<<ans<<endl;
		}while(next_permutation(cut,cut + n));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

// C function for extended Euclidean Algorithm 
int gcdExtended(int a, int b, int *x, int *y); 
  
// Function to find modulo inverse of a 
void modInverse(int a, int m) 
{ 
    int x, y; 
    int g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    else
    { 
        // m is added to handle negative x 
        int res = (x%m + m) % m; 
        cout << "Modular multiplicative inverse is " << res; 
    } 
} 
  
// C function for extended Euclidean Algorithm 
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

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

	ll n;
	cin>>n;
	double s=0;
	ll x;
	for(ll i=0; i<n; i++)
		{
			cin>>x;
			s+= (double)1/ double(x);
		}
	cout<<double(1/s);
	
	return 0;
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (YES) << endl;}else{cout << NO << endl;}
#define YES "YES"
#define NO "NO"

int main()
{
	int n, k;
	cin >> n >> k;
	if (n % k) cout << 1 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
// ・AOJ1142(setの練習問題)
// ・AOJ1129(vectorの練習問題)
// ・AOJ10032(stackの練習問題)
// ・AOJ10027(stringの練習問題)
// ・AOJ10021(sort || priority_queueの練習問題)
// ・AOJ1064(オーバーロードの練習問題)
// ・AOJ0138(mapの練習問題)
// ・AOJ0105(mapの練習問題)
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
	int n, r, p, c;
	vector<int> v;
	vector<int>::iterator ite;
	while(1){
		scanf("%d%d", &n, &r);
		if(n ==0 && r == 0) break;
		for (int i=1; i<=n; i++) { v.push_back(i); }
		for (int i=0; i<r; i++) {
			scanf("%d%d", &p, &c);
			ite = v.end()-p-c+1;
			for(int j=0; j<c; j++) {
				v.push_back(*ite);
				v.erase(ite);
			}
		// vector<int>::iterator test;
		// test = v.begin();
		// while(test != v.end()){printf("%d", *test); test++;}
		// printf("\n");
		}
		ite = v.end()-1;
		printf("%d\n", *ite);
	}
}

Measured memory_bytes: 1316
#include <iostream>
#include <cstring>

using namespace std;

int main(){


    string s;
    cin >> s;

    bool res = true;

    if (s[0] != 'A'){
        res = false;
    }

    bool found = false;
    int cindx = 0; 

    for(int i = 2; i < s.size() - 1; i++)
        if (s[i] == 'C'){
            found = true;
            cindx = i;
        }

    if (!found){
        res = false;
    }

    if (found){

        bool lower = true;

        for (int i = 1; i < s.size(); i++){
            if (i == cindx) continue;
            if (!islower(s[i])){
                lower = false;
            }
        }

        if (!lower){
            res = false; 
        }
    }


    if (res) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}


Measured memory_bytes: 256
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	if(n <= 599)
		cout << 8 <<"\n";
	else if(n <= 799)
		cout << 7 <<"\n";
	else if(n <= 999)
		cout << 6 <<"\n";
	else if(n <= 1199)
		cout << 5;
	else if(n <= 1399)
		cout << 4;
		else if(n <= 1599)
		cout << 3;
	else if(n <= 1799)
	cout << 2;
	else cout << 1 ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,a; cin >> n >> a;
  cout << n*n -a << endl;
}

Measured memory_bytes: 3628
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

MOD = 10 ** 9 + 7
n = rri()
every = pow(10, n, MOD)
none = pow(8, n, MOD)
no_zero = no_nine = pow(9, n, MOD)

zero_and_nine = every - no_zero - no_nine + none
zero_and_nine %= MOD
print zero_and_nine


Measured memory_bytes: 64968
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.next().length();
		for(int i=0; i<a; i++){
			System.out.print("x");
		}
		System.out.println();
	}
}


Measured memory_bytes: 35588
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m, c; cin >> n >> m >> c;
  vector<int> b(m); REP(i, m) cin >> b[i];
  int ans = 0;
  while (n--) {
    int source = 0;
    REP(i, m) {
      int a; cin >> a;
      source += a * b[i];
    }
    source += c;
    if (source > 0) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, a, b; cin >> n >> a >> b;
  if (a == b) {
    outl(1);
    return;
  } else if (n == 1 || a > b) {
    outl(0);
    return;
  }

  outl((b - a) * (n - 2) + 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{
    gearup;
    ll n,a,b; cin >> n >> a >> b;
    vl h(n);
    rep(i,n)cin>>h[i];
    ll dif = a-b;
    ll ma = 1e9 + 1,mi = 0;
    while(ma - mi > 1){
        ll mid = (ma + mi) /2;
        //midの値以下にできるか
        ll ttl = 0;
        auto H = h;
        rep(i,n){
            H[i] -= b * mid;
            if(H[i] > 0)ttl += (H[i] + dif -1)/dif; //切り上げ
        }
        if(ttl <= mid)ma = mid;
        else mi = mid;
    }
    out(ma);
}


Measured memory_bytes: 4764
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a % b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n)	cin >> a[i];
	rep(i, n)	cin >> b[i];
	sort(all(a));
	sort(all(b));
	int ret = 0;
	vector<int> amod(n), bmod(n);
	rep(i, 29) {

		int T = (1 << i);

		rep(j, n)	amod[j] = a[j] % (2 << i);
		rep(j, n)	bmod[j] = b[j] % (2 << i);
		sort(all(bmod));
		int cnt = 0;
		rep(j, n) {
			if (amod[j] & (1 << i)) {
				// ooxxxxxxoo
				cnt += lower_bound(all(bmod), 2*T - amod[j]) - bmod.begin();
				cnt += bmod.end() - lower_bound(all(bmod), (3*T - amod[j]));
			}
			else {
				// xxxxoooooxx
				auto s = lower_bound(all(bmod), T - amod[j]);
				auto t = lower_bound(all(bmod), 2*T - amod[j]);
				cnt += t - s;
			}
		}
		ret ^= ((cnt & 1) << i);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	int n,t,x,y;
	cin>>n;
	int time = 0,nx=0,ny=0;
	bool ans = true;
	rep(i,n){
		cin>>t>>x>>y;
		if(abs(nx-x)+abs(ny-y) > t-time || abs(nx+ny-x-y+t-time)%2 == 1){
			ans = false;
		}
		nx = x;
		ny = y;
		time = t;
	}
	cout<<(ans?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void bubble_sort(int *data, int n)
{
	int i, j;
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (data[j] > data[j + 1] && data[j] != -1 ){
				data[j] += data[j + 1];
				data[j + 1] = data[j] - data[j + 1];
				data[j] -= data[j + 1];
			}
		}
	}
}

int main(void)
{
	int before[1000], after[1000], num[1000], seisuu;
	char str[1000], check[1000];
	int i, j, flag, bef;
	
	flag = i = 0;
	memset(before, -1, sizeof(before));
	memset(after, -1, sizeof(after));
	memset(num, 0, sizeof(num));
	
	bef = 0;
	while (fgets(str, 999, stdin) != NULL){
		if (str[0] == '\n'){
			i = 0;
			flag = 1;
			continue;
		}
		j = seisuu = 0;
		while (str[j] != ','){
			seisuu = seisuu * 10 + str[j] - '0';
			j++;
		}
		
		if (flag){
			after[i] = seisuu;
		}
		else {
			before[i] = seisuu;
			bef++;
		}
		i++;
	}
	
	bubble_sort(before, bef);
	
	for (i = 0; i < bef; i++){
		while (before[i] == before[i + 1] && before[i] != -1 && before[i + 1] != -1){
			num[i]++;
			for (j = i; j < bef; j++){
				before[j] = before[j + 1];
			}
		}
	}
	
	memset(check, 0, sizeof(check));
	
	for (i = 0; i < bef; i++){
		for (j = 0; j < 1000; j++){
			if (before[i] == after[j]){
				num[i]++;
				check[i] = 1;
			}
		}
		if (check[i] && before[i] != -1){
			printf("%d %d\n", before[i], num[i] + 1);
		}
	}
	
	return (0);
}

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

int main(int argc, char const *argv[])
{
	int d, g; cin >> d >> g;
	vector<int> p(d), c(d);
	rep(i, d) cin >> p[i] >> c[i];

	int ans = 1e9;
	for (int mask = 0; mask < (1 << d); ++mask) {
		int sum = 0, cnt = 0;
		for (int i = 0; i < d; ++i) {
			if (mask & (1 << i)) sum += 100 * (i + 1) * p[i] + c[i], cnt += p[i];
		}

		int idx = -1;
		for (int i = d - 1; i >= 0; --i) {
			if ((mask & (1 << i)) == 0) {
				idx = i; break;
			}
		}

		if (idx != -1) {
			rep(i, p[idx]) {
				if (g <= sum + (idx + 1) * 100 * i) {
					ans = min(ans, cnt + i);
					break;
				}
			}
		} else {
			if (g <= sum) ans = min(ans, cnt);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n;
    scanf("%lli%*c",&n);
    i64 l=llinf,max=0LL;
    for(i64 i=0LL;i<n;++i){
        i32 a;
        scanf("%i%*c",&a);
        if(a){
            if(l==llinf) l=i;
        }
        else{
            if(i-l>max) max=i-l;
            l=llinf;
        }
    }
    if(n-l>max) max=n-l;
    printf("%lli\n",max+1LL);
    return 0;
}



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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    int minimo=0,sockets=0;
    while(b>0){
        b-=a;
        if(b<=0){
            minimo++;
        }else{
            b+=1;
            minimo++;
        }
    }
    cout<<minimo<<endl;
    return 0;
}


Measured memory_bytes: 256
var lines =[];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output:process.stdout,
});

rl.on('line',function(x){
    lines.push(x);
});

rl.on('close',function(){

    var tmp = lines.shift();
    var N = Number(tmp.split(" ")[0]);
    var T = Number(tmp.split(" ")[1]);
    var c,t;
    var result = Infinity;

    
    for(var i=0;i<N;i++){
        c=Number(lines[i].split(" ")[0]);
        t=Number(lines[i].split(" ")[1]);
        
        if(t<=T && c<result){result = c}
    }
    if(result != Infinity){console.log(result);}
    else{console.log("TLE");}
});

Measured memory_bytes: 7756
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.nextLine();
		
		int[] map = new int[500001];
		for(int i = 0; i < 50001; i++){
			map[i] = -1;
		}
		
		Integer[] amount = new Integer[m];
		for(int i = 0; i < m; i++){
			amount[i] = sc.nextInt();
		}

		/* ?????????????????? */
		Arrays.sort(amount, Comparator.reverseOrder());

		int ret = coinChange(n, amount, map);
		System.out.println(ret);
		
	}

	public static int coinChange(int n, Integer[] amount, int[] map){
		if(n < 0){
			return -1;
		}else if(n == 0){
			return 0;
		}else if(map[n] != -1){
			return map[n] + 1;
		}else{
			int min = 50001;
			for(int i = 0; i < amount.length; i++){
				int ret = coinChange(n - amount[i], amount, map);
				if(ret >= 0 && ret < min){
					min = ret;
				}
			}
			map[n] = min;
			return map[n] + 1;
		}
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  sort(arr.begin(), arr.end());
  cout << accumulate(arr.begin(), arr.begin() + k, 0) << endl;
  return 0;
}


Measured memory_bytes: 3616