akhauriyash/Code-Regression huggingface dataset:
//
// Created by yuu on 2019-04-20.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;

const long long INF = 1LL<<60;

int main(void){
    int N,W;

    int w[110];
    int v[110];

    cin>>N>>W;

    for (int i = 0; i < N; ++i) {
        cin>>w[i]>>v[i];
    }

    long long dp[110][100100];

    for (int i = 0; i < 110; ++i) {
        for (int j = 0; j < 100100; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

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

            if(k-v[i] >= 0){
                dp[i+1][k] = min(dp[i+1][k], dp[i][k-v[i]] +  w[i]);
            }

            dp[1+i][k] = min(dp[i+1][k], dp[i][k]);
        }
    }

    long long ans = 0;

    for (int i = 0; i < 100100; ++i) {
        if(dp[N][i] <= W)ans = i;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 86272
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <cmath>

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

  int N;
  std::cin >> N;
  std::vector<std::pair<int, int>> D(N, std::pair<int, int>(0, 0));

  for (int i = 0; i < N; i++) {
    std::cin >> D[i].first;
    std::cin >> D[i].second;
  }
  std::sort(D.begin(), D.end());

  int p = 0;
  double ad = 0;
  do {
    p++;
    double d = 0;
    for (int i = 1; i < D.size(); i++) {
      auto pp = D[i - 1];
      auto cp = D[i];
      d += std::sqrt(std::pow(pp.first - cp.first, 2.0) + std::pow(pp.second - cp.second, 2.0));
    }
    ad += d;
  } while(std::next_permutation(D.begin(), D.end()));

  std::cout << std::setprecision(10) << ad / p << std::endl;

  return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%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()
{
  int n; cin >> n;
  mint dp[110][4][4][4];

  rep(i,n+1) rep(j,4) rep(k,4) rep(l,4) dp[i][j][k][l].x = 0;
  dp[0][3][3][3].x = 1;

  // dp[i][j][k][l]
  rep(i,n) rep(j,4) rep(k,4) rep(l,4) rep(m,4) {
    if(m == 2) {
      if((k == 0 && l == 1) || (k == 1 && l == 0) || (j == 0 && k == 1) || (j == 0 && l == 1)) continue;
    }
    else if(m == 1) {
      if(k == 0 && l == 2) continue;
    }
    dp[i+1][k][l][m] += dp[i][j][k][l];
  }

  mint res;
  rep(j,4) rep(k,4) rep(l,4) res += dp[n][j][k][l];
  cout << res.x << "\n";
  
  return 0;
}


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> vec(Q);
  for(int i=0; i<Q; i++){
    cin >> vec.at(i);
  }
  vector<int> player(N);
  for(int i=0; i<Q; i++){
    player.at(vec.at(i)-1)++;
  }
  for(int i=0; i<N; i++){
    player.at(i) += K - Q;
    if(player.at(i) > 0){
      cout << "Yes";
    }
    else{
      cout << "No";
    }
    cout << endl;
  }
} 

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<queue>
#include<vector>
using namespace std;
const int maxn=1e5+5;
const int inf=1e9;
struct node{
	int x,y,id;
};
vector<int>a[maxn];
queue<node>q;
int dp[maxn][3];
int main(){
	int n,m,s,t;
	scanf("%d %d",&n,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d %d",&x,&y);
		a[x].push_back(y);
	}
	scanf("%d %d",&s,&t);
	q.push((node)<%s,0,0%>);
	for(int i=0;i<=n;i++)for(int j=0;j<=2;j++)dp[i][j]=inf;
	while(!q.empty()){
		node now=q.front();q.pop();
		int x=now.x,id=now.id,y=now.y;
		if(dp[x][id]<=y)continue;
		dp[x][id]=y;
		for(int i=0;i<(int)a[x].size();i++)q.push((node)<%a[x][i],y+1,(id+1)%3%>);
	}
	dp[t][0]==inf?puts("-1"):printf("%d\n",dp[t][0]/3);
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
int n, x, y, z;
LL dp[45][1<<17];
void MeltDowner(int x) {
    for (int i = 16; i >= 0; i --) {
        printf("%d", (x>>i)&1);
    }
    printf("\n");
}
int main() {
    cin >> n >> x >> y >> z;
    dp[0][0] = 1;
    int ban = (1<<(x+y+z-1)) | (1<<(y+z-1)) | (1<<(z-1));
    for (int i = 1; i <= n; i ++) {
        for (int S = 0; S < (1<<17); S ++) {
            for (int j = 1; j <= 10; j ++) {
                int nex = (S << j) | (1 << (j-1));
                nex &= ((1 << 17) - 1);

                if ( (nex & ban) == ban) {
                    continue;
                }
                (dp[i][nex] += dp[i-1][S]) %= MOD;
            }
        }
    }
    LL ans = 0;
    for (int i = 0; i < (1<<17); i ++) {
        ans = (ans + dp[n][i]) % MOD;
    }
    LL tot = 1;
    for (int i = 1; i <= n; i ++) {
        tot = tot * 10 % MOD;
    }
    printf("%lld\n", ((tot-ans)%MOD+MOD)%MOD );
}

Measured memory_bytes: 42240
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a+n);
    ll k1 = 0, k2 = 0, p = 0;
    repr(i, n-1) if(a[i] == a[i+1]) { k1 = a[i]; p= i; break; }
    for(ll i = p-2; i >= 0; i--) if(a[i] == a[i+1]) { k2 = a[i]; break; }
    cout << k1*k2;

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool a=true,b=true;
	int n;
	cin>>n;
	if((n/100)>=13||(n/100)==0)a=false;
	if((n%100)>=13||(n%100)==0)b=false;
	if(a&&b)cout<<"AMBIGUOUS"<<endl;
	else if(a)cout<<"MMYY"<<endl;
	else if(b)cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
l = list(map(int, input().split()))

keys = range(1,n+1)
values = [-1]*n
dic = dict(zip(keys,values))
dic[1] = 0
t = 1
i = 1

def inverse_lookup(d, x):
    for k,v in d.items():
        if x == v:
            return k

while i <= k:
    t = l[t-1]
    if dic[t] != -1:
        m  = dic[t]
        d = i-m
        r = (k-i+1)%d
        if r == 0:
            r = d
        ans = inverse_lookup(dic, (m+r-1))
        print(ans)
        break
    dic[t] = i
    i += 1
if i == k+1:
    print(t)

Measured memory_bytes: 41000
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

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

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    print(int(not bool(N)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 72464
from collections import deque
n, m = map(int,input().split())

g = [[] for _ in range(n)]

#重み付き無向グラフ
for i in range(m):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

q = deque([])

#訪問済みノード判定
check = [False]*n

cnt = 0

#連結成分のカウントBFS
for i in range(n):
    if check[i]:
        continue
    check[i] = True
    q.append(i)
    while q:
        v = q.popleft()
        x = g[v]
        for j in x:
            if check[j]:
                continue
            check[j] = True
            q.append(j)
    cnt += 1

print(cnt-1)

Measured memory_bytes: 26632
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long N;
vector<long long> S;
vector<vector<long long>> DP;

int main() {
	cin >> N;
	S.resize(N);
	for (long long n = 0; n < N; n++)cin >> S[n];
	DP.resize(N + 1, vector<long long>(10000 + 1, 0));
	DP[0][0] = 1;
	for (int n = 1; n <= N; n++) {
		for (int s = 0; s <= 10000; s++) {
			DP[n][s] = DP[n - 1][s];
			if (s - S[n - 1] >= 0)DP[n][s] += DP[n - 1][s - S[n - 1]];
		}
	}
	long long ans = 0;
	for (long long S = 10000; S >= 0; S--) {
		if (S % 10 == 0)continue;
		if (DP[N][S] != 0) {
			ans = S;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int n,k;
int vis[20];
bool check(int x){
	while(x){
		int d=x%10;
		x/=10;
		if(vis[d])return 0;
	}
	return 1;
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i=1,x;i<=k;i++)scanf("%d",&x),vis[x]=1;
	for(int i=n;;i++){
		if(check(i)){
			printf("%d\n",i);return 0;
		}
	}
	return 0;
}

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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    int n, m; cin>>n>>m;
    ll a[n+1], b[n+1], c[m+1], d[m+1];

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

    for (int i=1; i<=n; i++){
        ll min = LONG_MAX, res;
        for (int j=1; j<=m; j++){
            ll x = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(x<min){ min = x; res = j;}
        }
        cout<<res<<endl;
    }
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,l,r;
    cin>>n>>l>>r;
    if(!n)return;
    vi a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    REP(x,l,r){
        bool f=false;
        rep(i,n){
            if(x%a[i]==0){
                if(!(i%2))ans++;
                f=true;
                break;
            }
        }
        if(!f&&!(n%2))ans++;
    }
    cout<<ans<<endl;
    run();
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a == b && b == c) {
    cout << 1 << endl;
  }
  
  else if (a != b && b != c && c != a) {
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
  return 0;
}


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

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

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

    for(int i=0;i<m;i++){
        cin >> P[i].first >> P[i].second;
    }
    sort(P,P+m);

    int mn=0,res=0;

    for(int i=0;i<m;i++){
        if(P[i].first<mn)
            mn=min(mn,P[i].second);
        else{
            res++;
            mn=P[i].second;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int W, H, N, x[105], y[105], a[105], ans = 0;
	bool color[105][105];//true=white,false=black

	cin >> W >> H >> N;
	for (int i = 1; i <= W; i++) {
		for (int j = 1; j <= H; j++) {

			color[i][j] = true;

		}
	}
	for (int i = 1; i <= N; i++) {

		cin >> x[i] >> y[i] >> a[i];

	}

	for (int i = 1; i <= N; i++) {

		switch (a[i]) {

		case 1:
			if (x[i] != 0) {

				for (int j = 1; j <= x[i]; j++) {
					for (int k = 1; k <= H; k++) {

						color[j][k] = false;

					}
				}

			}
			break;
		case 2:
			if (x[i] != W) {

				for (int j = x[i] + 1; j <= W; j++) {
					for (int k = 1; k <= H; k++) {

						color[j][k] = false;

					}
				}

			}
			break;
		case 3:
			if (y[i] != 0) {

				for (int j = 1; j <= W; j++) {
					for (int k = 1; k <= y[i]; k++) {

						color[j][k] = false;

					}
				}

			}
			break;
		case 4:
			if (y[i] != H) {

				for (int j = 1; j <= W; j++) {
					for (int k = y[i] + 1; k <= H; k++) {

						color[j][k] = false;

					}
				}

			}
			break;

		}

	}
	for (int i = 1; i <= W; i++) {
		for (int j = 1; j <= H; j++) {

			if (color[i][j])ans++;

		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    double n;
    cin >> n;
    vector<double> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double res = v[0];
    for(int i = 1;i<n;i++){
        res = (res + v[i])/2;
    }
    cout << fixed << setprecision(5) << res << endl;
}

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

class Dice{
public:
	int dice[6];
	int buff1, buff2, buff3;
	void north(){
		buff1 = dice[0];
		buff2 = dice[1];
		buff3 = dice[5];
		dice[5] = dice[4];	// 5 <- 1'
		dice[0] = buff2;	// 0 <- 4
		dice[4] = buff1;	// 4 <- 5'
		dice[1] = buff3;	// 1 <- 0'
	}
	void south(){
		buff1 = dice[0];
		buff2 = dice[1];
		buff3 = dice[5];
		dice[0] = dice[4];	// 0 <- 1'
		dice[1] = buff1;	// 1 <- 5'
		dice[5] = buff2;	// 5 <- 4
		dice[4] = buff3;	// 4 <- 0'
	}
	void west(){
		buff1 = dice[0];
		buff2 = dice[2];
		buff3 = dice[5];
		dice[0] = buff2;	// 0 <- 2'
		dice[2] = buff3;	// 2 <- 5'
		dice[5] = dice[3];	// 5 <- 3
		dice[3] = buff1;	// 3 <- 0'
	}
	void east(){
		buff1 = dice[0];
		buff2 = dice[2];
		buff3 = dice[5];
		dice[2] = buff1;	// 2 <- 0'
		dice[5] = buff2;	// 5 <- 2'
		dice[0] = dice[3];	// 0 <- 3
		dice[3] = buff3;	// 3 <- 5'
	}
};

int main()
{
	Dice d;
	for(int n = 0; n < 6; n++)
		cin >> d.dice[n];

	string command;
	string::iterator itr;
	char direction;
	cin >> command;
	for(itr = command.begin(); itr != command.end(); itr++){
		direction = *itr;
		if(direction == 'N')
			d.north();
		if(direction == 'S')
			d.south();
		if(direction == 'E')
			d.east();
		if(direction == 'W')
			d.west();
	}
	cout << d.dice[0] << endl;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 1e5 + 50;
cs int M = 1e6 + 50;
cs int INF = 1e9 + 7;
int n, nd, S, T, p[N], q[N];
int fi[N << 1], f2[N << 1], nxt[M], to[M], w[M], ec = 1;
void add(int x, int y){
	nxt[++ec] = fi[x], fi[x] = ec, to[ec] = y, w[ec] = 1;
	nxt[++ec] = fi[y], fi[y] = ec, to[ec] = x, w[ec] = 0;
} int a[N], b[N], d[N << 1];
bool bfs(){
	memset(d, -1, (T + 1) << 2);
	queue<int> q; q.push(S); d[S] = 0;
	while(!q.empty()){
		int x = q.front(); q.pop();
		for(int e = fi[x], v; e; e = nxt[e])
		if(w[e] && d[v = to[e]] == -1){
			d[v] = d[x] + 1, q.push(v);
			if(v == T) return true; 
		}
	} return false;
}
int dfs(int x, int flw){
	if(x == T) return flw; int ans = 0;
	for(int &e = f2[x], v; e; e = nxt[e])
	if(w[e] && d[v = to[e]] == d[x] + 1){
		int dt = dfs(v, min(flw, d[v]));
		ans += dt, flw -= dt;
		w[e] -= dt, w[e ^ 1] += dt; if(!flw) break;
	} if(flw) d[x] = -1; return ans;
}
int dinic(){
	int flw = 0; while(bfs()){
		memcpy(f2, fi, (T + 1) << 2);
		flw += dfs(S, INF);
	} return flw; 
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
	scanf("%d", &p[i]), ++p[i];
	for(int i = 1; i <= n; i++)
	scanf("%d", &q[i]), ++q[i];
	for(int i = 1; i <= n; i++) if(!a[i]){
		a[i] = ++nd;
		for(int x = p[i]; x != i; x = p[x])
		a[x] = nd;
	}
	for(int i = 1; i <= n; i++) if(!b[i]){
		b[i] = ++nd; 
		for(int x = q[i]; x != i; x = q[x])
		b[x] = nd;	
	} 
	int ans = n; S = 0, T = ++nd; 
	for(int i = 1; i <= n; i++){
		if(p[i] == i){
			if(q[i] == i){ --ans; continue; }
			add(b[i], T);
		} else if(q[i] == i) add(S, a[i]);
		else{
			if(p[i] == q[i]) add(a[i], b[i]), add(b[i], a[i]);
			else add(b[i], a[i]);
		}
	} cout << ans - dinic();
	return 0;
}

Measured memory_bytes: 14240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n)
      : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool find(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i], --A[i], --B[i];
    ll dame = 1ll * N * (N - 1) / 2;
    vector<ll> res(M);
    res[M - 1] = dame;
    UnionFind uf(N);
    for (int i = M - 1; i >= 1; i--) {
      int a = uf.root(A[i]);
      int b = uf.root(B[i]);
      if (a == b) {
        res[i - 1] = dame;
      } else {
        dame -= 1ll * uf.size(a) * uf.size(b);
        res[i - 1] = dame;
        uf.unite(a, b);
      }
    }
    for (ll x : res) cout << x << endl;
  }
  return 0;
}


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

int main() {
	ll arr[32]={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};
    ll k;
    cin>>k;
    cout<<arr[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int n;
vector<ll> T(100);

ll gcl(ll x,ll y){
    if(x<y) swap(x,y);
    while(y>0){
        ll t=x%y;
        x=y;
        y=t;
    }
    return x;
}

int main(){
    cin>>n;
    rep(i,0,n) cin>>T[i];
    rep(i,1,n){
        T[i]=T[i]*(T[i-1]/gcl(T[i],T[i-1]));
    }

    cout<<T[n-1]<<endl;
}

Measured memory_bytes: 256
import sys, re
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    s = readline().strip()
    ans = []
    for w in re.split("[ .,]", s):
        if 3 <= len(w) <= 6:
            ans.append(w)
    write(" ".join(ans))
    write("\n")
solve()



Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
        	System.out.println("a > b");
        }else{
        	System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26116
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    bool c[26];
    for(int i = 0; i < 26; i++){
        c[i] = false;
    }
    for(int i = 0; i < s.size(); i++){
        c[s[i] - 'a'] = true;
    }
    int index = -1;
    for(int i = 0; i < 26; i++){
        if(!c[i]){
            index = i;
            break;
        }
    }
    if(index != -1){
        cout << (char)('a' + index) << endl;
    } else {
        cout << "None" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
use proconio::input;
use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        aa: [String; n],
    }

    let mut deque = VecDeque::new();

    for (i, a) in aa.into_iter().enumerate() {
        if i % 2 == 0 {
            deque.push_back(a);
        } else {
            deque.push_front(a);
        }
    }

    let ans = if n % 2 == 0 {
        deque.into_iter().collect::<Vec<_>>().join(" ")
    } else {
        deque.into_iter().rev().collect::<Vec<_>>().join(" ")
    };
    
    println!("{}", ans);
}


Measured memory_bytes: 20408
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

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

using namespace std;

long long a, b;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int n,a,b;

    cin >> n >> a >> b;

    int sum_a = n*a;
    int sum_b = b;

    if(sum_a>sum_b){
        cout << sum_b;
    }else{
        cout << sum_a;
    }    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int e1,e2,e3,e4;
  int ans=0;
  cin >> e1 >> e2 >> e3 >> e4;
  if(e1==e2 && e3==e4) ans++;
  else if(e1==e3 && e2==e4) ans++;
  else if(e1==e4 && e2==e3) ans++;
  if(ans==1) cout << "yes\n";
  else cout << "no\n";
  return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	int n;
	scanf("%d", &n);
	vector<int> p (n + 1);
	vector<int> ind (n + 1);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++) ind[p[i]] = i;
	multiset<int, greater<int>> s;
	multiset<int> t;
	s.insert(0); s.insert(0);
	t.insert(n + 1); t.insert(n + 1);
	ll ans = 0;
	for (int i = n; i >= 1; i--) {
		ll x, y, z, w;
		auto itr1 = s.upper_bound(ind[i]);
		y = *itr1;
		x = *(++itr1);
		auto itr2 = t.upper_bound(ind[i]);
		z = *itr2;
		w = *(++itr2);
		ll v = i * ((y - x) * (z - ind[i]) + (w - z) * (ind[i] - y));
		ans += v;
		s.insert(ind[i]); t.insert(ind[i]);
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int dp[100][100] = {};
int map[100][100];

int main() {
  int H, W;
  cin >> H >> W;
  REP(i, H) {
    string S;
    cin >> S;
    REP(j, W) {
      map[i][j] = S[j] == '#' ? 1 : 0;
    }
  }
  REP(i, H) {
    REP(j, W) {
      dp[i][j] = 999;
    }
  }
  
  dp[0][0] = map[0][0];
  REP(i, H) {
    REP(j, W) {
      if(i == 0 && j == 0) continue;
      int t1 = i == 0 ? 999 : dp[i-1][j] + (map[i][j] == map[i-1][j] ? 0 : 1);
      int t2 = j == 0 ? 999 : dp[i][j-1] + (map[i][j] == map[i][j-1] ? 0 : 1);
      dp[i][j] = min(t1, t2);
    }
  }
  dp[H-1][W-1] += map[H-1][W-1];
  int ret = (dp[H-1][W-1] + 1) / 2;
  cout << ret << endl;
}

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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;






int main() {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y <= 2019 && m <= 4 && d <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split(" "))
if a == 2 or b == 2:
    print(0)
elif a == 1 and b == 1:
    print(1)
elif a == 1 or b == 1:
    print(a * b - 2)
else:
    print(a * b - ((a + b) * 2 - 4))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define vpi vector<pii>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define forn(i,n) for(i=0;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define all(i,m) auto i=m.begin();i!=m.end();i++
#define mii map<int,int>
#define F first
#define S second

const int MAX=1000000;

lli binpow(lli a,lli b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	lli res=(binpow(a,b/2))%mod;
	res=(res*res)%mod;
	if(b%2)
		return (res*a)%mod;
	return res;
}	

int main()
{
    fast;
    lli n;
    cin>>n;
	lli ans=0,val=1;
	for(lli i=0;i<n;i++)
	{
		val=(((val*(n-i))%mod)*binpow(i+1,mod-2))%mod;
		ans=(ans+(val*(((binpow(9,n-i-1)-binpow(8,n-i-1))%mod+mod)%mod))%mod)%mod;
	}
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    int A, B;
    
    scanf("%d%d",&A, &B);
if(A+B>=A-B&&A+B>=A*B)
    {
        printf("%d",A+B);
    }
else if (A-B>=A+B && A-B>=A*B)
    {
        printf("%d",A-B);
    }
else if (A*B>=A+B && A*B>=A-B)
    {
        printf("%d",A*B);
    }
return 0;
}

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

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int a = vals[0];
        int b = vals[1];
        var s = Console.ReadLine();

        if (s[a] == '-' && s.Substring(0, a).All(ss => char.IsNumber(ss))
             && s.Substring(a + 1).All(ss => char.IsNumber(ss)))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
def main():
    n, m = map(int, input().split())
    ts = sorted(tuple(map(int, input().split())) for _ in range(n))
    res = 0
    i = 0
    while m > 0:
        b = min(ts[i][1], m)
        res += ts[i][0] * b
        m -= b
        i += 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x[n],y[n];
  for (int i = 0; i < n; ++i) cin>>x[i];
  for (int i = 0; i < n; ++i) cin>>y[i];
  int a1=0;
  for (int i = 0; i < n; ++i) a1+=abs(x[i]-y[i]);
  cout<<a1<<endl;
  double a2=.0;
  for (int i = 0; i < n; ++i) a2+=(double)abs(x[i]-y[i])*abs(x[i]-y[i]); 
  printf("%.6f\n",sqrt(a2));
  double a3=.0;
  for (int i = 0; i < n; ++i) a3+=(double)abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]); 
  printf("%.6f\n",pow(a3,1.0/3.0));
  int a4=0;
  for (int i = 0; i < n; ++i) a4=max(a4,abs(x[i]-y[i]));
  cout<<a4<<endl;
}


Measured memory_bytes: 3352
def insertionSort(A, N):
    for i in range(1, N):
        pri_lst(A)
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v

def pri_lst(A):
    print(" ".join(map(str,A)))

N = int(input())
A = list(map(int,input().split()))

insertionSort(A, N)
pri_lst(A)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+50;
int n,ans,pos,l,r,bpos;
int sum[N];
char s[N],t[N];
int main()
{
	int i;
	bool pd=1;
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(i=1;i<=n;i++)
	{
		if(s[i]!=t[i]) pd=0;
	}
	if(pd==1)
	{
		puts("0");
		return 0;
	}
	pos=n+1;ans=0;
	l=1;r=0;bpos=n+2;
	for(i=n;i>=1;i--)
	{
		if(t[i]==t[i-1]) continue;
		if(pos>i&&s[i]==t[i])
		{
			l=1;r=0;bpos=i+1;
			continue;
		}
		pos=min(pos,i);
		while(pos>0&&s[pos]!=t[i]) pos--;
		if(pos==0)
		{
			puts("-1");
			return 0;
		}
		r++;sum[r]=sum[r-1]+bpos-pos-1;
		while(l<r&&pos+(sum[r]-sum[l])>=i) l++;
		ans=max(ans,r-l+1);
		bpos=pos;
	}
	
	ans++;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

string s, t;

inline int check(int x)
{
	for (int i = 0; t[i] != '\0'; i++) {
		if (s[i + x] != t[i] && s[i + x] != '?') return 0;
	}
	for (int i = 0; t[i] != '\0'; i++) {
		s[i+x] = t[i];
	}
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == '?') s[i] = 'a';
	}
	cout << s << endl;
	return 1;
}

int main()
{
	cin >> s >> t;
	int l = s.length() - 1;
	for (int i = l; i >= 0; i--) {
		if (check(i) == 1) return 0;
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}

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

long f(long b, long n) {
  long ret = 0;
  for (long num = n; num > 0; num /= b)
    ret += num % b;
  return ret;
}

int main(int argc, char *argv[]) {
  long n, s, rt_n;
  scanf("%ld %ld", &n, &s);
  rt_n = sqrtl(n);
  // printf("n = %ld, s = %ld, rt_n = %ld\n", n, s, rt_n);
  // obviously impossible if s is larger than n
  if (s > n) {
    printf("-1\n");
    return 0;
  }
  // search all b <= sqrt(n)
  for (long b = 2; b <= rt_n; b++) {
    if (f(b, n) == s) {
      printf("%ld\n", b);
      return 0;
    }
  }
  // search all sqrt(n) < b <= n (n is 2 digit base b)
  // search all p where pb + q = n
  for (long p = rt_n; p > 0; p--) {
    long q = s - p;
    long b = (n - q) / p;  // bigger when p is smaller
    if ((n - q) % p == 0 && p >= 0 && p < b && q >= 0 && q < b) {
      printf("%ld\n", b);
      return 0;
    }
  }
  // search b >= n (n is 1 digit base b)
  if (n == s) {
    printf("%ld\n", n + 1);
    return 0;
  }
  printf("-1\n");
  
  return 0;
}


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

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);


	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d) cout << "Yes" << "\n";
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	Would you please return 0;
}

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

int A,B,C;

int main(){
	scanf("%d%d%d",&A,&B,&C);
	int sum1=A+B,sum2=B+C,sum3=A+C;
	printf("%d",min(sum1,min(sum2,sum3)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){

  int a, b, m;
  std::cin >> a >> b >> m;

  std::vector<int> av(a), bv(b);
  int min_a = 100000000, min_b = 10000000;
  for(int i=0; i<a; i++){
    std::cin >> av[i];
    min_a = std::min(min_a, av[i]);
  }
  for(int i=0; i<b; i++){
    std::cin >> bv[i];
    min_b = std::min(min_b, bv[i]);
  }

  int ret = min_a + min_b;
  for(int i=0; i<m; i++){
    int x, y, c;
    std::cin >> x >> y >> c;
    x--;
    y--;
    ret = std::min(ret, av[x]+bv[y]-c);
  }

  std::cout << ret << std::endl;

  
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++)
    cin >> S[i];
  int numAB = 0;
  int numHeadB = 0, numTailA = 0, numHeadBAndTailA = 0;
  for(int i=0; i<N; i++) {
    if(*(S[i].begin()) == 'B' && *(S[i].end()-1) == 'A') numHeadBAndTailA++;
    else if(*(S[i].begin()) == 'B') numHeadB++;
    else if(*(S[i].end()-1) == 'A') numTailA++;
    for(int j=0; j<S[i].size()-1; j++)
      if(S[i][j] == 'A' && S[i][j+1] == 'B')
	numAB++;
  }
  // cout << numAB << ' ' << numHeadB << ' ' << numTailA << ' ' << numHeadBAndTailA << endl;
  int ans = numAB;
  if(numHeadBAndTailA > 0) {
    ans += numHeadBAndTailA - 1;
    if(numHeadB == 0 && numTailA == 0) {
    } else if(numHeadB == 0) {
      ans += 1;
    } else if(numTailA == 0) {
      ans += 1;
    } else {
      ans += 2;
      ans += min(numHeadB-1, numTailA-1);
    }
  } else {
    ans += min(numHeadB, numTailA);
  }
  cout << ans << endl;
  return 0;
}


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

long long pow(int a, int b, int mod)
{
	int ret = 1;
	for(int i = 0 ; i < b ; i ++){
		ret = ret * a % mod;
	}
	return ret;
}

int main(void){
	long long n;
	cin>>n;
	vector<int> v(n);
	for(int i = 0 ; i < n ; i ++){
		cin>>v[i];
	}

 	int s = n-1;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	if (n % 2 == 1) v.push_back(0);

 	bool flag = true;
	for(int i = 0 ; i < n ; i ++){
		int a = v[i++];
		int b = v[i];
		if (a != s || b != s || a != b){
			flag = false;
			break;
		}
		s -= 2;
	}

	if (flag) cout<<pow(2, n/2, 1000000007)<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 896
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

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

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

int main()
{
	int n;
	cin >> n;
	vector<int> hl(n);
	rep(i, n) {
		cin >> hl[i];
	}
	int ans = 0;
	vector<int> ansl(n);
	rep(i, n) {
		while (hl[i] != ansl[i]) {
			ans++;
			repi(j, i, n) {
				if (hl[j] > ansl[j]) {
					ansl[j]++;
				}
				else
				{
					break;
				}
			}
		}
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 3672
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var result = 0;
        for(var i = 0; i < num; i++)
        {
            var input = ReadLine().Split(' ');
            result += ToInt32(input[1]) - ToInt32(input[0]) + 1;
        }

        WriteLine(result);
    }
}


Measured memory_bytes: 11220
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        if(a>8 || b>8) {
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }

    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    vector<int> a(k);
    rep(i, 0, k){
        cin >> a[i];
    }
    bool f = true;
    int MIN = 2, MAX = 3;
    repb(i, k - 2, 0){
        MIN = (MIN + a[i] - 1) / a[i] * a[i];
        MAX = (MAX / a[i + 1] * a[i + 1] + a[i + 1] - 1) / a[i] * a[i] + a[i] - 1;
    }
    int a1 = MAX, a2 = MIN;
    rep(i, 0, k){
        a1 = a1 / a[i] * a[i];
        a2 = a2 / a[i] * a[i];
    }
    if(a1 != 2 || a2 != 2) f = false;
    if(f == false) cout << -1 << endl;
    else cout << MIN << " " << MAX << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
   int n;
   scanf("%d", &n);
   int L[81];
   int i,j,k;
   int cnt = 0;
   int bo = 0;
   for (i = 1; i < 10; i++){
     for (j = 1; j < 10; j++){
       L[cnt] = i*j;
       cnt++;
     }
   }
  for (k = 0; k < 81; k++){
    if (L[k] == n){
      bo++;
    }
  }
  if (bo > 0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	vector<bool> ans(3, true);
	int a, b; std::cin >> a >> b;
	a--, b--;
	ans[a] = false, ans[b] = false;
	rep(i, 3) {
		if (ans[i])
			std::cout << i+1 << "\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n;
ll calc(vl a){
    ll ans=0;
    while(true){
        ll dd=0;
        for(int i=0;i<n;i++){
            dd+=a[i]/n;
        }
        if(dd==0)break;
        ans+=dd;
        for(int i=0;i<n;i++){
            a[i]=(a[i]%n)+dd-a[i]/n;
        }
    }
    return ans;
}
int main(){
    cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    cout<<calc(a)<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
dic2 = {}
for i in range(N):
    S,P = input().split()
    new = [P,i]
    dic[S].append(new)
ans = sorted(dic.items(), key=lambda x: x[0])
for i in ans:
    new_i = list(i)[-1]
    # print(new_i)
    x = []
    for i1 in new_i:
        # print(i1)
        dic2[i1[0]] = i1[-1]
        x.append(int(i1[0]))
    else:
        x.sort(reverse=True)
        for i in x:
            print(dic2[str(i)]+1)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

int main(void)
{
	int N;
	int V[21], C[21];
	int dp[51][51];

	memset(dp, 0, sizeof(dp));

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) {
			sum += V[i] - C[i];
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256