akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using P = pair<int, int>;

const int MAX = 1000000;
const int MOD = 1000000007;

/*
long long fac[MAX], finv[MAX], inv[MAX];

//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

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

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};

typedef struct edge{
   int to;
   int cost;
} edge;

vector<edge> graph[2010];
long long int d[2010];

void dijkstra(int s){
   priority_queue<P, vector<P>, greater<P> > que;
   for(int i = 0; i < 2010; i++){
       d[i] = INF;
   }
   d[s] = 0;
   que.push(P(s, 0));

   while (!que.empty()) {
       P p = que.top();
       que.pop();
       int v = p.first;
       if (d[v] < p.second) continue;

       for (int i=0; i<graph[v].size(); ++i) {
           edge e = graph[v][i];
           if (d[e.to] > d[v] + e.cost) {
               d[e.to] = d[v] + e.cost;
               que.push(P(e.to, d[e.to]));
           }
       }
   }
}
*/

int main(){
    long long int n;
    cin >> n;
    long long int ans = (n-1) * n / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int mod = 1e9 + 7;
const int maxn = 55;
int n;
ll k;
int a[70][maxn][maxn];
int ans[maxn][maxn], t[maxn][maxn];
bool ok = 0;

void work() {
  n = read(), k = read();
  rep(i, 1, n) rep(j, 1, n) a[0][i][j] = read();
  rep(x, 1, 62) {
    rep(i, 1, n) rep(j, 1, n) rep(k, 1, n) a[x][i][j] = (a[x][i][j] + a[x - 1][i][k] * 1ll * a[x - 1][k][j]) % mod;
  }
  rep(x, 0, 62) {
    if (k & (1ll << x)) {
      // cout<<x<<endl;
      if (!ok) {
        rep(i, 1, n) rep(j, 1, n) ans[i][j] = a[x][i][j];
        ok = 1;
      } else {
        memset(t, 0, sizeof(t));
        rep(i, 1, n) rep(j, 1, n) rep(k, 1, n) t[i][j] = (t[i][j] + ans[i][k] * 1ll * a[x][k][j]) % mod;
        rep(i, 1, n) rep(j, 1, n) ans[i][j] = t[i][j];
      }
    }
  }
  int ss = 0;
  rep(i, 1, n) rep(j, 1, n) (ss += ans[i][j]) %= mod;
  cout<<ss<<endl;
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define MOD1 1000000007
int main(){
  ll n,m,k,i,j;
  ll dp[100010][13]={0};
  string s;
  cin >> s;
  n = s.size();
  dp[0][0]=1;
  rep(i,n){
    rep(j,13){
      if(s[i]=='?'){
        rep(k,10){
          dp[i+1][(j*10+k)%13] += dp[i][j];
          dp[i+1][(j*10+k)%13] %= MOD1;
        }
      }else{
        k = (ll)(s[i]-'0');
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= MOD1;
      }
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}

Measured memory_bytes: 13760
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int n,m,k;cin>>n>>m>>k;
    bool flag = false;
    for(int i=0;i<=m;i++){
        for(int j=0;j<=n;j++){
            if (i*n+j*m-2*i*j==k) flag = true;
        }
    }
    if (flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

int main(){
/*/Debug by file input
    ifstream fin("input");
    cin.rdbuf(fin.rdbuf());// */
    solve();
    return 0;
}


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

using namespace std;

int main()
{
    int num, n, d, rev;
    cin>>num;
    while(num)
    {
        n=num%10;
        if(n==7) break;
        else {
            num=num/10;
        }
    }
    if(n==7)
      cout<<"Yes";
    else
    {
        cout<<"No";
    }
      
}

Measured memory_bytes: 3636
k,n=map(int,input().split())
a=sorted(list(map(int,input().split())))
dist=2*10e+12
for i in range(n):
  p1=i
  p2=i+1
  if i+1!=n:
    dist=min(k-(a[p2]-a[p1]), dist)
  else:
    p2=0
    dist=min(a[p1]-a[p2],dist)
    print(dist)


Measured memory_bytes: 100000
import heapq
n,a,b= map(int,input().split())
h =[int(input()) for i in range(n)]
h.sort()
p = a-b
def c(w):
    #w de umakuikkuka
    k = 0
    for i in range(n):
        l[i] = l[i]-b*w
        if l[i] > 0:
            k += l[i]//p
            if l[i] % p != 0:
                k += 1
    if w >= k:
        return True

s = 0
f = 10**14
while f-s >=2:
    m = (f+s)//2
    l = h[::]
    if c(m):
        f = m
    else:
        s = m
l = h[::]
if c(s):
    print(s)
else:
    print(f)

Measured memory_bytes: 12736
# -*- coding: utf-8 -*-
from itertools import permutations, combinations
from fractions import gcd
from collections import Counter
from math import sqrt
import sys
input = sys.stdin.readline
def lcm(x, y):
    return (x*y//gcd(x, y))
def small_letters():
    return [chr(i) for i in range(97, 97+26)]
def capital_letters():
    return [chr(i) for i in range(65, 65+26)]
def continual_letters(list_x):
    """example"""
    """[2,2,2,2,4,4,5,5,5,8,8,8,8,8] => [4,2,3,5]"""
    i,j = 0,0
    result = []
    k = len(list_x) - 1
    while(True):
        A = list_x[i]
        while(True):
            print(j)
            if list_x[j] != A:
                break
            if j >= k:
                break
            j += 1
        result.append(j-i)
        if i >= k:
            break
        i = j
    result[-1] += 1
    return result


def main():
    """ここに書いてね"""
    H,N = map(int,input().split())
    hissatu = list(map(int,input().split()))
    if sum(hissatu) >= H:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 16244
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}

vector<int>vec(200004);
vector<int>vec2(200004);
int sum(int xx) {
	if (xx == 0) {
		return vec2[0];
	}
	return vec2[xx] + sum(vec[xx]);
}

signed main() {
	int  h, w;
	cin >> h >> w;
	vector<vector<char>>vec(h + 2, vector<char>(w + 2,'.'));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			cin >> vec[i][j];
		}
	}
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			if (vec[i][j] == '#' && vec[i][j + 1] != '#' && vec[i][j - 1] != '#' && vec[i - 1][j] != '#' && vec[i + 1][j] != '#') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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

int main(){
  ll n,ans=0;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i>0){
      ans+=(a[i-1]>a[i] ? a[i-1]-a[i] : 0);
      a[i]+=(a[i-1]>a[i] ? a[i-1]-a[i] : 0);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5196
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

"""
方針　各桁を0にするか1にするかは独立に考えてよい
 
K = 10101 の時
0か1か好きに選べる桁をfとして
* X = 10101
* X = 10100
* X = 100ff
* X = 0ffff
を試し、最大になるものを選ぶ
 
2**39 < 10**12 < 2**40　なので40桁について考え
fのときどっちを選ぶとよいかを前計算しておく
""" 
 
L = [0]*40  # (i桁目が1である数)
for i in range(N):
    for j in range(40):
        L[j] += (A[i] >> j)&1
 
default = [(N - L[i]) * (2**i) if (K>>i)&1 == 1 else L[i] * (2**i) for i in range(40)]
free = [max(L[i] * (2**i), (N-L[i])*(2**i)) for i in range(40)]
 
ans = sum([K^A[i] for i in range(N)])
for i in range(40):
    if (K >> i)&1 == 1:
        ans = max(ans,
                  sum(free[:i]) + L[i]*(2**i) + sum(default[i+1:]))
print(ans)


Measured memory_bytes: 14620
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 2010;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;

int s,ans = 0;
int fac[MAXN],ifac[MAXN];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

int ksm(int x,int b) {
	int res = 1;
	for(;b;b >>= 1,(x *= x) %= mod) if(b & 1) (res *= x) %= mod;
	return res % mod;
}

int C(int x,int y) {
	if(x < y) return 0;
	return (fac[x] * ifac[y] % mod * ifac[x - y] % mod) % mod;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(s);
	fac[0] = ifac[0] = 1ll;
	for(int i = 1;i <= s; ++i)
		fac[i] = (fac[i - 1] * i % mod) % mod;
	ifac[s] = inv(fac[s]) % mod;
	for(int i = s - 1;i >= 1; --i)
		ifac[i] = (ifac[i + 1] * (i + 1) % mod) % mod;
	for(int i = 1,v;i <= s; ++i) {
		v = s - i * 2;
		if(v <= 0) break;
		(ans += C(v - 1,i - 1)) %= mod;
	}
	printf("%lld\n",(ans % mod + mod) % mod);
	return 0;
}



Measured memory_bytes: 3796
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll k;in(k);
  ll n = 50;
  vector<ll> A(n, n-1 + k/n);
  k %=n ;
  loop(i,0,n) {
    if (k == 0) break;
    A[i] += n;
    loop(j,0,n) {
      if (i==j) continue;
      A[j]--;
    }
    
    k--;
  }
  print(n);
  for (auto &&a: A) cout << a << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	pair<string, pair<int, int>> A[100]; 
	for (int i = 0; i < N; ++i)
	{
		A[i].second.second = i + 1;
		cin >> A[i].first >> A[i].second.first;
	}

	sort(A, A+N);
	int cnt = 0;

	for (int i = 0; i < N; ++i)
	{
		if ((i < N-1)&&(A[i].first == A[i+1].first))
		{
			cnt++;
		}
		else if (cnt == 0)
		{
			cout << A[i].second.second << endl;
		}
		else
		{
			for (int j = i; j >= i-cnt; --j)
			{
				cout << A[j].second.second << endl;
			}
			cnt = 0;
		}
	}

	return 0;
}

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


int main(){
	string ln;
	cin >> ln;
	while(~ln.find("eggegg"))ln.replace(ln.find("eggegg"),6,"egg egg");
	while(~ln.find("chickenchicken"))ln.replace(ln.find("chickenchicken"),14,"chicken chicken");
	stringstream ss(ln);
	string t;
	string ans;
	while(ss >> t){
		string c;
		for(int i = 0 ; i < t.size() ;){
			if(t[i] == 'e') c += 'e' , i += 3;
			else if(t[i] == 'c') c += 'c' , i += 7;
		}
		if(c.size() > ans.size()) ans = c;	
	}
	cout << (ans[ans.size()-1]=='c' ? "chicken" : "egg") << endl;
}

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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%s%s", &t[1],&t[2] );
  printf("%s%s\n", t[2],t[1]);
return 0;
}


Measured memory_bytes: 128
import fractions
from functools import reduce

def lcm_2(x, y):
    return (x * y) // fractions.gcd(x, y)
    
def lcm(l):
    return reduce(lcm_2, l, 1)
    
n = int(input())
t = [int(input()) for _ in range(n)]

print(lcm(t))

Measured memory_bytes: 64236
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main()
{
    int n;
    int d;
    set<int> st;

    cin >> n;

    for (unsigned i = 0; i < n; ++i) {
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
typedef long long ll;
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
#define pq dp
using namespace std;
const ll mxx = 1e5+10;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    //FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t=1, n, k, m, a, b, c, d, cs = 1;
    //cin >> t;
    set<ll>s;
    map<string, ll>mp;

    while(t--){
              cin >> a >> b;
              if(a==b){
                      cout << "Draw" << endl;
              }
              else if(a==1){
                      cout << "Alice" << endl;
              }
              else if(b==1){
                      cout << "Bob" << endl;
              }
              else if(a>b){
                      cout << "Alice" << endl;
              }
              else{
                      cout << "Bob" << endl;
              }

    }
    return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
     
    int main(){
      int N, K, i, j, t, sum;
      int l[51];
      
      scanf("%d %d",&N,&K);
     
      for(i = 0; i < N; i++){
        scanf("%d", &l[i]);
      }
     
      for(i = 0; i < K; i++){
        for(j = 0; j < N; j++){
          if(l[t] < l[j]){
    	
    	t = j;
          
          }
        }
        
        sum += l[t];
        l[t] = 0;
      
      }
      
      printf("%d",sum);
      return 0;
    }

Measured memory_bytes: 128
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n,k;
    cin>>n>>k;

    vi v(n);
    for(auto& c:v)
        cin>>c;

    int beg=1,en=*max_element(all(v));
    int ans;

    while(beg<=en)
    {
        int mid=(beg+en)/2;

        int cur=0;
        for(auto c:v)
        {
            cur+=iceil(c,mid)-1;
        }

        if(cur<=k)
        {
            ans=mid;
            en=mid-1;
        }
        else
            beg=mid+1;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e4 + 5);

int n, m;
vector<int> available;
vector<int> cand;

ll dp[MAX_N];

map<int, int> cost;

vector<int> ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int tmp;
    scanf("%d", &tmp);
    available.push_back(tmp);
  }

  cost[1] = 2;
  cost[2] = 5;
  cost[3] = 5;
  cost[4] = 4;
  cost[5] = 5;
  cost[6] = 6;
  cost[7] = 3;
  cost[8] = 7;
  cost[9] = 6;

  for (auto e: available) {
    cand.push_back(cost[e]);
  }

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

  dp[0] = 0;

  for (int i = 1; i <= n; ++i) {
    for (auto e: cand) {
      if (i - e >= 0) {
        dp[i] = max(dp[i], dp[i - e] + 1);
      }
    }
  }

  int i = n;
  while (i > 0) {
    int tmp = -1;
    int tmp_cost = 0;

    if (dp[i] - 1 == 0) { // to gracefully use all match
      for (auto e: available) {
        // printf("%d %d %d %d\n", e, i, dp[i - cost[e]], dp[i] - 1);
        if (i - cost[e] == 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }
    else {
      for (auto e: available) {
        // printf("%d %d %d %d\n", e, i, dp[i - cost[e]], dp[i] - 1);
        if (i - cost[e] >= 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }

    // cout << i << ":" << tmp << endl;

    ans.push_back(tmp);
    i -= tmp_cost;
  }

  for (auto e: ans) {
    printf("%d", e);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0; (i)<(n); ++(i))
#define ARRAY_SIZE 1000000

ll T[ARRAY_SIZE];

ll h1(ll key){
  return key % ARRAY_SIZE;
}

ll h2(ll key){
  return 1 + (key % (ARRAY_SIZE - 1));
}

ll h(ll key, ll i){
  return (h1(key) + i * h2(key)) % ARRAY_SIZE;
}

void insert(ll key){
  ll i = 0, j;
  while(1){
    j = h(key, i);
    if(T[j] == 0){
      T[j] = key;
      return;
    }
    else ++i;
  }
}

bool search(ll key){
  ll i = 0, j;
  while(1){
    j = h(key, i);
    if(T[j] == key) return true;
    else if(T[j] == 0 || i >= ARRAY_SIZE) return false;
    else ++i;
  }
}

ll make_key(string strkey){
  string res = "";
  for(char x : strkey){
    if(x == 'A') res += "1";
    else if(x == 'C') res += "2";
    else if(x == 'G') res += "3";
    else if(x == 'T') res += "4";
  }
  return stoll(res);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  string str, strkey;
  ll key;
  REP(i,n){
    cin >> str >> strkey;
    key = make_key(strkey);
    if(str[0] == 'i'){
      insert(key);
    }
    else if(str[0] == 'f'){
      if(search(key)) cout << "yes" << "\n";
      else cout << "no" << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 10944
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a,t;
  int a2[5];
  cin>>a;
  t=a;
  for(int i=0;i<3;i++){
    a2[i]=a%10;
    a=a/10;
  }
  if(t==a2[0]*100+a2[1]*10+a2[2]){
  cout<<"Yes"<<"\n";
  return(0);
  }
  cout<<"No"<<"\n";
  return(0);
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner scn = new Scanner(System.in);
    int n = scn.nextInt();
    List<Integer> numList = new ArrayList<>();
    for(int i = 1;i<10;i++){
      for(int j = 1; j < 10; j++){
        numList.add(i*j);
      }
    }
    if(numList.contains(n)){
      System.out.println("Yes");
    }else{
      System.out.println("No");      
    }
  }
}

Measured memory_bytes: 22860
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    map<int, int> mp1, mp2;
    for(int i = 0; i < n; i++){
        if(i & 1){
            mp1[a[i]]++;
        }
        else mp2[a[i]]++;
    }
    int ans = 0;
    vector<pii> P, Q;
    for(auto it : mp1){
        P.pb({it.second, it.first});
    }
    for(auto it : mp2){
        Q.pb({it.second, it.first});
    }
    P.pb({0, -1});
    Q.pb({0, -1});
    rs(P);
    rs(Q);
    if(P[0].second == Q[0].second){
        int ff = 0, ss = 0;
        rep(i, 1, P.size() - 1) ff += P[i].first;
        ff += Q[0].first;
        rep(i, 2, Q.size() - 1) ff += Q[i].first;
        rep(i, 1, Q.size() - 1) ss += Q[i].first;
        ss += P[0].first;
        rep(i, 2, P.size() - 1) ss += P[i].first;
        ans = min(ff, ss);
    }
    else{
        rep(i, 1, P.size() - 1) ans += P[i].first;
        rep(i, 1, Q.size() - 1) ans += Q[i].first;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6524
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;

int nums[10];
char color[10];

int dfs(const vector<int> &v, vector<bool> used){
  int n = v.size();
  int cnt = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < i; j++){
      for(int k = 0; k < j; k++){
	if(!used[i] && !used[j] && !used[k]){
	  if((v[i] == v[j] && v[i] == v[k])
	     || (v[k] + 1 == v[j] && v[j] + 1 == v[i])) {
	    used[i] = true;
	    used[j] = true;
	    used[k] = true;
	    cnt = max(cnt, 1 + dfs(v, used));
	    used[i] = false;
	    used[j] = false;
	    used[k] = false;
	  }
	}
      }
    }
  }
  return cnt;
}

int calc(vector<int> v){
  int n = v.size();
  if(n % 3) return 0;
  sort(v.begin(), v.end());
  vector<bool> used(n, false);
  return dfs(v, used);
}

int main(){
  int T;
  cin >> T;
  while(T--){
    int cnt = 0;
    vector<int> r, g, b;
    rep(i, 9) cin >> nums[i];
    rep(i, 9) cin >> color[i];
    rep(i, 9){
      switch(color[i]){
      case 'R':
	r.push_back(nums[i]);
	break;
      case 'G':
	g.push_back(nums[i]);
	break;
      case 'B':
	b.push_back(nums[i]);
	break;
      }
    }
    cnt = calc(r) + calc(g) + calc(b);
    if(cnt == 3) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, cur, p[max_n], nxt[max_n], used[max_n], ans[max_n];
vector<int> g[max_n], g2[max_n];

bool dfs(int v) {
    if (used[v] == cur) {
        return false;
    }
    used[v] = cur;
    for (int to : g[v]) {
        if (p[to] == -1 || dfs(p[to])) {
            p[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    return false;
}

void dfs2(int v) {
    used[v] = 1;
    for (int to : g2[v]) {
        if (used[to] == 0) {
            dfs2(to);
            ans[to] = nxt[v];
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i + 1 < n; ++i) {
        int k;
        scanf("%d", &k);
        g[i].resize(k);
        for (int &x : g[i]) {
            scanf("%d", &x);
            --x;
        }
    }
    memset(nxt, -1, sizeof(nxt));
    memset(p, -1, sizeof(p));
    for (int run = 1; run; ) {
        run = 0;
        ++cur;
        for (int i = 0; i + 1 < n; ++i) {
            if (nxt[i] == -1 && dfs(i)) {
                run = 1;
            }
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        if (nxt[i] == -1) {
            puts("-1");
            return 0;
        }
    }
    int root;
    for (int i = 0; i < n; ++i) {
        if (p[i] == -1) {
            root = i;
            break;
        }
    }
    p[root] = n - 1;
    nxt[n - 1] = root;
    for (int i = 0; i + 1 < n; ++i) {
        for (int to : g[i]) {
            if (to != nxt[i]) {
                g2[p[to]].push_back(i);
            }
        }
    }
    memset(used, 0, sizeof(used));
    dfs2(n - 1);
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        printf("%d %d\n", nxt[i] + 1, ans[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 17664
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			string s = Console.ReadLine();
			string t = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			if (t.Substring(0, s.Length) == s) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}

		}

	}
}


Measured memory_bytes: 25780
#include <bits/stdc++.h>
using namespace std;
template<class T>
inline void read(T &a){
    T s = 0, w = 1;
    char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') w = -1; c = getchar();}
    while(c >= '0' && c <= '9'){s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
    a = s*w;
}
int n;
const int maxn = 100001;
int a[maxn];
int omax, tmax,ok;
int main(){
    read(n); for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = 1; i <= n; i++){
        if(a[i] > omax){
            tmax = omax; omax =  a[i];
        }
        else if(a[i] > tmax) tmax = omax;
        ok |= a[i];
    }
    if(ok % 2) printf("first");
    else printf("second");
    return 0;
}

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

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

    string ans;

    if(N%10 == 3) ans = "bon";
    else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) ans = "pon";
    else ans = "hon";

    cout << ans << endl;
}

Measured memory_bytes: 3580
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
for i in range(N):
    if i >= K and T[i-K] == T[i]:
        T[i] = 'a'
ans = 0
for i in T:
    if i == 'r':
        ans += P
    elif i == 's':
        ans += R
    elif i == 'p':
        ans += S
print(ans)

Measured memory_bytes: 77712
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans=0,sum =0;
  ans+=min(a,k);
  sum+=min(a,k);
  if(sum>=k){
    cout<<ans<<endl;
    return 0;
  }
  sum+=b;
  if(sum>=k){
    cout<<ans<<endl;
    return 0;
  }
  ans -= k-sum;
  cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 3620
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n=o.a();
  return n*n*n;
}

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

typedef long long ll;
ll MOD = 1e9+7;

ll a[10000];
ll b[10000];
ll asum=0;
ll bsum=0;
int main()
{
	int n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		asum+=a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		bsum+=b[i];
	}
	ll minus=0;
	ll even=0;
	if(asum>bsum)
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]<b[i])
		{
			if((b[i]-a[i])%2==0)
				even+=(b[i]-a[i])/2;
			else
				even+=(b[i]-a[i]-1)/2;
		}
		if(a[i]>b[i])
			minus+=a[i]-b[i];
	}
	if(minus<=even)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
def main():
    import itertools
    N = int(input())
    A_list = list(map(int, input().split()))

    comb = list(itertools.combinations(A_list, 3))
    #print(comb)

    count = 0

    for val in comb :
        if val[0] != val[1] and val[0] != val[2] and val[1] != val[2] :
            if val[0] < val[1] + val[2] and val[1] < val[0] + val[2] and val[2] < val[1] + val[0] :
                count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20408
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

class Dice {
public:
    Dice(int i_one, int i_two, int i_three, int i_four, int i_five, int i_six)
      : one(i_one)
      , two(i_two)
      , three(i_three)
      , four(i_four)
      , five(i_five)
      , six(i_six)
    {
    }

    inline void E() noexcept
    {
        int buf_one   = this->one;
        int buf_three = this->three;
        int buf_four  = this->four;
        int buf_six   = this->six;

        this->one   = buf_four;
        this->three = buf_one;
        this->four  = buf_six;
        this->six   = buf_three;
    }

    inline void N() noexcept
    {
        int buf_one   = this->one;
        int buf_two   = this->two;
        int buf_five  = this->five;
        int buf_six   = this->six;

        this->one   = buf_two;
        this->two   = buf_six;
        this->five  = buf_one;
        this->six   = buf_five;
    }

    inline void S() noexcept
    {
        int buf_one   = this->one;
        int buf_two   = this->two;
        int buf_five  = this->five;
        int buf_six   = this->six;

        this->one   = buf_five;
        this->two   = buf_one;
        this->five  = buf_six;
        this->six   = buf_two;

    }

    inline void W() noexcept
    {
        int buf_one   = this->one;
        int buf_three = this->three;
        int buf_four  = this->four;
        int buf_six   = this->six;

        this->one   = buf_three;
        this->three = buf_six;
        this->four  = buf_one;
        this->six   = buf_four;
    }

    inline void roll(int top) noexcept
    {
        if (top == this->two) {
            this->N();
        } else if (top == this->three) {
            this->W();
        } else if (top == this->four) {
            this->E();
        } else if (top == this->five) {
            this->S();
        } else if (top == this->six) {
            this->S();
            this->S();
        }
    }

    inline void print(int front) noexcept
    {
        if (front == this->two) {
            std::cout << this->three << std::endl;
        } else if (front == this->three) {
            std::cout << this->five << std::endl;
        } else if (front == this->five) {
            std::cout << this->four << std::endl;
        } else if (front == this->four) {
            std::cout << this->two << std::endl;
        }
    }

private:
    int one;
    int two;
    int three;
    int four;
    int five;
    int six;
};

int main()
{
    int one, two, three, four, five, six;
    std::cin >> one >> two >> three >> four >> five >> six;
    Dice dice(one, two, three, four, five, six);

    int q;
    std::cin >> q;

    for (std::size_t i = 0; i < q; ++i) {
        int top, front;
        std::cin >> top >> front;

        dice.roll(top);
        dice.print(front);
    }

    return 0;
}


Measured memory_bytes: 3076
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
int main(){
	int n=gi(),ans=0;
	for(int i=1;i<=n;i++){
		int x=gi();if(x!=i)ans++;
	}
	if(ans>2)puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
ary = []
n.times do |i|
  ary[i] = gets.split.map(&:to_i)
end
ary = ary.sort_by{|x| x[1]}

time = 0
n.times do |i|
  time += ary[i][0]
  if time > ary[i][1]
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 23056
#include <iostream>

using namespace std;

int main()
{
    char a;
    cin >> a;
    if (a == 'a'){
        cout << 'b';
    }else if (a == 'b'){
        cout << 'c';
    }else if (a == 'c'){
        cout << 'd';
    }else if (a == 'd'){
        cout << 'e';
    }else if (a == 'e'){
        cout << 'f';
    }else if (a == 'f'){
        cout << 'g';
    }else if (a == 'g'){
        cout << 'h';
    }else if (a == 'h'){
        cout << 'i';
    }else if (a == 'i'){
        cout << 'j';
    }else if (a == 'j'){
        cout << 'k';
    }else if (a == 'k'){
        cout << 'l';
    }else if (a == 'l'){
        cout << 'm';
    }else if (a == 'm'){
        cout << 'n';
    }else if (a == 'n'){
        cout << 'o';
    }else if (a == 'o'){
        cout << 'p';
    }else if (a == 'p'){
        cout << 'q';
    }else if (a == 'q'){
        cout << 'r';
    }else if (a == 'r'){
        cout << 's';
    }else if (a == 's'){
        cout << 't';
    }else if (a == 't'){
        cout << 'u';
    }else if (a == 'u'){
        cout << 'v';
    }else if (a == 'v'){
        cout << 'w';
    }else if (a == 'w'){
        cout << 'x';
    }else if (a == 'x'){
        cout << 'y';
    }else if (a == 'y'){
        cout << 'z';
    }
    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s;
    cin >> s;
    Int len = s.length();
    Int n = stol(s);
    Int answer = 0;
    for (Int i = 3; i <= len; ++i) {
        // 長さ i の準753数を列挙する
        Int kosuu = pow(3, i);
        for (Int j = 0; j < kosuu; ++j) {
            string num = "";
            Int l = j;
            for (Int k = 0; k < i; ++k) {
                if (l == 0) { 
                    num += '0';
                } else {
                    Int x = (l % 3);
                    num += char(x + '0');
                    l /= 3;
                }
            }
            for (Int k = 0; k < len; ++k) {
                if (num[k] == '0') {
                    num[k] = '3';
                }
                else if (num[k] == '1') {
                    num[k] = '5';
                }
                else if (num[k] == '2') {
                    num[k] = '7';
                }
            }
            bool a = (num.find('3') != string::npos && num.find('5') != string::npos && num.find('7') != string::npos);
            bool b = (n >= stoi(num));
            if (a && b) {
                answer++;
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 4064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG H, W; cin >> H >> W;
    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
    }
    else if (H % 2 == 1 && W % 2 == 1)
    {
        cout << (H * W + 1) / 2 << endl;
    }
    else
    {
        cout << H * W / 2 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= K) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;
int main () {
    int n;
    cin >> n ;
    for (int i=0;i<n;i++) {
        int b;
        b = pow(2,i);
        if (b==n) { 
            cout << b << endl;
            break;
        }
        else if (b>n)  {
            cout << b/2 << endl; 
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, ans = 0; cin >> n;
	for (int i = 1; i <= n; i++) {
		ans += i;
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int i,j,h,w;

	while(1){

		scanf("%d %d",&h,&w);
		if(h==0&&w==0)break;

		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0||i==h-1)printf("#");
				else if(j==0||j==w-1)printf("#");
				else printf(".");
			}
			printf("\n");
		}

		printf("\n");

	}

	return 0;

}

Measured memory_bytes: 572