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

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

using namespace std;
using ll = long long;

int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 | c % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min({a * b, b * c, c * a}) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    char s[100];
    char t[100];
    char u[100];

    int n, i;
    int a, b;
    scanf("%s", s);
    scanf("%s", s);
    for (i = 0; i < strlen(s); i++)
    {
        s[i] = s[i];
    }
    for (i = 0; i < strlen(t); i++)
    {
        t[i] = t[i];
    }
    scanf("%d", &a);
    scanf("%d", &b);

    scanf("%s", u);
    for (i = 0; i < strlen(u); i++)
    {
        u[i] = u[i];
    }

    if (strcmp(s, u) == 0)
    {
        b--;
    }
    else
    {
        a--;
    }
    printf("%d %d\n", a, b);
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long unsigned
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 1000005
#define mod 2000003
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;
int a[5],n;
int main() {
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);
    cin>>a[1]>>a[2]>>a[3];
    n=3;
    sort(tot(a));
    if(a[1]+a[2]==a[3])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}




Measured memory_bytes: 764
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> X;
  vector<ll> x;
  x.push_back(X);
  

  rep(i, N) {
  	cin>> X;
    x.push_back(X);
  }
  if (N==1) {
    cout << abs(X-x[0]) << endl;
    return 0;
  }
  sort(ALL(x));
  ll kyori[N];
  ll gcd_now;
  rep_s(i, 1, N+1) {
  	if (i==1) gcd_now = x[i] -x[i-1];
  	gcd_now = gcd(gcd_now, x[i]-x[i-1]);
  }
  //cout << "X: " << X << ", x[0]:" << x[0] << endl;
  cout << gcd_now << endl;
 
}


Measured memory_bytes: 1400
int T[20][20],X,Y,x,y,p,q,i,c;
void R(x,y){(0<=x&&x<X&&0<=y&&y<Y&&!T[y][x])?T[y][x]=1,i++,R(x-1,y),R(x+1,y),R(x,y-1),R(x,y+1):0;}
main(){for(;scanf("%d%d",&X,&Y),X;printf("%d\n",i)){
	for(i=0;i<X*Y;i++){
		for(x=i%X,y=i/X;(c=getchar())=='\n';);
		switch(c){
			case'@':p=x;q=y;
			case'.':T[y][x]=0;break;
			case'#':T[y][x]=1;
		}
	}
	i=0;R(p,q);
}exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(m[x]==0) v.push_back(x);
		m[x]++;
	}
	int ans=0;
	for(int i=0;i<v.size();i++)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main() {
	ll N, C, K;
	cin >> N >> C >> K;
	vector<ll> t(N);
	for (int i = 0; i < N; ++i) { cin >> t[i]; }
	sort(t.begin(), t.end());

	int res = 1;
	int cnt = 1;
	int lim = t[0] + K;
	for (int i = 1; i < N; ++i) {
		if ((t[i] > lim) || (cnt >= C)) {
			++res;
			lim = t[i] + K;
			cnt = 1;
		} else {
			++cnt;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
INF = 105 * 10**7
dp = [INF] * 100010

N = int(input())
h = list(map(int, input().split())) + [0] * 10

dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))

print(dp[N-1])


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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    string s;
    cin >> s;

    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;

    return 0;
}

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

const int N=20;

int n,a[N],x,y,ans;
vector <pair <int,int>> v[N];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		for(int j=0;j<a[i];j++)
		{
			scanf("%d%d",&x,&y);
			v[i].push_back({--x,y});
		}
	}

	for(int mask=0;mask<(1<<n);mask++)
	{
		bool ok=true;
		vector <int> dp(n,-1);
		for(int i=0;i<n and ok;i++)
		{
			if(!(mask&(1<<i))) continue;
			for(auto p:v[i])
			{
				if(dp[p.first]==-1) dp[p.first]=p.second;
				if(dp[p.first]!=p.second) ok=false;
			}
		}

		for(int i=0;i<n and ok;i++)
		{
			if(!(mask&(1<<i))) continue;
			for(auto p:v[i])
				if((p.second==1) ^ (((mask&(1<<p.first))>0))) ok=false;
		}

		if(ok) ans=max(ans,__builtin_popcount(mask));
	}

	printf("%d",ans);
}

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>

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

using namespace std;


int main(){
	int H, W, N; cin >> H >> W >> N;
	vector<long long> res(10,0);
	map<pair<int, int>, int> count;
	rep(i,N){
		int a,b; cin >> a >> b;
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				int x = a + i - 1; int y = b + j - 1;
				pair<int, int> cord = make_pair(x,y);
				if(x <= 0|| x >= H-1 || y <= 0 || y >= W-1)
					continue;
				auto itr = count.find(cord);
				if(itr != count.end()){
					int temp = count[cord];
					count[cord]++;
					res[temp]--;
					res[temp+1]++;
				}
				else{
					count[cord] = 1;
					res[1]++;
				}
			}
		}
	}
	int sum = 0;
	rep(i,10)
		sum += res[i];
	cout << ((long long)(H-2)*(W-2)) - sum << endl;
	rep(i,9)
		cout << res[i+1] << endl;
}

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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


ll bx(ll n)
{
  ll temp=10;
  while(n)
  {
    temp=min(temp,n%10);
    n/=10;
  }
  return temp;
}

ll ax(ll n)
{
  ll temp=0;
  while(n)
  {
    temp=max(temp,n%10);
    n/=10;
  }
  return temp;
}



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

ll n,x=0,cnt=0,y=0;
cin>>n;
//set<<ll>s;

vl a(n+1),store(n+1),ans(n+1);


for(int i=1;i<=n;i++)cin>>a[i];

  for(int i=n;i>=1;i--)
  {
   //ans[i]=store[i];
   store[i]%=2;
   if(store[i]!=a[i])ans[i]=1;
//if(i==3)cout<<store[3]<<"\n";
    ll j;
    if(ans[i])
      {
        cnt++;
    for( j=1;j*j<i;j++)
    {
        if(i%j==0)
        {
          if(j!=i/j)
            {
              store[j]++;
             if(j!=1) store[i/j]++;
            }
        }

  
    }
          if(j*j==i&&i!=1)store[j]++;
    
    }
   // store[i]=a[i];
  }

//cout<<store[3]<<"\n";

 /* for(int i=1;i<=n/2;i++)
  {
    store[i]%=2;
    if(a[i]!=store[i])store[i]=1;
    else store[i]=0;
    if(store[i])cnt++;
  }*/
cout<<cnt<<"\n";
  for(int i=1;i<=n;i++)if(ans[i])cout<<i<<" ";

cout<<endl;

return 0;

}

Measured memory_bytes: 5632
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	long long ans = k;
	for (int i = 1; i < n; i++) {
		ans *= k - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int n1 = n / 100;
    int n2 = (n % 100) / 10;
    int n3 = n % 10;
    if (n1 == 7 || n2 == 7 || n3 == 7)
    {
        printf("Yes", n);
    }
    else
    {
        printf("No", n);
    }
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int A , B , C , K;
	cin >> A >> B >> C >> K;

	while (K>0&&A>=B) {
		B *= 2;
		K--;
	}
	while (K > 0 &&B >= C) {
		C *= 2;
		K--;
	}
	if (A<B&&B<C) {
		cey;
	}
	else {
		cen;
	}

    return 0;
}



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

using namespace std;

#define rg register
#define In inline
#define ll long long

const int N = 500;

typedef pair<int,int>pii;

namespace IO{
	In ll read(){
		ll s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s  + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(ll x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
}
using namespace IO;

int f[N+5][N+5],p[N*N+5];
int n;
int mx[4] = {0,-1,0,1};
int my[4] = {1,0,-1,0};
bool stay[N+5][N+5];

queue<pii>q;

In bool check(int x,int y){
	return 1 <= x && x <= n && 1 <= y && y <= n;
}

void bfs(int sx,int sy){
	q.push(make_pair(sx,sy));
	while(!q.empty()){
		int x = q.front().first,y = q.front().second;
		q.pop();
		for(rg int i = 0;i < 4;i++){
			int xx = x + mx[i],yy = y + my[i];
			if(check(xx,yy) && f[x][y] + stay[x][y] < f[xx][yy]){
				f[xx][yy] = f[x][y] + stay[x][y];
				q.push(make_pair(xx,yy));
			}
		}
	}
}

int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	n = read();
	for(rg int i = 1;i <= n * n;i++)p[i] = read();
	for(rg int i = 1;i <= n;i++)
		for(rg int j = 1;j <= n;j++)f[i][j] = min(min(i-1,j-1),min(n-i,n-j));
	int ans = 0;
	for(rg int i = 1;i <= n;i++)
		for(rg int j = 1;j <= n;j++)stay[i][j] = 1;
	for(rg int i = 1;i <= n * n;i++){
		int x = (p[i] - 1) / n + 1;
		int y = (p[i] - 1) % n + 1;
		ans += f[x][y];
		stay[x][y] = 0;
		bfs(x,y);
/*cout<<"leaving: "<<p[i]<<" ";cout<<endl;
for(rg int j = 1;j <= n;j++){
	for(rg int k = 1;k <= n;k++)cout<<f[j][k]<<" ";cout<<endl;
}*/
	}
	write(ans),putchar('\n');
	return 0;
}

Measured memory_bytes: 5788
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

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

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

int main(){
  int n,ans=1,c=0;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="A") c++;
    else c--,ans*=(c>=0);
  }

  cout <<(ans&&!c? "YES":"NO")<<endl;
  return 0;
}

Measured memory_bytes: 3172
implicit none
integer:: n,i
integer,allocatable,dimension(:):: t,x,y,x_a,y_a,t_a

read(5,*) n

allocate(t(n))
allocate(x(n))
allocate(y(n))
allocate(x_a(n))
allocate(y_a(n))
allocate(t_a(n))

do i=1,n
    read(5,*) t(i), x(i), y(i)
enddo

x_a(1)=x(1)
y_a(1)=y(1) 
t_a(1)=t(1) 

do i=2,n
    x_a(i)=abs(x(i)-x(i-1))
    y_a(i)=abs(y(i)-y(i-1))    
    t_a(i)=abs(t(i)-t(i-1))     
enddo

do i=1,n
    if (mod(t_a(i),2)/=mod(x_a(i)+y_a(i),2) .or. t_a(i)<x_a(i)+y_a(i)) then
        write(6,*) "No"
        goto 100
    endif
enddo

write(6,*) "Yes"

100 end


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    UL dp[10001] = {};

    void Solve() {
        UL N, W; cin >> N >> W;
        rep(i, N) {
            UL v, w; cin >> v >> w;
            for (UL t = W; t >= w; t--) {
                dp[t] = max(dp[t], dp[t - w] + v);
            }
        }
        UL ans = 0;
        rep(w, W + 1) ans = max(ans, dp[w]);
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    total = sum(A)
    Q = int(input())
    for _ in range(Q):
        B, C = map(int, input().split())
        total = total + (C - B) * cnt[B]
        cnt[C] += cnt[B]
        cnt[B] = 0
        print(total)
if __name__ == "__main__":
    main()

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

typedef long long int ll;

using namespace std;

void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
	
	int n;
	cin>>n;
	vector <pair<string,int>> v(n);
    for(int i=0;i<n;i++)
    {
        string s;
        int t;
        cin>>s;
        cin>>t;
        v[i]=make_pair(s,t);
    }
    string x;
    cin>>x;
    bool flag=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(flag)
            sum+=v[i].second;
        if(v[i].first==x)
            flag=1;

    }
    cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
card_list = list(map(int, input().split()))

card_list.sort()
card_list.reverse()

Alice = 0
Bob = 0

for i in range(N):
    if i % 2 == 0:
        Alice += card_list[i]
    else:
        Bob += card_list[i]
        
print(Alice - Bob)
        

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	long long h, w;
	cin >> h >> w;
	long long a[3];
	long long ans[10];
	a[0] = h / 3 * w;
	a[1] = (h - h / 3) / 2 * w;
	a[2] = h * w - a[0] - a[1];
	ans[0] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = h / 3 * w;
	a[1] = w / 2 * (h - h / 3);
	a[2] = h * w - a[0] - a[1];
	ans[1] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = w / 3 * h;
	a[1] = (w - w / 3) / 2 * h;
	a[2] = w * h - a[0] - a[1];
	ans[2] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = w / 3 * h;
	a[1] = h / 2 * (w - w / 3);
	a[2] = w * h - a[0] - a[1];
	ans[3] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = (h / 3 + 1) * w;
	a[1] = (h - h / 3 - 1) / 2 * w;
	a[2] = h * w - a[0] - a[1];
	ans[4] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = (h / 3 + 1) * w;
	a[1] = w / 2 * (h - h / 3 - 1);
	a[2] = h * w - a[0] - a[1];
	ans[5] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = (w / 3 + 1) * h;
	a[1] = (w - w / 3 - 1) / 2 * h;
	a[2] = w * h - a[0] - a[1];
	ans[6] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	a[0] = (w / 3 + 1) * h;
	a[1] = h / 2 * (w - w / 3 - 1);
	a[2] = w * h - a[0] - a[1];
	ans[7] = max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]);
	sort(ans, ans + 8);
	cout << ans[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int n, k; cin >> n >> k;
	int ma = (n - 1)*(n - 2) / 2;
	if (ma < k)cout << -1 << endl;
	else {
		vector<pii>res;
		for (int i = 1; i <= n - 1; ++i) {
			res.push_back({ i,n });
		}
		int rem = ma - k;
		int ci = 1, cj = 2;
		for (int i = 0; i < rem; ++i) {
			res.push_back({ ci,cj });
			++cj;
			if (cj == n) {
				++ci;
				cj = ci + 1;
			}
		}
		cout << res.size() << endl;
		for (auto p : res) {
			cout << p.first << " " << p.second << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S; char c = 'a';
    sort(S.begin(), S.end());
    for (int i = 0; i < S.length(); ++i) {
        if (c == S[i]) c = (char)((int)c + 1);
    }
    if (c > 'z') printf("%s\n", "None");
    else printf("%c\n", c);
}


Measured memory_bytes: 3816
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
A=list(map(int,input().split()))
A.append(0)
A.insert(0,0)
B=[0]
C=[0]
for i in range(n+1):
  B.append(gcd(B[-1],A[i+1]))
  C.append(gcd(C[-1],A[n-i]))
ans=1
for i in range(n):
  c=gcd(B[i],C[n-i-1])
  if c>ans:
    ans=c
print(ans)

Measured memory_bytes: 14436
import java.util.Scanner;

class Main{

	//static long[] a;



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();

		int[] A =new int[N+1];

		int sum = 0;
		int p = 0;
		for(int i = 0;i < N;i++){					///合計の算出
			A[i] =sc.nextInt();
			sum +=  Math.abs(A[i] - p);
			p = A[i];
		}
		A[N] = 0;
		sum +=  Math.abs(A[N] - p);


		int[] ans = new int[N];

		for(int i= 0;i < N;i++){
			int subp = 0;

			if(i == 0){
				subp = 0;
			}else{
				subp = A[i-1];
			}
			int subsum1 = 0;
			subsum1 = Math.abs(A[i] - subp);
			subp = A[i];
			subsum1 +=Math.abs(A[i+1] - subp);

			int subsum2 = 0;
			if(i == 0){
				subsum2 = Math.abs(A[i+1] - 0);
			}else{
				subsum2 = Math.abs(A[i+1] - A[i-1]);
			}
			ans[i] = sum - Math.abs(subsum1-subsum2);
		}

		for(int i = 0;i < N;i++){
			System.out.println(ans[i]);
		}

	}
}




Measured memory_bytes: 64716
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int a,b,k;
	cin >> a >> b >> k;
	if(b-a+1 < 2*k) for(int i = a; i <= b; i++)printf("%d\n",i);
	else {for(int i = a; i < k+a; i++) printf("%d\n",i);
	for(int i = b-k+1; i <= b; i++) printf("%d\n",i);
	}
	return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int a, b, cnt = 0;
    string s, front, end;
    cin >> a >> b;
    REP(i, a, b + 1)
    {
        s = to_string(i);
        front = s.substr(0, 2);
        end = s.substr(3, 2);
        reverse(all(end));
        if (front == end)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

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

  long long a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);

  long long res = 1;
  for (int i = 0; i < n; ++i) {
    if (res == 0) break;
    if (a[i] > 1000000000000000000 / res) {
      cout << -1 << endl;
      return 0;
    }
    
    res *= a[i];
  }

  cout << res << endl;
}


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

int main()
{
    int a,b;
    
    cin >> a >> b;
    
    if(a > b)
        cout << "a > b" << endl;
    else if(a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	string s;
	cin >> s;
	int i = 0,even_zero = 0,even_one = 0,odd_zero = 0,odd_one = 0;
	while(s[i] != '\0'){
		if(i % 2 == 0){
			if(s[i] == '0'){
				even_zero++;
			}else{
				even_one++;
			}
		}else{
			if(s[i] == '0'){
				odd_zero++;
			}else{
				odd_one++;
			}
		}
		i++;
	}
	cout << min(even_zero + odd_one, even_one + odd_zero) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
	int N, AC=0,WA=0,TLE=0,RE=0;
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		char S[100];
		scanf("%s", &S);
		if (S[0]=='A'){
			AC+=1;
			continue;
		}
		else if (S[0]=='W'){
			WA++;
			continue;
		}
		else if (S[0]=='T'){
			TLE++;
			continue;
		}
		else if (S[0]=='R'){
			RE++;
			continue;
		}
		
	
		
		
	}
	printf("\nAC x %d\nWA x %d\nTLE x %d\nRE x %d\n", AC,WA,TLE,RE);
	
	
	return 0;
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long m,n;
	cin>>m>>n;
	long long sum = 0,x;
	for(int i=0;i<n;++i)
		cin>>x, sum+=x;
	cout<<max(m-sum,-1LL);
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;

const int mod = 1000003;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<mint> prod(mod);//, prodinv(mod);
    prod[0]=1;
    //prodinv[mod-1]=-1;
    rep2(i,1,mod)prod[i]=prod[i-1]*i;
    //rep2(i,1,mod)prodinv[mod-i-1]=mint(mod-i)*prodinv[mod-i];
    //rep2(i,0,mod)prodinv[i]=prod[i].inv();
    ll q;cin>>q;
    rep(i,q){
        ll x,d,n;cin>>x>>d>>n;
        mint mx=mint(x),md=mint(d);
        if(d==0){cout<<mx.pow(n).x<<endl;continue;}
        mint l = mx/md;
        mint r = (mx+md*(n-1))/md;
        if(n>=mod||r.x<l.x){cout<<0<<endl;continue;}
        cout<<(prod[r.x]/prod[l.x-1]*md.pow(n)).x<<endl;

    }
    return 0;
}

Measured memory_bytes: 8704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=5010,M=210;
int nxt[N][M];
lint x[N],a[N][M],dt[N];
int main(){
	int n=ni,m=ni;
	for(int i=2;i<=n;i++){
		x[i]=x[i-1]+ni;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			a[i][j]=ni;
		}
	}
	memset(dt,0,sizeof(dt));
	lint ans=0;
	for(int i=n;i>=1;i--){
		lint cur=0;
		for(int j=1;j<=m;j++){
			cur+=a[i][j];
			dt[i+1]+=a[i+1][j]-a[i][j];
			for(int &k=nxt[i][j]=i+1;k<=n&&a[i][j]>=a[k][j];k=nxt[k][j]){
				dt[k]-=a[k][j]-a[i][j];
				dt[nxt[k][j]]+=a[k][j]-a[i][j];
			}
		}
		for(int j=i;j<=n;j++){
			cur+=dt[j];
			apmax(ans,cur-(x[j]-x[i]));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12672
#include<stdio.h>
int main(){
    int D,N;
    scanf("%d",&D);
    scanf("%d",&N);
    
    if(D == 0 && N != 100){
        printf("%d",N);
    }else if(D == 0 && N == 100){
        printf("101");
    }else if(D == 1 && N != 100){
        printf("%d",N*100);
    }else if(D == 1 && N == 100){
        printf("10100");
    }else if(D == 2 && N != 100){
        printf("%d",N*10000);
    }else{
        printf("1010000");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	vector<char> s(9);
	rep(i, 9) {
		cin >> s[i];
	}
	cout << s[0] << s[4] << s[8] << endl;
}	

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ll = long long int;
using ha = pair<ll, ll>;
struct RollingHash {
	static const ll mul0 = 10003, mul1 = 10007;
	static const ll add0 = 1000010007, add1 = 1003333331;
	size_t len;
	//vector<ll> hash_, hash2_;
	vector<ha>hash_;
	//static vector<ll> pmo_, pmo2_;
	static vector<ha>pmo_;
	void init(const vector<ll>& s) {
		len = s.size();
		hash_.resize(len + 1);
		hash_[0] = make_pair(0, 0);

		if (pmo_.empty()) {
			pmo_.push_back(make_pair(1, 1));
		}
		while (pmo_.size() <= len) {
			pmo_.push_back(make_pair(pmo_.back().first*mul0, pmo_.back().second*mul1));
		}
		for (unsigned int i = 0; i < len; ++i) {
			hash_[i + 1] = make_pair((hash_[i].first * mul0 + s[i]), (hash_[i].second*mul1 + s[i]));
		}
		return;
	}
	void init(const string& s) {
		vector<ll>v;
		for (char c : s) {
			v.push_back(c);
		}
		init(v);
	}
	ha hash(const int l, const int r)const { // s[l..r]
		return make_pair(hash_[r + 1].first - hash_[l].first * pmo_[r + 1 - l].first,
			hash_[r + 1].second - hash_[l].second * pmo_[r + 1 - l].second);
	}
	ha  hash()const { // s[all]
		return hash(0, len - 1);
	}

	//hash????????????
	static ha concat(const ha L, const ha R, const int RLength) { // hash(L+R) 
		return make_pair((R.first + L.first*pmo_[RLength].first), (R.second + L.second*pmo_[RLength].second));
	}

	//index????????????from??????to????????????????????????????????\????????????
	ha get_changed_hash(const int index, const ll from, const ll to)const {
		const ha p(hash());
		return make_pair(
			p.first + (to - from) * pmo_[len - index - 1].first,
			p.second + (to - from) * pmo_[len - index - 1].second);
	}
};
vector<ha> RollingHash::pmo_;

int main() {
	int N; cin >> N;
	vector<long long int>as(N);
	for (int i = 0; i < N; ++i) {
		cin >> as[i];
	}
	RollingHash rh;
	rh.init(as);
	int ans = 1;
	for (int i = 1; i < N; ++i) {
		bool ok = true;
		int l = 0;
		int nl = l + i;
		while(nl < N) {
			int nsize = min(i, N - nl);
			if (rh.hash(l, l + nsize - 1) != rh.hash(nl, nl + nsize - 1)) {
				ok = false;
			}
			l = nl;
			nl = l + i;
		}
		if (ok&&(N%i)==0) {
			ans = (N - 1) / i + 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11692
# coding: utf-8
# Your code here!
def main():
    numbers = int(input())
    result = 0
    for number in range(1,numbers+1):
        if number % 3 != 0 and number % 5 != 0:
            result += number
    print(result)
    
if __name__ == "__main__":
    main()
    


Measured memory_bytes: 9164
#include<stdio.h>
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	int i,m[n],sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
		sum=sum+m[i];
		}
		x=x-sum;
		int low=1000;
		for(i=0;i<n;i++){
			if(low>m[i]){
				low=m[i];
				}
			}
		int r=x/low;
		printf("%d",n+r);
	return 0;
	}


Measured memory_bytes: 128
import static java.lang.System.*;
import java.util.*;

class Cost {
	int x, y, c;
	
	Cost(int _x, int _y, int _c) {
		x = _x;
		y = _y;
		c = _c;
	}
}

public class Main {
	static int[] dx = {-1, 0, 1, 0};
	static int[] dy = {0, -1, 0, 1};
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);

        int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] map = new char[h][w];
		LinkedList<Cost> open = new LinkedList<Cost>();
		
		for(int i=0; i<h; i++) {
			map[i] = sc.next().toCharArray();
			
			for(int j=0; j<w; j++) {
				if(map[i][j] == '#') open.add(new Cost(j, i, 0));
			}
        }
		
		int ans = 0;
		while(!open.isEmpty()) {
			Cost now = open.poll();
			ans = Math.max(ans, now.c);
			
			for(int i=0; i<4; i++) {
				int nx = now.x + dx[i];
				int ny = now.y + dy[i];
				int nc = now.c + 1;
				
				if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
				if(map[ny][nx] == '#') continue;
				
				map[ny][nx] = '#';
				open.add(new Cost(nx, ny, nc));
			}
		}
		
        out.println(ans);
    }
}


Measured memory_bytes: 75852
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

const int MAX_N = 1000000;

class UnionFind{
public:
    UnionFind(int n){
        REP(i, n){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}

        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
private:
    int rank[MAX_N], par[MAX_N];
};

struct Edge{
    int to, from, cost;
};

bool comp(const Edge& le, const Edge& re){
    return le.cost < re.cost;
}

int N, M;
std::vector<Edge> E;

int kruskal(){
    std::sort(E.begin(), E.end(), comp);

    int res = 0;
    UnionFind uf(N);

    REP(i, M){
        Edge e = E[i];

        if(!uf.same(e.to, e.from)){
            uf.unite(e.to, e.from);
            res += e.cost;
        }
    }

    return res;
}

int main(){
    while(std::cin >> N >> M, N){
        E.clear();
        
        REP(i, M){
            int to, from, cost;
            std::cin >> to >> from >> cost;
            E.push_back({to, from, cost});
        }

        std::cout << kruskal() << std::endl;
    }
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N, M, a, b;
	cin >> N >> M;
	vector<int> res(N);
	while (M--) {
		cin >> a >> b;
		res[a - 1]++;
		res[b - 1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<deque>
using namespace std;
int n;
int a[200010];
bool forwards;
deque<int> D;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        if(i%2==1) D.push_back(a[i]);
        else D.push_front(a[i]);
    }
    if(n%2)
        while(!D.empty()) {printf("%d ",D.front()); D.pop_front();}
    else
        while(!D.empty()) {printf("%d ",D.back()); D.pop_back();}
}

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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  long long n, x = 0, result = 0;
  cin >> n;

  string s;
  cin >> s;

  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'I')
      x++;
    else if (s[i] == 'D')
      x--;

    result = x > result ? x : result;
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
    string s;
    cin >> s;
    if(s == "SUN") {
        cout << 7 << endl;
    } else if(s =="MON") {
        cout << 6 << endl;
    } else if(s =="TUE") {
        cout << 5 << endl;
    } else if(s =="WED") {
        cout << 4 << endl;
    } else if(s =="THU") {
        cout << 3 << endl;
    } else if(s =="FRI") {
        cout << 2 << endl;
    } else if(s =="SAT") {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
*a, = map(int,input().split())
S = [0]*(N)
for i in range(N):
    S[i] = S[i-1] + a[i]
Sn = S[-1]
ans = 10**15
for i in range(N-1):
    ans = min(ans,abs(Sn-S[i]*2))
print(ans)

Measured memory_bytes: 24832
#include "bits/stdc++.h"
using namespace std;

#define ll long long
ll n,m,a,b,ret=0;
multimap<ll,ll> pq;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>m;
	for(ll i=0;i<n;i++){
		cin>>a>>b;
		pq.insert(pair<ll,ll>(a,b));
	}
	for(auto it=pq.begin();it!=pq.end();++it){
		if(m==0)
			break;
		if(m-it->second>=0){
			ret+=(it->first*it->second);
			m-=it->second;
		}
		else{
			ret+=(it->first*m);
			m=0;
		}
	}
	cout<<ret;
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

#define MAX 100000000

struct NODE {
    int distance;
    int state;
} vertex[101];

int W[101][101];
int V, n, sum;

int min(int a, int b) {
    return (a > b ? b : a);
}

void prim(int start) {
    int x, p, step;

    for (x = 0; x < V; x++) {
	vertex[x].distance = MAX; vertex[x].state = 0;
    }
    vertex[start].distance = 0; 
    for (step = 1; step <= V; step++) {
	int minimum = MAX;
	for (x = 0; x < V; x++)
	    if (vertex[x].state == 0 && vertex[x].distance < minimum) {
		p = x; minimum = vertex[x].distance;
	    }
	vertex[p].state = 1;
	sum += minimum;
	for (x = 0 ; x < V; x++)
	    //	    if (vertex[x].state == 0)
		vertex[x].distance = min(vertex[x].distance, W[p][x]);
    }
}

int main(void) {
    int i, j;
    int from, to, m;
     
    while (1) {
	scanf("%d", &V);
        if (V == 0) break;
	scanf("%d", &n);
         
        for (i = 0; i <= V; i++)
            for (j = 0; j <= V; j++)
                W[i][j] = MAX;
         
	for (i = 0; i < n; i++) {
            scanf("%d,%d,%d", &from, &to, &m);
            W[from][to] = (m / 100) - 1;
	    W[to][from] = (m / 100) - 1;
        }

	sum = 0;

        prim(0);

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

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = "";
		while(stdIn.hasNext()) {
		s += stdIn.nextLine();
		}
		s = s.toLowerCase();
		int[] ans = new int[k.length];
		for(int i = 0; i < s.length(); i++) {
			for(int j = 0; j < k.length; j++) {
				if(s.charAt(i) == k[j]) {
					ans[j]++;
				}
			}
		}
		
		for(int i = 0; i < 26; i++) {
			System.out.println(k[i]+" : " + ans[i]);
		}
	}
}

Measured memory_bytes: 18260
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF = 987654321;
const int MOD = 1000000007;

ll XOR(ll x){
  if(x % 4 == 0) return x;
  if(x % 4 == 1) return 1;
  if(x % 4 == 2) return x+1;
  if(x % 4 == 3) return 0;
  return -1;
}

int main(){
  ll A,B;
  scanf("%lld %lld",&A,&B);
  if(A == 0) A = 1;
  ll ans = XOR(A-1)^XOR(B);
  if(A == 0) printf("%lld\n",ans^0);
  else printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional> 

using namespace std;

#define mp make_pair
#define pb push_back
#define pf push_front
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int (i)=0;(i)<(n);++(i))
#define rep(i,st,ed) for(register int (i)=(st);(i)<=(ed);++(i))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename T> inline T qmin(const T a,const T b) {return a<b?a:b;}
template<typename T> inline T qmax(const T a,const T b) {return a>b?a:b;}
template<typename T> inline void getmin(T &a,const T b) {if(a>b) a=b;}
template<typename T> inline void getmax(T &a,const T b) {if(a<b) a=b;}

inline void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=1e9+7;
const ll linf=1e17+7;
const int N=2e5+7;

ll a[N];
int n;

il bool check(int p){
	ll cur=a[p];
	for(int i=1;i<=n;++i){
		if(i==p) continue;
		if(a[i]>cur*2) return false;
		cur+=a[i];
	}
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",a+i);
	sort(a+1,a+n+1);
	int ul=0,ur=n+1;
	while(ur-ul>1){
		int mid=ul+ur>>1;
		if(check(mid)) ur=mid;else ul=mid;
	}
	printf("%d\n",n-ur+1);
	return 0;
} 

Measured memory_bytes: 1024
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n - 1) cout << a[i] << " ";
    cout << a[n - 1] << endl;
    REP(i, 1, n) {
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        rep(i, n - 1) cout << a[i] << " ";
        cout << a[n - 1] << endl;
    }
}


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

//A:0 C:1 G:2 T:3
ll dp[105][4][4][4];

int main(){
	int n;
	cin >> n;
	
	//dp初期条件,最初の二桁は何を使っても良い。
	rep(j,4){
		rep(k,4){
			rep(l,4){
				dp[0][j][k][l] = 1;
				dp[1][j][k][l] = 1;
			}
		}
	}
	
	rep(j,4){
		rep(k,4){
			rep(l,4){
				if(l == 1 && k == 2 && j == 0) continue;
				if(l == 2 && k == 1 && j == 0) continue;
				if(l == 1 && k == 0  && j == 2) continue;
				dp[2][l][k][j] += dp[1][k][j][1];
			}
		}
	}
	
	for (int i = 2; i < n-1; ++i) {
		rep(j,4){
			rep(k,4){
				rep(l,4){
					rep(m,4){
						if(m == 1 && l == 2 && k == 0) continue;
						if(m == 2 && l == 1 && k == 0) continue;
						if(m == 1 && l == 0 && k == 2) continue;
						if(m == 1 && k == 2 && j == 0) continue;
						if(m == 1 && l == 2 && j == 0) continue;
						dp[i+1][m][l][k] += dp[i][l][k][j] % MOD;
					}
				}
			}
		}
	}
	
	ll ans = 0;
	
	rep(j,4){
		rep(k,4){
			rep(l,4){
				ans += dp[n-1][j][k][l] % MOD;
				ans %= MOD;
			}
		}
	}
	
	cout << ans  << endl;
	
	return 0;
}


Measured memory_bytes: 256
def month(n):
    if 0 < n and n < 13:
        return True
    else:
        return False


num = input()
if month(int(num[2:])):
    if month(int(num[:2])):
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if month(int(num[:2])):
        print('MMYY')
    else:
        print('NA')


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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;
ll computemincost(vector < pair < ll , ll > > v, ll n, ll m) {
	ll cost = 0, i, j, k;
	sort(v.begin(), v.end());
	for(auto shop:v) {
		ll quantity = min(m, shop.S);
		cost += quantity * shop.F;
		m -= quantity;
	}
	return cost;
}
int main() 
{
	fastIO;
	ll n, m, i, j, k;
	vector < pair < ll , ll > > v;
	cin>>n>>m;
	fo(i,n) {
		cin>>j>>k;
		v.pb({j,k});
	}
	cout<<computemincost(v, n, m);
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(void) {
    int n, a, b, t, cnt=0;
    scanf("%d%d%d", &n, &a, &b);
    for(int i=0; i<n; i++) {
        scanf("%d", &t);
        if(t<a || t>=b) cnt++;
    }

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

    return 0;
}

Measured memory_bytes: 256
/*
 Remember not to use arithmetic operation in double while comparision 

 priority of uses
 array > maps > unordered_maps
*/

#include<bits/stdc++.h>
#define lli long long int
#define vl vector<lli>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define pll pair<lli,lli>
using namespace std;
vi adj[100001];
bool vis[100001];
int dp[100001];
void dfs(int index)
{
	vis[index]=true;
	for(auto x:adj[index])
	{
		if(!vis[x])
			dfs(x);
		dp[index]=max(dp[index],1+dp[x]);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,m,a,b;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		vis[i]=false;

	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		adj[a].pb(b);
	}

	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			dfs(i);
	}
	lli ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,0LL+dp[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 8320