akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N;
int R[500500], C[500500];
int S[512][512], I[512][512];

const int DR[] = {0, 1, 0, -1}, DC[] = {1, 0, -1, 0};

void update(int r0, int c0) {
  int g0 = S[r0][c0];
  deque<int> qr, qc, qd;
  qr.push_back(r0);
  qc.push_back(c0);
  qd.push_back(0);
  while (!qr.empty()) {
    const int r = qr[0]; qr.pop_front();
    const int c = qc[0]; qc.pop_front();
    const int d = qd[0]; qd.pop_front();
    for (int dd = 0; dd < 4; ++dd) {
      const int rr = r + DR[dd], cc = c + DC[dd];
      if (rr < 0 || cc < 0 || rr >= N || cc >= N || (rr == r0 && cc == c0)) {
        continue;
      }
      const int nd = I[rr][cc] > I[r0][c0] ? d + 1 : d;
      if (S[rr][cc] > 0 && S[rr][cc] == nd + g0) {
        // cout<<rr<<' '<<cc<<' '<<nd<<' '<<g0<<' '<<I[rr][cc]<<' '<<I[r0][c0]<<endl;
        --S[rr][cc];
        if (I[rr][cc] > I[r0][c0]) {
          qr.push_back(rr);
          qc.push_back(cc);
          qd.push_back(d + 1);
        } else {
          qr.push_front(rr);
          qc.push_front(cc);
          qd.push_front(d);
        }
      } 
    }
  }
}

int main() {
  N = in();
  for (int i = 0; i < N * N; ++i) {
    int k = in() - 1;
    R[i] = k / N;
    C[i] = k % N;
    I[R[i]][C[i]] = i;
  }
  for (int r = 0; r < N; ++r) {
    for (int c = 0; c < N; ++c) {
      S[r][c] = min(min(r, N - r - 1), min(c, N - c - 1)) + 1;
    }
  }

  Int res = 0;
  // for (int i = 0; i < 2; ++i) {
  for (int i = 0; i < N * N; ++i) {
    // for (int r = 0; r < N; ++r) {
    //   for (int c = 0; c < N; ++c) {
    //     printf("%d ", S[r][c]);
    //   }
    //   puts("");
    // }
    // puts("");

    res += S[R[i]][C[i]] - 1;
    update(R[i], C[i]);
    --S[R[i]][C[i]];
  }
  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 8912
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair< ll, ll > P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll K, X;
  cin >> K >> X;
  if (500 * K >= X)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

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

ll price[4], pricePer2L[4];
bool av[4];
ll N;

int main() {
  for(int i = 0; i < 4; i++) {
    cin >> price[i];
    pricePer2L[i] = price[i] * (1 << (3 - i));
  }

  cin >> N;

  N *= 4;

  ll minPricePer2L = pricePer2L[0];

  av[0] = true;

  for(int i = 1; i < 4; i++) {
    if(pricePer2L[i] < minPricePer2L) {
      minPricePer2L = pricePer2L[i];
      av[i] = true;
    }
  }

  ll ans = 0;

  for(ll i = 3; i >= 0; i--) {
    if(av[i]) {
      ans += (N / (1 << i)) * price[i];
      N %= (1 << i);
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int x;
 	cin >> x;
 	if(x==3||x==5||x==7){
 		cout << "YES" << endl;
 	}else{
 		cout << "NO" << endl;
 	}
 }

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func f(n int) int {
  s := 0
  for n > 0 {
    s += n % 10
    n /= 10
  }
  return s
}

func main() {
  var n, a, b int
  fmt.Scan(&n, &a, &b)
  tot := 0
  for i := 1; i < n + 1; i++ {
    if s := f(i); s >= a && s <= b {
      tot += i
    }
  }
  fmt.Println(tot)
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
typedef struct pp{
    char name[100];
    int t;
}P;
  
P Q[LEN + 1];
int head=1, tail, n;
  
void enqueue(P x){
    Q[tail] = x;
 
if(tail >= LEN){
tail=0;
}
 
else{
    
        tail++;
}
     
}
  
P dequeue(){
    P y; 
y = Q[head];
 
  if(head >= LEN){
head = 0;
}
 
else{
    
        head++;
}  
    return y;
}
  
  
int main(){
    int i, q;
    int time=0;
    scanf("%d %d", &n, &q);
    tail=n+1;
 
    for (i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
        }
   
    while (head != tail){
        if (Q[head].t > q){ 
            Q[head].t -= q; 
            time += q;
            enqueue(dequeue(Q[head]));
        }
        else if (Q[head].t <= q){
            time += Q[head].t;
            printf("%s %d\n",Q[head].name,time);
            dequeue(Q[head]);
        }
    }
  
    return 0;
}

Measured memory_bytes: 10756
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int  N, X, T;
    while(cin>>N>>X>>T){
        cout<<(N+X-1)/X*T<<endl;
    }
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


Measured memory_bytes: 3156
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,k,s,ans=0;
  cin>>n>>k>>s;
  vector<ll>v(n,0);
  if(s==1e9){
    ll i=0;
    for(;i<k;i++){
      v[i]=1e9;
    }
    for(;i<n;i++){
      v[i]=1e9-1;
    }
  }
  else{
    ll i=0;
    for(;i<k;i++){
      v[i]=s;
    }
    for(;i<n;i++){
      v[i]=1e9;
    }
  }
  for(ll i=0;i<n-1;i++){
    cout<<v[i]<<" ";
  }
  cout<<v[n-1]<<endl;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
	int n,l,x[101]={0},a,i,j,k,m;
	char s[101][101];
	char al[26]={"abcdefghijklmnopqrstuvwxyz"};
	scanf("%d %d", &n, &l);
	for(i=0; i<n; i++)
	scanf("%s", &s[i]);
	for(i=0; i<n-1; i++)
	{
		for(j=i+1; j<n; j++)
		{
			for(k=0; k<l; k++)
			{
				a=0;
				for(m=0; m<26; m++)
				{
					if(s[i][k]==al[m]&&s[j][k]!=al[m])
					{
						x[j]++;
						a=1;
						break;
					}
					if(s[j][k]==al[m]&&s[i][k]!=al[m])
					{
						x[i]++;
						a=1;
						break;
					}
				}
				if(a==1)
				break;
			}
		}
	}
	for(i=0; i<n; i++)
	{
		a=n;
		for(j=0; j<n; j++)
		{
			if(a>x[j])
			{
				a=x[j];
				m=j;
			}
		}
		printf("%s", s[m]);
		x[m]=n;
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
import math
import fractions
import collections
import itertools
N=int(input())
l=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        l.append(1)
    else:
        l.append(0)
flag=0
#print(l)
for i in range(N-2):
    num=l[i]+l[i+1]+l[i+2]
    #print(i,i+1,i+2)
    if num==3:
        flag=1
        break
if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 72768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int mod = 1E9 + 7;
const int inf = 1 << 29;

int main() {
  char alpha;
  cin >> alpha;
  if (isupper(alpha)) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	map<string,int>m;
	m["Rock"]=1;
	m["Fire"]=2;
	m["Scissors"]=3;
	m["Snake"]=4;
	m["Human"]=5;
	m["Tree"]=6;
	m["Wolf"]=7;
	m["Sponge"]=8;
	m["Paper"]=9;
	m["Air"]=10;
	m["Water"]=11;
	m["Dragon"]=12;
	m["Devil"]=13;
	m["Lightning"]=14;
	m["Gun"]=15;
	int n;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		in.erase(unique(all(in)),in.end());
		if(in.size()==1){
			cout<<"Draw"<<endl;
			continue;
		}
		vi w(in.size());
		rep(i,in.size())w[i]=m[in[i]];
		bool h=false;
		rep(i,in.size()){
			bool hh=true;
			rep(j,in.size()){
				int t=w[i],s=w[j];
				if(t==s)continue;
				if(t>s&&t-s<8||t<s&&15-s+t<8)hh=false;
			}
			if(hh){
				h=true;
				cout<<in[i]<<endl;
				break;
			}
		}
		if(!h)cout<<"Draw"<<endl;
	}
}

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

using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    int* counter;
    counter = new int[N+1];
    int i;
    counter[0] = 0;
    for(i = 0; i < N; i++){
        counter[i+1] = counter[i] + ((S[i] == 'A'&& S[i+1] == 'C')? 1:0);
    }
    int head, tail;
    head = 0;
    tail = 0;
    for(i = 0; i < Q; i++){
        cin >> head >> tail;
        head = head -1;
        tail = tail - 1;
        cout << counter[tail] - counter[head] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};



template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> enum_divisor(ll x){
	ll tmp = x;
	vector<ll> res;
	for(ll i=1; i*i<=x; i++){
		if(tmp%i == 0){
			res.push_back(i);
			if(i*i != tmp) res.push_back(tmp/i);//iが√tmpのときは重複して数えないようにする
		} 
	}
	return res;
}

////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {

	ll N, M;
	cin >> N >> M;
	vector<ll> A(M);
	for(int i=0; i<M; i++) cin >> A[i];
	//print_vec(A);

	ll sum_days = 0;
	for(int i=0; i<M; i++){
		sum_days += A[i];
	}

	ll ans = N - sum_days;

	if(ans < 0) cout << "-1" << endl;
	else cout << ans << endl;
	

}



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


int main()
{
	int N;
	cin>>N;
	
	 int i,tot=0;
	for(i=1;i<=N;++i)
	{ 
		for(int j=1;j<=N;++j)
		{
			for(int k=1;k<=N;++k)
			{
				int temp;
				temp=__gcd(j,k);
				
				
				//cout<<k<<"# ";
				
				tot+=__gcd(i,temp);
			}
		}
	}
			cout<<tot<<endl;

}

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

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

inline void Main() {
  int n; cin >> n;
  vector<int> a(n), b;
  rep(i, n) cin >> a[i];
  sort(all(a));
  rep(i, n) {
    repi(j, 1, a[n-1] / a[i] + 1) {
      // cout << a[i] * j << endl;
      b.push_back(a[i] * j);
    }
  }
  sort(all(b));
  int r = 0;
  rep(i, n) {
    int x = upper_bound(all(b), a[i]) - lower_bound(all(b), a[i]);
    if (x >= 2) {
      // cout << i << endl;
      r++;
    }
  }
  cout << n - r << endl;
}

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


Measured memory_bytes: 20380
while True:
    n=int(input())
    max=0
    min=1000
    sum=0
    ave=0
    if n==0:
        break
    for i in range(n):
        s=int(input())
        sum+=s
        if s<min:
            min=s
        if max<s:
            max=s
    ave=(sum-min-max)//(n-2)
    print(ave)



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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int n;
	h >> n;
	vli v(n);
	f(i, 0, n, 1)
		h >> v[i];
	vli temp(n);
	temp[n - 1] = v[n - 1];
	fr(i, n - 2, 0, 1)
		temp[i] = (temp[i + 1] + v[i]) % modn;
	lli ans = 0;
	f(i, 1, n, 1)
		ans = (ans + ((v[i - 1] * temp[i]) % modn)) % modn;
	g << ans;

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 6364
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
boad = [None]*h
for i in range(h):
    boad[i] = list(input())
# print(boad)

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    for j in range(w):
        if boad[i][j] == '.':
            cnt = 0
            for k in range(8):
                x = i+dx[k]
                y = j+dy[k]
                if (x >= 0 and x < h) and (y >= 0 and y < w) and (boad[x][y] == '#'):
                    cnt += 1
                boad[i][j] = str(cnt)
for i in range(h):
    print(''.join(boad[i]))


Measured memory_bytes: 3832
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
	stack<int> st;
	int a, b;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			b = st.top(); st.pop();
			a = st.top(); st.pop();
			st.push(a + b);
		}
		else if (s[0] == '-') {
			b = st.top(); st.pop();
			a = st.top(); st.pop();
			st.push(a - b);
		}
		else if (s[0] == '*') {
			b = st.top(); st.pop();
			a = st.top(); st.pop();
			st.push(a * b);
		}
		else {
			st.push(atoi(s.c_str()));
		}
	}
cout << st.top() << endl;
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N;
vi P;

int main()
{
    cin >> N;
    P = vi(N);
    REP(i, N)
    {
        cin >> P[i];
    }

    vi Q = vi(N + 1);
    REP(i, N)
    {
        Q[P[i]] = i + 1;
    }

    ll ans = 0;
    set<ll> L = set<ll>();
    set<ll> R = set<ll>();
    L.insert(0);
    L.insert(-Q[N]);
    R.insert(N + 1);
    R.insert(Q[N]);
    for (ll i = N - 1; i > 0; --i)
    {
        ll j = Q[i];
        ll l1 = -(*L.upper_bound(-j));
        ll l2 = -(*L.upper_bound(-l1));
        ll r1 = *R.upper_bound(j);
        ll r2 = *R.upper_bound(r1);
        if (r1 <= N)
        {
            ans += i * (j - l1) * (r2 - r1);
        }
        if (l1 >= 1)
        {
            ans += i * (r1 - j) * (l1 - l2);
        }
        L.insert(-j);
        R.insert(j);
    }

    OUT(ans);
}

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

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<vector<ll>> dp(W+2,vector<ll>(H+1,0)); //0,W+1が範囲外の処理
  dp[1][0]=1;
  //x個の間で正しいあみだくじを作る方法は
  int fi[]={1,1,2,3,5,8,13,21,34,55};
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      dp[j][i]=dp[j-1][i-1]*fi[j-2]*fi[W-j]
        +dp[j][i-1]*fi[j-1]*fi[W-j]
        +dp[j+1][i-1]*fi[j-1]*fi[W-j-1];
      dp[j][i]%=1000000007;
    }
  }
  cout<<dp[K][H]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  deque<int> dq;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (i & 1)
      dq.push_front(a);
    else
      dq.push_back(a);
  }

  if (n & 1)
    reverse(dq.begin(), dq.end());

  int c = 0;
  for (auto d : dq) {
    if (c > 0)
      cout << " ";
    cout << d;
    c++;
  }
  cout << endl;
}


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

using namespace std;

int main()
{
    int n , k ;
    cin>>n>>k ;
    int cnt = 0 ;
    for(int i = 1 ; i <= n ; i += 2)
        cnt++;
    if(cnt >= k)
        return cout<<"YES\n" , 0 ;
    return cout<<"NO\n" , 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int a, b, c, d; cin >> a >> b >> c >> d;
    while(1) {
        if (c <= b) {
            cout << "Yes" << endl;
            return 0;
        }
        else c -= b;

        if (a <= d) {
            cout << "No" << endl;
            return 0;
        }
        else a -= d;
    }


    return 0;
}

Measured memory_bytes: 3624
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N=$key->A[0];
$S=$key->X[0][0];
$x = 0;
$max = 0;
for($i=0;$i<$N;$i++) {
  if ($S[$i]=='I') {
    $x++;
  }
  if ($S[$i]=='D') {
    $x--;
  }
  if ($x > $max) {
    $max = $x;
  }
}
printf("%d\n",$max);


Measured memory_bytes: 3832
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=2E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
template<class T>
bool scan(T &ret){
    char c;int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template<class T>
T gcd(T a,T b){
    return b==0?a:gcd(b,a%b);
}
template<class T>
T qpow(T a,T b,T mod){
    T ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(a*ret)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret%mod;
}
LL pre[maxn];
void solve(){
    int n;cin>>n;
    rep1(i,n){
        LL t;cin>>t;
        pre[i]=pre[i-1]+t;
    }
    LL x,y,ans=INF;
    rep1(i,n-1){
        x=pre[i],y=pre[n]-pre[i];
        ans=min(ans,abs(x-y));
    }
    cout<<ans<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#define maxn 100050
#define HR 1000000007
using namespace std;
int s[maxn],dp[maxn];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	s[0]=dp[0]=1;
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		for (int j=1;j<=k;j++)
		s[j]=(s[j-1]+dp[j])%HR;
		for (int j=1;j<=k;j++)
		if (j-x>0) dp[j]=(s[j]-s[j-x-1]+HR)%HR;else
			dp[j]=s[j];
	}
	printf("%d\n",dp[k]);
	return 0;
}

/*
dp[i][j]表示前i个人 一共分了j个的方案数
dp[i][j]=dp[i-1][j-k] (0<=k<=a[i]) 
前缀和优化 
*/

Measured memory_bytes: 896
import sys

if __name__ == '__main__':
    _ = sys.stdin.readline().rstrip()
    n = 0
    for line in sys.stdin.readlines():
        line = line.rstrip()
        a, b = list(map(lambda x:int(x), line.split(' ')))
        if a == b:
            n += 1
        else:
            n = 0
        if n == 3:
            print('Yes')
            exit()
    print('No')
        

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y)
{ 
    ll res = 1;  
    while (y > 0) { 
        if (y & 1) res = (res * x); 
        y = y >> 1;
        x = (x * x);   
    } 
    return res; 
}
vector <ll> vec;
void rec(ll ind, ll len) {
	ll add = 10;
	vec.pb(ind);
	ll tempind = ind % 10;
	if (len == 10) {
		return;
	}
	for (ll i = -1; i < 2; i++) {
		if (i == 1) {
			if (tempind != 9)
				rec(add * ind + i + tempind, len + 1);
		}
		else if (i == -1) {
			if (tempind != 0)
				rec(add * ind + i + tempind, len + 1);
		}
		else {
			rec(add * ind + i + tempind, len + 1);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for (ll i = 1; i <= 9; i++) {
    	rec(i, 1);
    }
    sort(all(vec));
    ll n;
    cin >> n;
    cout << vec[n - 1] << endl;
 	return 0;
}

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

bool isPrime(int x) {
    if (x == 2) {
        return true;
    }
    if (x < 2 || x % 2 == 0) {
        return false;
    }

    int MAX = sqrt(x);
    int i = 3;
    while (i <= MAX) {
        if (x % i == 0) {
            return false;
        }
        i = i + 2;
    }

    return true;
}

int minPrime(int x) {
    if (x == 2) {
        return 2;
    }
    if (x % 2 == 0) {
        x++;
    }
    
    while (true) {
        if (isPrime(x)) {
            return x;
        }
        x = x + 2;
    }
}

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

    cout << minPrime(x) << endl;

    return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
dist = [[] for i in range(N + 1)]
for i in range(M):
    a, b = getNM()
    dist[a].append(b)
    dist[b].append(a)

pos = deque([[1, 0]])
ignore = [-1] * (N + 1)
ans = [-1] * (N + 1)
ignore[1] = 0

while len(pos) > 0:
    u, time = pos.popleft()
    for i in dist[u]:
        if ignore[i] != -1:
            continue
        ignore[i] = time + 1
        ans[i] = u
        pos.append([i, time + 1])
ans.pop(0)
ans.pop(0)
flag = True
for i in ans:
    if i < 0:
        flag = False
if flag:
    print('Yes')
    for i in ans:
        print(i)
else:
    print('No')

Measured memory_bytes: 100052
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];

void solve(int mask, int sub, int a, int b){
	int n=__builtin_popcount(mask^sub);
	if (n==1){
		cout<<a<<' '<<b<<' ';
		return ;
	}
	int bit=__builtin_ctz(a^b), bit2=__builtin_ctz(mask^sub^(1<<bit));
	if (a&(1<<bit)){
		solve(mask, sub^(1<<bit), a, a^(1<<bit2));
		solve(mask^(1<<bit), sub, a^(1<<bit2)^(1<<bit), b);
	}
	else{
		solve(mask^(1<<bit), sub, a, a^(1<<bit2));
		solve(mask, sub^(1<<bit), a^(1<<bit2)^(1<<bit), b);
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>a>>b;
	if (__builtin_popcount(a^b)%2==0) kill("NO")
	cout<<"YES\n";
	solve((1<<n)-1, 0, a, b);
	
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
n = int(input())
s = dict(Counter(input()))
for i in range(n-1):
  c = Counter(input())
  for j,k in s.items():
    s[j] = min(k,c[j])
can_use = []
for i,j in s.items():
  for k in range(j):
    can_use.append(i)
can_use.sort()
print(*can_use,sep='')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string S; 
  cin>>S; 
  if(S=="hi"||S=="hihi"||S=="hihihi"||S=="hihihihi"||S=="hihihihihi"){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>
#include <chrono>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    ll n;
    cin >> n;
    vector<ll>ans(4,0);
    string s;
    rep(cnt, 0, n) {
        cin >> s;
        if (s == "AC") {
            ans.at(0)++;
        }
        else if (s == "WA") {
            ans.at(1)++;
        }
        else if (s == "TLE") {
            ans.at(2)++;
        }
        else if (s == "RE") {
            ans.at(3)++;
        }
    }
    cout << "AC x " << ans.at(0) << endl << "WA x " << ans.at(1) << endl << "TLE x " << ans.at(2) << endl << "RE x " << ans.at(3) << endl;

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)
bool check(string a){
	if(a[0]=='0'&&a[1]!='0')return true;
	else if(a[0]=='1'&&(a[1]=='0'||a[1]=='1'||a[1]=='2'))return true;
	
	return false;
}


int main(){
	string S;
	cin>>S;
	
	bool f1 = check(S.substr(0,2));
	bool f2 = check(S.substr(2));
	
	if(f1&&f2){
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(f1&&!f2){
		cout<<"MMYY"<<endl;
	}
	else if((!f1)&&f2){
		cout<<"YYMM"<<endl;
	}
	else{
		cout<<"NA"<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  string s;
  int k;
  cin >> s;
  cin >> k;
  string str = "bcdefghijklmnopqrstuvwxyza";
  string str2 = "abcdefghijklmnopqrstuvwxyz";
  int len = s.size();
  REP(i, len) {
    int cnt = 25 - str.find(s[i]);
    if (cnt <= k) {
      s[i] = 'a';
      k -= cnt;
    }
  }

  if (k > 0) {
    k %= 26;
    char _c = str2[str2.find(s[len - 1]) + k];
    s[len - 1] = _c;
  }

  cout << s << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int n;

map<int, int> prime_factor(ll n){
  map<int, int> res;
  for(int i = 2; i * i <= n; i++){
    while(n % i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

map<int, int> primes;

int main(){
  cin >> n;
  REP(i, n) {
    map<int, int> pf_i = prime_factor(i + 1);
    for(auto itr = pf_i.begin(); itr != pf_i.end(); itr++) {
      primes[itr->first] += itr->second;
    }
  }

  int num74 = 0, num24 = 0, num14 = 0, num4 = 0, num2 = 0;
  for(auto itr = primes.begin(); itr != primes.end(); itr++) {
    if(itr->second >= 74) num74++;
    if(itr->second >= 24) num24++;
    if(itr->second >= 14) num14++;
    if(itr->second >= 4) num4++;
    if(itr->second >= 2) num2++;
  }

  cout << num74 + num24 * (num2 - 1) + num14 * (num4 - 1) + num4 * (num4 - 1) / 2 * (num2 - 2) << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N_MAX 1000
#define MAX 100000
#define ERROR -1

int main(){
	int N=0,I[MAX],R[MAX],i,j,ans;
	scanf("%d",&N);
	if(N>N_MAX) return ERROR;
	for(i=0;i<N;i++){
		scanf("%d %d",&I[i],&R[i]);
		if(I[i]>R[i]) return ERROR;
	}
	for(j=0;j<i;j++){
		ans+=(R[j]-I[j])+1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,a=0,i;
  string s;
  cin>>n;
  map<string,long long>m;
  for(i=0;i<n;i++)
  {
    cin>>s;
    sort(s.begin(),s.end());
    a+=m[s];
    m[s]++;

  }
  cout<<a<<endl;

}


Measured memory_bytes: 11136
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ull unsigned long long
#define endl '\n'

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5+1;
const ll P = 31;
const double PI =  acos(-1.0);

int main() {
//  freopen("angle2.in", "r", stdin);
//  freopen("angle2.out", "w", stdout);
    IOS
    ll n;
    cin >> n;
    ll x = 1000;
    while(x < n) {
        x+=1000;
    }
    cout << x-n << endl;
}
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdlib>
#define NULL -1
using namespace std;

int main() {
	int  n, i;
	cin >> n >> i;
	cout << n - i + 1 << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
ll n,m,arr[sz],brr[sz],k,l,crr[sz],t,i,j,hi,lo,mi;
int main()
{
 scanf("%lld %lld",&n,&k);
 for(i=0;i<n;i++)
    scanf("%lld",&arr[i]);
 sort(arr,arr+n);
 for(i=0;i<k;i++)
    l+=arr[i];
 printf("%lld\n",l);
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, Q;
    cin >> N >> Q;
    vector<list<int>> v(N);
    while (Q--) {
        int q, t; cin >> q >> t;
        if (q == 0) {
            int x;
            cin >> x;
            v[t].push_back(x);
        } else if (q == 1) {
            bool f = false;
            for (auto& x  : v[t]) {
                if (f) cout << " ";
                cout << x;
				f = true;
            }
            cout << endl;
        } else {
            int u; cin >> u;
            v[u].splice(v[u].end(), v[t]);
            v[t].clear();
        }
    }
}


Measured memory_bytes: 18624
#include <stdio.h>

int A[500001],H;

void maxHeapify(int A[],int i){
    int l = i*2;
    int r = i*2+1;
    int largest,kari;

    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;

    if(r <= H && A[r] > A[largest]) largest = r;
    if(largest != i){
        kari = A[i];
        A[i] = A[largest];
        A[largest] = kari;
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int A[]){
  int i;
  for(i = H/2; i >= 1; i--) maxHeapify(A, i);
}



int main(){
    int i,p,l,r;

    scanf("%d",&H);
    for(i=1; i<=H; i++) scanf("%d",&A[i]);
    buildMaxHeap(A);

    for(i=1; i<=H; i++) printf(" %d",A[i]);
    printf("\n");
  
    return 0;
}


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

int main() {
  int a=0;
string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++){
  if(s.at(i)!=s.at(n-1-i)){a=1;
                           cout<<"No"<<endl;
                          break;}
  }
  
  if(a==0){for(int i=0;i<=(n-3)/2;i++){
  if(s.at(i)!=s.at(((n-3)/2)-i)){a=1;
                                cout<<"No"<<endl;
                                break;}
  }}
  if(a==0){cout<<"Yes"<<endl;}
}
 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int hpa, ata, hpb, atb;
    cin>>hpa>>ata>>hpb>>atb;
    while(true) {
        hpb -= ata;
        if(hpb <= 0) {
            cout<<"Yes";
            break;
        }
        hpa -= atb;
        if(hpa <= 0) {
            cout<<"No";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	int a;
	cin >> a;
	if (a < 3200) {
		put("red");
	} else {
		string s;
		cin >> s;
		put(s);
	}
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int cnt[26];

int main() {
    fastio();

    fill_n(cnt, 26, INT_MAX);

    int n;
    cin >> n;
    forn(i, n) {
        string s;
        cin >> s;
        vi temp(26);
        for (char c : s) {
            temp[c - 'a']++;
        }
        forn(j, 26) {
            chmin(cnt[j], temp[j]);
        }
    }

    string ans;
    forn(i, 26) {
        forn(j, cnt[i]) {
            ans.push_back(i + 'a');
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

int n,i,j,max,min;
int R[200000];

scanf("%d",&n);

for(i=0 ; i<n ; i++){
  scanf("%d",&R[i]);
  }

max=R[1]-R[0];
min=R[0];

for(i=1 ; i<n ; i++){
if(R[i]-min>max) max=R[i]-min;
if(R[i]<min) min=R[i]; 
}

printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n;
  cin >> n;
  string s;
  while(n>0) {
    n--;
    s += n%26+'a';
    n /=26;
  }
  reverse(rng(s));
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
    long long int X;
    cin>>X;
    if(X>=-40 && X<=40)
    {

        if(X>=30)
       {
           cout<<"Yes";

       }
       else
       {
           cout<<"No";
       }
    }
    return 0;

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int count=0;
  int l1=s.length();
  int l2=t.length();
  for(int i=0;i<l2;i++)
    	count+=(s[i]!=t[i]);
  for(int i=1;i<l1-l2;i++)
  {
        int c=0;
        for(int j=i;j<i+l2;j++)
    	    c+=(s[j]!=t[j-i]);
    	if(c<count)
    	    count=c;
  }
  cout<<count;
  return 0;
} 


Measured memory_bytes: 3584
N, K = (int(x) for x in input().split())
d = []
for i in range(1,N+1):
  d.append(i)
#print(d)
#dset = set(d)
for i in range(K):
    di = int(input())
    A = [int(x) for x in input().split()]
      #Aset = set(A)
#    print(A)
    for a in A:
      if a in d:
      	d.remove(a)
print(len(d))



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

vector<int> cnt(100005,0);

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    for(int i=0; i<M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        cnt[a-1]++, cnt[b-1]++;
    }
    bool flag = true;
    for(int i=0; i<N; i++) {
        if(cnt[i]%2) flag = false; 
    }
    cout << (flag ? "YES" : "NO") << "\n";
}

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

int main(){
    int n;
    cin >> n;
    vector<int64_t>  l(n+1);
    l.at(0) = 2;
    l.at(1) = 1;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 2;i<=n;i++){
        l.at(i) = l.at(i-1) + l.at(i-2);
    }
    cout << l.at(n) << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




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

int a,b,c;
cin>>a>>b>>c;
a=a+b+c;
if(a>=22)cout<<"bust"<<endl;
else cout<<"win"<<endl;



	return 0;
}


Measured memory_bytes: 256
import math
n, p = map(int, input().split())
gcd = 1
f = 2
upper = math.floor(math.pow(p, 1/n))

if n == 1:
  gcd = p
else:
  while True:
    if f > upper:
      break
    fn = f**n
    while p%fn == 0:
      gcd *= f
      p /= fn
    if f == 2:
      f = 3
    else:
      f += 2

print(gcd)


Measured memory_bytes: 3060