akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define max(a,b) ((a) > (b) ? (a) : (b))
#define mix(a,b) ((a) < (b) ? (a) : (b))

int main(void) {
	int N;
	
	scanf("%d", &N);
	
	switch (N % 10) {
		case 2: case 4: case 5: case 7: case 9:
			printf("hon\n");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon\n");
			break;
		case 3:
			printf("bon\n");
			break;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdint>

int main() {
  std::int64_t n;
  std::cin >> n;
  std::vector<char> s;
  while (n != 0) {
    std::int64_t q = n > 0 ? n / -2 : (1 - n) / 2;
    s.push_back(n + 2 * q == 0 ? '0' : '1');
    n = q;
  }
  std::reverse(s.begin(), s.end());
  std::cout << (s.empty() ? "0" : std::string(s.begin(), s.end())) << std::endl;
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
$count = trim(fgets(STDIN));
$taro = 0;
$hanako = 0;

for($i = 0;$i < $count; $i++){
list($a,$b) = explode(" ",trim(fgets(STDIN)));
$result = strcasecmp($a,$b);
if($result > 0){
$taro += 3;
}elseif($result === 0){
$taro += 1;
$hanako += 1;
}else{
$hanako += 3;
}
}
echo $taro." ".$hanako;
?>



Measured memory_bytes: 9228
#include "stdio.h"

int main(int argc, char const *argv[])
{
	int kaku[1000];
	int bango;
	int i;
	kaku[0] = 1;
	kaku[1] = 1;
	scanf("%d",&bango);
	for(i = 2;i < 1000;i++){
		kaku[i] = kaku[i - 2] + kaku[i - 1];
	}
	printf("%d\n", kaku[bango]);
	return 0;
}

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


#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define prd(t) printf("%d",t)
#define prld(t) printf("%ld",t)
#define prlld(t) printf("%lld",t)
#define prc(t) printf("%c",t)
#define prs(t) printf("%s",t)
#define prf(t) printf("%f",t)
#define prsp() printf(" ")
#define prnl() printf("\n")
#define MOD 1000000007
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define fo(i,a,b) for(int i=a;i<b;i++)


void solve(){
	long long int x;
	sclld(x);
	long long int i=0;
	long long int p=100;
	while(x>p){
         p=p*(101/100.0);
         i++;
	}
    prlld(i);
}


int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	//int t; scd(t);
	//while(t--){
		solve();
		//prnl();
	//}
	return 0;
}

Measured memory_bytes: 1704
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()

    acc = 0
    for i in a:
        acc ^= i
    
    ans_lst = []
    for i in a:
        ans = acc^i
        ans_lst.append(ans)

    print(*ans_lst)
main()


Measured memory_bytes: 115020
#!/usr/bin/env python3

def main():
    n, t = map(int, input().split())
    cts = []
    for i in range(n):
        ci, ti = map(int, input().split())
        cts.append((ci, ti))
    cts = [ct for ct in cts if ct[1] <= t]
    if len(cts) == 0:
        print("TLE")
    else:
        cts.sort(key=lambda ct: ct[0])
        print(cts[0][0])

main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << a[n-1] << endl;

  return 0;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()]for _ in range(N)]

cand = {}
sums = 0
ans = 0
for i in ab:
    if(i[0] in cand):
        cand[i[0]] += i[1]
    else:
        cand[i[0]] = i[1]

cand = sorted(cand.items(), key=lambda x:x[0])
for i in cand:
    sums+=i[1]
    if(sums>=K):
        ans = i[0]
        break
print(ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,M,X; cin >> N >> M >> X;
    VI A(M); REP(i,M) cin >> A[i];
    int c1=0, c2=0;
    REP(i,M){
        if(A[i] < X) c1++;
        else c2++;
    }
    cout << min(c1,c2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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

}


Measured memory_bytes: 256
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void put_str(char *str) { while(*str) putchar_unlocked(*str++); }

typedef struct Node { int parent, left, right, depth; } Node;
void tree_depth(Node *tree, int node, int depth) {
    tree[node].depth = depth;
    for(int i = tree[node].left; ~i; i = tree[i].right) {
        tree_depth(tree, i, depth + 1);
    }
}
int main(int argc, char **argv) {
    int n = get_uint();
    Node tree[n];
    for(int i = 0; i < n; ++i) tree[i].parent = tree[i].left = tree[i].right = -1;
    for(int i = 0; i < n; ++i) {
        int id = get_uint();
        int k = get_uint();
        for(int j = 0, d; j < k; ++j) {
            int c = get_uint();
            tree[c].parent = id;
            if(j) tree[d].right = c;
            else tree[id].left = c;
            d = c;
        }
    }
    for(int i = 0; i < n; ++i) {
        if(tree[i].parent == -1) {
            tree_depth(tree, i, 0);
            break;
        }
    }
    for(int i = 0; i < n; ++i) {
        put_str("node ");
        put_uint(i);
        put_str(": parent = ");
        if(~tree[i].parent) put_uint(tree[i].parent);
        else put_str("-1");
        put_str(", depth = ");
        put_uint(tree[i].depth);
        put_str(~tree[i].parent ? ~tree[i].left ? ", internal node, [" : ", leaf, [" : ", root, [");
        if(~tree[i].left) {
            int j = tree[i].left;
            put_uint(j);
            for(j = tree[j].right; ~j; j = tree[j].right) {
                put_str(", ");
                put_uint(j);
            }
        }
        put_str("]\n");
    }
    return 0;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
        int A, B;
        cin >> A >> B;
        
                cout <<  max({2*A-1, A+B,2*B-1})<< endl;

        return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
flag=0;maxi=0
for i in range(n):
  if a[i]>maxi:maxi=a[i]
  if maxi-a[i]>=2:
    flag=1
    break
if flag==1:print("No")
else:
  print("Yes")


Measured memory_bytes: 14524
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++) cin >> a[i] >> b[i];

    vector<bool> one2i(n+1, false);
    vector<bool> i2n(n+1, false);
    for(int i = 0; i < m; i++){
        if(a[i] == 1){
            one2i[b[i]] = true;
        }
    }
    for(int i = 0; i < m; i++){
        if(b[i] == n){
            i2n[a[i]] = true;
        }
    }

    string ans = "IMPOSSIBLE";
    // cout << ans << endl;
    for(int i = 2; i < n; i++){
        if(one2i[i] == true && i2n[i] == true){
            ans = "POSSIBLE";
        }
    }

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


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
long long dp[3010][3010];
string s, t;
long long fun(long long x, long long y)
{
    if (x < 0 || y < 0)
        return 0;
    if (dp[x][y] != -1)
        return dp[x][y];
    if (s[x] == t[y])
        return dp[x][y] = 1 + fun(x - 1, y - 1);
    return dp[x][y] = max(fun(x - 1, y), fun(x, y - 1));
}
int main()
{

    cin >> s;
    cin >> t;
    long long l1 = s.length(), l2 = t.length();
    memset(dp, -1, sizeof(dp));
    long long ans = fun(l1 - 1, l2 - 1);
    // cout << ans << endl;
    string fin = "";
    fin.clear();
    long long x = l1 - 1, y = l2 - 1;
    while (x >= 0 && y >= 0)
    {
        if (s[x] == t[y])
        {
            fin = s[x] + fin;
            x--, y--;
        }
        else
        {
            if (x == 0)
                y--;
            else if (y == 0)
                x--;
            else if (dp[x - 1][y] > dp[x][y - 1])
                x--;
            else
                y--;
        }
    }
    cout << fin;
}

Measured memory_bytes: 71296
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;


int main(){
   ll n;
   cin >> n;
   n--;
   ll res = n * (n + 1) / 2;
   cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };

int main()
{
  int H, W, ans = 0;
  cin >> H >> W;
  vector<vector<int>> M(H, vector<int>(W, -1));
  queue<pair<int, int>> q;
  rep(i, H) rep(j, W) {
    char c;
    cin >> c;
    if (c == '#') {
      M[i][j] = 0;
      q.push({j, i});
    }
  }
  
  while (!q.empty()) {
    auto p = q.front(); q.pop();
    rep(i, 4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || M[ny][nx] != -1) continue;
      M[ny][nx] = M[p.second][p.first]+1;
      ans = max(M[ny][nx], ans);
      q.push({nx, ny});
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
	int n[4], a[4]={1, 4, 7, 9};
	for(int i=0; i<=3; i++)cin >> n[i];
	sort(n, n+4);
	for(int i=0; i<=3; i++)
	{
		if(n[i]!=a[i]){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
wf = []
for _ in range(n):
  wf.append(list(map(int,input().split())))
cnt = [[0 for _ in range(n)] for _ in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      if wf[i][j] > wf[i][k] + wf[k][j]:
        print(-1)
        exit()
      elif wf[i][j] == wf[i][k] + wf[k][j]:
        cnt[i][j] += 1
#print(cnt)
ans = 0
for i in range(n):
  for j in range(n):
    if cnt[i][j] <= 2:
      ans += wf[i][j]
print(ans//2)

Measured memory_bytes: 44764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a , b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k){
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
int main() {
	int N;
	cin >> N;
	vector<int>V(N);
	vector<int>Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
		Y[i] = V[i];
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < N; ++i) {
		if (Y[i] < V[N / 2 - 1])
			cout << V[N / 2] << endl;
		else if (Y[i] > V[N / 2])
			cout << V[N / 2 - 1] << endl;
		else if (Y[i] == V[N / 2 - 1])
			cout << V[N / 2] << endl;
		else if (Y[i] == V[N / 2])
			cout << V[N / 2 - 1] << endl;
	}
	return 0;
}

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

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

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include <math.h>

int main() {
    int n, i, j, a;
    int nun[10000];
    int count = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++)
        scanf("%d", &nun[i]);
    
    for (i = 0; i < n; i++){
        a = 1;
        if (nun[i] == 2)
            a = 1;
        else if ((nun[i] < 2) || ((nun[i] > 2)&&(nun[i] % 2 == 0)))
            a = 0;
        else {
            j = 3;
            while(j <= sqrt(nun[i])){
                if(nun[i] % j == 0){
                    a = 0;
                    break;
                }
                j = j + 2;
            }
        }
        
        if(a == 1)
            count++;
    }
    printf("%d\n", count);
    
    return 0;
    
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll ans = 0;
    REP(i, n){
        ll a; cin >> a;
        ans += (a%2==1) && (i%2==0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

int main() {
    int n, w;
    cin >> n >> w;
    int weight[n];
    ll values[n];
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> values[i];
    }

    ll dp[n + 1][100100] = {};
    for (int i = 0; i < n; i++) {
        for (int sum_w = 0; sum_w <= w; sum_w++) {
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + values[i]);
            }
            
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
            
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 82608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll M, K;
    cin >> M >> K;
    ll N = 1 << M;
    vector<ll> a(N*2);
    if ( K >= N || ( M == 1 && K == 1 )) {
        cout << (-1) << '\n';
        return 0;
    } else {
        if ( K == 0 ) {
            for (int i = 0; i < N; i++ ) {
                a[i] = i;
                a[2*N-1-i] = i;
            } 
        } else {
            a[N-1] = K;
            a[2*N-1] = K;
            for (int i = 0, p = 0; i < N; i++ ) {
                if ( i != K ) {
                    a[p] = i;
                    a[2*N-2-p] = i;
                    p++;
                }
            } 
        }

        for ( int i = 0; i < 2*N; i++ ) {
            cout << (i>0 ? " " : "") << a[i];
        }
        cout << '\n';
        return 0;
    }  
}

Measured memory_bytes: 3840
// A.

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int x, y;
	cin >> x >> y;
	int g[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	bool ans = g[x] == g[y];
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


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

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(n, a, b);
  out((abs(a - b) & 1) ? "Borys" : "Alice");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll a,b;
    for(int i = 0; i < 7;i++){
        cin >> a >> b;
        cout << a - b << endl;
    }
    
	return 0;
}



Measured memory_bytes: 3184
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

const lint MOD = 1e9 + 7;

lint power(lint x, lint n){
    lint t = 1;
    while(n > 0){
        if(n & 1){
            t = ((t % MOD) * (x % MOD)) % MOD;
        }
        x = ((x % MOD) * (x % MOD)) % MOD;
        n >>= 1;
    }
    return (t % MOD);
}

int main(){
    lint m, n;
    cin >> m >> n;
    cout << power(m, n) << endl;
    return 0;
}


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

int main()
{
    long n;
    cin >> n;
    bool arr[n+1];
    for(long i = 1; i <= n; i++)
        arr[i] = true;
    for(long i = 3; i <= n; i += 3)
    {
        arr[i] = false;
    }
    for(long i = 5; i <= n; i += 5)
    {
        arr[i] = false;
    }
    long long sum = 0;
    for(long i = 1; i <= n; i++)
    {
        if(arr[i])
            sum += i;
    }
    cout << sum;
}


Measured memory_bytes: 4568
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(0<a&&a<9&&0<b&&b<9){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }

  }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

ll ok(vl& a, vl& b, ll d) {
  ll tmp = 0;
  rep(j, d) { tmp += (a[j] - b[j]) * (a[j] - b[j]); }
  ll x = (ll)sqrtl(tmp);
  if (tmp == x * x)
    return true;
  else
    return false;
}

int main() {
  //
  ll n, d;
  cin >> n >> d;
  vvl x(n, vl(d, 0));
  rep(i, n) {
    rep(j, d) { cin >> x[i][j]; }
  }
  ll cnt = 0;
  rep(i, n) {
    REP(j, i + 1, n) {
      if (ok(x[i], x[j], d)) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1016
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#ifndef JHELPER1_COMMON_H
#define JHELPER1_COMMON_H

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
using namespace std;

constexpr ll MOD = 1000 * 1000 * 1000 + 7;

#define READ_VEC(v) for(auto &e: v){in >> e;}
#define READ_PAIR_VEC(v) for(auto &e: v){in >> e.first >> e.second;}
#define ALL(c) std::begin(c), std::end(c)

// Returns x^y modulo MOD. O(log2(y)).
ll modPow(ll x, ll y) {
  ll res = 1, a = x;
  while (y > 0) {
    if ((y & 1) > 0) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    y >>= 1;
  }
  return res;
}

// Returns a^-1 module MOD.
ll inverse(ll a) {
  /*
   * Fermat's little theorem
   * http://en.wikipedia.org/wiki/Proofs_of_Fermat's_little_theorem
   *
   * <pre>
   * a^p = a (mod p)
   * a^(p-1) = 1 (mod p)
   * ..
   * 1/a = a^(p-2) (mod p)
   * </pre>
   */
  return modPow(a, MOD - 2);
}

#endif //JHELPER1_COMMON_H


class BMultipleOf9 {
public:
  void solve(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    ll tot = 0;
    for (const auto &c : s) {
      int v = c - '0';
      tot += v;
    }
    if (tot % 9 == 0) out << "Yes" << endl;
    else  out << "No" << endl;
  }
};


int main() {
  BMultipleOf9 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3340
sample = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000}
while True :
    try :
        temp = input()
        f = temp[0]
        total = 0 
        for _ in temp[1:] :
            if sample[f] < sample[_] : total -= sample[f]
            else : total += sample[f]
            f = _
        total += sample[temp[-1]]
        print(total)
    except : break

Measured memory_bytes: 7416
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    double x;
    cin >> x;
    ll a = floor(x / 1.08), b = ceil(x / 1.08);
    if (floor(a * 1.08) == x)
        cout << a << endl;
    else if (floor(b * 1.08) == x)
        cout << b << endl;
    else
        cout << ":(" << endl;
}

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt();
	vector<pair<int, int>> a(n * 2);
	for (int i = 0; i < n * 2; ++i) {
		a[i] = {nxt(), i};
	}
	vector<int> used(n);
	sort(all(a));
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		used[a[i].second / 2] ^= a[i].second % 2 + 1;
		ans += a[i].first;
	}

	if (find(all(used), 0) != used.end() || *min_element(all(used)) == *max_element(all(used))) {
		cout << ans << "\n";
		return 0;
	}

	long long cur = ans;
	long long tmp[2] = {0, 0};
	for (auto p : a) {
		tmp[p.second % 2] += p.first;
	}
	ans = min(tmp[0], tmp[1]);

	if (a[n].second / 2 != a[n - 1].second / 2) {
		ans = min(ans, cur - a[n - 1].first + a[n].first);
	} else {
		ans = min(ans, cur - a[n - 1].first + a[n + 1].first);
		ans = min(ans, cur - a[n - 2].first + a[n].first);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2176
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

eat=p[:x]+q[:y]+r
eat.sort(reverse=True)
ans=sum(eat[:x+y])

print(ans)



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

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

	if(A == 1)
		A = 14;
	if(B == 1)
		B = 14;
	
	if(A > B)
		cout << "Alice";
	else if(A < B)
		cout << "Bob";
	else
		cout << "Draw";
	cout << endl;
}

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

using namespace std;

typedef long long int ll;

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

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

int main()
{
	ll x,y;
	cin >> x >> y;
	ll ans = 0;
	if(x != y){
		ans++;
		while(1){
			x *= 2;
			if(x > y) break;
			ans++;
		}
	}else ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
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;
		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 int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long 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;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
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;
}

int main() {
	string s;
	int k;
	cin >> k >> s;
	if (s.size() > k) {
		s.erase(k);
		cout << s << "...";
	}
	else {
		cout << s;
	}
}

Measured memory_bytes: 3552
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[5];
	while(cin>>s)
	{
		if(strlen(s)==2)
		{
			cout<<s<<endl;
		}
		else
		{
			cout<<s[2]<<s[1]<<s[0]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            long W = in.nextLong();
            long H = in.nextLong();
            long x = in.nextLong();
            long y = in.nextLong();
            System.out.println((W * H / 2.0) + " " + ((W % 2 == 0 && x == W / 2 && H % 2 == 0 && y == H / 2) ? 1 : 0));
        }
    }
}


Measured memory_bytes: 27020
s,t=open(0)
m=len(t:=t[:-1])
for i in range(51):
 if all(c in'?'+d for c,d in zip(s[-i-m:],t)):s=s.replace(*'?a');exit(print(s[:-i-m]+t+s[-i:]))
print('UNRESTORABLE')

Measured memory_bytes: 9012
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N=1000;
int kansuu(string X,string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  int i,j;
  X=' '+X;
  Y=' '+Y;
  for(i=0;i<=m;i++)
    c[i][0]=0;
  for(j=1;j<=n;j++)
    c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }

  return maxl;
}
int main(void){
  string s1;
  string s2;
  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    cout << kansuu(s1, s2) << endl;
    //printf("\n");
  }
  return 0;
}



Measured memory_bytes: 7124
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
char col[1000];
int main() {
	int N = 0;
	int timing = 0;
	int counto = 0;
	cin >> N;
	while (N > timing) {
		counto++;
		timing += counto;
	}
	cout << counto;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	ll H,W;
	cin>>H>>W;
	ll sma,big;
	ll a[5],b[5],c[5];
	ll d[5];
	if(H%3==0 || W%3==0){
		cout<<0<<endl;
		return 0;
	}
	sma=min(H,W);
	big=max(H,W);
	a[0]=(big+2)/3*sma;
	b[0]=(big-((big+2)/3))/2*sma;
	c[0]=H*W-a[0]-b[0];

	a[1]=(big)/3*sma;
	b[1]=(big-((big)/3))/2*sma;
	c[1]=H*W-a[1]-b[1];
	
	a[2]=(big+2)/3*sma;
	b[2]=(big-((big+2)/3))*(sma/2);
	c[2]=H*W-a[2]-b[2];

	a[3]=(big)/3*sma;
	b[3]=(big-((big)/3))*(sma/2);
	c[3]=H*W-a[3]-b[3];

	ll mini=INF;
	for(int i=0;i<4;i++){
		//cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
		mini=min(mini,(max(a[i],max(b[i],c[i]))-(min(a[i],min(b[i],c[i])))));
	}

	swap(sma,big);
	a[0]=(big+2)/3*sma;
	b[0]=(big-((big+2)/3))/2*sma;
	c[0]=H*W-a[0]-b[0];

	a[1]=(big)/3*sma;
	b[1]=(big-((big)/3))/2*sma;
	c[1]=H*W-a[1]-b[1];
	
	a[2]=(big+2)/3*sma;
	b[2]=(big-((big+2)/3))*(sma/2);
	c[2]=H*W-a[2]-b[2];

	a[3]=(big)/3*sma;
	b[3]=(big-((big)/3))*(sma/2);
	c[3]=H*W-a[3]-b[3];

	for(int i=0;i<4;i++){
		//cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
		mini=min(mini,(max(a[i],max(b[i],c[i]))-(min(a[i],min(b[i],c[i])))));
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, v, w, t;
    long a_, b_;

    scanf("%d %d", &a, &v);
    scanf("%d %d", &b, &w);
    scanf("%d", &t);

    if (a < b)
    {
        a_ = (long)a + (long)v * (long)t;
        b_ = (long)b + (long)w * (long)t;

        if (a_ >= b_)
        {
            printf("YES");
            return 0;
        }
    }
    else
    {
        a_ = (long)a - (long)v * (long)t;
        b_ = (long)b - (long)w * (long)t;
        if (a_ <= b_)
        {
            printf("YES");
            return 0;
        }
    }

    printf("NO");
    return 0;
}


Measured memory_bytes: 1732
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n")
  const len = parseInt(input[0]);
  const orders = input[1].split(" ");
  const points = input[2].split(" ");
  const addPoints = input[3].split(" ");

  var sum = 0;
  var prevOrder = -9
  
  for(var i = 0; i < len; i++) {
    var order = orders[i]-1;
    sum += parseInt(points[order]);
    if (prevOrder === order-1) {
        sum += parseInt(addPoints[prevOrder]);
    }
    prevOrder = order
  }
    
  console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	string S; cin >> S;
	int C = INF, F = -INF;
	rep(i, 0, S.size()) {
		if (S[i] == 'C')C = min(C, i);
		if (S[i] == 'F')F = max(F, i);
	}
	if (C < F)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  ull a, b, c;
  cin >> a >> b >> c;
  ull tmp = 0;
  
  if(a + b < c){
    tmp = c - (a + b);
  }
  else{
    cout << "No" << endl;
    return 0;
  }
  if(4 * a * b < tmp * tmp){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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

int top, S[1000];

void push(int x){
    /*topを加算してからその位置へ挿入*/
    S[++top] = x;
}

int pop(){
    top--;
    /*topが指していた要素を返す*/
    return S[top + 1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2100
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s,t;
    cin >> s >> t;
    string dic[26];
    string dicB[26];
    F0R(i,26){
      dic[i] = "";
      dicB[i] = "";
    }
    F0R(i,s.length()){
      F0R(j,26){
        if(s[i] - 97 == j)
          dic[j] += "1";
        else dic[j] += "0";

        if(t[i] - 97 == j)
          dicB[j] += "1";
        else dicB[j] += "0";
      }
    }
    sort(dic,dic+26);
    sort(dicB,dicB+26);
    F0R(i,26){
      if(dic[i] != dicB[i]){
        cout << "No"<<endl;
        return 0;
      }
    }
    cout << "Yes"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 12856
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6


def dfs(r, c, now_c, next_c):
    tmp_board[r][c] = next_c
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
            dfs(nr, nc, now_c, next_c)


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        if ope[0] == board[0][0] or ope[-1] == C - 1 or any(ope[i] == ope[i + 1] for i in range(3)):
            continue
        tmp_board = copy.deepcopy(board)
        for color in ope:
            dfs(0, 0, tmp_board[0][0], color)
        dfs(0, 0, tmp_board[0][0], C - 1)
        dfs(0, 0, tmp_board[0][0], -1)
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)

Measured memory_bytes: 6492
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    K = int(input().strip())
    X = map(int, input().strip().split())
    return N, K, X


def solve(N, K, X):
    ans = 0
    for x in X:
        ans += min(x, abs(K - x)) * 2
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 3060
#include <string.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n = 0, taro_point = 0, hanako_point = 0;
	char taro_card[100 + 1] = { 0 },
		hanako_card[100 + 1] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> taro_card >> hanako_card;
		int result = strcmp(taro_card, hanako_card);
		if (result > 0) {
			taro_point += 3;
		}
		else if (result < 0) {
			hanako_point += 3;
		}
		else {
			taro_point++;
			hanako_point++;
		}
	}
	cout << taro_point << " " << hanako_point << endl;
	return 0;
}

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

int N;
ll T[1100], A[1100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> T[i] >> A[i];

    ll t = 1;
    ll a = 1;
    for (int i = 0; i < N; i++) {
        ll new_t;
        if (t % T[i] == 0) new_t = t/T[i];
        else new_t = t/T[i] + 1;
        
        ll new_a;
        if (a % A[i] == 0) new_a = a/A[i];
        else new_a = a/A[i] + 1;

        ll n = max(new_t, new_a);
        t = n * T[i];
        a = n * A[i];
    }

    cout << t+a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
#define int long long
using namespace std;
typedef pair<int,int> P;
int n,m;
vector<int> G[N];
int flag;
int col[N];
 
P cnt;
void dfs(int pos,int c){
  if(col[pos]!=-1 && c!=col[pos]) flag = 1;
  if(col[pos]!=-1 && c==col[pos]) return; 
  if(flag) return;
  c? cnt.first++:cnt.second++;
  col[pos] = c;
  for(int nx:G[pos])dfs(nx,!c);
}
 
map<int,int> A;

int calc(int d){
  int a = (n-d)/2;
  int b = n - a;
  return a*b;
}

int dp[N];
int DP(){
  int sum = 0;
  for(P a:A) sum+=a.first*a.second;

  for(P a:A){
    dp[0] = 1;
    for(int j=0;j<N;j++)if(dp[j]) dp[j] = a.second+1;
    for(int j=0;j<N;j++){
      if(j+a.first>=N)break;
      if(dp[j] == 0)continue;
      dp[j+a.first] = max(dp[j+a.first],dp[j] - 1);
    }
  }
  
  int res = 0;
  for(int i=0;i<N;i++)
    if(dp[i]>0) res = max(res,calc(abs(i-(sum-i))));
  return res;
}

signed main(){
  cin>>n>>m;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
 
  memset(col,-1,sizeof(col));
  for(int i=0;i<n;i++) {
    if(col[i]!=-1)continue;
    cnt = P(0,0); 
    dfs(i,0);
    A[abs(cnt.first-cnt.second)]++;
  }

  if(flag) cout<<"-1"<<endl,exit(0);
  cout<<DP()-m<<endl;
  return 0;
}

Measured memory_bytes: 11324
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = list(map(int, input().split()))
aa = list(map(lambda x: x // 2, a))

lcm = lcm_list(aa)

for b in a:
    if (lcm - (b // 2)) % b != 0:
        print(0)
        exit(0)

answer = ((M - lcm) // (lcm * 2)) + 1
print(answer)


Measured memory_bytes: 16308
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,an=0;
	cin >> N;
	ll k = 0;
	rep(i, N) {
		ll A;
		cin >> A;
		if (A == 0) {
			k = 0;
		}
		A += k;
		
		an += A / 2;
		k = A % 2;
	}
	cout << an << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint a,b,c; cin>>a>>b>>c;
	puts(c-(a+b)>0 && 4*a*b<(c-(a+b))*(c-(a+b))?"Yes":"No");
	return 0;
}


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

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

	long long int n, h, x, y, d = 0, k, i;
	vector<long long int> a, b;
	cin >> n >> h;
	for (int i = 0; i < n; ++i){
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(a.begin(), a.end(), greater<long long int>());
	sort(b.begin(), b.end(), greater<long long int>());
	for (i = 0; i < n; ++i){
		if (b[i] < a[0]){
			break;
		}
		d += b[i];
		if (d >= h){
			cout << i+1 << "\n";
			return 0;
		}
	}
	k = (h-d)/a[0];
	if ((h-d)%a[0] != 0){
		k += 1;
	}
	cout << i+k << "\n";
	return 0;
}

Measured memory_bytes: 2036