akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
using namespace std;


int main() {
	string s;
	string t;
	vector<char> s_;
	vector<char> t_;
	bool check = false;
	int minlength = 0;

	cin >> s >> t;

	FOR(i, 0, s.length())
		s_.push_back(s[i]);
	FOR(i, 0, t.length())
		t_.push_back(t[i]);

	sort(s_.begin(), s_.end());
	sort(t_.rbegin(), t_.rend());

	if (s.length() >= t.length())
		minlength = t.length();
	else
		minlength = s.length();

	FOR(i, 0, minlength) {
		if (s_[i] < t_[i]) {
			check = true;
			break;
		}
		else if (s_[i] > t_[i])
			break;
		if (i == minlength - 1)
			if (s.length() < t.length())
				check = true;
	}

	if (check)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

    ll dp[100010];
    REP(i, n + 1) {
        dp[i] = LONG_LONG_MAX;
    }

    dp[0] = 0;

    REP(i, n + 1) {
        if (i == 0) continue;
        // 1円
        dp[i] = min(dp[i], dp[i - 1] + 1);
        // 6円
        ll delta = 6;
        while (true) {
            if (i - delta < 0) break;
            dp[i] = min(dp[i], dp[i - delta] + 1);
            delta *= 6;
        }
        // 9円
        delta = 9;
        while (true) {
            if (i - delta < 0) break;
            dp[i] = min(dp[i], dp[i - delta] + 1);
            delta *= 9;
        }
    }

    MSG(dp[n])
}


Measured memory_bytes: 1024
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

avet=[]
for c in h:
  avet.append(abs((t-6/1000*c)-a))

#print(avet)

for i in range(n):
  if avet[i] == min(avet):
    ans = i+1
print(ans)

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 3000;
string s,t;
int dp[MAX_N+1][MAX_N+1];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> s >> t;
  int n = s.size();
  int m = t.size();

  forn1(i,n) {
    forn1(j,m) {
      dp[i][j] = max(max(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]+(s[i-1]==t[j-1]));
    }
  }

  string ans;
  int i = n, j = m;
  while (i > 0 || j > 0) {
    if (i > 0 && dp[i][j] == dp[i-1][j]) i--;
    else if (j > 0 && dp[i][j] == dp[i][j-1]) j--;
    else {
      i--,j--;
      if (s[i] == t[j]) ans.push_back(s[i]);
    }
  }

  reverse(ans.begin(),ans.end());

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35456
import sys

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def dfs(A):
    m = min(A[A != 0])  # sortしてるので必ず最小値
    # sub_A = [a % m for a in A[1:]]
    sub_A = A[1:] % m  # 最小値で余り
    ans = np.insert(sub_A[sub_A != 0], 0, m)  # 非ゼロ抽出
    if len(ans) != 1:
        ans = dfs(np.sort(ans))
    return ans


def solve():
    N = ii()
    A = np.array(sorted(il()))
    return dfs(A).item()


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 23116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int m=0;
    map<string, int> s;
    string t;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> t;
        s[t] += 1;
        m = max(m, s[t]);
        
    }
    
    for(pair<string, int> a : s){
        
        string ans = a.first;
        int p = a.second;
        
        if(p>=m){
            
            cout << ans << endl;
            
        }
        
    }
    
    return 0;
    
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>

int main() {
  long int K, N;
  std::cin >> K >> N;
  std::vector<long int> A(N);
  for(int i=0; i<N; ++i) {
    std::cin >> A[i];
  }
  long int maxdist = A[0] + K - A[N-1];
  for(int i=0; i<N-1; ++i) {
    // if (A[i+1] - A[i] > maxdist) maxdist = A[i+1] - A[i];
    maxdist = A[i+1] - A[i] > maxdist ? A[i+1] - A[i]  : maxdist;
  }
  std::cout << K - maxdist;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	    string s1;
	    string s2;
	    cin>>s1>>s2;
	    int l1=s1.length();
	    int l2=s2.length();
	    int ai[l1][l2];
	      if(s1[0]==s2[0])ai[0][0]=1;
	      else ai[0][0]=0;
	    for(int i=1;i<l2;i++){
	        if(s1[0]==s2[i])ai[0][i]=1;
	        else ai[0][i]=ai[0][i-1];
	    }
	    for(int i=1;i<l1;i++){
	        if(s1[i]==s2[0])ai[i][0]=1;
	        else ai[i][0]=ai[i-1][0];
	    }
	    for(int n1=1;n1<l1;n1++){
	        for(int n2=1;n2<l2;n2++){
	            if(s1[n1]==s2[n2])
	            ai[n1][n2]=ai[n1-1][n2-1]+1;
	            else
	               ai[n1][n2]=(ai[n1-1][n2]>ai[n1][n2-1])?ai[n1-1][n2]:ai[n1][n2-1];
	        }
	    }
	    string s="";
	    int t=0;
	    int i=l1-1;
	    int j=l2-1;
	    while(t<1){
	        if(s1[i]==s2[j]){
	            s=string(1,s1[i])+s;
	            i--;
	            j--;
	        }else{
	        if(i>0){
	            if(ai[i][j]==ai[i-1][j])i--;
	            else if(j>0){
	               if(ai[i][j]==ai[i][j-1])j--;
	            }
	        }
	        else if(j>0){
	            if(ai[i][j]==ai[i][j-1])j--; 
	        }}
	        if(i<0||j<0)t++;
	        if((i==0&&j==0)&&s1[i]!=s2[i])t++;
	    }
	    cout<<s;
	return 0;
}

Measured memory_bytes: 35456
#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;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n = 5;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  int ans = 0;
  int MX = 0;

  REP(i,n){
    if(a[i]%10 == 0) ans += a[i];
    else{
      ans += a[i]/10 * 10 + 10;
      MX = max(MX, 10 - a[i]%10);
    }
  }

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

Measured memory_bytes: 3628
import java.util.Scanner;

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

		for(int i = 0; i < a; i++) {
			int T = sc.nextInt();
			int S = sc.nextInt();
			Dice copy = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
			int ans = solv(T,S,copy,0);
			System.out.println(ans);
		}
	}

	public static int solv(int a, int b, Dice dice,int count) {
		if(dice.Top == a && dice.S == b) return dice.E;
		if(count == 4) return -1;
		int ans = -1;
		Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnN();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnS();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnE();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnW();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		return ans;
	}
}

	 class Dice {
		int Top; 
		int Bottom; 
		int N; 
		int S; 
		int W; 
		int E; 
		Dice(int a, int b, int c, int d, int e, int f) {
			Top = a;
			S = b;
			E = c;
			W = d;
			N = e;
			Bottom = f;
		}

		public void TurnN() {
			int tmp = Top;
			Top = S;
			S = Bottom;
			Bottom = N;
			N = tmp;
		}

		public void TurnW() {
			int tmp = Top;
			Top = E;
			E = Bottom;
			Bottom = W;
			W = tmp;
		}

		public void TurnE() {
			int tmp = Top;
			Top = W;
			W = Bottom;
			Bottom = E;
			E = tmp;
		}

		public void TurnS() {
			int tmp = Top;
			Top = N;
			N = Bottom;
			Bottom = S;
			S = tmp;
		}
	}


Measured memory_bytes: 26708
import math

L = int(input())
N = int(math.log2(L))+1

M = 2*(N-1)

# print(N, )
edges = []
for i in range(N-1):
    edges.append('{0} {1} {2}'.format((i+1) , (i+2), 0))
    
for i in range(N-1):
    edges.append('{0} {1} {2}'.format((i+1) , (i+2), 2**i))

node = L-2**(N-1)
X = 2**(N-1)

while node > 0:
    M += 1
    t = int(math.log2(node))+1
    edges.append('{0} {1} {2}'.format(t, N, X))
    node -= 2**(t-1)
    X += 2**(t-1)
    
output = """{0} {1}
{2}""".format(N,M,'\n'.join(edges))
print(output)

Measured memory_bytes: 3064
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 18
#define ll long long
#define mo 998244353
ll qpow(ll x,int y=mo-2){
	ll r=1;
	for (;y;y>>=1,x=x*x%mo)
		if (y&1)
			r=r*x%mo;
	return r;
}
int n;
int a[1<<N],p[1<<N],e[1<<N],f[1<<N];
void fwt(int F[]){
	for (int i=1;i<1<<n;i<<=1)
		for (int j=0;j<1<<n;j+=i<<1)
			for (int k=j;k<j+i;++k){
				int x=F[k],y=F[k+i];
				F[k]=(x+y)%mo;
				F[k+i]=(x-y+mo)%mo;
			}
}
int main(){
	scanf("%d",&n);
	ll sum=0;
	for (int i=0;i<1<<n;++i)
		scanf("%d",&a[i]),sum+=a[i];
	sum=qpow(sum);
	for (int i=0;i<1<<n;++i)
		p[i]=a[i]*sum%mo;
	
	for (int i=0;i<1<<n;++i)
		f[i]=-1+mo;
	(f[0]+=1<<n)%=mo;
	fwt(f);
	(p[0]=p[0]-1+mo)%=mo;
	fwt(p);
	
	sum=0;
	for (int i=1;i<1<<n;++i){
		e[i]=(ll)f[i]*qpow(p[i])%mo;
		sum+=e[i];
	}
	e[0]=(mo-sum%mo)%mo;
	fwt(e);
	ll inv=qpow(1<<n);
	for (int i=0;i<1<<n;++i)
		e[i]=e[i]*inv%mo;
	for (int i=0;i<1<<n;++i)
		printf("%d\n",e[i]);
	return 0;
}

Measured memory_bytes: 6928
from collections import Counter
n = int(input())
a = [input() for i in range(n)]
b = Counter(a)
b.setdefault("AC", 0)
b.setdefault("WA", 0)
b.setdefault("TLE", 0)
b.setdefault("RE", 0)
print("AC" + " x " + str(b["AC"]))
print("WA" + " x " + str(b["WA"]))
print("TLE" + " x " + str(b["TLE"]))
print("RE" + " x " + str(b["RE"]))

Measured memory_bytes: 16620
N=int(input())
N_list=list(str(N))

if len(N_list)==1:
    M=int(N_list[0])
    if N%M==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==2:
    I=int(N_list[0])+int(N_list[1])
    if N%I==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==3:
    U=int(N_list[0])+int(N_list[1])+int(N_list[2])
    if N%U==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==4:
    K=int(N_list[0])+int(N_list[1])+int(N_list[2])+int(N_list[3])
    if N%K==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==5:
    O=int(N_list[0])+int(N_list[1])+int(N_list[2])+int(N_list[3])+int(N_list[4])
    if N%O==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==6:
    G=int(N_list[0])+int(N_list[1])+int(N_list[2])+int(N_list[3])+int(N_list[4])+int(N_list[5])
    if N%G==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==7:
    W=int(N_list[0])+int(N_list[1])+int(N_list[2])+int(N_list[3])+int(N_list[4])+int(N_list[5])+int(N_list[6])
    if N%W==0:
        print("Yes")
    else:
        print("No")
elif len(N_list)==8:
    S=int(N_list[0])+int(N_list[1])+int(N_list[2])+int(N_list[3])+int(N_list[4])+int(N_list[5])+int(N_list[6])+int(N_list[7])
    if N%S==0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,C, D;
  cin >> N;
  A = N/1000;
  B = N%1000/100;
  C = N%1000%100/10;
  D = N%1000%100%10;
  if(A==B && A== C){
    cout << "Yes";
  } else if(B==C&&B==D){
    cout << "Yes";
  } else {
    cout << "No";  
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  char A,B;
  cin >> A >> B;
  if(A > B) {
    cout << ">" << endl;
  }else if(A < B) {
    cout << "<" << endl;
  }else {
    cout << "=" << endl;
  }
}

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

const string possible = "POSSIBLE";
const string impossible = "IMPOSSIBLE";
int n, k, a[101010];

int main()
{
    cin >> n >> k;
    int m = 0;
    rep(i, n)
    {
        cin >> a[i];
        if(a[i] == k)
        {
            cout << possible << endl;
            return 0;
        }
        m = max(m, a[i]);
    }
    if(k >= m)
    {
        cout << impossible << endl;
        return 0;
    }
    
    int g = a[n - 1];
    rep(i, n - 1)
    {
        g = __gcd(g, a[i]);
    }
    
    if(k % g != 0)
    {
        cout << impossible << endl;
    }
    else
    {
        cout << possible << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
int dp [MAX_N];

void dfs (int u, int p) {
  for (int nxt : adj[u]) {
    if (nxt != p) {
      dfs(nxt, u);

      dp[u] ^= dp[nxt] + 1;
    }
  }
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(1, 0);

  if (dp[1] == 0) {
    cout << "Bob" << endl;
  } else {
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 17288
#!/usr/bin/env python3
import sys


from bisect import bisect_right
import itertools


def solve(N: int, x: int, a: "List[int]"):
    a.sort()
    acum = list(itertools.accumulate(a))
    ans = bisect_right(acum, x)
    if ans == N and acum[-1] < x:
        ans -= 1
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x, a)


if __name__ == "__main__":
    main()


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main() {
    ll ans=0;
    vector<ll>cnt(5,0);
    ll n;cin >>n;
    char c[5]={'M','A','R','C','H'};
    for (int i = 0; i < n; ++i) {
        string s;cin >>s;
        for (int j = 0; j < 5; ++j){
            if(s[0]==c[j])cnt[j]++;
        }
    }
    for (int i = 0; i < 3; ++i) {
        for (int j =i+1; j <4; ++j) {
            for (int k = j+1; k <5; ++k) {
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(new Main().tap_dance(scanner.nextLine()));
		scanner.close();
	}
	
	public String tap_dance(String str) {
		int i;
		for(i = 0; i < str.length(); i++) {
			if((i + 1) % 2 == 1) {
				if(str.charAt(i) == 'L') {
					return "No";
				}
			}else {
				if(str.charAt(i) == 'R') {
					return "No";
				}
			}
		}
		return "Yes";
	}
}


Measured memory_bytes: 21844
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

function Tree() {
  this.root = null;
  this.keys = {};
}
Tree.prototype.insert = function (val) {
  var z, y, x;
  this.keys[val] = null;
  z = {'left': null, 'right': null, 'key': val, 'parent': null};
  y = null;
  x = this.root;
  while (x !== null) {
    y = x;
    if (z.key < x.key) x = x.left;
    else x = x.right;
  }
  z.parent = y;

  if (y === null) this.root = z;
  else if (z.key < y.key) y.left = z;
  else y.right = z;
}
Tree.prototype.find = function (val) {
  return (this.keys.hasOwnProperty(val));
}
Tree.prototype.printTree = function() {
  function p(node, depth) {
    var indent = '', i;
    for (i = 0; i < depth; i++) indent = indent + '  ';
    if (node === null) {
      console.log(indent + 'NIL');
      return;
    }
    console.log(indent + node.key);
    p(node.left, depth+1);
    p(node.right, depth+1);
  }
  p(this.root, 0);
}
Tree.prototype.print = function() {
  function inorder(node) {
    var res = [];
    if (node === null) return res;
    res = res.concat(inorder(node.left));
    res.push(node.key);
    res = res.concat(inorder(node.right))
    return res;
  }
  function preorder(node) {
    var res = [];
    if (node === null) return res;
    res.push(node.key);
    res = res.concat(preorder(node.left));
    res = res.concat(preorder(node.right));
    return res;
  }
  console.log(' ' + inorder(this.root).join(' '));
  console.log(' ' + preorder(this.root).join(' '));
}

si = require('fs').createReadStream(config.input, {encoding: 'ascii'});
rl = require('readline').createInterface({
  input: si, output: process.stdout});

t = new Tree();

rl.on('line', function (line) {
  var inst;
  inst = line.split(' ');
  if (inst[0] === 'insert') {
    t.insert(parseInt(inst[1], 10));
  } else if (inst[0] === 'find') {
    console.log(t.find(parseInt(inst[1], 10)) ? 'yes' : 'no');
  } else if (inst[0] === 'print') {
    //t.printTree();
    t.print();
  }
});

Measured memory_bytes: 169692
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}
#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: u64, m: u64, k: u64
    }

    let cb = comb(n*m-2, k-2, M);
    let mut ret = 0u64;
    for d in 0..n {
        let tmp = (n - d) * m % M * m % M;
        ret += tmp * d;
        ret %= M;
    }
    for d in 0..m {
        let tmp = (m - d) * n % M * n % M;
        ret += tmp * d;
        ret %= M;
    }
    ret *= cb;
    ret %= M;
    println!("{}", ret);
}

#[doc = " a / b modulo m == a * modinv(b, m) % m"]
#[allow(dead_code)]
fn modinv(a_: u64, m_: u64) -> u64 {
    let m = m_ as i64;
    let mut a = a_ as i64;
    let mut b = m as i64;
    let mut u = 1;
    let mut v = 0;
    while b != 0 {
        let t = a / b;
        a -= t * b;
        std::mem::swap(&mut a, &mut b);
        u -= t * v;
        std::mem::swap(&mut u, &mut v);
    }
    u %= m;
    if u < 0 {
        u += m
    };
    u as u64
}
#[allow(dead_code)]
fn comb(n: u64, r: u64, m: u64) -> u64 {
    let mut ret = 1u64;
    for i in 0..r {
        ret *= n - i;
        ret %= m;
    }
    for i in 1..r + 1 {
        ret *= modinv(i, m);
        ret %= m;
    }
    ret
}
#[doc = " combination with repetition"]
#[allow(dead_code)]
fn comb_rep(n: u64, r: u64, m: u64) -> u64 {
    comb(n + r - 1, r, m)
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int x,y;
int tax(int pp){
    int p = 0;
    for(int i = 1 ; i < 1000 ; i++){
        if(i*(100+x)/100 == pp){
            p = i;
            break;
        }
    }
    return p*(100+y)/100;
}

int main(){
    int s;
    while(cin >> x >> y >> s,(x|y|s)){
        int max = 0;
        for(int i = 1 ; i <= s/2 ; i++){
            max = std::max(max,tax(i)+tax(s-i));
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import cmath
import numpy as np
import sys

INF=10**18
MOD=10**9+7
MAX=10**5

def main():
    N=int(input())
    h=list(map(int, input().split()))
    h.insert(0, 0)
    h.append(INF)

    dp=[INF]*(N+5)
    dp[1]=0
    for i in range(1,N):
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
        dp[i+2]=min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))

    print(dp[N])

if __name__=='__main__':
    main()


Measured memory_bytes: 22764
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;

int main()
{
    string sN;
    cin >> sN;
    int sum = 0;
    rep(i, sN.size()) sum += sN[i] - 48;
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3716
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()

S = [list(sr()) for _ in range(H)]
S = np.array([[1 if x == '.' else 0 for x in row] for row in S])

U = np.zeros((H, W), np.int32)
D = np.zeros((H, W), np.int32)
L = np.zeros((H, W), np.int32)
R = np.zeros((H, W), np.int32)

for h in range(H-1):
    U[h+1] = (U[h] + 1) * S[h]
    D[H-h-2] = (D[H-h-1] + 1) * S[H-h-1]
for w in range(W-1):
    L[:, w+1] = (L[:, w] + 1) * S[:, w]
    R[:, W-w-2] = (R[:, W-w-1] + 1) * S[:, W-w-1]


print(((U + D + L + R) * S).max() + 1)


Measured memory_bytes: 157232
A, B, C = map(int,input().split())
K = int(input())

for k in range(K):
  #print(A, B, C)  
  if A >= B:
    B*=2
  else:
    C*=2


ans = False
if A < B < C:
  ans = True
  
print("Yes" if ans else "No")

Measured memory_bytes: 9172
n=int(input())
A=[]*n
A[:]=map(int,input().split())

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
      
left=[0]*n
right=[0]*n
for i in range(1,n):
  left[i]=gcd(left[i-1],A[i-1])
  right[n-1-i]=gcd(right[n-i],A[n-i])

ans=0
for i,j in zip(left,right):
  ans=max(ans,gcd(i,j))
print(ans)  

Measured memory_bytes: 14584
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
}

Measured memory_bytes: 66908
// AOJ 1182 Railway Connection
// 2018.2.22 bal4u
 
#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 10001

int d[22][102][102];
int p[22], q[22][52], r[22][52];
int hi[102], to[102][204], w[102][204];
int dist[102], fare[22][10010];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int s, int g)
{
	int i, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	enq(s, 0), dist[s] = 0;
	while (qsize) {
		s = que[0].s, deq();
		if (s == g) return dist[g];
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + w[s][i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return -1;
}

int main()
{
	int N, M, C, S, G, i, j, k;
	int x, y, c, t;

	while (N = in()) {
		M = in(), C = in(), S = in()-1, G = in()-1;

		memset(d, INF, sizeof(d));
		for (c = 0; c < C; c++) for (i = 0; i < N; i++) d[c][i][i] = 0;

		for (i = 0; i < M; i++) {
			x = in()-1, y = in()-1, t = in(), c = in()-1;
			if (t < d[c][x][y]) d[c][x][y] = d[c][y][x] = t;
		}

		for (c = 0; c < C; c++) {
			for (k = 0; k < N; k++) for (i = 0; i < N; i++) if (d[c][i][k] < INF) {
				for (j = 0; j < N; j++) if (d[c][k][j] < INF) {
					t = d[c][i][k] + d[c][k][j];
					if (t < d[c][i][j]) d[c][i][j] = t;
				}
			}
		}

		for (c = 0; c < C; c++) p[c] = in();
		for (c = 0; c < C; c++) {
			for (i = 1; i < p[c]; i++) q[c][i] = in();
			q[c][p[c]] = MAX-1;
			for (i = 1; i <= p[c]; i++) r[c][i] = in();
		}

		if (!M) { puts(S == G? "0": "-1"); continue; }

		for (c = 0; c < C; c++) {
			for (i = 1; i <= p[c]; i++) for (j = q[c][i-1]+1; j <= q[c][i]; j++)
				fare[c][j] = fare[c][j-1] + r[c][i];
		}

		memset(hi, 0, sizeof(hi));
		for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
			t = INF;
			for (c = 0; c < C; c++) if (d[c][i][j] < MAX) {
				if (t > (k=fare[c][d[c][i][j]])) t = k;
			}
			if (t < INF) {
				k = hi[i]++, to[i][k] = j, w[i][k] = t;
				k = hi[j]++, to[j][k] = i, w[j][k] = t;
			}
		}
		printf("%d\n", dijkstra(S, G));
	}
	return 0;
}



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

using namespace std;

const int maxn = 200010;

int b, n, tag[maxn];
char str[maxn];

int pw[15];
int *a[15], tot = 1;

int getbit(int v, int x) {
	return v / pw[x] % 3;
}

int add(int x, int y) {
	int ret = 0;
	for (int i = 0; i < b; i++) {
		ret += (getbit(x, i) + getbit(y, i)) % 3 * pw[i];
	}
	return ret;
}

int cal(int v) {
	int ret = v;
	for (int i = 1; i <= b; i++) {
		int x = getbit(ret, i-1) + a[i][v % pw[i]];
		x %= 3;
		ret += (x - getbit(ret, i-1)) * pw[i-1];
	}
	return ret;
}

int rev(int v) {
	int ret = 0;
	for (int i = 0; i < b; i++) {
		int x = getbit(v, i);
		if (x == 2) ret += pw[i];
		if (x == 1) ret += 2 * pw[i];
	}
	return ret;
}

int main() {
	pw[0] = 1;
	for (int i = 1; i < 15; i++) pw[i] = pw[i-1] * 3;
	scanf("%d", &b); scanf("%s", str+1);
	for (int i = 0; i <= b; i++) {
		a[i] = new int[pw[i]];
		for (int j = 0; j < pw[i]; j++) {
			a[i][j] = 0;
		}
	}
	n = int (strlen(str + 1));
	for (int i = 1; i <= n; i++) tag[i] = tag[i-1] ^ (str[i] == 'S');
	for (int i = 1; i <= n; i++) {
		if (str[i] != 'R') continue;
		int w = 0, nw = 0;
		for (int x = 0; x < b; x++) {
			// w = mod 3^x 是什么才会对 3^x 位有影响
			for (int v = 0; v < 3; v++) {
				int t = w + pw[x] * v;
				int tt = cal(t);
				if (tag[i] & 1) {
					a[x+1][t] += 2;
					if (getbit(tt, x) == 1) nw = t;
				} else {
					a[x+1][t] += 1;
					if (getbit(tt, x) == 2) nw = t;
				}
			}
			w = nw;
		}
	}
	for (int i = 0; i < pw[b]; i++) {
		if (tag[n]) printf("%d ", rev(cal(i)));
		else printf("%d ", cal(i));
	}
	puts("");
	return 0;
}

Measured memory_bytes: 8160
n = int(input())

def change(x):
  for i in range(26):
    if x == i:
      return "abcdefghijklmnopqrstuvwxyz"[i]

r = []

while n >= 1:
  n = n - 1
  r.append(change(n%26))
  #print(n,end=" ")
  #print(change(n%26))
  n = n // 26

s = len(r)
  
for i in range(s):
  print(r[s-1-i], end='')
  

Measured memory_bytes: 9144
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    lst = [0 for _ in range(2 * 10 ** 5 + 1)]

    for a in a_lst:
        lst[a] += 1

    for i in range(1, n + 1):
        print(lst[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 108768
# input
stairs, broken = map(int, input().split())
conditions = [1] * (stairs + 1)
for i in range(broken):
  tmp = int(input())
  conditions[tmp] = 0
  
# main
for i in range(2, stairs+1):
  conditions[i] *= (conditions[i-1] + conditions[i-2]) % (10**9+7)

print(conditions[stairs])

Measured memory_bytes: 6964
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n,k;cin>>n>>k;
     int a[n];
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     bool dp[k+1];
     memset(dp,false,sizeof dp);
     for(int stone=0;stone<=k;stone++)
     {
         for(int i=0;i<n;i++)
         {
             if(stone>=a[i] && dp[stone-a[i]]==false)
             {
                 dp[stone] = true;
             }
         }
     }
     if(dp[k]==true)
     {
         cout<<"First"<<endl;
     }
     else
     {
         cout<<"Second"<<endl;
     }
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int max(int a, int b){return a<b?b:a;}
char S[3001], T[3001], c;
short (*dp)[3001];
int s, t, i, j, k;
int main(void){
	dp = malloc(sizeof(short) * 3001 * 3001);
	while((c=getchar())!=10){S[s++]=c;}
	while((c=getchar())!=10){T[t++]=c;}
	for(i=s-1; i>=0; i--){
		for(j=t-1; j>=0; j--){
			dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
			if(S[i]==T[j]){dp[i][j] = max(dp[i][j], dp[i+1][j+1]+1);}
		}
	}
	i=0; j=0, k=dp[0][0];
	while(k){
		if(dp[i+1][j]==k){i++;}
		else if(dp[i][j+1]==k){j++;}
		else{putchar(S[i]); i++; j++; k--;}
	}
	putchar(10);
	free(dp);
}


Measured memory_bytes: 17792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    l, r, d = map(int, input().split())
    ans = 0
    for i in range(l, r + 1):
        if i % d == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8972
input = gets(nil).chomp

o = {}

input.split("\n").each do |line|
  ws = line.split(" ")
  ws.each do |w|
    o[w] = 0 unless o[w]
    o[w] += 1
  end
end

m = 0
o.each {|k,v| m = v if v > m}

a1 = o.select{|k,v| v == m}.keys[0]
a2 = o.keys.max_by{|v| v.size}

puts "#{a1} #{a2}"

Measured memory_bytes: 6104
#!/usr/bin/env pypy3


def final_length(st):
    s = 0
    t = 0
    for c in st:
        if c == "S":
            s += 1
        elif c == "T":
            if s > 0:
                s -= 1
            else:
                t += 1
    return s + t


def main():
    print(final_length(input()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40432
N = int(input())

if N == 2:
    print(-1)

elif N == 3:
    ptn = ['abb','a.c','ddc']
    print('\n'.join(ptn))

else:
    ptns = {
        4: ['abcc','abdd','eegh','ffgh'],
        5: ['abc..','abc..','ghhdd','g.iee','jjiff'],
        6: ['abc...','abc...','ddeeff','gghhii','...jkl','...jkl'],
        7: ['abc....','abc....','def....','def....','m..gghh','m..iijj','.nnkkll']
    }
    x = N//4 - 1
    y = N - 4*x
    ansss = [['.']*(N) for _ in range(N)]
    for k in range(x):
        for i in range(4):
            for j in range(4):
                ansss[4*k+i][4*k+j] = ptns[4][i][j]
    for i in range(y):
        for j in range(y):
            ansss[4*x+i][4*x+j] = ptns[y][i][j]
    print('\n'.join([''.join(anss) for anss in ansss]))


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

int main() {
  string S; cin >> S;
  int ans = 0;
  int n = S.size();
  rep(i, n/2) {
    if (S[i] != S[n-1-i]) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
  ll h;
  cin >> h;
  ll x = h;
  ll cnt = 0;
  while(x!=0)
  {
    x = x >> 1;
    cnt++;
  }
  ll tmp = 1;
  for (ll i = 0; i < cnt; i++)
  {
    tmp *= 2;
  }
  cout << tmp-1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int A,B,C;
	cin >> A>>B>>C;
	if (A*C <= B)cout << C << endl;
	else cout << B / A << endl;


	return 0;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{
    int h , a ;
    cin >> h >> a ;
    cout << (h + a - 1)/ a ;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int a, c, B;
  cin >> a >> c >> B;
  int A = min(a, c);
  int C = max(a, c);
  if(A <= B && B <= C) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
  int X,Y;
  cin>>X>>Y;
  if (Y%2 == 1){
    cout<<"No"<<endl;
  }
  else if(2*X<=Y && Y<=4*X){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n;
    n=n%10;
    ll arr[5]={2,4,5,7,9};
    for(i=0;i<5;i++)if(n==arr[i]){cout<<"hon";break;}
    if(i>=5)
    {
        if(n==3)cout<<"bon";
        else cout<<"pon";
    }
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <stdbool.h>

long mypow(long i, long n){
    long sum = 1;
    long j;
    for(j = 0 ; j < n; j++){
        sum*=i;
    }
    return sum;
}

bool check(long i,long a,long n){
    int y = 0;
    long temp = i;
    while(i){
        y += i%10;
        i = i/10;
    }
    return (mypow(y+a,n) == temp);
}

long arr[10000];

int main()
{
    long a,n,m,i;
    long cnt = 0;
    scanf("%ld %ld %ld",&a,&n,&m);

    for(i = 1; mypow(i,n) < m; i++){
        arr[i] = mypow(i,n);
    }

    while(--i){
        if(check(arr[i],a,n)) cnt++;
    }

    printf("%ld\n",cnt);
}


Measured memory_bytes: 2740
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}



int main(void) {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
}
		


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()


on = []

Ma = 0

for i in range(n):
    kkk = []
    p = onem()
    for j in range(p):
        kkk.append(l())
    on.append(kkk)
for i in range(2**n):
    ppp = '{:015b}'.format(i)
    ppp = list(ppp[15-n:])
    ppp.reverse()
    su = 0
    for r in range(n):
        if ppp[r] == "1":
            su += 1
    f = False
    for j in range(n):
        if ppp[j] == "1":
            for k in range(len(on[j])):
                a,b = on[j][k]
                a -= 1
                if b ^ int(ppp[a]):
                    f = True
                    break
    if not f:
        Ma = max(Ma,su)
print(Ma)






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


public class MyProgram
{	

    public static void Main()
	{
        int N = int.Parse(Console.ReadLine());
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        long sum = 0;
        foreach(int i in n) sum += i-1;
        
	    Console.WriteLine(sum);
	}
}

Measured memory_bytes: 13296
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  long long rol = x / 11;
  if (x % 11 >= 7) cout << rol*2 + 2 << endl;
  else if (x % 11 > 0) cout << rol*2 + 1 << endl;
  else cout << rol*2 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[22], B[22];

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
	}
	long long int ans = INF;
	for(int i = 0; i < (1 << N); i++){
		long long int cnt = 0;
		for(int j = 0; j < N; j++){
			if(i & (1 << j)){
				cnt += 1;
			}
		}
		if(cnt != N / 2){
			continue;
		}
		vector<long long int> v1, v2;
		for(int j = 0; j < N; j++){
			if(i & (1 << j)){
				if(j % 2 == 0){
					v1.push_back(B[j]);
				}else{
					v1.push_back(A[j]);
				}
			}else{
				if(j % 2 == 0){
					v2.push_back(A[j]);
				}else{
					v2.push_back(B[j]);
				}
			}
		}
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		v2.push_back(INF);
		bool flag = false;
		/*
		for(int j = 0; j < v1.size(); j++){
			cout << v1[j] << " ";
		}cout << endl;
		for(int j = 0; j < v.size(); j++){
			cout << v2[j] << " ";
		}cout << endl;
		*/
		for(int j = 0; j < v1.size(); j++){
			if(v1[j] < v2[j]){
				flag = true;
			}
			if(v1[j] > v2[j + 1]){
				flag = true;
			}
		}
		v2.pop_back();
		if(flag){
			continue;
		}
		int P[22] = {};
		int cnt1 = 2, cnt2 = 1;
		for(int num = 1; num <= 50; num++){
			for(int j = 0; j < N; j++){
				if(i & (1 << j)){
					if(j % 2 == 0){
						if(B[j] == num){
							P[j] = cnt1;
							cnt1 += 2;
						}
					}else{
						if(A[j] == num){
							P[j] = cnt1;
							cnt1 += 2;
						}
					}
				}else{
					if(j % 2 == 0){
						if(A[j] == num){
							P[j] = cnt2;
							cnt2 += 2;
						}
					}else{
						if(B[j] == num){
							P[j] = cnt2;
							cnt2 += 2;
						}
					}
				}
			}
		}
		/*
		for(int j = 0; j < N; j++){
			cout << P[j] << " ";
		}cout << endl;
		*/
		cnt = 0;
		for(int j = 0; j < N; j++){
			for(int k = N - 1; k > j; k--){
				if(P[k - 1] > P[k]){
					swap(P[k - 1], P[k]);
					cnt += 1;
				}
			}
		}
		ans = min(ans, cnt);
		//cout << i << endl;
	}
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/10  Problem: ARC 086 B / Link: http://arc086.contest.atcoder.jp/tasks/arc086_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	L = 0;
	R = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		L = min(L, v[i]);
		R = max(R, v[i]);
	}
	vector<pair<int, int>>ans;
	if (abs(R) > abs(L)) {
		int index = 0;
		for (int i = 1; i < N; i++) {
			if (v[i] > v[index]) {
				index = i;
			}
		}
		ans.push_back({ index,N - 1 });
		ans.push_back({ index,N - 1 });
		ans.push_back({ index,N - 1 });
		for (int i = 1; i < N - 1; i++) {
			ans.push_back({ N - 1,N - 1 });
			ans.push_back({ N - 1,i });
		}
		ans.push_back({ N - 1,N - 1 });
	}
	else {
		int index = 0;
		for (int i = 1; i < N; i++) {
			if (v[i] < v[index]) {
				index = i;
			}
		}
		ans.push_back({ index,0 });
		ans.push_back({ index,0 });
		ans.push_back({ index,0 });
		for (int i = N - 2; i >= 1; i--) {
			ans.push_back({ 0,0 });
			ans.push_back({ 0,i });
		}
		ans.push_back({ 0,0 });
	}
	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i.first + 1 << " " << i.second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

S = int(input())

import math

tar = math.sqrt(S)
if int(tar) == tar:
    x2y1 = 0
    x1 = y2 = int(tar)
else:
    x2y1 = (int(tar) + 1) ** 2 - S
    x1 = y2 = int(tar) + 1

tmp = x2y1
x2 = 1
for p in range(int(x2y1) + 1):
    if x2 <= 10 ** 9 and (x2y1 // x2) <= 10 ** 9: break
    elif tmp % p > 0: continue
    #
    for i_p in range(1, 65):
        if tmp % (p ** (i_p + 1)) > 0: break
    x1 *= (p ** i_p)

y1 = x2y1 // x2
print(0, 0, x1, y1, x2, y2)

# if abs(x1 * y2 - x2 * y1) == S:
#     print('AC')
# else:
#     print('WA')

Measured memory_bytes: 3064