akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h> //abs

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> frames(N);
  int sum = 0;
  for (int &e: frames) {
    cin >> e;
    sum += e;
    e *= N;
  }
	
  auto it = min_element(begin(frames), end(frames), [sum] (int a, int b){
    return abs(b - sum) > abs(a - sum);
  });
  
  cout << it - begin(frames) << endl;
  return 0;
}

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

using namespace std;

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

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

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

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

ll dp[10010][2][110] = {};

int main()
{
	string k;
	int d;
	cin>>k>>d;
	
	int l = k.length();
	dp[0][0][0] = 1;
	for (int i = 0; i < l; i++){
		int D = k[i]-'0';
		for (int smaller = 0; smaller < 2; smaller++){
			for (int j = 0; j < d; j++){
				for (int digit = 0; digit <= (smaller?9:D); digit++){
					dp[i+1][smaller||(digit<D)][(j+digit)%d] += dp[i][smaller][j];
					dp[i+1][smaller||(digit<D)][(j+digit)%d] %= mod;
				}
			}
		}
	}
	cout<<(dp[l][0][0] + dp[l][1][0]-1+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    TSTART();
    vector<bool> vb(26);
    REP(i,SZ(s)){
      DUMP(s[i]-'a');
      vb[s[i]-'a'] = true;
    }

    bool solved = false;
    REP(i,26){
      if(!vb[i]){
	cout << (char)('a' + i) << endl;
        solved = true;
	break;
      }
    }

    if(!solved)
      cout << "None" << endl;
    
    TSTOP();
  }
  return 0;
}



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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int q;
  cin >> q;

  while (q--) {

    long long a, b, c = 0;
    cin >> a >> b;

    if (a > b) swap(a, b);
    if (b <= a + 1) {
      cout << 2 * a - 2 << '\n';
      continue;
    }

    int l = 1, r = 1e9 + 5;
    while (l < r) {
      c = (l + r) / 2;
      if (c * c < a * b) l = c + 1;
      else r = c;
    }
    c = l - 1;
    
    if (c * (c + 1) < a * b) {
      cout << 2 * c - 1 << '\n';
    } else {
      cout << 2 * c - 2 << '\n';
    }
  }
} 

Measured memory_bytes: 256
// 絶対値が最大の要素を取り除く.
// 0をはさむか否かで場合分け.
#include<iostream>
using namespace std;
int main() {
  int n,l,min,max,eaten;
  cin >> n >> l;
  min = l;
  max = l+n-1;
  if(min>0) eaten = min;
  else if(max<0) eaten = max;
  else eaten = 0;
  cout << n*(2*l+n-1)/2 - eaten;
  return 0;
}

Measured memory_bytes: 256
# 2019/08/01

n,m=map(int,input().split())

def divisors(n,m):
    div=[]
    end=int(pow(m,0.5))
    for i in range(1,end+1):
        if m%i==0:
            div.append(i)
            div.append(m//i)
    div.sort(reverse=True)
    return div

res=divisors(n,m)
for e in res:
    if m//n>=e:
        print(e)
        break


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

using namespace std;

vector<int> cnt(1000000);

int main(){
    int n;cin>>n;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        cnt[x]++;
    }
    int rj=0;
    for(int i=1;i<=1000000;i++){
        if(cnt[i]){
            if(cnt[i]==1)rj++;
            for(int j=i+i;j<=1000000;j=j+i){
                cnt[j]=0;
            }
        }
    }
    cout <<rj<<endl;
}


Measured memory_bytes: 7076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int n;
cin>>n;
int p[n];
int tmp;
for(int i=0;i<n;++i){
  cin>>tmp;
  p[i]=tmp;
}
int ans=0;
bool judge=true;
for(int i=0;i<n-2;++i){
  judge=true;
  if(p[i]<p[i+1] && p[i+2]<p[i+1]){
    judge=false;
  }
  if(p[i]>p[i+1] && p[i+2]>p[i+1]){
    judge=false;
  }
  
  if(judge){
    ans+=1;
  }
}
cout<<ans<<"\n";
return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 200200;
const int Mod = 998244353;

int Inv[N];
int Fact[N];
int iFact[N];

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int add(int x, int y)
{
    return add_self(x, y), x;
}

int sub(int x, int y)
{
    return sub_self(x, y), x;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int fp(int x, ll y)
{
    int Res = 1;
    for(; y > 0; y >>= 1, x = mul(x, x))
        if(y & 1)
            Res = mul(Res, x);
    return Res;
}

int C(int n, int m)
{
    if(n < 0)   return 0;
    if(m < 0)   return 0;
    if(n < m)   return 0;
    return mul(Fact[n], mul(iFact[m], iFact[n - m]));
}

void PreCalcMod()
{
    Inv[1] = 1;
    for(int i = 2; i < N; i++)  Inv[i] = (Mod - mul(Mod / i, Inv[Mod % i])) % Mod;

    Fact[0] = iFact[0] = 1;
    for(int i = 1; i < N; i++)  Fact[i] = mul(i, Fact[i - 1]);
    for(int i = 1; i < N; i++)  iFact[i] = mul(Inv[i], iFact[i - 1]);
}

int main()
{
    PreCalcMod();

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

    k = n - 1 - k;

    int Ans = 0;

    for(int j = k; j < n; j++)
    {
        add_self(Ans, mul(C(n - 1, j), mul(m, fp(m - 1, j))));
    }

    cout << Ans << endl;
}


Measured memory_bytes: 5972
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll N, A, B; cin >> N >> A >> B;
  vector<ll> x(N); rep(i, N) cin >> x[i];

  ll ans = 0;
  for (int i = 0; i < N - 1; ++i){
    ans += min((x[i + 1] - x[i]) * A, B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const double INF = 100000000;
using namespace std;

//i???????????????????????????
bool getBit(int num, int i){
    return ((num & (1 << i)) != 0);
}

//i?????????1?????????
int setBit(int num, int i){
    return num | (1 << i);
}

//i?????????0?????????
int clearBit(int num, int i){
    int mask = ~(1 << i);
    return num & mask;
}

//i?????????v??§???????????????
int updateBit(int num, int i, int v){
    int mask = ~(1 << i);
    return (num & mask) | (v << i);
}

int main(){
    int n, m, p, a, b;
    while(scanf("%d%d%d%d%d",&n,&m,&p,&a,&b), n){
        a--; b--;
        double g[40][40];
        rep(i,40) memset(g[i],-1,sizeof(g[i]));

        double t[10];
        rep(i,n) scanf("%lf",&t[i]);
        rep(i,p){
            int a, b;
            double c;
            scanf("%d%d%lf",&a,&b,&c);
            a--; b--;
           g[a][b] = g[b][a] = c;
        }

        double dp[500][40];
        rep(i, 1 << n) rep(j, 40) dp[i][j] = INF;
        dp[(1 << n) - 1][a] = 0;

        double ans = INF;
        for(int s = (1 << n) - 1; s >= 0; s--){
            ans = min(ans, dp[s][b]);
            rep(i,n){
                if(getBit(s,i)){
                    rep(v,m){
                        rep(u,m){
                            if(g[v][u] == -1) continue;
                            dp[clearBit(s,i)][u] = min(dp[clearBit(s,i)][u], dp[s][v] + g[v][u] / t[i]);
                        }
                    }
                }
            }
        }
        if(ans == INF){
            printf("Impossible\n");
        }else{
            printf("%.3f\n",ans);
        }
    }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

vector<int> par, depth;

void init(int n){
    par.resize(n); depth.resize(n);
    for(int i=0; i<n; i++){
        par[i]=i;
        depth[i]=0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    return par[x]=find(par[x]);
}

void unite(int x, int y){
    x=find(x), y=find(y);
    if(x == y) return;
    if(depth[x] < depth[y]) par[x]=y;
    else{
        par[y]=x;
        if(depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int N, M; cin >> N >> M;
    vi p(N);
    for(auto &x : p){
        cin >> x;
        x--;
    }
    vi x(M), y(M);
    init(N);
    for(int i=0; i<M; i++){
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
        unite(x[i], y[i]);
    }

    int ans=0;
    for(int i=0; i<N; i++){
        if(same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		if(s.length() == 2) {
			System.out.println(s);
		}else {
			for(int i = 0; i < 3; i++) {
				System.out.print(s.charAt(2-i));
			}
			System.out.print('\n');
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32732
from collections import defaultdict


n,m=map(int,input().split())
d=defaultdict(int)
parent=[-1]*(n+1)
def find(a):
    if parent[a]<0:
        return a
    parent[a]=find(parent[a])
    return parent[a]
    # else:
    #     l = []
    #     while parent[a]>0:
    #         l.append(a)
    #         a=parent[a]
    #     for i in l:
    #         parent[i]=a
    #     return a

def union(a,b):
    parent[a]+=parent[b]
    parent[b]=a
    d[parent[a]]+=d[parent[b]]+1
for i in range(m):
    a,b= map(int, input().split())
    if a>b:a,b=b,a
    a=find(a)
    b=find(b)
    if a!=b:
        union(a,b)
ans=0

for x in parent[1:]:
    x=-x
    ans=max(ans,x)
print(ans)

Measured memory_bytes: 52400
N, A, B = input().split()
'''                                                                                                                                     
N = input()                                                                                                                             
A = input()                                                                                                                             
B = input()                                                                                                                             
'''
N = int(N)
A = int(A)
B = int(B)
priceA = A * N
if  priceA <= B:
    print(priceA)
else:
    print(B)


Measured memory_bytes: 3064
#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;

int n, q, k;
vector<P> G[100010];
int d[100010];

void dfs(int now, int pre, int l){
    d[now] = l;
    rep(i, 0, G[now].size()){
        int next = G[now][i].first;
        if(pre == next) continue;
        dfs(next, now, l + G[now][i].second);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n - 1){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(P(b, c));
        G[b].push_back(P(a, c));
    }
    cin >> q >> k;
    k--;
    dfs(k, -1, 0);
    rep(i, 0, q){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 15872
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int n = s.length();
		int lm = 0;
		if(n % 2 == 0){
			lm = n/2;
		}else{
			lm = n/2;
		}
		//System.out.println(lm);
		int i = 0, j = n - 1;
		int count = 0;
		while(i < lm ){
			//System.out.println(s.charAt(i));
			if(s.charAt(i) != s.charAt(j)){
				count++;
			}
			i++;
			j--;
		}
		System.out.println(count);
		
	}
		
		
}

Measured memory_bytes: 25300
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
    int N, a;
    cin >> N;
    int minus = 1;
    for(int i = 0; i < N; i++) {
        cin >> a;
        if(a%2 == 0) {
            minus *= 2;
        }
        else {
            minus *= 1;
        }
    }
    cout << (int)pow(3, N) - minus << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int x;
  cin>>x;
  out(10-x/200);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (((100*a+10*b+c) % 4 == 0) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;


int main()
{
	int t[31 + 3];
	t[0] = t[1] = 0;
	t[2] = 1;
	for (int i = 3; i < 31 + 3; ++i)
		t[i] = t[i-1] + t[i-2] + t[i-3];

	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", (t[n+2]/10+365) / 365);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
vector<int> A;

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

vector<int> bun(int l, int r){
	vector<int> ret;
	if(r-l <= 1){
		ret.push_back(A[l]);
		return ret;
	}
	vector<int> left = bun(l,(l+r)/2);
	vector<int> right = bun((l+r)/2,r);
	ret.push_back(gcd(left[0],right[0]));
	if(left.size() == 1){
		ret.push_back(right[0]);
	}
	if(right.size() == 1){
		ret.push_back(left[0]);
	}
	rep(i,left.size()){
		if(i==0) continue;
		ret.push_back(gcd(right[0],left[i]));
	}
	rep(i,right.size()){
		if(i==0) continue;
		ret.push_back(gcd(left[0],right[i]));
	}

	return ret;
}

int main(void){
  int n;
  cin>>n;
  int a;
    rep(i,n){
  	cin>>a;
  	A.push_back(a);
  }
  vector<int> ans = bun(0,A.size());
  sort(all(ans));
  reverse(all(ans));
  cout<<ans[0]<<endl;
  return 0;
}


Measured memory_bytes: 1912
#include <stdio.h>
 
class Dice4{
public:
    int number[6];
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
};
 
int main(){
    int n,k,j;
    scanf("%d",&n);
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
                &array[i].number[3],&array[i].number[4],&array[i].number[5]);
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}




Measured memory_bytes: 2624
n,m,q = map(int,input().split())
lr = [[0] * (n+1) for i in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    lr[l][r] += 1
for i in range(len(lr)):
    for j in range(len(lr[i])-1):
        lr[i][j+1] = lr[i][j]+lr[i][j+1]
pq = [list(map(int,input().split())) for _ in range(q)]
for i in range(len(pq)):
    ans=0
    for j in range(pq[i][0],pq[i][1]+1):
        ans+=lr[j][pq[i][1]]-lr[j][pq[i][0]-1]
    print(ans)

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



int A[3000000], B[3000000], C[100000];

void CountingSort(int A[], int B[], int k, int n) {
	for (int i = 0; i <= k; i++)
		C[i] = 0;
	for (int i = 0; i < n; i++)
		C[A[i]]++;
	for (int i = 1; i <= k; i++)
		C[i] += C[i - 1];
	for (int i = n - 1; i >= 0; i--) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	int k = 0;
	for (int i = 0; i < n; i++) {
		if (k < A[i])
			k = A[i];
	}

	CountingSort(A, B, k, n);

	for (int i = 0; i < n; i++) {
		printf("%d", B[i]);
		if (i == n - 1)
			printf("\n");
		else
			printf(" ");
	}
}


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
} // }}}

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

    size_t H, W;
    cin >> H >> W;

    int black = 0;
    vector<string> mat(H);
    for (size_t i = 0; i < H; ++i) {
        cin >> mat[i];
        for (size_t j = 0; j < W; ++j) {
            if (mat[i][j] == '#') {
                black++;
            }
        }
    }

    queue<pair<int, int>> que;
    que.emplace(0, 0);

    auto dist = make_v(INF, H, W);
    dist[0][0] = 0;

    while (!que.empty()) {
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for (size_t i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (inside(ny, nx, H, W) && dist[ny][nx] > dist[y][x] + 1 && mat[ny][nx] != '#') {
                que.emplace(ny, nx);
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }

    int allmat = H * W;
    if (dist[H - 1][W - 1] == INF) {
        cout << -1 << "\n";
    } else {
        cout << allmat - black - dist[H - 1][W - 1] - 1 << "\n";
    }

    return 0;
}


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

int func(int d, int N) {
	int res = 0;
	vector<int> v(d, 0);
	for (int i = 0; i < pow(3, d); ++i) {
		int x = i;
		for (int j = 0; j < d; ++j) {
			v[j] = x % 3;
			x /= 3;
		}

		ll sum = 0;
		bool a = false;
		bool b = false;
		bool c = false;
		for (int j = 0; j < d; ++j) {
			sum *= 10;
			if (v[j] == 0) {
				a = true;
				sum += 3;
			}
			if (v[j] == 1) {
				b = true;
				sum += 5;
			}
			if (v[j] == 2) {
				c = true;
				sum += 7;
			}
		}
		if (a && b && c) {
			if (sum <= N) { ++res; }
		}
	}

	return res;
}

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

	int d = 0;
	int x = N;
	while (x > 0) {
		++d;
		x /= 10;
	}

	int res = 0;
	for (int i = 3; i <= d; ++i) {
		res += func(i, N);
	}

	cout << res << endl;

	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int a[N][3], n, dp[N], cache[N][3];

int solve(int i, int j){
    int &ans = cache[i][j];
    if(ans != -1)
    return ans;
    if(i >= n)
    return 0;
    if(j == 0)
    return cache[i][j] = a[i][j] + max(solve(i + 1, 1), solve(i + 1, 2));
    if(j == 1)
    return cache[i][j] = a[i][j] + max(solve(i + 1, 0), solve(i + 1, 2));
    if(j == 2)
    return cache[i][j] = a[i][j] + max(solve(i + 1, 0), solve(i + 1, 1));
}

void solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> a[i][j];
        }
    }
    memset(cache, -1, sizeof cache);
    cout << max({solve(0, 0), solve(0, 1), solve(0, 2)});
}

int32_t main(){
    IOS;
    int t = 1;
    bool test = 0;
    if(test) cin >> t;
    for(int i = 1; i <= t; ++i)
    solve();
    return 0;
}

/*

  
*/
  

Measured memory_bytes: 12992
#include <stdio.h>

int main(void)
{
    long n, i, j, cusum=0, total=0;
    long a[200000];
    long mod = 1000000007;

    scanf("%ld", &n);
    for(i=0; i<n; i++){
        scanf("%ld", &a[i]); 
        cusum=(cusum+a[i]) % mod;   //累積和
    }

    for(i=0; i<n; i++){
        cusum -= a[i];
        if(cusum < 0) cusum += mod;
        
        total += a[i]*cusum;
        total %= mod;
    }

    printf("%ld", total);
}

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

int main(){
    string S, substr[5]; cin >> S;
    int K; cin >> K;
    int N = S.size();
    set<string> SDP;
    
       for(int i = 0; i < N; i++){
            for(int j = i; j < i + 5; j++){
                if(j >= N) break;
                string sub = S.substr(i, j + 1 - i);
                SDP.insert(sub);
            }
        }
        auto itr = SDP.begin();
        for(int i = 0; i < K - 1 ; i++) itr++;
        cout << *itr << endl; 
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
 
int Findgcd_by_Euclid(int, int);
 
#define MAX_KIND 100002
 
int main()
{
	int monster[MAX_KIND] = { 0 };
	int d;
	int i;
	int gcd;
	scanf("%d", &d);
 
	scanf("%d", &monster[0]);
	gcd = monster[0];
 
	for (i = 1; i < d; i++)
	{
		scanf("%d", &monster[i]);
		gcd = Findgcd_by_Euclid(monster[i], gcd);
	}
	printf("%d", gcd);
	return 0;
}
 
int Findgcd_by_Euclid(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var P int
	var Q int
	var R int
	fmt.Scan(&P)
	fmt.Scan(&Q)
	fmt.Scan(&R)

	if P <= R {
		if Q <= R {
			fmt.Println(P + Q)
		} else if Q > R {
			fmt.Println(P + R)
		}
	}
	if P > R {
		if Q <= P {
			fmt.Println(Q + R)
		} else if Q > P {
			fmt.Println(P + R)
		}
	}
}

Measured memory_bytes: 512
n = int(input())
hxy = []
for i in range(n):
    x, y, h = map(int, input().split())
    hxy.append([h, x, y])
    
hxy.sort(reverse=True)

for i in range(101):
    for j in range(101):
        h0, x0, y0 = hxy[0]
        H = h0 + abs(x0-i) + abs(y0-j)
        if all(h == max(H - abs(x-i) - abs(y-j), 0) for h, x, y in hxy):
            print(i, j, H)
            break

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

int c[15], a[15][15];

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

int main() {
    int k; scanf("%d", &k);
    int ans = 0;
    for (int i = 1; i <= k; i++)
        for (int j = 1; j <= k; j++)
            for (int l = 1; l <= k; l++)
                ans += gcd(gcd(i, j), l);
    printf("%d\n", ans);
}

Measured memory_bytes: 1728
S = input().split()
stack = []

operator = ['+', '-', '*']

for i in range(len(S)):
    if not(S[i] in operator):
        stack.append(int(S[i]))
    elif S[i] == operator[0]:
        a = stack.pop()
        b = stack.pop()
        stack.append(a + b)
    elif S[i] == operator[1]:
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif S[i] == operator[2]:
        a = stack.pop()
        b = stack.pop()
        stack.append(a * b)
print(stack[0])


Measured memory_bytes: 5604
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 #define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k,mo;
main()

{
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<0<<endl;
    else if((n+m)%2==0)
    {
        cout<<(n+m)/2<<endl;
    }
    else cout<<"IMPOSSIBLE"<<endl;
}


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

#define int long long

signed main(){
  int n;
  int x[200], y[200], h[200];
  cin >> n;

  int tx, ty, th;
  for(int i = 0;i < n;i++){
    cin >> x[i] >> y[i] >> h[i];
  }

  for(int i = 0;i < n;i++){
    if(h[i] != 0){
      tx = x[i];
      ty = y[i];
      th = h[i];
      break;
    }
  }

  for(int i = 0;i <= 100;i++){
    for(int j = 0;j <= 100;j++){
      int hh = llabs(ty-i) + llabs(tx-j) + th;
      int cnt = 0;
      for(int p = 0;p < n;p++){
        if(max(hh-llabs(y[p]-i)-llabs(x[p]-j), 0ll) == h[p]){
          cnt++;
        }else{
          break;
        }
      }
      if(cnt == n){
        cout << j << " " << i << " " << hh << endl;
        return 0;
      }
    }
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, A[100000], p;
ll res;
pair<int, int>cb[100000];

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> cb[i].second >> cb[i].first;
	}
	sort(A, A + N);
	sort(cb, cb + M);
	for (int i = M - 1; i >= 0; --i) {
		while (p != N&&cb[i].first > A[p] && cb[i].second) {
			A[p] = cb[i].first;
			--cb[i].second;
			++p;
		}
	}
	for (int i = 0; i < N; ++i) {
		res += A[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n;
  cin >> n;
  ll a[200000];
  vector<int> b(n);
  for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for (int i = 0; i < n; ++i) a[i] -= i + 1;

  std::sort(a, a + n);

  int middle;
  if (n % 2 == 0) middle = n / 2;
  else middle = (n - 1) / 2;

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += abs(a[i] - a[middle]);
  }

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


Measured memory_bytes: 2560
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 998244353;


ll N,ans=INF;
char S[200009];
ll a[200009];
ll b[200009];


int main() {

	cin >> N;
	cin >> S;

	FOR(i, 0, N) {
		a[i + 1] = a[i]; b[i + 1] = b[i];
		if (S[i] == '.')a[i+1]++;
		else b[i+1]++;
	}
	FOR(i, 1, N+1) {
		ans = min(ans, b[i] + a[N] - a[i]);
	}
	ans = min(ans, a[N]);
	ans = min(ans, b[N]);
	cout << ans << endl;


	return 0;
}

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

using namespace std;

#define ll long long

signed main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	double ans = 0;
	for (auto ai : a) ans += 1.0 / ai;
	cout << setprecision(12) << 1.0 / ans << endl;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int all = 0, cnt = 0;
  rep(i,n){
    if (s.at(i) == 'R') all++;
  }
  rep(i,all){
    if (s.at(i) == 'R') cnt++;
  }
  int ans = all - cnt;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);


long long N;
vector<long long> A, B;
long long btn[100002] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		long long a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}

	long long ans = 0;
	for(int i=N-1; i>=0; i--){
		long long a;
		if(i == N-1){
			a = A[i];
		}
		else{
			a = A[i] + (btn[i+1] - A[i+1]);
		}
		long long r = a % B[i];
		if(r == 0){
			btn[i] = a;
			continue;
		}
		long long u = B[i] - r;
		ans += u;
		btn[i] = a + u;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1010
#define FOR(i,s,e) for(int i=s; i<=e; i++)
char maze[MAXN][MAXN];
long long memo[MAXN][MAXN];
const long long MOD = 1e9 + 7;
int r, c;
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
int f(int i, int j) {
    if(i == r && j == c) return 1;
    if(i > r || j > c) return 0;
    if(maze[i][j] == '#') return 0;
    if(memo[i][j] != -1) return memo[i][j];
    return memo[i][j] = (f(i+1, j) + f(i, j+1)) % MOD;
}
void solve() {
    cin >> r >> c;
    FOR(i,1,r) {
        FOR(j,1,c) {
            cin >> maze[i][j];
        }
    }
    memset(memo, -1, sizeof(memo));
    cout << f(1,1) << endl;
}
int main() {
  __fastio;
  solve();
  return 0;
}


Measured memory_bytes: 9344
fun main(args: Array<String>) {
    val (a, b, x) = readLine()?.split(" ")?.map(String::toLong) ?: return
    val s = a / x
    val e = b / x
    val t = e - s + if (a % x == 0L) {
        1
    } else {
        0
    }
    println(t.toString())
}


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

int main () {
	char str[255], temp[255];
	scanf("%s", str);
	
	for (int i = 0, j = 0 ; str[i] != '\0' ; i++) {
		if(str[i] == '1') {
			temp[j] = '1';
			j++;
			temp[j] == '\0';
		} else if(str[i] == '0') {
			temp[j] = '0';
			j++;
			temp[j] = '\0';
		} else {
			if ( j > 0) {
				temp[--j] = '\0';
			}
		}
	}
	printf("%s", temp);
	return 0;
}

Measured memory_bytes: 1732
// B - Five Dishes
#include <bits/stdc++.h>
using namespace std;

int main(){
	int time = 0, max_dif = 0;
	for(int i=0; i<5; ++i){
		int a; cin>>a;
		int dif = ((a+9)/10) * 10 - a;
		if(max_dif<dif) max_dif = dif;
		time += a + dif;
	}
	cout<< time - max_dif <<endl;
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

int main() {
  ll n, r;
  cin >> n >> r;
  ll ans = r + 100 * (10 - n);
  if (n >= 10) ans = r;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

N, K = splitintinput()
mod = 10 ** 9 + 7
ans = 0
for i in range(K, N+2):
    ans += i * (N+1-i) + 1
    ans = ans % mod

print(ans)

Measured memory_bytes: 27324
"""

二次元のデータセットをリスト1つとして管理し
これを１つの正方形とする。

まず、指定されたindexのx,y座標リストを取得する
それぞれの方向によって、




"""

while(1):

	blocks = []
	blocks.append([0,0])
	#print(blocks[0])
	#print(blocks[0][1])
	N = input()
	
	N = int(N)
	
	if N == 0:
		break
	list_y = []
	list_x = []
	
	l_count = N-1
	num = 1
	
	while(1):
		
		if l_count == 0:
			break
			
		place,vector = input().split() #nはindex indexは正方形を１つずつおいていくときに、1ずつ上がっていく
		# まず、n番目のリストを取得し, dによって4通りの数値演算。それはリストの0番目がx, 1番目がyとして判断すれば良い
		place = int(place)
		vector = int(vector)
		
		get_x = blocks[place][0]
		get_y = blocks[place][1]
		
		if vector == 0:
			get_x -= 1
			blocks.append([get_x,get_y])
		elif vector == 1:
			get_y -= 1
			blocks.append([get_x,get_y])
		elif vector == 2:
			get_x += 1
			blocks.append([get_x,get_y])
		elif vector == 3:
			get_y += 1
			blocks.append([get_x,get_y])
		
		l_count -= 1
		num += 1
	
	#print(blocks)	
	
	
	for i in range(N):
		list_x.append(blocks[i][0])
		list_y.append(blocks[i][1])
	
	#print(list_x)
	#print(list_y)
	"""
	print(max(list_x))
	print(min(list_y))
	"""	
	
	print('%d %d' % (max(list_x)-min(list_x)+1,max(list_y)-min(list_y)+1))	
		
	
	#max_x =  [kv for kv in blocks[0] if kv[0] == max(blocks[0])] 
	
	#print(max_x)








Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 1 ;i<=n ;i++){
    scanf("%hd",&A[i]);
  }
  for(i = 0;i<=VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]] = C[A[j]]+1;
  }
  
  for(i = 1 ;i<=VMAX+1;i++){
    C[i] = C[i]+C[i-1];
  }
  for(j=n ;j>=1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(j = 1;j<n+1;j++){
    if(j ==n)
    printf("%d\n",B[j]);
    else printf("%d ",B[j]);
    }
  return 0;
}



Measured memory_bytes: 9712
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n, m, cnt = 0;
    string s;
    cin >> n >> m >> s;
    for(ll i = 0; i < s.size(); i ++)
    {
        if(s[i] == '-')
        {
            cnt ++;
        }
    }
    if(cnt == 1)
    {
        if(s[n] == '-')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


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

using ll = long long;

#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 ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#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 vl = vector<ll>;
using vvl = vector<vl>;
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);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    auto f = [](int n) {
        int ret = 0;
        while (n) ret += n%10, n /= 10;
        return ret;
    };
    std::cout << (n%f(n) == 0 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
/*
    _________             ____    __   __    __      __       __       __   __  
   |___   ___|           /  __)  |  | |  |  |  \    /  |     /  \     |  \ |  | 
       | |     __       (  {__   |  | |  |  |   \  /   |    / /\ \    |   \|  | 
       | |    /__\       \__  \  |  |_|  |  |    \/    |   / ____ \   |       | 
       | |                __)  ) {       }  |  |\__/|  |  / /    \ \  |  |\   | 
       |_|               (____/   \_____/   |__|    |__| /_/      \_\ |__| \__| 
*/
#include<bits/stdc++.h>
#define t_suman ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define pll pair<ll,ll>
#define VP vector< pll >
#define VLL vector< ll >
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rrep(i,a,b) for(int (i) = (a); (i) > (b); (i)--)
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
#define in insert
#define out erase
#define MOD 1000000007
#define MAX 1000005
using namespace std;

bool compare(const pair<ll,ll>& a , const pair<ll,ll>& b){
    return a.first<b.first;
}

ll gcd(ll a, ll b){ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
}
ll power(ll x, unsigned ll y){ 
    int res = 1; 
   
    while(y>0){  
        if (y & 1) res = res*x; 
   
        y = y>>1;
        x = x*x;
    } 
    return res; 
}
ll digSum(ll n){
	return n==0 ? 0 : (n%10)+digSum(n/10);
}
ll digMul(ll n){
	return n==0 ? 0 : (n%10)*digSum(n/10);
}
ll countNumberOfDigs(ll n){
	if(n==0)return 1;
	ll count=0;
	while(n!=0){
		n/=10;
		count++;
	}
	return count;
}
bool isPrime(ll n){ 
    if (n <= 1) return false; 
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}
void allPrime(map<ll,bool>& m){
	vector<bool> ar(MAX,1);
	ar[0]=0,ar[1]=0;
	rep(i,2,MAX){
		if(ar[i]){
			for(int j=2;i*j<MAX;j++){
				ar[i*j]=0;
			}
		}
	}
	rep(i,2,MAX){
		if(ar[i]){
			m[i]=1;
		}
	}
}
ll printNcR(ll n, ll r) 
{ 
  
    // p holds the value of n*(n-1)*(n-2)..., 
    // k holds the value of r*(r-1)... 
    long long p = 1, k = 1; 
  
    // C(n, r) == C(n, n-r), 
    // choosing the smaller value 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            // gcd of p, k 
            long long m = __gcd(p, k); 
  
            // dividing by gcd, to simplify product 
            // division by their gcd saves from the overflow 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
  
        // k should be simplified to 1 
        // as C(n, r) is a natural number 
        // (denominator should be 1 ) . 
    } 
  
    else
        p = 1; 
  
    // if our approach is correct p = ans and k =1 
    return p; 
} 
int main(void)
{
	t_suman;

	ll n1,n2;
	cin>>n1>>n2;
	ll ans=((n1*(n1-1))/2)+((n2*(n2-1))/2);
	cout<<ans;
	return 0;
}

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

// fenwick tree
int f[N];
void init(){for(int i=0;i<=N;i++)f[i]=0;}

void add(int i, int x){for(;i<=N;i+=i&-i)f[i]+=x;}

int sum(int i)
{
    int ret=0;
    for(;i>0;i-=i&-i)ret+=f[i];
    return ret;
}

int rangesum(int l, int r){return sum(r)-sum(l-1);}
// fenwick tree

int c[N];
vector<int> ql[N],qid[N];

int ans[N];

int a[N];

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

    for(int i=0;i<n;i++)cin>>c[i];

    for(int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;

        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    for(int i=1;i<=n;i++)
    {
        if(a[c[i-1]]>0)add(a[c[i-1]],-1);
        add(i,1);
        a[c[i-1]]=i;

        for(int j=0;j<ql[i].size();j++)
        {
            ans[qid[i][j]]=rangesum(ql[i][j],i);
        }
    }

    for(int i=0;i<q;i++)cout<<ans[i]<<endl;

    return 0;
}



Measured memory_bytes: 52920
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll ans = A[0];
  int count = 1;
  for (int i = 1; i < N; ++i) {
    if (count == N-1) break;
    ans += A[i];
    count++;
    if (count == N-1) break;
    ans += A[i];
    count++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4404