akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,a,b,sum=0;
    scanf("%lld",&n);
    vector<pair<long long int, long long int> >x;
    for(i=0;i<n;i++)
    {
        //scanf("%lld",&a,&b); scanf dileh hoy na ken? :(
        cin>> a >> b;
        x.push_back(pair<long long int, long long int>(b,a));
    }
    sort(x.begin(),x.end());
    for(i=0;i<n;i++)
    {
        sum+=x[i].second;
        if(sum>x[i].first)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    long sum = 0;
    vector<int> H(N);
    for(int i=0; i<N; i++) cin >> H.at(i);
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    for(int i = K; i <N; i++) sum += H.at(i);
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int d[11][11];
int dist[101][101];
int done[11][11];
int main() {
	int A,B;
	cin >> A >> B;
	for(int i=1;i<=A;i++){
		for(int j=1;j<=B;j++){
			cin >> d[i][j];
		}
	}
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			int m=0;
			for(int x=1;x<=A;x++){
				for(int y=1;y<=B;y++){
					m=max(m,d[x][y]-x*i-y*j);
				}
			}
			for(int x=1;x<=A;x++){
				for(int y=1;y<=B;y++){
					if(m==d[x][y]-x*i-y*j){
						done[x][y]=true;
					}
				}
			}
			dist[i][j]=m;
			if (i<5&&j<5){
				cerr << i << ", " << j << ": " << dist[i][j] << endl;
			}
		}
	}
	for(int x=1;x<=A;x++){
		for(int y=1;y<=B;y++){
			if(!done[x][y]){
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
	cout << 202 << " " << 2*100+101*101 << endl;
	for(int i=0;i<100;i++){
		cout << i+1 << " " << i+2 << " X" << endl;
	}
	for(int i=0;i<100;i++){
		cout << i+103 << " " << i+102 << " Y" << endl;
	}
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			cout << i+1 << " " << j+102 << " " << dist[i][j] << endl;
		}
	}
	cout << 1 << " " << 102 << endl;


	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    int nowx = 1,nowy = 1;
    auto ceil = [](int x,int y){
        return (x+y-1)/y;
    };
    rep(i,n){
        int x,y;
        scanf("%lld%lld",&x,&y);
        int pos = max(ceil(nowx,x),ceil(nowy,y));
        nowx = x*pos,nowy = y*pos;
        // trace(nowx,nowy,x,y,pos);
    }
    cout <<nowx + nowy << endl;
    return 0;
}


Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
}



Measured memory_bytes: 24576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
map<string,ll> ma;
void Init(){
	ma["SAT"]=1;
	ma["SUN"]=7;
	ma["MON"]=6;
	ma["TUE"]=5;
	ma["WED"]=4;
	ma["THU"]=3;
	ma["FRI"]=2;
}
int main()
{
	string s;
	cin>>s;
	Init();
	cout<<ma[s]<<endl;
	return 0;
}

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

using namespace std;

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

    if (count(s.begin(), s.end(), 'R') >
        count(s.begin(), s.end(), 'B')) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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




int main(void)
{
	int n,i,j,p=0;
	char a[40],aa[40],box[3],x=0;
	int b[40],bb[40],y=0,minv,v=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",box);//入力文字をcharとint型配列に分けて格納
		a[i]=box[0];
		b[i]=box[1]-'0';
		aa[i]=a[i];//選択ソート用に別の配列にも格納
		bb[i]=b[i];
	}
	//bubble sort
	for(i=0;i<n-1;){ //i ソート済みの配列番号
		for(j=n-1;j>=i;j--){ //末尾からソート済みまでの範囲をソート
			if(j!=0&&b[j-1]>b[j]){//隣接交換
				y=b[j-1];
				x=a[j-1];
				b[j-1]=b[j];
				a[j-1]=a[j];
				b[j]=y;
				a[j]=x;
				if(b[j-1]==b[j]&&a[j]==a[j-1]) p=1;//bubblesortは同じ値なら入れ替わらないので起こり得ないが、出力の安定か否かを判断
			}
			if(i==j) i++;//ソート済みまでいけばiをインクリメント
			
		}
	}
	
	for(i=0;i<n;i++){
		printf("%c%d",a[i],b[i]);
		if(i!=n-1) printf(" ");
	}
	if(p==0) printf("\nStable\n");
	else printf("\nNot stable\n");
	
	//selection sort
	p=0;
	for(i=0;i<n;i++){//i ソート済みの配列番号
		minv=37;//制約条件より最大値を格納
		for(j=i;j<n;j++){//未ソート部分から最小値を捜索
			if(bb[j]<minv){
				minv=bb[j];
				v=j;
			}
		}
		if(minv!=bb[i]){//最小値が左端でなければ交換
			y=bb[i];
			x=aa[i];
			bb[i]=minv;
		    aa[i]=aa[v];
			bb[v]=y;
			aa[v]=x;
			if(aa[v]==aa[i]) p=1;//出力の安定か否かを判断
		}
	}
	for(i=0;i<n;i++){
		printf("%c%d",aa[i],bb[i]);
		if(i!=n-1) printf(" ");
	}
	if(p==0) printf("\nStable\n");
	else printf("\nNot stable\n");

   	return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include<math.h>
int main() {
	long long n, k, i, mod = 1e9+7, sum=0;
	scanf("%lld %lld", &n, &k);
	for(i=k; i<=n+1; i++){
		sum += i*n - i*i + i + 1;
		sum %= mod;
	}
	printf("%lld", sum);
	return 0;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  
  string S;
  cin >> S;
  
  if(S=="ABC"){
    cout << "ARC";
  }else{
    cout << "ABC";
  }
  
  return 0;
}


Measured memory_bytes: 3624
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x + (n % x > 0)) * t;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000

signed main(void)
{
    int N, T;
    cin >> N >> T;
    int t[N];
    int sum = T*N;
    rep(i,N) {
        cin >> t[i];
    }
    rep(i,N-1){
        sum -= max(T - (t[i+1] - t[i]) , (int)0);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, a;
    cin >> h >> a;
    cout << (h / a) + (h % a != 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define MOD 998244353
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll INF = 1e17;
const double pi = 3.141592653589793;

int T;
ll algor[15][15] = {};
ll cost[15] = {};
ll ans = INF;
ll N, M, X;

void solve(ll cur, ll visit) {
  if(cur == 0) {
    solve(cur + 1, visit | (1 << (cur + 1)));
    solve(cur + 1, visit);
    return;
  }

  bool flag = true;
  ll tmp = 0;
  if(cur == N + 1) return;

  ll price[15] = {};
  for(int i = 1 ; i <= N ; i++) {
    if( (visit & (1 << i) ) > 0) {
      tmp += cost[i];
      for(int j = 1 ; j <= M ; j++) {
        price[j] += algor[i][j];
      }
    }
  }
  for(int i = 1 ; i <= M ; i++) {
    if(price[i] < X) flag = false;
  }

  if(flag) {
    ans = min(ans, tmp);
  }

  solve(cur + 1, visit | (1 << (cur + 1)));
  solve(cur + 1, visit);
  return;
}


int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> N >> M >> X;

  for(int i = 1 ; i <= N ; i++) {
    cin >> cost[i];
    for(int j = 1 ; j <= M ; j++) {
      cin >> algor[i][j];
    }
  }
  solve(0, 1 << (N + 1));
  if(ans == INF) cout << "-1" << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



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

        vll dp(100);
        dp[0] = 2;
        dp[1] = 1;
        rep(i, 2, 90) {
                dp[i] = dp[i-1] + dp[i-2];
        }
        cout << dp[N] << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1000000007LL;
vector<ll> f,fi;
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
ll ncr(ll n,ll r){
    if(n<r)return 0;
    if(r==0)return 1;
    return f[n]*fi[r]%MOD*fi[n-r]%MOD;
}
int main(){
    int n;cin>>n;
    f.resize(n+10,0);
    fi.resize(n+10,0);
    f[0]=1;
    for(ll i=1;i<=n;i++)f[i]=f[i-1]*i%MOD;
    fi[n]=mpow(f[n],MOD-2LL);
    for(ll i=n-1;i>=0;i--)fi[i]=fi[i+1]*(i+1)%MOD;
    vector<vector<ll>> dp(n+10,vector<ll>(n+10,0));
    int a,b,c,d;cin>>a>>b>>c>>d;
    dp[a-1][0]=1;
    for(int i=a;i<=b;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD;
            ll s=1;
            for(int k=1;k<c;k++)s=s*ncr(n-j+i*k,i)%MOD;
            for(int k=c;k<=d;k++){
                if(j-i*k<0)break;
                s=s*ncr(n-j+i*k,i)%MOD;
                dp[i][j]+=dp[i-1][j-i*k]*s%MOD*fi[k]%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[b][n]<<endl;
}


Measured memory_bytes: 8320
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            s[i] = str.split("");
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int count = 0;
                if (s[i][j].equals("#")) {
                    try {
                        if (s[i - 1][j].equals("#"))
                            count++;
                    } catch (Exception e) {

                    }
                    try {
                        if (s[i][j - 1].equals("#"))
                            count++;
                    } catch (Exception e) {

                    }
                    try {
                        if (s[i][j + 1].equals("#"))
                            count++;
                    } catch (Exception e) {

                    }
                    try {
                        if (s[i + 1][j].equals("#"))
                            count++;
                    } catch (Exception e) {

                    }
                    if (count == 0) {
                        System.out.println("No");
                        return;
                    }
                } else
                    ;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22160
#include <stdio.h>

int max3(int a, int b, int c) {
  int max;

  max = a;

  if(max < b) {
    max = b;
  }

  if (max < c) {
    max = c;
  }

  return max;
}

int main(void) {
  int a, b, c, k, i, max;
  scanf("%d %d %d", &a, &b, &c);
  scanf("%d", &k);

  max = max3(a, b, c);


  for ( i = 0; i < k; i++) {
    if(a%max == 0) {
      a=a*2;
    }
    else if(b%max == 0) {
      b=b*2;
    }
    else {
      c=c*2;
    }
  }

  printf("%d\n", a + b + c);
  return 0;
}


Measured memory_bytes: 128
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

  ll k;
	cin >> k;
  queue<ll> que;
  que.push(1);
  que.push(2);
  que.push(3);
  que.push(4);
  que.push(5);
  que.push(6);
  que.push(7);
  que.push(8);
  que.push(9);
  ll x;
  FOR(i, 0, k-1) {
    x = que.front();
    que.pop();
    if (x % 10 != 0) {
      que.push(10*x+(x%10)-1);
    }
    que.push(10*x+(x%10));
    if (x % 10 != 9) {
      que.push(10*x+(x%10)+1);
    }
  }
	cout << x << "\n";
}


Measured memory_bytes: 1792
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
s = defaultdict(int)
for v in a: s[v]+=1
edge = []
for v in s.items():
    if v[1] > 1: edge.append(v[0])
    if v[1] > 3: edge.append(v[0])
(edge).sort()
if len(edge)>1:
    print(edge[-1]*edge[-2])
else:
    print(0)

Measured memory_bytes: 18600
p = 998244353
n, k = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(k)]
DP = [0] * (2 * n + 1)
DP[0] = 1
DP[1] = -1
for i in range(n):
    for l, r in LR:
        DP[i + l] += DP[i]
        DP[i + r + 1] -= DP[i]
    DP[i + 1] += DP[i]
    DP[i + 1] %= p
print(DP[n - 1])


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

const long long INF = 1LL << 60;

int main() {
	int a[4],b[4];
	int c[4][4];
  	bool can=true;
    
    REP(i,3){
      REP(j,3){
        cin >> c[i][j];
      }
    }
  
  REP(i,3){
    b[i]=c[1][i];
    a[i]=c[i][1]-b[1];
  }
  
  REP(i,3){
    REP(j,3){
      if(c[i][j] != a[i]+b[j]){
        can = false;
        break;
      }
    }
  }
  
    if(can)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[10];
int main() {
	cin >> s;
	for (int i = 0; i < 4; ++i) s[i] -= '0';
	int a = s[0] * 10 + s[1];
	int b = s[2] * 10 + s[3];
	if (1 <= a && a <= 12) {
		if(1 <= b && b <= 12) puts("AMBIGUOUS");
		else puts("MMYY");
	} else {
		if(1 <= b && b <= 12) puts("YYMM");
		else puts("NA");
	}
	return 0;
}

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

//template
#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()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    string s; cin>>s;
    stack<char> st;
    rep(i,0,s.size()){
        if(st.size()&&st.top()=='S'&&s[i]=='T')st.pop();
        else st.push(s[i]);
    }
    printf("%d\n",st.size());
    return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N; cin >> N;
	vector<ll>A(N), B(N);
	for (int i = 0; i < N; ++i)cin >> A[i];
	for (int i = 0; i < N; ++i)cin >> B[i];
	vector<ll>plus;
	ll sum = 0;
	int num = 0;
	for (int i = 0; i < N; ++i) {
		ll dif = A[i] - B[i];
		if (dif < 0)sum -= dif, num++;
		else plus.push_back(dif);
	}
	if (num == 0)cout << 0 << endl;
	else {
		int res = num;
		sort(plus.begin(), plus.end(), greater<ll>());
		ll p = 0;
		for (int i = 0; i < plus.size(); ++i) {
			p += plus[i];
			++res;
			if (p >= sum)break;
		}
		if (p >= sum)cout << res << endl;
		else cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 2936
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	

	clock_t startTime=clock();

	ll n;
	cin>>n;
	ll ar[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}

	set<ll> s;
	ll extra=0;
	rep(i,0,n)
	{
		if(ar[i]>3199)
		{
			extra++;
			continue;
		}

		s.insert(ar[i]/400);
	}

	ll ans=s.size();

	if(ans==0)
	{
		ans=1,extra--;
	}

	cout<<ans<<" "<<extra+ans<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char ch[55][55];
int n, m;

bool func(int i, int j){
	if (i > 0 && ch[i-1][j] == '#')
		return true;
	if (i < n-1 && ch[i+1][j] == '#')
		return true;
	if (j > 0 && ch[i][j-1] == '#')
		return true;
	if (j < m-1 && ch[i][j+1] == '#')
		return true;
	return false;	
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++ )
		scanf("%s", &ch[i]);
	bool bl = true;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (ch[i][j] == '#' && !func(i, j)){
				bl = false;
				break;
			}
	if (bl)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//g++ hoge.cpp -I . で実行
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        long long n, m, a, b;
        scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
        printf("%lld\n", floor_sum(n, m, a, b));
    }
    return 0;
}

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

int main()
{
	int l;
	string s;
	cin >> s;
	l = s.size();
	if (s.front() == s.back()) {
		cout << (l % 2 ? "Second" : "First") << endl;
	}
	else {
		cout << (l % 2 ? "First" : "Second") << endl;
	}
	return 0;
}


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

inline int max (const int p, const int q) {return p > q ? p : q;}

const int N = 53;
int n, a[N], ans;

int main () {
	scanf ("%d", &n);
	int i; for (i = 1; i <= n; ++i) scanf ("%d", &a[i]);
	for (i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) ans += a[i] * a[j];
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
N,M,R = map(int, input().split())
r = list(map(int, input().split()))
ABC = [ [int(j) for j in input().split()] for _ in range(M)]

inf = float("inf")
costmap =   [  [inf] * (N+1)  for _ in range(N+1)] 

for i in range(M):
    a,b,c = ABC[i]

    costmap[a][b] = c
    costmap[b][a] = c


for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            if costmap[i][j] > costmap[i][k] + costmap[k][j]:
                c = costmap[i][k] + costmap[k][j]
                costmap[i][j] = c
                costmap[j][i] = c

from itertools import permutations
ans = inf
for itr in permutations( [x for x in range(R)]):
    tmp = 0
    now = r[itr[0]]
    for n in itr[1:]:
        tmp += costmap[now][ r[n] ]
        now = r[n]
    ans = min(ans, tmp)
print(ans)



Measured memory_bytes: 51672
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int H,W,D;
    cin >> H >> W >> D;
    typedef pair<int, int> P;
    vector<P> A(H*W);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int tmp;
            cin >> tmp;
            tmp--;
            A[tmp]=P(i,j);
        }
    }
    vector< int > vt(H*W);//cost
    fill(vt.begin(), vt.end(), -1);
    for(int d=0; d<D; d++){
        int a=d;
        vt[a]=0;
        a+=D;
        while(a<=H*W-1){
            vt[a]=vt[a-D]+abs(A[a].first-A[a-D].first)+abs(A[a].second-A[a-D].second);
            a+=D;
        }
    }

    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        cout << vt[r]-vt[l] << endl;
    }
    


    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

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


int H, W;
char mat[1010][1010];
int dp[1010][1010];

int main(){
	
	scanf("%d %d", &H, &W);
	rep(i, 0, H) scanf("%s", mat[i]);
	
	dp[H-1][W-1] = 1;
	for(int i=H-1; i>=0; i--){
		for(int j=W-1; j>=0; j--){
			if(mat[i][j]=='#') continue;
			if(i+1<H && mat[i+1][j]!='#') dp[i][j] = (dp[i][j] + dp[i+1][j])%mod;
			if(j+1<W && mat[i][j+1]!='#') dp[i][j] = (dp[i][j] + dp[i][j+1])%mod;
		}
	}
	
	cout << dp[0][0] << '\n';
	
	
	
	
	return 0;
}

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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        if (500*i+100*j+50*k==X) ans++;
      }
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    string a[10000];
    int c,d,e;
    while(true){
        cin>>a[0];
        if(a[0]=="-"){
            break;
        }
        cin>>c;
        e=a[0].size();
        for(int i=1;i<=c;i++){
            cin>>d;
            a[i]=a[i-1].substr(d,e-d)+a[i-1].substr(0,d);
        }
        cout<<a[c]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong(), b = in.nextLong();
		in.close();
		long targ = getGCD(a, b);

		// 素因数分解
		long cnt = 1;
		if (targ % 2 == 0 ) {
			targ /= 2;
			cnt++;
			while ( targ % 2 == 0 ) {
				targ /= 2;
			}
		}

		Long div = 3L;
		while ( div <= Math.sqrt(targ) ) {
			if ( targ % div == 0 ) {
				// System.out.println("div:" + div);
				cnt++;
			}
			while ( targ % div == 0 ) {
				targ /= div;
			}
			div += 2;
		}

		if ( targ != 1 ) cnt++;
		System.out.println(cnt);
	}

	private static long getGCD(long a, long b) {
		if ( b == 0 ) return a;
		else return getGCD(b, a % b);
	}
}


Measured memory_bytes: 31572
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 100050
int n,a[N],b[N],mp[N][3],l[2];
void gun() {
	puts("No"); exit(0);
}
int main() {
	scanf("%d",&n);
	int i,x,y,z;
	for(x=0;x<3;x++) for(i=1;i<=n;i++) scanf("%d",&mp[i][x]);
	for(i=1;i<=n;i++) {
		x=mp[i][0], y=mp[i][1], z=mp[i][2];
		if(x+1==y&&y+1==z) {
			if(z%3) gun();	
			a[i]=z/3, b[i]=0;
		}else if(x-1==y&&y-1==z) {
			if(x%3) gun();
			a[i]=x/3, b[i]=1;
		}else gun();
		if((a[i]&1)!=(i&1)) gun();
		if(b[i]) l[i&1]^=1;
	}
	for(i=1;i<=n;i++) {
		while(a[i]!=i) {
			l[!(i&1)]^=1;
			swap(a[i],a[a[i]]);
		}
	}
	puts(l[0]||l[1]?"No":"Yes");
}


Measured memory_bytes: 2176
a=input()
for i in range(8):
    s=int(a[0])
    ans=[a[0]]
    for j in range(3):
        if (i>>j)&1:
            s+=int(a[j+1])
            ans+=["+"]+[a[j+1]]
        else:
            s-=int(a[j+1])
            ans+=["-"]+[a[j+1]]
    if s==7:
        print(*ans,sep="",end="")
        print("=7")
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int main()
{
    long long a,b;cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll s, w;
    cin >> s >> w;
    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
from sys import stdin
n = int(stdin.readline())
bricks = [int(x) for x in stdin.readline().split()]
if 1 not in bricks:
    ans = -1
else:
    counter = 1
    ans = 0
    for i in range(n):
        if bricks[i] == counter:
            counter += 1
        else:
            ans += 1
print(ans)

Measured memory_bytes: 72012
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
   string s;
  cin>>s;
  ll count=0;
  for(ll i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='L'){
        count++;
        break;
      }
    }
    else {
      if(s[i]=='R'){
        count++;
        break;
      }
    }
  }
  if(count==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from collections import deque

n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def get_dists(f):
    dists = [0 for _ in range(n)]
    q = deque()
    q.append((f, -1, 0))
    while len(q) > 0:
        num, f_num, dist = q.popleft()
        for node in edges[num]:
            if node == f_num:
                continue
            else:
                dists[node] = dist + 1
                q.append((node, num, dist+1))
    return dists

dist_1 = get_dists(0)
dist_n = get_dists(n-1)

ans = 0
for i in range(n):
    if dist_1[i] <= dist_n[i]:
        ans += 1

fennec = ans
snuke = n - fennec
if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 66224
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
#define int long long
using namespace std;

signed main() {
	int n, k; cin >> n >> k;
	int ans = (n / k)*(n / k)*(n / k);
	if (k % 2 == 0) {
		ans += (n / (k/2)-n/k)*(n / (k / 2) - n / k)*(n / (k / 2) - n / k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def ReRooting(nodeCount, edges, identity, merge, addNode):
  adjacents = [[] for _ in range(nodeCount)]
  indexForAdjacents = [[] for _ in range(nodeCount)]
  for u,v in edges:
    indexForAdjacents[v].append(len(adjacents[u]))
    indexForAdjacents[u].append(len(adjacents[v]))
    adjacents[u].append(v)
    adjacents[v].append(u)
  childSubtreeRes = [[identity]*len(adjacents[i]) for i in range(nodeCount)]
  nodeRes = [identity]*nodeCount
  parents = [-1]*nodeCount
  order = [0]*nodeCount
  index = 0
  stack = [0]
  for node in stack:
    order[index] = node
    index += 1
    for adjacent in adjacents[node]:
      if adjacent == parents[node]:
        continue
      stack.append(adjacent)
      parents[adjacent] = node
  for node in order[::-1]:
    parent = parents[node]
    result = identity
    parentIndex = -1
    for j in range(len(adjacents[node])):
      if adjacents[node][j] == parent:
        parentIndex = j
        continue
      result = merge(result, childSubtreeRes[node][j])
    if parentIndex >= 0:
      childSubtreeRes[parent][indexForAdjacents[node][parentIndex]] = addNode(result, node)
  for node in order:
    accumsFromTail = [identity]*len(adjacents[node])
    for j in range(len(accumsFromTail)-1, 0, -1):
      accumsFromTail[j-1] = merge(childSubtreeRes[node][j], accumsFromTail[j])
    accum = identity
    for j in range(len(accumsFromTail)):
      result = addNode(merge(accum, accumsFromTail[j]), node)
      childSubtreeRes[adjacents[node][j]][indexForAdjacents[node][j]] = result
      accum = merge(accum, childSubtreeRes[node][j])
    nodeRes[node] = addNode(accum, node)
  return nodeRes

n, mod = map(int, input().split())
edge = []
for _ in range(n-1):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  edge.append((x, y))
def merge(a, b):
  return a*b % mod
def addNode(a, id):
  return a+1
for i in ReRooting(n, edge, 1, merge, addNode):
  print(i-1)


Measured memory_bytes: 66120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

int main(){
    ll a,b,c,k,ans=0;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    if (k>a) ans+=a;
    else ans+=k;
    if (k>a+b) ans-=(k-a-b);
    printf("%lld",ans);
    return 0;
}




Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
long long  h,w;
cin >>h>>w;
long long  output =0;
if(h==1||w==1){
output =1;
}
else if(w%2==0){
output = (w/2)*h;
}else{
  
if(h%2==0){
output = (h*w)/2;
}else{
output = ((h-1)/2)*w + (w-1)/2 + 1;
}

}
  
cout << output <<endl; 
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  string s;
  int a,b;
  cin>>s;
  
  a=stoi(s.substr(0,2));
  b=stoi(s.substr(2,2));
  
  if(a==0&&b==0)cout<<"NA";
  else if(a==0&&b>12)cout<<"NA";
  else if(b==0&&a>12)cout<<"NA";
  else if(a==0)cout<<"YYMM";
  else if(b==0)cout<<"MMYY";
  else if(a>12&&b>12)cout<<"NA";
  else if(a>12)cout<<"YYMM";
  else if(b>12)cout<<"MMYY";
  else cout<<"AMBIGUOUS";
  
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

n = gets.chomp.to_i
shop = []
n.times do |i|
  (s, p) = gets.chomp.split(/ /)
  p = p.to_i
  shop << [s, p, i + 1]
end
shop.sort!{|a, b| a[0]<=>b[0]}

n = shop[0][0]
array = [[]]
shop.each do |s|
#  p s
  if n == s[0]
    array[-1].push([s[1], s[2]])
  else
    array << [[s[1], s[2]]]
  end
  n = s[0]
end
#p array
array.each do |e|
  e.sort!{|a, b|b[0]<=>a[0]}
  e.each do |ee|
    puts ee[1]
  end
end


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

int main(){
    int a,b,sum=0;
    cin >> a;
    b=a;
    while(b>0){
        sum +=b%10;
        b=b/10;
    }
    if(a%sum==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Dice:
    diceNum = []
    pos = 0
    def setNum(self,i):
        self.pos = i[0]
        self.diceNum.append(i[0])
        self.diceNum.append(i[1])
        self.diceNum.append(i[2])
        self.diceNum.append(i[3])
        self.diceNum.append(i[4])
        self.diceNum.append(i[5])
    def getTopPos(self):
        return self.diceNum[0]    
    def moveToTopnum(self,n):
        i = 0
        for i in range(0,4):
            if (self.getTopPos() == n ):
                return True
            self.move("S")
        else:
            for j in range(0,4):
                if (self.getTopPos() == n ):
                    return True
        return False
    def getFrontPos(self):
        return self.diceNum[1]
    def getRightPos(self):
        return self.diceNum[2]
    def yokoRotate(self):
            i0=self.diceNum[0]
            i1=self.diceNum[2] 
            i2=self.diceNum[4] 
            i3=self.diceNum[1]
            i4=self.diceNum[3]
            i5=self.diceNum[5]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
    def move(self,d):
        if (d == "E"):
            i0=self.diceNum[3]
            i1=self.diceNum[1] 
            i2=self.diceNum[0] 
            i3=self.diceNum[5]
            i4=self.diceNum[4]
            i5=self.diceNum[2]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "W"):
            i0=self.diceNum[2]
            i1=self.diceNum[1] 
            i2=self.diceNum[5] 
            i3=self.diceNum[0]
            i4=self.diceNum[4]
            i5=self.diceNum[3]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "S"):
            i0=self.diceNum[4]
            i1=self.diceNum[0] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[5]
            i5=self.diceNum[1]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "N"):
            i0=self.diceNum[1]
            i1=self.diceNum[5] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[0]
            i5=self.diceNum[4]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
 
l = list(map(int,input().split()))
dice = Dice()
dice.setNum(l)

n = int(input())
while (n > 0):
    n = n -1
    (t,f) = map(int,input().split())
    dice.moveToTopnum(t)
    for i in range(0,3):
        if ( dice.getFrontPos() == f):
            break
        dice.yokoRotate()
    print (dice.getRightPos())



Measured memory_bytes: 5620
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

d1 = c1[1] - c2[1]
d2 = c1[1] - c3[1]
ans = 0

for i in range(3):
    if c1[i] - c2[i] != d1:
        ans = 1
        break
    if c1[i] - c3[i] != d2:
        ans = 1
        break

if ans == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 100005

ll p[N], q[N], r[N];
ll sp[N], sq[N], sr[N];

int x, y, a, b, c;

ll f(int x, int n) {
	return sq[x] + sr[n - x];
}

int main(void) {
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	REP(i, a) {
		scanf("%lld", &p[i]);
	}
	REP(i, b) {
		scanf("%lld", &q[i]);
	}
	REP(i, c) {
		scanf("%lld", &r[i]);
	}

	sort(p, p + a);
	sort(q, q + b);
	sort(r, r + c);

	FOR(i, 1, a + 1) {
		sp[i] = p[a - i];
		if (i) {
			sp[i] += sp[i - 1];
		}
	}

	FOR(i, 1, b + 1) {
		sq[i] = q[b - i];
		if (i) {
			sq[i] += sq[i - 1];
		}
	}

	FOR(i, 1, c + 1) {
		sr[i] = r[c - i];
		if (i) {
			sr[i] += sr[i - 1];
		}
	}

	ll ans = 0;
	REP(i, x + 1) {
		int nx = x - i;
		if (nx <= c) {
			ll tmp = sp[i];
			int fc = c - nx;
			int l = max(0, y - fc);
			int r = y;
			while (r - l >= 3) {
				int m1 = l + (r - l) / 3;
				int m2 = r - (r - l) / 3;
				if (f(m1, y + nx) < f(m2, y + nx)) {
					l = m1;
				}
				else {
					r = m2;
				}
			}

			ll pm = 0;
			FOR(j, l, r + 1) {
				pm = max(pm, f(j, y + nx));
			}

			tmp += pm;
			ans = max(ans, tmp);
		}
	}

	printf("%lld\n", ans);
	//scanf("%d", &a);
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  x, y = map(int, input().split())
  a.append((x, y))
b = []
for _ in range(M):
  x, y = map(int, input().split())
  b.append((x, y))

for x, y in a:
  res = 0
  for i in range(M):
    if abs(x - b[i][0]) + abs(y - b[i][1]) < abs(x - b[res][0]) + abs(y - b[res][1]):
      res = i
  print(res + 1)

Measured memory_bytes: 39408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k)
	{
		cout<<x*n<<endl;
	}
	else
	{
		cout<<x*k+(n-k)*y<<endl;
	}
	
	
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >>n;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll sub = a.back()-a[0];
    if(a.back()-a[0]>1){
        cout <<"No"<<endl;
        return 0;
    }else if(sub==1){
        i=0;
        ll coler = 0;
        while(a[i]<a.back()){
            coler++;
            i++;
        }
        ll nokori=1+a[0]-coler;
        if(nokori<1){
            cout << "No"<< endl;
            return 0;
        }
        if(n-i>=nokori*2){
            cout << "Yes"<<endl;
        }else{
            cout << "No"<<endl;
        }
    }else{
        if(a[0]+1==n){
            cout << "Yes"<<endl;
        }else{
            if(a[0]*2<=n){
                cout << "Yes"<<endl;
            }else{
                cout << "No"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int temp=2*i;
    int ans=0;
    for(int j=1;j<=sqrt(temp);j++){
      for(int k=1;k<=sqrt(temp);k++){
        if(j*j+k*k>=temp) break;
        int l=temp-j*j-k*k;
        if(l!=(int)sqrt(l)*(int)sqrt(l)) continue;
        int p=sqrt(l);
        if((k+p-j)%2==0 and (p+j-k)%2==0 and (j+k-p)%2==0 and j+k>p and k+p>j and p+j>k) ans++;
      }
    }
    cout<<ans<<endl;
  }  
  return 0;
}


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

int main()
{
	vector<int> a = {0, 300000, 200000, 100000};

	int x, y;
	cin >> x >> y;

	int ans = 0;

	if (x <= 3)
	{
		ans += a[x];
	}
	if (y <= 3)
	{
		ans += a[y];
	}

	if (x == 1 && y == 1)
	{
		ans += 400000;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   if(a<6) cout << 0 << endl;
   else if (a<13) cout << b/2 << endl;
   else cout << b << endl;
 }

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

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

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum%10==0)
    {
        sort(arr,arr+n);
        for(int i=0;i<n;i++)
        {
            if((sum-arr[i])%10!=0){
                cout<<sum-arr[i]<<endl;
                return 0;
            }
        }
        cout<<0;
        return 0;
    }
    cout<<sum<<endl;


}



Measured memory_bytes: 3628
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

double A,B,H,M;

double ans = 0;

const double pi = 3.141592653589793;

void solve(){
    double speed_hour = 2.0*pi/720.0;
    double speed_minute = 2.0*pi/60.0;
    double rad_hour = speed_hour*(H*60.0+M);
    double rad_minute = speed_minute*(M);
    double rad = (rad_hour - rad_minute);
    // cout << speed_hour << endl;
    // cout << speed_minute << endl;
    // cout << rad_hour << endl;
    // cout << rad_minute << endl;
    // cout << rad << endl;
    // cout << "cos=" << cos(rad) << endl;
    ans = A*A + B*B - 2*A*B*cos(rad);
    // cout << ans << endl;
    ans = sqrt(ans);
}

int main(){
    cin >> A >> B >> H >> M;

    solve();

	cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(){
  int x[1001]={0},i,j,n;
  for(i=2;i<35;i++)for(j=i*i;j<1001;j*=i)x[j]=1;x[1]=1;
  scanf("%d",&n);
  for(i=n;i>0;i--)if(x[i]){printf("%d",i);return 0;}
}


Measured memory_bytes: 1736