akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 414159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int t[N*8];

int ans[N];

vi adj[N];
map<int,int>m;

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(sum(v*2, tl, tm, l, min(r, tm))
           , sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] , t[v*2+1]);
    }
}


int n,k,a,b,c,d,x,y,arr[N];
string s;


void dfs(int u,int p)
{
    int x=sum(1,1,N,1,arr[u]-1);
    int y=sum(1,1,N,arr[u],arr[u]);
    ans[u]=max(x+1,t[1]);
    update(1,1,N,arr[u],x+1);
    for(auto i : adj[u])
    {
        if(i==p)continue;
        dfs(i,u);
    }
    update(1,1,N,arr[u],y);
}



void solve()
{
    cin>>n;
    forn(i,1,n)cin>>arr[i];

    vi A;
    forn(i,1,n)A.pb(arr[i]);
    sort(all(A));
    int k=2;
    forn(i,0,n-1)
    {
        if(!m[A[i]])m[A[i]]=k++;
    }

    forn(i,1,n)arr[i]=m[arr[i]];


    //forn(i,1,n)cout<<arr[i]<<" ";nl;

    forn(i,1,n-1)
    {
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1,0);
    forn(i,1,n)cout<<ans[i]<<"\n";
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 48276
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x,y;
    x=read(), y=read();
    int res=(y*1900+(x-y)*100)*(1ll<<y);
    printf("%lld\n",res);
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

bool check(const vi& a, const vi& b) {
    int d = 0;
    rep(i, 0, a.size()) { d += (a[i] - b[i]) * (a[i] - b[i]); }

    if (sqrt(d) - (int)sqrt(d) < EPS) { return true; }
    return false;
}

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

    int n, d;
    cin >> n >> d;

    vvi p(n, vi(d, 0));
    rep(i, 0, n) {
        rep(j, 0, d) { cin >> p[i][j]; }
    }

    int cnt = 0;
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            if (check(p[i], p[j])) { ++cnt; }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')
rgb = {'R', 'G', 'B'}

for i in range(n-1):
    for j in range(i+1, n):
        if j - i + j < n:
            if {s[i], s[j], s[j-i+j]} == rgb:
                ans -= 1

print(ans)


Measured memory_bytes: 68236
/*
ID: Aldew
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("lamps.in");
//ofstream fout("lamps.out");


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    while (k --){
        if (b <= a){
            b *= 2;
        }
        else {
            c *= 2;
        }
    }

    if (b > a && c > b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <queue> 

#define MAX 2000000
  
using namespace std;


void maxheapify(int [], int, int);
void build_heap(int heap[], int n);
void insert(int P[], int k);
void extract(int P[]);

int Pqueue[MAX], H = 0;

int main()
{
	priority_queue<int> pqueue;
	
	while (true)
	{
		string cmd;
		cin >> cmd;
		if (cmd == "end") break;
		else if (cmd == "insert")
		{
			int key;
			cin >> key;
			pqueue.push(key);
		}
		else if (cmd == "extract")
		{
			cout << pqueue.top() << endl;
			pqueue.pop();
		}
	}
}


void insert(int P[], int k)
{
	P[++H] = k;
	build_heap(P, H);
}

void extract(int P[])
{
	cout << P[1] << endl;
	P[1] = P[H--];
	maxheapify(P, H, 1);
	
}


void maxheapify(int heap[], int n, int node)
{
	int max = node, l = 2 * node, r = 2 * node + 1;
	if (l <= n && heap[node] < heap[l])
		max = l;
	if (r <= n && heap[max] < heap[r])
		max = r;
	
	if (max != node)
	{
		swap(heap[node], heap[max]);
		maxheapify(heap, n, max);
	}
}


void build_heap(int heap[], int n)
{
	for (int i = n/2; i >= 1; i--)
		maxheapify(heap, n, i);
}



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

int main(){
  int n;
  cin >> n;
  vector<int> f(n);
  for(int i=1; i<sqrt(n); i++){
    for(int j=1; j<sqrt(n); j++){
      for(int k=1; k<sqrt(n); k++){
        int m=i*i+j*j+k*k+i*j+j*k+k*i;
        if(m<=n){
        f[m-1]++;
        } 
      }
    }
  }

  rep(i, n){
    cout << f[i] << endl;
  }

  return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, m, op[100005];
LL rd, s[100005], dif[100005];

int act[100005], perm[100005], temp[100005];

void go(int A[100005], int B[100005]){
	FI(i, 1, n) temp[i] = B[A[i]];
}

int main(){
	scanf("%d", &n);
	FI(i, 1, n) scanf("%lld", &s[i]);
	scanf("%d %lld", &m, &rd);
	FI(i, 1, m) scanf("%d", &op[i]);
	FI(i, 1, n - 1) perm[i] = act[i] = i;
	FI(i, 1, m) swap(act[op[i] - 1], act[op[i]]);
	while(rd){
		if(rd & 1){
			go(perm, act);
			FI(i, 1, n - 1) perm[i] = temp[i];
		}
		go(act, act);
		FI(i, 1, n - 1) act[i] = temp[i];
		rd >>= 1;
	}
	
	LL cur = s[1];
	printf("%lld\n", cur);
	FI(i, 1, n - 1){
		cur += s[perm[i] + 1] - s[perm[i]];
		printf("%lld\n", cur);
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> frqs(M, 0);

  int k, a;
  for (int i = 0; i < N; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> a;
      frqs[--a] += 1;
    }
  }


  int num = 0;
  for(int frq: frqs){
    if(frq == N) num++;
  }

  cout << num << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
string S;
long long cnt;
struct Node
{
	int R, G, B;
}F[4005], B[4005];
int main()
{
	cin >> N >> S;
	F[0].R = 0;
	F[0].G = 0;
	F[0].B = 0;
	B[N - 1].R = 0;
	B[N - 1].G = 0;
	B[N - 1].B = 0;
	for (int i = 1; i < N; i++)
	{
		F[i] = F[i - 1];
		if (S[i - 1] == 'R')
		{
			F[i].R++;
		}
		else if (S[i - 1] == 'G')
		{
			F[i].G++;
		}
		else
		{
			F[i].B++;
		}
	}
	for (int i = N - 2; i >= 0; i--)
	{
		B[i] = B[i + 1];
		if (S[i + 1] == 'R')
		{
			B[i].R++;
		}
		else if (S[i + 1] == 'G')
		{
			B[i].G++;
		}
		else
		{
			B[i].B++;
		}
	}
	for (int i = 1; i < N; i++)
	{
		if (S[i] == 'R')
		{
			cnt += F[i].G * B[i].B + F[i].B * B[i].G;
		}
		else if (S[i] == 'G')
		{
			cnt += F[i].R * B[i].B + F[i].B * B[i].R;
		}
		else
		{
			cnt += F[i].G * B[i].R + F[i].R * B[i].G;
		}
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 1; i + 2 * j < N; j++)
		{
			if (S[i] != S[i + j] && S[i] != S[i + 2 * j] && S[i + j] != S[i + 2 * j])
			{
				cnt--;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll choose(ll n,ll k){
  ll x=n,y=1,ans=1;
  rep(i,k){
    ans=ans*x/y;
    x--;
    y++;
  }
  return ans;
}

int main() {
  ll n,p;
  cin >> n >> p;
  vl a(n);
  ll Z=0,O=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2==0){
      Z++;
    }
    else{
      O++;
    }
  }
  ll X=0;
  ll i=0;
  while(i<=O){
    if(i%2==0){
      X+=choose(O,i);
    }
    i++;
  }
  ll A;
  if(p==0){
    A=(ll)pow(2,Z);
    A*=X;
    cout << A << endl;
  }
  else{
    A=(ll)pow(2,Z);
    A*=((ll)pow(2,O)-X);
    cout << A << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  double A[n];
  double num = 0;
  for(int i = 0; i < n; i++){
    cin >> A[i];
    num += 1 / A[i];
  }
  double ans = 1 / num;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A[1000000];
ll B[1000000];
ll C[1000000]={};
ll N;
ll M;
ll K;

vector<int> target;
using Graph = vector<vector<int>>; //第一引数のノードは、その中のベクターにあるノードとつながりがある

bool visited[1000000];




void dfs(const Graph &G) {
    //cout << "start" << endl;
    ll tarsize= target.size();
    vector<int> next_target;
    ll next_v;
    rep(ti,tarsize){
        ll v = target[ti];
        //cout << "base " << v << endl;
        visited[v] = true; // v を訪問済にする
        // v から行ける各頂点 next_v について
        for (auto next_v : G[v]) { 
            //cout << next_v << endl;
            if (visited[next_v]) continue; // next_v が探索済だったらスルー
            C[next_v]=v;
            //cout << "in " << v << endl;
            visited[next_v]= true;
            next_target.push_back(next_v);
        }
    }
    target.clear();
    target = next_target;

    //cout << "next" << endl;
    if(target.size()>0) dfs(G); // 再帰的に探索


}
//以下を、main関数の中で使用

int main(){

    
    cin >> N;
    cin >> M;
    Graph G(N+10);
    rep(mi,M){
        cin >> A[mi];
        cin >> B[mi];
        G[A[mi]].push_back(B[mi]);
        G[B[mi]].push_back(A[mi]);
    }
    target.push_back(1);
    dfs(G);
       


    cout << "Yes" << endl;
    for( int ni = 2 ; ni <=N ; ni++ ){
        cout << C[ni] << endl;
    }

}

Measured memory_bytes: 25292
#include <stdio.h>
typedef struct Dice{
	int	f1;
	int	f2;
	int	f3;
	int	f4;
	int	f5;
	int	f6;
	int tmp;
}Dice;

int main(void)
{
	char roll;
	Dice D0;
	scanf("%d%d%d%d%d%d", &D0.f1, &D0.f2, &D0.f3, &D0.f4, &D0.f5, &D0.f6);
	while(scanf("%c", &roll) != EOF){
		D0.tmp = D0.f1;
		switch(roll){
			case 'E':
				D0.f1 = D0.f4;
				D0.f4 = D0.f6;
				D0.f6 = D0.f3;
				D0.f3 = D0.tmp;
				break;
			case 'N':
				D0.f1 = D0.f2;
				D0.f2 = D0.f6;
				D0.f6 = D0.f5;
				D0.f5 = D0.tmp;
				break;
			case 'S':
				D0.f1 = D0.f5;
				D0.f5 = D0.f6;
				D0.f6 = D0.f2;
				D0.f2 = D0.tmp;
				break;
			case 'W':
				D0.f1 = D0.f3;
				D0.f3 = D0.f6;
				D0.f6 = D0.f4;
				D0.f4 = D0.tmp;
				break;
			default:
				break;
		}
	}
	printf("%d\n", D0.f1);
	return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

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

#define f first
#define s second

typedef pair<int,int> pii;

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif

int n,m;
vector<pii> line;
vector<int> cut;

bool load = false;
bool input(){
	if(load)return false;
	
	cin>>n>>m;
	line = vector<pii>(n);
	cut = vector<int>(m);
	
	rep(i,n)cin>>line[i].f>>line[i].s;
	rep(i,m)cin>>cut[i];
	
	return load = true;
}

const int T = 111111;
const int N = 1111111111;
int A[T],B[T];
int sumA[T],sumB[T];

ll solve(){
	
	cut.push_back(0);
	cut.push_back(N-2);
	sort(cut.begin(),cut.end());
	
	rep(i,T)A[i]=B[i]=sumA[i]=sumB[i]=0;
	rep(i,cut.size()){
		int val = cut[i];
		if(i!=0)val-=cut[i-1];
		if(i%2==0)A[i]=val;
		else B[i]=val;
	}
	
	sumA[0]=A[0];
	reps(i,1,cut.size()){
		sumA[i] = sumA[i-1]+A[i];
		sumB[i] = sumB[i-1]+B[i];
	}
	ll sum = 0;
	/*
	rep(i,cut.size())printf("%3d ",A[i]);puts("");
	rep(i,cut.size())printf("%3d ",B[i]);puts("");
	rep(i,cut.size())printf("%3d ",sumA[i]);puts("");
	rep(i,cut.size())printf("%3d ",sumB[i]);puts("");
	*/
	rep(i,line.size()){
		int st = line[i].f;
		int en = line[i].s;
		
		int stnum = upper_bound(cut.begin(),cut.end(),st)-cut.begin();
		int ennum = upper_bound(cut.begin(),cut.end(),en)-cut.begin();
		
		bool sta = stnum%2==0;
		bool ena = ennum%2==0;
		
		int maxi = max(stnum, ennum);
		int mini = min(stnum, ennum);
		
		ll val = 0;
		
		
		if(stnum==ennum){
			if(st>en)val += st-en;
			else val+=en-st;
		}else{
			if(sta)val += sumA[maxi-1]-sumA[mini];
			else val += sumB[maxi-1]-sumB[mini];
			if(st>en){
				val += st-cut[stnum-1];
				if(sta==ena) val += cut[ennum]-en;
			}else{
				val += cut[stnum]-st;
				if(sta==ena) val += en-cut[ennum-1];
			}
		}
		
		//printf("st=%d  en=%d  stnum=%d  ennum=%d  sta=%d  ena=%d  maxi=%d  mini=%d\n",st,en,stnum,ennum,sta,ena,maxi,mini);
		//printf("i=%d val=%d\n",i,val);
		sum += val;
	}
	
	
	return sum;
}

void c_solve(){
	cout<<solve()<<endl;
}

int main(){
	while(input())c_solve();	
}

/*
1 8
200 100
5
15
25
35
45
55
65
75

*/

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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<pipii> vpipii;
typedef vector<vpipii> vvpipii;
typedef vector<vbool> vvbool;

int main(){FIN

	string s,t,ans;
	
	cin >> s >> t;
	vvpipii dp(SZ(s)+1,vpipii(SZ(t)+1,{-INF,{0,0}}));
	dp[0][0] = {0,{0,0}};
	
	fore(i,0,SZ(s)){
		fore(j,0,SZ(t)){
			if(s[i]==t[j]) dp[i+1][j+1] = max(dp[i+1][j+1],make_pair(dp[i][j].fst+1,make_pair(i,j)));
			dp[i+1][j] = max(dp[i+1][j],make_pair(dp[i][j].fst,make_pair(i,j)));
			dp[i][j+1] = max(dp[i][j+1],make_pair(dp[i][j].fst,make_pair(i,j)));
		}
	}
	pipii p = {0,{0,0}};
	fore(i,0,SZ(s)+1)
		fore(j,0,SZ(t)+1)
			p = max(p,make_pair(dp[i][j].fst,make_pair(i,j)));
	int a,b;
	pii ant,cur = p.snd;
	ans="";
	while(cur.fst || cur.snd){
		a = cur.fst;b=cur.snd;
		ant = dp[a][b].snd;
		if(ant == make_pair(a-1,b-1))ans+=s[a-1];
		cur = ant;
	}
	reverse(ALL(ans));
	cout << ans << "\n";
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> l(n+1), r(n+1);
    partial_sum(a.begin(), a.end(), l.begin()+1, [](ll x, ll y){return gcd(x, y);});
    partial_sum(a.rbegin(), a.rend(), r.rbegin()+1, [](ll x, ll y){return gcd(x, y);});

    ll ans = 0;
    rep(i, n) chmax(ans, gcd(l[i], r[i+1]));
    ppp(ans);


    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
  ll n;
  cin>>n;
  FOR(a,1,3501) FOR(b,1,3501){
    ll cons=4LL*a*b-n*(a+b);
    ll tg=n*a*b;
    if(cons<0) continue;
    int cl=1, cr=3500;
    while(cl!=cr){
      int mid=(cl+cr)/2;
      if(mid*cons>tg){
        cr=mid;
      }else if(mid*cons<tg){
        cl=mid+1;
      }else{
        cr=mid,cl=mid;
      }
    }
    if(cl*cons==tg){
      cout<<a<<" "<<b<<" "<<cl<<"\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a && c<=b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> x(N); vector<int> y(N); 
  for (int i=0; i<N; i++){
    cin >> x[i];
    cin >> y[i];
  }
  vector<double> factorial = {1.0, 1.0, 2.0, 6.0, 24.0, 120.0, 720.0, 5040.0, 40320.0};
  double factor = factorial[N-1] * 2.0;
  double sum = 0.0;

  vector<vector<double>> distance_path(N, vector<double>(N, 0));
  for (int i1 = 0; i1 < N; i1++){
    for(int i2 = 0; i2 < N; i2++){
      distance_path.at(i1).at(i2) = factor * sqrt(pow((x[i1] - x[i2]),2.0) + pow((y[i1] - y[i2]),2.0));
      sum += distance_path.at(i1).at(i2);
    }
  }

  double mean;
  mean = sum / factorial[N] / 2.0;

  cout << setprecision(15) << mean << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, s, l;

  scanf("%d%d", &a, &b);

  // 面積の計算
  s = a*b;
  // 周の長さの計算
  l = (a+b)*2;

  printf("%d %d\n", s, l);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <unordered_map> 
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    std::unordered_map<string, int> mp;
    long long int ans=0;

    for (int i = 0; i < n; i++) {
        string s;
        std::cin >> s;
        sort(s.begin(),s.end());
        if(mp[s]!=0){
            ans+=mp[s];
            mp[s]++;
        }else{
            mp[s]=1;
        }
    }
    std::cout << ans << std::endl;
}


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

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


int main(void){

    //Inputの値
    int n;//商品の種類
    int m;//選択する人気商品の個数
    
    //作業用変数
    int sum;//総得票数
    int counter;//選択した人気商品の数
    
    //初期値
    sum = 0;
    counter = 0;
    
    //値を獲得する。
    cin >> n >> m;
    
    //各商品の票数
    int A[n];
    
    //for分で得票数を取得する。併せて総得票数を計算する
    rep(i,n) cin >> A[i], sum += A[i];
    
    //人気商品か否かを確認し、人気商品の数を数える
    rep(i,n) if( A[i] * 4 * m  >= sum ) counter += 1;
    
    //人気商品がN個獲得できたかどうか確認する。
    if(counter >= m) cout << "Yes" << endl;
    else cout << "No" <<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n := nextFloat64()

	ans := math.Pow(2, (math.Floor(math.Log2(n))))

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<ll,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<ll> a(n);
	vector<P> p(m);
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}
	for (int i = 0; i < m; i++){
		cin>>p[i].second>>p[i].first;
	}

	sort(all(a));
	sort(all(p));
	reverse(all(p));

	int pos = 0;
	for (int i = 0; i < m; i++){
		int cnt = 0;
		while(a[pos]<p[i].first && cnt<p[i].second){
			a[pos] = p[i].first;
			cnt++;
			pos++;
		}
	}
	cout<<accumulate(all(a),0LL)<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main () {
    int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	vector<int> count(40,0);
	rep(i,40)
		rep(j,N)
			if ((A[j] >> i) & 1LL)
				count[i]++;
	ll ans = 0;
	rep(i,40) {
		ll x = K + 1;
		if (((x >> i) & 1LL) == 0)
			continue;
		x &= ~(1LL << i);
		for (int j=0; j < i; ++j) {
			if (count[j] > N - count[j]) {
				x &= ~(1LL << j);
			} else {
				x |= (1LL << j);
			}
		}
		ll cur = 0;
		rep(j,N)
			cur += x ^ A[j];
		ans = max(ans, cur);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;
struct bsrss{
	int s;
	int rs[305];
};
int main()
{
	int n,m;
	int t,t1;
	int anm[305][305]={0};
	cin >> n >> m;
	for(t=1;t<=n;t++)
	{
		anm[t][0] = 1;
		for(t1=1;t1<=m;t1++)
		{
			scanf("%d",&anm[t][t1]);
		}
	}
	bsrss *bsrs;
	bsrs = (bsrss*)malloc(sizeof(bsrss)*(m+1));
	for(t=1;t<=m;t++)
		bsrs[t].s = 0;
	int minn=-1,sc=0;
	for(t=1;t<=n;t++)
		bsrs[ anm[t][ anm[t][0]]].rs[bsrs[ anm[t][ anm[t][0]]].s++] = t;
	while(1)
	{
		int maxx = 0,w=0;
		for(t=1;t<=m;t++)
			if(maxx < bsrs[t].s)
			{
				maxx = bsrs[t].s;
				w = t;
			}
		if(minn > maxx ||minn==-1)	minn = maxx;
		sc++;
		if(sc == m)	break;
		for(t=0;t<bsrs[w].s;t++)
		{
			anm[bsrs[w].rs[t]][0] ++;
			while(bsrs[  anm[bsrs[w].rs[t]][anm[bsrs[w].rs[t]][0]]    ].s == -1)
				anm[bsrs[w].rs[t]][0] ++;
			bsrs[ anm[bsrs[w].rs[t]][ anm[bsrs[w].rs[t]][0]]].rs[bsrs[ anm[bsrs[w].rs[t]][ anm[bsrs[w].rs[t]][0]]].s++] = bsrs[w].rs[t];
		}
		bsrs[w].s = -1;
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String a = sc.next();
    String b = sc.next();
    if (a.equals(b)) {
      System.out.println("H");
    } else {
      System.out.println("D");
    }
  }
}

Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i, j;
    int n;

    int result = 0;

    scanf("%d", &n);
    for(i = 1; i <= n - 1; i++){
        //iはaのこと
        int b_max = n / i;
        if(b_max * i == n)
            result += b_max - 1;
        else
            result += b_max;


    }


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


    return 0;
}

Measured memory_bytes: 1732
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N,p[3],P,K;
string T;
char t[3]={'r','s','p'};
//たされたかどうか
bool used[100010];

int main(){

  cin>>N>>K>>p[1]>>p[2]>>p[0]>>T;
  fill(used,used+N+10,false);
  ll ans=0;
  REP(i,K){
    REP(j,3){
      if(t[j]==T[i]){
        ans+=p[j];
        used[i]=true;
      }
    }
  }
  FOR(i,K,N){
    REP(j,3){
      if(t[j]==T[i] && (T[i]!=T[i-K]||(T[i]==T[i-K] && used[i-K]==false))){
        ans+=p[j];
        used[i]=true;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;

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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;

int main()
{
	in >> N;
	std::vector<std::pair<LL, LL>>A(N);
	std::vector<LL>ans(N);
	rep(i, N)
	{
		in >> A[i].first;
		A[i].second = i;
	}
	std::sort(A.begin(), A.end());
	rep(i, N)
	{
		auto ter = A[i].second;
		if (i >= N / 2)
		{
			ans[ter] = A[N / 2 - 1].first;
		}
		else
		{
			ans[ter] = A[N / 2].first;
		}
	}
	rep(i, N) out << ans[i] << std::endl;
	return 0;
}


Measured memory_bytes: 6912
s=input()
n=len(s)

from collections import Counter
c=Counter()
m=0
c[m]+=1
d=1
s=s[::-1]
for i in range(n):
  m+=int(s[i])*d
  m%=2019
  d*=10
  d%=2019
  c[m]+=1
ans=0
for v in c.values():
  ans+=v*(v-1)//2
print(ans)


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n, m;
    cin >> n >> m;

    int count = 0;

    vector<int> coins(m);
    rep(i, m) cin >> coins[i];
    sort(coins.rbegin(), coins.rend());


    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i <= n; i++) {
        if (dp[i] == INT_MAX) continue;
        for (int j = 0; j < m; j++) {
            int value = coins[j];
            if (i + value > n) continue;
            cmin(dp[i + value], dp[i] + 1);
        }
    }

    cout << dp[n] << endl;

}




Measured memory_bytes: 3180
let input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
const inputArray = input.split('\n');
for (let i = 0; i < inputArray.length; i++) {
  const lineArray = inputArray[i].split(' ');
  const a = Number(lineArray[0]);
  const b = Number(lineArray[2]);
  const op = lineArray[1];
  if (op === '?') {
    break;
  } else if (op === '+') {
    console.log(a+b);
  } else if (op === '-') {
    console.log(a-b);
  } else if (op === '*') {
    console.log(a*b);
  } else if (op === '/') {
    console.log(Math.floor(a/b));
  };
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

li n;
li a[100100];
bool can[100100];

int main(void)
{
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);

	li sum = 0;
	rep(i, n) {
		sum += a[i];
		if (i == n - 1 ||  sum * 2 >= a[i + 1]) {
			can[i] = true;
		} else {
			can[i] = false;
		}
	}
	li res = 0;
	for (li i = n - 1; i >= 0; i--) {
		if (can[i]) {
			res++;
		} else {
			break;
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
pair<int,int> to[3001][3001];
int n,m,dp[3001][3001];
string s,t;

int main(){
	cin >> s >> t;
	n=s.size(),m=t.size();
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j < m ; j += 1){
			if(dp[i][j] > dp[i][j+1]){
				dp[i][j+1] = dp[i][j];
				to[i][j+1] = {i,j};
			}
			if(dp[i][j] > dp[i+1][j]){
				dp[i+1][j] = dp[i][j];
				to[i+1][j] = {i,j};
			}
			if(dp[i][j] > dp[i+1][j+1]){
				dp[i+1][j+1] = dp[i][j];
				to[i+1][j+1] = {i,j};
			}
			if(s[i] == t[j]){
				if(dp[i][j]+1 > dp[i+1][j+1]){
					dp[i+1][j+1] = dp[i][j] + 1;
					to[i+1][j+1] = {i,j};
				}
			}
		}
	}
	pair<int,int> curr;
	int val = 0;
	for(int i = 0 ; i <= n ; i += 1){
		for(int j = 0 ; j <= m ; j += 1){
			if(dp[i][j] > val){
				val = dp[i][j];
				curr = {i,j};
			}
		}
	}
	if(val == 0){
		return 0;
	}
	string ans="";
	while(curr.first > 0){
		pair<int,int> tt = to[curr.first][curr.second];
		if(dp[tt.first][tt.second] == dp[curr.first][curr.second]-1){
			ans += s[tt.first];
		}
		curr = tt;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 105856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadKey();

        }
    }
}


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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	VS s(n);
	VL t(n);
	string x;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i];
	}
	cin >> x;
	LL ans = 0;
	int f=0;
	for (int i = 0; i < n; i++) {
		ans += f*t[i];
		if (s[i] == x) {
			f=1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int n,k,i,flag,tmp;
    int d[10],cnt[10]={0};
    scanf("%d %d",&n,&k);
    for(i=0;i<k;i++){
        scanf("%d",&d[i]);
        cnt[d[i]]++;
    }
    for(i=n;;i++){
        tmp = i;
        flag = 1;
        for(;;){
            if(tmp==0) break;
            if(cnt[tmp%10]==1){
                flag = 0;
                break;
            }
            tmp/=10;
        }
        if(flag==1){
            printf("%d\n",i);
            break;
        }
    }
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    vector<int>adj[100005];
    vector<int>h(100005);
    vector<int>connect(100005);
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,m;
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>h[i];
        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            a--;
            b--;
            adj[a].push_back(b);
            connect[a]++;
            connect[b]++;
        }
        int total=0;
        vector<int>ans(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<adj[i].size();j++){
                if(h[i]>h[adj[i][j]])
                    ans[i]++;
                else if(h[i]<h[adj[i][j]])
                    ans[adj[i][j]]++;
            }
        }
        for(int i=0;i<n;i++){
            if(ans[i]==connect[i] || (connect[i]==0 && ans[i]==0))
                total++;
        }
        cout<<total;
        return 0;
    }


Measured memory_bytes: 8716
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  char num[6];
  int count=0,ans=0;
  for(int i=0;i<6;i++){
    cin>>num[i];
    if(num[i]=='1'){
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[110];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[i] % 10 != 0) {
			cout << sum - a[i] << endl;
			return 0;
		}
	}
	cout << "0" << endl;
	return 0;
}



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

using namespace std;
#define int long long


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

#define arr (int)(4e3)

int f[arr];
int rf[arr];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[arr-1]=powmod(f[arr-1],MOD-2, MOD);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

signed main(void)
{
	IOS;
	// int n;
	// cin>>n;
	// vi a(n); vi b(n);
	// for(int  i = 0; i < n; i++) {
	// 	cin>>a[i];
	// }
	// for(int i = 0; i < n; i++)
	// 	cin>>b[i];
	// vi c=a; vi d=b;
	// int cnt=0;
	// while(1) {
	// 	int no=0;
	// 	for(int i = 0; i < n; i++) {
	// 		if(d[i]!=a[i]) {
	// 			no=1;
	// 			break;
	// 		}
	// 	}
	// 	if(!no) {
	// 		cout<<cnt<<endl;
	// 		return 0;
	// 	}
	// 	if(!next_permutation(all(d))) {
	// 		break;
	// 	}
	// 	cnt++;
	// }
	// cnt=0;
	// while(1) {
	// 	// for(int i: c)
	// 	// 	cout<<i<<" ";
	// 	// cout<<endl;
	// 	// for(int i: b)
	// 	// 	cout<<i<<" ";
	// 	// cout<<endl;
	// 	int no=0;
	// 	for(int i = 0; i < n; i++) {
	// 		if(c[i]!=b[i]) {
	// 			no=1;
	// 			break;
	// 		}
	// 	}
	// 	if(!no) {
	// 		cout<<cnt<<endl;
	// 		return 0;
	// 	}
	// 	if(!next_permutation(all(c))) {
	// 		break;
	// 	}
	// 	cnt++;
	// }


	// int cnt=0;
	// int n; cin>>n;
	// string s; cin>>s;
	// for(int i = 0; i <= n-3; i++) {
	// 	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
	// 		cnt++;
	// 	}
	// }
	// cout<<cnt<<endl;

	int k,x; cin>>k>>x;
	if(k*500 >= x) {
		cout<<"Yes"<<endl;
	} else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    double a[n];
    double ave = 0;
    REP(i,n){
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;
    int ans = 0;
    double mn = INF;
    REP(i,n){
        if(abs(a[i] - ave) < mn){
            ans = i;
            mn = abs(a[i] - ave);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse2")
 
    #include <bits/stdc++.h>
    #include <vector> 
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
 
    #define int         long long
    #define ll          long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define mp          make_pair
    #define all(a)      (a).begin(),(a).end()
    #define FF           first
    #define SS           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define rep(i,a,b)  for(int i=a;i<b;i++)
     ll hell=1000000007;



   
  
    int solve(){  
       
        string s;
        cin>>s;
        cout<<s;
        if(s[s.size()-1]=='s')cout<<"es";else cout<<"s";


     return 0;
        
        }


    signed main()
    {       


 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
 
    int t=1,k=1;                                                                                                                  
    //cin>>t;
   
    while(t--)
    {
     
     // cout<<"Case #"<<k++<<": ";
     solve();
     //cout<<endl;
    }
    return 0;
    } 

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		sc.close();
		
		int s[] = new int[26];
		int t[] = new int[26];
		Arrays.fill(s, -1);
		Arrays.fill(t, -1);
		
		String ans ="Yes";
		for(int i=0;i<S.length();i++) {
			int a = S.charAt(i)-'a';
			int b = T.charAt(i)-'a';
			if(s[a]!=-1||t[b]!=-1) {
				if(s[a]!=b||t[b]!=a) {
					ans = "No";
					break;
				}
			}
			s[a]=b;
			t[b]=a;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27264
import sys
input=sys.stdin.readline
n=int(input())
ab=[]
for _ in range(n):
	a,b=map(int,input().split())
	ab.append((a,b))
ab.sort()
if n%2==1:
	m=ab[n//2][0]
else:
	m=(ab[n//2-1][0]+ab[n//2][0])
ab.sort(key=lambda x:x[1])
if n%2==1:
	M=ab[n//2][1]
else:
	M=(ab[n//2-1][1]+ab[n//2][1])
print(M-m+1)

Measured memory_bytes: 95652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int n, k; cin >> n >> k;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  int ans = 1e9;
  rep(i,n-k+1) {
    if (arr[i] >= 0) {
      ans = min(ans, arr[i+k-1]);
      continue;
    }
    if (arr[i+k-1] <= 0) {
      ans = min(ans, -arr[i]);
      continue;
    }
    int left = abs(arr[i]);
    int right = abs(arr[i+k-1]);
    int tmp = left + right + min(left, right);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 640
from functools import lru_cache
import sys

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

@lru_cache(maxsize=None)
def dp(i):
    if i == 1 or i == 2:
        return 0
    elif i == 3 or i == 4:
        return 1
    else:
        return (dp(i - 3) + dp(i - 1)) % mod


S = int(input())
print(dp(S))


Measured memory_bytes: 10164
#include <iostream>

void solve() {
    int a, b, c;
    std::cin >> a >> b >> c;

    for (int k = 0; k < b; ++k) {
        if ((a * k) % b == c) {
            std::cout << "YES" << std::endl;
            return;
        }
    }

    std::cout << "NO" << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256