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

using namespace std;

typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll INF = numeric_limits<ll>::max() / 4;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	while (true)
	{
		ll n, m, s, g1, g2;
		cin >> n >> m >> s >> g1 >> g2;
		s--;
		g1--;
		g2--;
		if (n == 0)
			break;
		VVI dis(n, vector<ll>(n, INF));
		for (int i = 0; i < n; i++)
			dis[i][i] = 0;
		for (int i = 0; i < m; i++)
		{
			ll b1, b2, c;
			cin >> b1 >> b2 >> c;
			b1--;
			b2--;
			dis[b1][b2] = c;
		}
		for (int k = 0; k < n; k++)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
				}
			}
		}
		ll res = INF;
		for (int i = 0; i < n; i++)
		{
			ll tmp = dis[s][i] + dis[i][g1] + dis[i][g2];
			res = min(res, tmp);
		}
		cout << res << endl;
	}
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll mo=1000000007;
int N,K;
ll dp[101010];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	
	cin>>N>>K;
	ll sum=0;
	for(i=K;i>=1;i--) {
		dp[i]=modpow(K/i,N);
		for(j=i*2;j<=K;j+=i) dp[i]-=dp[j];
		dp[i]=(dp[i]%mo+mo)%mo;
		sum+=i*dp[i]%mo;
	}
	cout<<sum%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4388
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

class student{
public:
    int arrive;
    int number;
};

int main(){

    int N ;
    cin >> N;
    vector<student> students(N);
    for(int i = 0 ; i < N ; i++){
        int tmp_arrive;
        cin >> tmp_arrive;
        students[i].arrive =  tmp_arrive;
        students[i].number =  i + 1     ;
    }

    sort(students.begin(), students.end(),
         [](const student& x, const student& y){return x.arrive < y.arrive;});

    for(int i = 0 ; i < N ; i++){
        cout << students[i].number << " ";
    }

    cout << endl;

}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n,vector<int>(d));
	rep(i,n)rep(j,d) cin >> x[i][j];

	int ans = 0;
	rep(i,n){
		For(j,i+1,n){
			// 点i と 点jを比較する
			ll sum = 0;
			rep(k,d){
				ll tmp = x[i][k] - x[j][k];
				tmp *= tmp;
				sum += tmp;
			}
			for(int l = 1; l * l <= sum; l++){
				if(l*l == sum) ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

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

Measured memory_bytes: 17064
k = int(input())
ans = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ans[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,m) for(int i=a;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    //初期化
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    queue<pair<int,int>> q;
    int h,w; cin>>h>>w;
    char s[h][w]; int cnt=0;
    rep(i,h)rep(j,w){
        cin>>s[i][j];
        if(s[i][j]=='#') cnt++;
    }
    int d[h][w]; rep(i,h)rep(j,w) d[i][j]=INF;
    int sy=0,sx=0,gy=h-1,gx=w-1; //盤面,スタート,ゴール
    d[sy][sx]=0;
    q.push(make_pair(sy,sx));

    //実行
    while(q.size()){
        pair<int,int> p=q.front(); //キューの先頭を取り出す
        q.pop(); //取り出したら削除
        int prev=d[p.first][p.second]; //一手前の手数prev
        rep(i,4){ //4方向探索
            int cy=p.first+dy[i];
            int cx=p.second+dx[i];
            if(0<=cy&&cy<h&&0<=cx&&cx<w){ //範囲外取得キケン
                if(s[cy][cx]=='.' and d[cy][cx]==INF){ //通行可能かつ未到達
                    d[cy][cx]=prev+1;
                    q.push(make_pair(cy,cx));
                }
            }
        }
    }
    if(d[gy][gx]==INF) cout<<-1<<endl;
    else cout<<h*w-cnt-d[gy][gx]-1<<endl;

    return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  string s;
  cin>>s;
  for(int i =0; i<s.length(); i+= 2)
  {
    cout<<s[i];
  }
  cout<<endl;
}


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

int main()
{
    int N, Q;
    cin >> N >> Q;

    fenwick_tree<ll> ft(N);
    rep(i, N) {
        int a;
        cin >> a;
        ft.add(i, a);
    }

    rep(_, Q) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            ft.add(p, x);
        } else if (t == 1) {
            int l, r;
            cin >> l >> r;
            cout << ft.sum(l, r) << '\n';
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 8204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <deque>
using namespace std;
int main(){
	int n;
	cin >> n;
	deque<int> num;
	deque<int>::iterator pos;
	int d=0,a;
	for (int i=1;i<=n;i++){
		cin >> a;
		if (d==1) { num.push_front(a); d=0; }
			else {num.push_back(a);d=1; }
	}
	if (d==0){
		for (pos=num.begin();pos != num.end();pos++)
			cout << *pos << " ";
	}
		else {
		for (pos=num.end()-1;pos != num.begin()-1;pos--)
			cout << *pos << " ";
		}
	return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#define MAX 100005
#define NONE -1
typedef struct{
  int parent,left,right;
}Node;
Node tree[MAX];
int n,depth[MAX];
void print_out(int a){
  int i,b;
  printf("node %d: ",a);
  printf("parent = %d, ",tree[a].parent);
  printf("depth = %d, ",depth[a]);
  if(tree[a].parent == NONE) printf("root, ");
  else if(tree[a].left == NONE) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,b=tree[a].left;b!=NONE;i++,b=tree[b].right){
    if(i) printf(", ");
    printf("%d",b);
  }
  printf("]\n");
}
int dep(int a,int b){
  depth[a]=b;
  if(tree[a].right != NONE) dep(tree[a].right,b);
  if(tree[a].left != NONE) dep(tree[a].left,b+1);
}
int main(){
  int i,j,a,b,c,d,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent = NONE;
    tree[i].left = NONE;
    tree[i].right = NONE;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&b,&a);
    for(j=0;j<a;j++){
      scanf("%d",&c);
      if(j == 0) tree[b].left = c;
      else tree[e].right=c;
      e = c;
      tree[c].parent = b;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].parent == NONE) d = i;
  }
  dep(d,0);
  for(i=0;i<n;i++){
    print_out(i);
  }
  return 0;
}

Measured memory_bytes: 5300
while 1:
    n=input()
    if n==0:break
    value=0
    for i in range(n):
        x,y,h,w=map(int,raw_input().split())
        size=x+y+h
        if size<=60 and w<=2:value+=600
        elif size<=80 and w<=5:value+=800
        elif size<=100 and w<=10:value+=1000
        elif size<=120 and w<=15:value+=1200
        elif size<=140 and w<=20:value+=1400
        elif size<=160 and w<=25:value+=1600
    print value

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

int main()
{
    char b;
    cin >> b;
    if (b == 'A')
        cout << "T" << endl;
    if (b == 'C')
        cout << "G" << endl;
    if (b == 'G')
        cout << "C" << endl;
    if (b == 'T')
        cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, xi, yi;

    scanf("%d%d%d", &n, &xi, &yi);

    int a[n];

    for(int i=0;i<n;i++)
        scanf("%d", a+i);

    int dp[2][n];

    for(int i=0;i<n;i++) {
        dp[0][i] = -1;
        dp[1][i] = -1;
    }

    for(int i=n-1;i>=0;i--) {
        if(i != 0) {
            dp[0][i] = abs(a[i - 1] - a[n - 1]);
            dp[1][i] = abs(a[i - 1] - a[n - 1]);
        } else {
            dp[0][i] = abs(yi - a[n - 1]);
            dp[1][i] = abs(xi - a[n - 1]);
        }
        for(int j=i+1;j<n;j++) {
            dp[0][i] = max(dp[1][j], dp[0][i]);
            dp[1][i] = min(dp[0][j], dp[1][i]);
        }
    }

    int res = dp[0][0];

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll a, b, c;

set<pair<P, ll>> spp;

int main() {
	ll cnt = 0;
	cin >> a >> b >> c;
	if (a % 2 || b % 2 || c % 2) {
		cout << cnt << endl;
		return 0;
	}
	while (spp.find({ {a,b},c }) == spp.end()) {
		cnt++;
		int ka = a / 2 + b / 2;
		int kb = b / 2 + c / 2;
		int kc = c / 2 + a / 2;
		if (ka % 2 || kb % 2 || kc % 2) {
			cout << cnt << endl;
			return 0;
		}
		spp.insert({ { a,b }, c });
		a = ka, b = kb, c = kc;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int main()
{



	string s;

	cin>>s;


	if(s[s.size()-1]=='s')
    {
       cout<<s<<"es"<<endl;
    }
	else cout<<s<<"s"<<endl;



















}


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

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

using namespace std;

using uint=unsigned int;
using ll=long long;

uint xor128(){
	static uint d[]={1145141919,1919810893,810893364,364114514};
	uint t=d[0]^(d[0]<<11);
	REP(i,3)
		d[i]=d[i+1];
	return d[3]=d[3]^(d[3]>>19)^(t^(t>>8));
}

struct Node{
	Node *l,*r;
	int s,v,mn;
} buf[200000];

using NP=Node*;

NP newNode(int v){
	static int c=0;
	buf[c]=Node{NULL,NULL,1,v,v};
	return &buf[c++];
}

const int inf=1145141919;

int Mini(NP x){
	return x?x->mn:inf;
}

int Size(NP x){
	return x?x->s:0;
}

NP Update(NP x){
	x->s=Size(x->l)+Size(x->r)+1;
	x->mn=min({x->v,Mini(x->l),Mini(x->r)});
	return x;
}

NP LinkL(NP x,NP l){
	x->l=l;
	return Update(x);
}

NP LinkR(NP x,NP r){
	x->r=r;
	return Update(x);
}

NP CutL(NP x){
	x->l=NULL;
	return Update(x);
}

NP CutR(NP x){
	x->r=NULL;
	return Update(x);
}

NP Merge(NP a,NP b){
	if(!a)
		return b;
	else if(!b)
		return a;
	else if(xor128()%(a->s+b->s)<a->s)
		return LinkR(a,Merge(a->r,b));
	else
		return LinkL(b,Merge(a,b->l));
}

using Res=Node;

Res Split(NP x,int k){
	if(k<=0)
		return Res{NULL,x};
	else if(x->s<=k)
		return Res{x,NULL};
	else if(k<=Size(x->l)){
		Res s=Split(x->l,k);
		return Res{s.l,Merge(s.r,CutL(x))};
	}else{
		Res s=Split(x->r,k-Size(x->l)-1);
		return Res{Merge(CutR(x),s.l),s.r};
	}
}

void Set(NP x,int k,int v){
	int ls=Size(x->l);
	if(k<ls)
		Set(x->l,k,v);
	else if(k==ls)
		x->v=v;
	else
		Set(x->r,k-ls-1,v);
	Update(x);
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

NP t[200000];

int main(){
	int n=read(),q=read();
	REP(i,n)
		t[i]=newNode(read());
	while(n>1){
		int k=n/2;
		REP(i,k)
			t[i]=Merge(t[i*2],t[i*2+1]);
		if(k*2<n)
			t[k]=t[k*2];
		n=(n+1)/2;
	}
	NP root=t[0];
	REP(_,q){
		int x=read(),y=read(),z=read();
		if(x==0){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y-1);
			Res s3=Split(s2.r,1);
			root=Merge(Merge(s1.l,s3.l),Merge(s2.l,s3.r));
		}else if(x==1){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y);
			printf("%d\n",Mini(s2.l));
			root=Merge(s1.l,Merge(s2.l,s2.r));
		}else if(x==2){
			Set(root,y,z);
		}
	}
}

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

int main() {
    uint64_t A;
    double B;
    std::cin >> A >> B;

    if (A == 0 || B < 0.01) {
        std::cout << 0 << std::endl;
        return 0;
    }

    uint64_t b = (uint64_t)(std::round(B * 100.0));
    uint64_t ans = (A * b) / 100;

    std::printf("%lu\n", ans);

    return 0;
}


Measured memory_bytes: 3844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
ll a,b,ans;
bool calc(ll xl,ll yl,ll len)
{
	ll xr=xl+len,yr=yl-len;
	if (xr<=yr) return xr*yr<a*b;
	if (xl>=yl) return xl*yl<a*b;
	ll t=(yl+xl)/2;
//	pr(666);
//	pr(t);
	if ((yl-xl)%2==0) return t*t<a*b;
	else return t*(t+1)<a*b;
}
bool check(ll x)
{
	ll y=x;x=1;
	ll o=a-1,p=x-b+1;
	//pr(o),pr(p);
	if (p<=0) 
	{
		if (calc(x,y,o)==0) return 0;
		x+=o,y-=o;x++; 
		if (calc(x,y,y)==0) return 0;
	}
	else if (o<p) 
	{
		if (calc(x,y,a-1)==0) return 0;
		x+=o,y-=o;x++;
		if (calc(x,y,p-o)==0) return 0;
		x+=p-o,y-=p-o;y--;
		if (calc(x,y,y)==0) return 0;
	}
	else
	{
		if (calc(x,y,p)==0) return 0;
		x+=o,y-=o;y--;
		if (calc(x,y,o-p)==0) return 0;
		x+=o-p,y-=o-p,x++;
		if (calc(x,y,y)==0) return 0;
	}
	return 1;		
}
int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		scanf("%lld %lld",&a,&b);
		if (a>b) swap(a,b);
		ll l=a-1,r=a-1+b-1;
		//pr(calc(9,35,35));return 0;
		//pr(check(42));return 0;
		while (l<=r)
		{
			ll mid=(l+r)/2;
			if (check(mid)) ans=mid,l=mid+1;
			else r=mid-1;
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fsort(const pair<int,int>&a,const pair<int,int>&b)
{
  if(a.second==b.second)return a.first<b.first;
  else return a.second<b.second;
}
int main()
{
  int n;
  cin>>n;
  vector<pair<int,int> >a(n);
  for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
  sort(a.begin(),a.end(),fsort);
 // for(int i=0;i<n;i++)cout<<a[i].first<<' '<<a[i].second<<endl;
  int d=0;
  for(int i=0;i<n;i++)
  {
    d+=a[i].first;
    if(d>a[i].second)
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
if n == 1 and m == 1:
    ans = 1
elif n == 1:
    ans = m-2
elif m == 1:
    ans = n-2
elif n == 2 or m == 2:
    ans = 0
else:
    ans = (n - 2)*(m - 2)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define LOOP(i,x,n) for(int i=(x);i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

int n,a,b;
vector<int> h;
bool f(int k){
  vector<int> g=h;
  REP(i,n)g[i]-=b*k;
  int tmp=a-b;
  int sum=0;
  REP(i,n){
    if(g[i]>=0){
      sum+=(g[i]+tmp-1)/tmp;
    }
  }
  return sum<=k;
}

int bins(int l,int u){
  while(u-l>1){
    int m=l+(u-l)/2;
    (f(m)?u:l)=m;
  }
  return u;
}

signed main(){

  cin>>n>>a>>b;
  h=vector<int>(n);
  REP(i,n)cin>>h[i];

  cout<<bins(0,1e9)<<endl;

  return 0;
}


Measured memory_bytes: 1792
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  s = InputLine.to_s

  if ((s == 'AAA') or (s == 'BBB')) then
    puts 'No'
  else
    puts 'Yes'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
  int main() {
  int a;
  cin>>a;
  if (a==1) cout<<"NO";
if (a==2) cout<<"NO";
if (a==3) cout<<"YES";
  if (a==4) cout<<"NO";
  if (a==5) cout<<"YES";
  if (a==6) cout<<"NO";
  if (a==7) cout<<"YES";
  if (a==8) cout<<"NO";
  if (a==9) cout<<"NO";
  
  
  cout << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	{
	char a[100];
	int b;
		for(int i=1;i<=3;i++)
		{
			scanf("%c",&a[i]);
			if(a[i]=='\n'){
				 b=2;
			break;}
			else b=3;
			}
	if(b==2){
		for(int i=1;i<=2;i++)
		{
				printf("%c",a[i]);	
			}
		}
	else {
		for(int i=3;i>=1;i--){
			printf("%c",a[i]);
			
			}
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>                                
#include <iostream>                                 
                                                    
int main(int argc, char const* argv[])              
{                                                   
    int num;                                        
    std::cin >> num;                                
                                                    
    // int* data = (int*)malloc(sizeof(int) * num); 
    int data[200000];                               
    for (int i = 0; i < num; i++) {                 
        std::cin >> data[i];                        
        // std::cout << data[i];                    
    }                                               
                                                    
    int  max  = -1000000000;                        
    int  min  = data[0];                            
    for (int i = 1; i < num; i++) {                 
        max = std::max(max, data[i] - min);         
        min = std::min(min, data[i]);               
    }                                               
                                                    
    std::cout << max << std::endl;                  
    return 0;                                       
}                                                   



Measured memory_bytes: 3900
#include "bits/stdc++.h"
#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

ll modpow(ll n, ll e, ll m = mod){
	ll res = 1;
	n %= m;
	e %= (m - 1);
	while(e) {
		if(e & 1) res = res * n % m;
		n = n * n % m;
		e >>= 1;
	}
	return res;
}

ll N,M,Q,K,L,H,W,D;
string S;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;
	vct<ll> x(N),y(M);
	rep(i,N) cin >> x[i];
	rep(j,M) cin >> y[j];
	vct<int> dx(N),dy(M);
	rep1(i,N - 1) dx[i] = x[i] - x[i - 1];
	rep1(i,M - 1) dy[i] = y[i] - y[i - 1];
	ll ans;
	ll pox = 0;
	ll poy = 0;
	rep1(i,N - 1){
	    pox += (ll)i * (N - i) * dx[i];
	    pox %= mod;
	}
	rep1(i,M - 1){
	    poy += (ll)i * (M - i) * dy[i];
	    poy %= mod;
	}
	ans = pox * poy % mod;
	esc(ans);
}


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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a;
    string s;

    cin>>a>>s;

    if(a<3200){
        cout<<"red"<<endl;
    }
    else{
        cout<<s<<endl;
    }


    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int ans = 0, score = 0;
	for (int i = 0; i < n - 1; i++) {
		if (h[i] >= h[i + 1]) {
			score++;
			continue;
		}

		ans = max(ans, score);
		score = 0;
	}
	ans = max(ans, score);
	score = 0;

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


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int N = 200010;

int ch[N][2], dep[N], n, m, tot;
ll L, ans;
char s[N];

void insert()
{
    m = strlen(s + 1); int now = 0;
    FOR(i, 1, m)
    {
        if (!ch[now][s[i] - '0']) ch[now][s[i] - '0'] = ++tot;
        now = ch[now][s[i] - '0']; s[i] = 0;
    }
}

ll lowbit(ll x) {return x & -x;}

void dfs(int x)
{
    if (dep[x] >= L) return;
    int chi = 0;
    if (ch[x][0]) ++chi; if (ch[x][1]) ++chi;
    if (chi == 1) ans ^= lowbit(L - dep[x]);
    if (ch[x][0]) dep[ch[x][0]] = dep[x] + 1, dfs(ch[x][0]);
    if (ch[x][1]) dep[ch[x][1]] = dep[x] + 1, dfs(ch[x][1]);
}

int main()
{
    scanf("%d%lld", &n, &L);
    FOR(i, 1, n)
    {
        scanf("%s", s + 1);
        insert();
    }
    dfs(0);
    if (ans) puts("Alice"); else puts("Bob");
    return 0;
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    string e = "AKIHABARA";
    for (int i = 0; i < e.size(); i++) {
        if (s.size() < i) break;
        if (s.size() == i){
            if (e[i] == 'A') s.push_back('A');
            break;
        } 
        // i < s.size() 
        if (s[i] != e[i] && e[i] == 'A') {
            s.insert(i, "A");
        }
    }
    cout << (s == e ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		Long X = sc.nextLong();
		Long K = sc.nextLong();
		Long D = sc.nextLong();

		if(X < 0){
			X *= -1;
		}

		Long cnt = (long) Math.floor(X/D);

		if(cnt == 0){
			if(K%2==0){
				System.out.println(X);
				return;
			}else{
				System.out.println(Math.abs(X-D));
				return;
			}
		}

		if(K < cnt){
			System.out.println(X-D*K);
			return;
		}
		  
		if((K-cnt)%2==0){
			System.out.println(X-D*cnt);
			return;
		}else{
			System.out.println(Math.abs(X-D*(cnt+1)));
			return;
		}

	}
}


Measured memory_bytes: 35684
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []

for idx, value in enumerate(Query):
    if value[0] == "1":
        reverse ^= True
        head, back = back, head
    else:
        if value[1] == "1":
            head += [value[2]]
        else:
            back += [value[2]]

if reverse == False:
    head.reverse()
    print("".join(head + Slist + back))
else:
    head.reverse()
    print("".join(head + Slist[::-1] + back))

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

int main() {

    int N;
    cin >> N;

    int cnt = 0;

    rep(i, N) {
        int a;
        cin >> a;
        if (i % 2 == 1) continue;
        else {
            if (a % 2 == 1) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>

long n;

int main() {
    scanf("%ld", &n);
    if (n % 2 == 1) {
        printf("0\n");
        return 0;
    }
    long sum = 0;
    for (long i = 1, j = 2; i < 26; i++) {
        j *= 5;
        sum += n / j;
    }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

int main(){
    string s; cin >> s;
    int N = s.size();

    vector<vector<ll>> dp(N+5, vector<ll>(15, 0));
    vector<ll> mod13(N+5, 0);
    mod13[0] = 1;
    for(int i=1; i<=N; ++i) mod13[i] = mod13[i-1]*10%13;

    if(s.back() != '?') dp[0][s.back()-'0'] = 1;
    else{
        for(int i=0; i<10; ++i) dp[0][i] = 1;
    }

    for(int i=1; i<N; ++i){
        for(int j=0; j<13; ++j){
            if(s[N-1-i] != '?'){
                int add = (s[N-1-i]-'0')*mod13[i]%13;
                dp[i][j] = dp[i-1][(j-add+13)%13];
            }
            else{
                for(int k=0; k<10; ++k){
                    int add = k*mod13[i]%13;
                    dp[i][j] += dp[i-1][(j-add+13)%13];
                    dp[i][j] %= mod;
                }
            }
        }
    }

    cout << dp[N-1][5] << endl;
    return 0;
}

Measured memory_bytes: 16000
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int m=sc.nextInt();
			for(int k=0; k<m; k++) {
				String s = sc.next();
	            Set<String> set = new HashSet<String>();
	            for(int i=1;i<=s.length();i++){
	                String s1 = s.substring(0, i);
	                String s2 = s.substring(i);
	                String r1 = (new StringBuffer(s1)).reverse().toString();
	                String r2 = (new StringBuffer(s2)).reverse().toString();
	                set.add(s1+s2);
	                set.add(s1+r2);
	                set.add(s2+s1);
	                set.add(r2+s1);
	                set.add(r1+s2);
	                set.add(r1+r2);
	                set.add(s2+r1);
	                set.add(r2+r1);
	            }
	            System.out.println(set.size());
			}
			
		}
	}
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> b(n-1);
	for(int& x : b) cin >> x;
	vector<int> a(n);
	
	a[0] = b[0];
	a[n-1] = b[n-2];
	for(int i = 1; i < n-1; i++) {
		a[i] = min(b[i-1], b[i]);
	}
	
	cout << accumulate(a.begin(), a.end(), 0) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	double ans=0;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		ans+=1.0/(double)a;
	}
	ans=1.0/ans;
	printf("%.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline--------------------------------------------
    d = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())
    print(d[k-1])
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 66384
#include <iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
ans = [(i%26)+1 for i in range(D)]
manzoku_down = [0]*26
for i in range(D):
    tmp = -float('inf')
    for j in range(26):
        last = 0
        for l in range(0,i+1):
            if ans[l] == j+1:
                last = l+1
        manzoku_down[j] = C[j]*((i+1)-last)
    for k in range(26):
        if S[i][k]-sum(manzoku_down)+manzoku_down[k] >= tmp:
            tmp = S[i][k]-sum(manzoku_down)+manzoku_down[k]
            ans[i] = k+1
for i in ans:
    print(i)

Measured memory_bytes: 68984
n=int(input())
A=list(map(int,input().split()))
now=A[0]
cnt=0
ans=-1
for i in range(1,n):
    if A[i]<=now:
        cnt+=1
        now=A[i]
    else:
        ans=max(ans,cnt)
        cnt=0
        now=A[i]
print(max(ans,cnt))

Measured memory_bytes: 20568
#include <iostream>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    /*ここから下は初めの最短ルート*/
        for (int i = 0; i < ty - sy; i++) {
            cout << 'U';
        }

        for (int i = 0; i < tx - sx; i++) {
        cout << 'R';
        }
    /*以下はじめの復路*/
        for (int i = 0; i < ty - sy; i++) {
        cout << 'D';
        }
        for (int i = 0; i < tx - sx; i++) {
        cout << 'L';
        }
    /*以下2回目行き*/
            cout << "LU" << flush;
            for (int i = 0; i < ty - sy; i++) {
            cout << 'U';
            }
            for (int i = 0; i < tx - sx; i++) {
            cout << 'R';
            }
            cout << "RD";
    /*以下2回目かえり*/
           cout << "RD";
           for (int i = 0; i < ty - sy; i++) {
            cout << 'D';
         }
         for (int i = 0; i < tx - sx; i++) {
            cout << 'L';
            }
            cout << "LU" << flush;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int maxn=2e5+1e2;

int a[maxn],b[maxn];

int getint()
{
	char ch;int b=1;
	for(ch=getchar();ch>'9'||ch<'0';ch=getchar())if(ch=='-')b=-1;
	int num=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar())num=num*10+ch-'0';
	return num*b;
}

int main()
{
	int n=getint();
	for(int i=1;i<=n;i++)a[i]=getint();
	int head=1,tail=n;
	for(int i=n;i>=1;i--)
	{
		int t=(n-i)&1;
		if(!t)
		{
			b[head++]=a[i];
		}
		else b[tail--]=a[i];
	}
	for(int i=1;i<=n;i++)printf("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 3712
from heapq import *

n,m,s,t=map(int,input().split())
s-=1
t-=1
INF=float("inf")
Gyen=[[]for i in range(n)]
Gsnu=[[]for i in range(n)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  Gyen[u].append([v,a])
  Gyen[v].append([u,a])
  Gsnu[u].append([v,b])
  Gsnu[v].append([u,b])

def dijkstra(G,s):
  d=[INF]*n
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,(d[node],node))
  return d

yen=dijkstra(Gyen,s)
snu=dijkstra(Gsnu,t)
ans=10**15
ans_list=[]
for i in reversed(range(n)):
  ans=min(ans,yen[i]+snu[i])
  ans_list.append(10**15-ans)
print(*ans_list[::-1], sep='\n')


Measured memory_bytes: 136652
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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;}

const int INF = 1e9;
int n;
ll a[100100];

int mini = INF;

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

  cin >> n;
  REP(i,n) {
    cin >> a[i];
    if(a[i] < mini) mini = a[i];    
  }

  bool f = true;
  while(f){
    int tmp = mini;
    int cnt = 0;
    REP(i, n) {
      if(a[i]%mini != 0){
	a[i] %= mini;
      }
      else{
	cnt++;
      }
    }
    if(cnt == n) break;
    REP(i, n) mini = min((int)a[i], mini);
    
  }

  cout << mini << endl;

  return 0;
}


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

int main(void){
  
  int n,i;
  int AC=0,WA=0,TLE=0,RE=0;
  char s[100001][16];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
    if(strcmp(s[i],"AC")==0) AC++;
    if(strcmp(s[i],"WA")==0) WA++;
    if(strcmp(s[i],"TLE")==0) TLE++;
    if(strcmp(s[i],"RE")==0) RE++;
  }
  
  printf("AC x %d\n",AC);
   printf("WA x %d\n",WA);
   printf("TLE x %d\n",TLE);
   printf("RE x %d\n",RE);

  return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    while (H != 0 || W != 0)
    {
        for (int i = 0; i < H; i++)
        {
            if(i==0 || i==H-1)
            {
                for (int j = 0; j < W; j++)
                {
                    cout << "#";
                }
                cout<< endl;
            }
            else
            {
                cout << "#";
                for (int j = 1; j < W-1; j++)
                {
                    cout << ".";
                }
                cout << "#" << endl;
            }
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3112
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		//int n = Integer.parseInt(st.nextToken());
		//int k = Integer.parseInt(st.nextToken());
		HashMap<Long,Long> map = new HashMap<>();
		long arr[] = new long[n];
		long one = 1;
		//st = new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++)
		{
				long x = Long.parseLong(st.nextToken());
				if(!map.containsKey(x))
					map.put(x,one);
				else
					map.put(x,map.get(x)+1);
				arr[i]=x;
		}
//		Arrays.sort(arr);
		long sum=0;
		for(int i=0;i<n;i++)
			sum += arr[i];
		//System.out.println(sum);
		int q = Integer.parseInt(br.readLine());
		while(q-->0)
		{
			st = new StringTokenizer(br.readLine());
			long b = Integer.parseInt(st.nextToken());
			long c = Integer.parseInt(st.nextToken());
			if(map.containsKey(b)){
			long f1 = map.get(b);
			sum -= b*f1;
			sum += c*f1;
			map.remove(b);
			if(!map.containsKey(c))
			map.put(c,f1);
			else
				map.put(c,map.get(c)+f1);}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 69820
void main() {
	(arr => ((A, B) => max(A + B, A - B, A * B))(arr[0], arr[1]))(readAs!(int[])).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
# input
n = gets.chomp.to_i
P = gets.chomp.split.map(&:to_i)
Q = gets.chomp.split.map(&:to_i)

# main
R = P.permutation.to_a.sort
a = 0
b = 0

R.length.times do |i| 
  if R[i] == P then
    a = i + 1
  end
  if R[i] == Q then
    b = i + 1
  end
  if a != 0 and b != 0 then
    break
  end
end
    
# output
puts (b-a).abs


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

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

    int ua, la, ub, lb, ca, cb, uar, lar, ubr, lbr;
    ua = a/1000; ub = b/1000;
    uar = (ua%10)*10 + ua/10; ubr = (ub%10)*10 + ub/10;
    la = a%100; lb = b%100;
    lar = (la%10)*10 + la/10; lbr = (lb%10)*10 + lb/10;
    ca = a/100 - ua*10; cb = b/100 - ub*10;

    int sum = 0;
    if(ua == ub){
        sum += cb-ca + 1;
        if(la > uar){
            sum--;
        }
        
        if(lb < ubr){
            sum--;
        }
    }else{
        if(la <= uar){
            sum += 10-ca;
        }else{
            sum += 9-ca;
        }

        if(lb >= ubr){
            sum += cb+1;
        }else{
            sum += cb;
        }
    }
    if(ub - ua > 1){
        sum += (ub-ua-1) * 10;
    }

    cout << sum << endl;
    
    return 0;
}


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


using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    Int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(Int i=0;i<(Int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}


//INSERT ABOVE HERE

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  Int ans=n,cnt=n;
  vector<Int> dp(n+1,0);
  function<void(Int,Int,Int)> dfs=[&](Int v,Int p,Int d){
    if(p<0) dp.assign(n+1,0);
    Int res=0;
    for(Int u:G[v]){
      if(u==p) continue;
      dfs(u,v,d+1);
      res++;
    }
    chmax(dp[d],res);
    if(p<0){
      Int len=0;
      while(dp[len]) len++;
      if(len>ans) return;
      Int val=1;
      for(Int i=0;i<len;i++) val*=dp[i];
      if(len+1<ans) ans=len+1,cnt=val;
      else if(len+1==ans) chmin(cnt,val);
      //cout<<v<<":"<<len<<" "<<val<<endl;
    }
  };
  
  function<void(Int,Int)> dfs2=[&](Int a,Int b){
    dp.assign(n+1,0);
    dfs(a,b,0);
    dfs(b,a,0);
    Int len=0;
    while(dp[len]) len++;
    if(len>ans) return;
    Int val=2;
    for(Int i=0;i<len;i++) val*=dp[i];
    if(len+1<ans) ans=len+1,cnt=val;
    else if(len+1==ans) chmin(cnt,val);
  };
  
  for(Int i=0;i<n;i++) dfs(i,-1,0);
  for(Int i=0;i<n;i++)
    for(Int j:G[i]) dfs2(i,j);
  
  cout<<ans<<" "<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
S = gets.chomp
head = S[0..1].to_i
tail = S[2..3].to_i

if 1 <= head && head <= 12
  if 1 <= tail && tail <= 12
    ans = 'AMBIGUOUS'
  else
    ans = 'MMYY'
  end
else
  if 1 <= tail && tail <= 12
    ans = 'YYMM'
  else
    ans = 'NA'
  end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int a[105], n;

int main()
{
	int i, cnt;
	cin >> n;
	int bubblesort();
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cnt = bubblesort();
	for(i = 0; i < n; i++)
	{
		if(i > 0)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	cout << cnt << endl;
}

int bubblesort()
{
	int i, j, cnt = 0, tmp;
	for(i = 0; i < n - 1; i++)
	{
		for(j = 0; j < n - 1 - i; j++)
		{
			if(a[j] > a[j + 1])
			{
				tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
				cnt++;
			}
		}
	}
	return cnt;
}


Measured memory_bytes: 3096