akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;

static string n;

int main()
{
	while(cin >> n){
		int res = 0;
        for(char i:n){
            res += i - '0';
        }

        if (res % 9 == 0)
            cout << "Yes\n";
        else
        {
            cout << "No\n";
        }        
	}
	
	return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

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

int lcm(int a, int b){
    return a * b / gcd(a, b);
}



int main() {
  int N; cin >> N;
  
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(A.begin(), A.end());
  
  int cnt=0;
  rep(i, N) {
    if(A[i]%2==1) ++cnt;
  }
  if(cnt%2==0) dump("YES");
  else dump("NO");
}


Measured memory_bytes: 640
N, M =  map(int, input().split())
A = list(map(int, input().split()))
assert len(A) == N
# 商品iは得票Ai
# 総得票数の1/4M以上の商品をM個選ぶ
total = sum(A)
import math
thres = math.ceil(total / (4 * M))
count = len([i for i in range(N) if A[i] >= thres])
if count >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 62200
d = ''
for i in range(26):
    d += chr(ord('a') + i)
for i in range(26):
    d += chr(ord('A') + i)

def decode(c,key):
    i = d.find(c)
    return d[(i-key) % 52]

while True:
    N = int(input())
    if N == 0: break
    ks = list(map(int,input().split()))
    S = input()
    ans = ''
    for i,c in enumerate(S):
        ans += decode(c, ks[i%N])
    print(ans)

Measured memory_bytes: 5612
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N; cin >> N;
	vector<ll> a(N+1); 
	for (int i = 1; i < N + 1;i++) cin >> a[i];

	int prev = 1;
	int ans = 0;
	map<ll, ll> p;
	p[1] = 1;
	while (1) {
		prev = a[prev];
		p[prev]++;
		if (p[prev] == 2) {
			cout << -1 << endl;
			return 0;
		}
		ans++;

		if (prev == 2) {
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d", &n)
#define sc(s) scanf("%s", s)

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

char s[4];
int main(void){
    scanf("%s", s);
    if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3]) printf("Bad\n");
    else printf("Good\n");


    return 0;
}



Measured memory_bytes: 256
mod=1000000007

n,k=[int(i) for i in input().split(" ")]



facts=[1 for i in range(n+k+1)]

for i in range(1,n+k+1):
    facts[i]=i*facts[i-1]


tables=[[-1 for i in range(k+1)] for j in range(n+1)]

for i in range(1,n+1):
    for j in range(1,k+1):
        if i<j:
            tables[i][j]=0
        elif j==1:
            tables[i][j]=1

        elif i==j:
            tables[i][j]=facts[i]

        else:
            tables[i][j]=j*(tables[i-1][j]+tables[i-1][j-1])

def f(n,k):
    if n<k:
        return 0
    if k==1:
        return 1

    elif n==k:
        return facts[n]

    elif tables[n][k]!=-1:
            return tables[n][k]

    else:
        retval=(k*f(n-1,k)+k*f(n-1,k-1))
        tables[n][k]=retval
        return retval

retval=0
for i in range(1,k+1):
    retval+=(tables[n][i]//facts[i])%mod

print(retval%mod)



Measured memory_bytes: 375692
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

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


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,  n) cin >> a.at(i);

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int alice = 0;
	int bob = 0;

	rep(i,n){
		if(i%2 == 0)
			alice += a.at(i);
		else
			bob += a.at(i);
	}
	cout << alice - bob << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = ReadText();

            var count = 0;
            var pre = '0';
            foreach (var s in S)
            {
                if (pre != s)
                {
                    count++;
                }
                pre = s;
            }

            return count;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 11232
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {


        int inpt = int.Parse(Reader.ReadLine());
        int ki = inpt / 2;
        int gu = inpt / 2;
        if(inpt % 2 != 0) {
            ki++;
        }

        int ans = ki * gu;
        Console.WriteLine(ans);
    
    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


50


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

int main(){

  int a[100],num,i,j,minj,swap,count=0;

  scanf("%d",&num);
  for(i = 0; i < num; i++){
    scanf("%d",&a[i]);
  }

  for(i = 0; i < num; i++){
    minj = i;
    for(j = i+1; j < num; j++){
      if(a[j] < a[minj]){
	  minj = j;

      }
    }

      swap =a[i];
      a[i] = a[minj];
      a[minj] = swap;
      if(i != minj){
      count++;
      }
  }

  for(i = 0; i < num-1; i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1028
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  while(1) {
      int n,x;
      cin >> n >> x;
      if(n == 0 && x == 0) break;
      vi data(n);
      rep(i,n) data[i] = i + 1;
      int count = 0;
      rep(i,n) {
          rep(j,n) {
              rep(k,n) {
                  if(i != j && j != k && k != i && data[i] + data[j] + data[k] == x) count++;
              }
          }
      }
      cout << count / 6 << "\n";
  }
}


Measured memory_bytes: 3212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
	int n;
	cin>>n;
	REP(i,n){
		string s ;
		cin >>s;
		list<char> l;
		l.push_back(s[0]);
		int p=0;
		for(int j=1;j<s.size();j+=3){
			char c=s[j+2];
			if(s[j]=='-'){
				p++;
				if(p>=l.size()){
					l.push_back(c);
				}
			}else{
				p--;
				if(p<0){
					l.push_front(c);
					p=0;
				}
			}
		}
		EACH(list<char>,it,l){
			cout<<(*it);
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>

int main()
{
  std::string S, result = "YES";
  std::string str_pattern[4] = {"dream", "dreamer", "erase", "eraser"};
  std::cin >> S;

  int end = S.length();
  while(end > 0)
  {
    bool match = false;
    for(int i = 0; i < 4; i++)
    {
      int start = end - str_pattern[i].length();
      if(start < 0)
      {
        continue;
      }
      
      if(S.compare(start,  str_pattern[i].length(), str_pattern[i]) == 0)
      {
        end -= str_pattern[i].length();
        match = true;
        break;
      }
    }
    
    if(match == false)
    {
      result = "NO";
      break;
    }
  }
  
  std::cout << result;
  return 0;
}

Measured memory_bytes: 3252
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    A.sort()
    lenA = len(A)
    ans = 0

    if K == 1:
        print(0)
        sys.exit()

    def com(n, r, mod):
        r = min(r, n - r)
        if r == 0:
            return 1
        res = ilist[n] * iinvlist[n - r] * iinvlist[r] % mod
        return res

    def modinv(a, mod=10 ** 9 + 7):
        return pow(a, mod - 2, mod)

    ilist = [0]
    iinvlist = [1]
    tmp = 1
    for i in range(1, N + 1):
        tmp *= i
        tmp %= mod
        ilist.append(tmp)
        iinvlist.append(modinv(tmp, mod))

    sum_of_com = []
    now = 0

    for i in range(K-2, N+1):
        now += com(i, K-2, mod)
        sum_of_com.append(now)

    ans = 0
    for first in range(lenA-K+1):
        ans -= A[first] * sum_of_com[lenA-first-K]
    for last in range(K-1, lenA):
        ans += A[last] * sum_of_com[last-K+1]
    ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 103084
import sys
input = sys.stdin.buffer.readline
from random import randrange


q = int(input())
queries = [list(map(int, input().split())) for i in range(q)]

set_ = set()

for category, x in queries:
    if category == 0:
        set_.add(x)
        print(len(set_))
    elif category == 1:
        print(int(x in set_))
    else:
        if x in set_:
            set_.remove(x)


Measured memory_bytes: 49124
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, Long> map = new TreeMap<>();
		List<Long> out = new ArrayList<>();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			switch (sc.nextByte()) {
				case 0:
					map.put(sc.next(), sc.nextLong());
					break;
				case 1:
					String str = sc.next();
					if(map.containsKey(str)) {
						out.add(map.get(str));
					}else{
						out.add(0L);
					}
					break;
				case 2:
					map.remove(sc.next());
					break;
			}
		}
		for (long n : out) {
			System.out.println(n);
		}
	}
}



Measured memory_bytes: 194648
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-b-b)<<endl;
}


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

int main() {

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

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

  map<int, int> m;
  vector<int> a(n + 5), p(n + 5, 0);
  long long ans = 0, sum = 0;
  m[0] = 1;

  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = (a[i] - 1 + k) % k;

    sum = (sum + a[i]) % k;
    if (i >= k) m[p[i-k]]--;
    // if (i >= k && a[i] == 0)  ans++;
    ans += m[sum];
    m[sum]++;
    p[i] = sum;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long n=gl();
	    long m=gl();
	    String S=gs();
	    String T=gs();

	    long l=n*m/uclid(n,m);
	    long lwn=l/n;
	    long lwm=l/m;
	    long lmk=lwn*lwm/uclid(lwn, lwm);
	    for (int i=0; lmk*i<l; i++) {
	    	char c1 = S.charAt((int)(lwm*i));
	    	char c2 = T.charAt((int)(lwn*i));
	    	if (c1!=c2) {
	    		System.out.println(-1);
	    		return;
	    	}
	    }


	    System.out.println(l);
//        if(k%2==0) {
//
//		    System.out.println(a-b);
//        } else {
//        	System.out.println(b-a);
//
//        }
	}

	 // ユークリッドの互除法
    public static long uclid(long m, long n) {
    	if (m<n) {
			m^=n;
			n^=m;
			m^=n;
		}

		while(true) {
			long t=m%n;
			if (t==0) {
				return n;
			} else {
				m=n;
				n=t;
			}
		}
    }

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

namespace nyg
{
	const int N=101000;

	int begin[N],next[N*2],to[N*2];

	int n,m,e;

	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}

	bool vis[N];
	void dfs(int p)
	{
		if(vis[p])return;
		vis[p]=1;
		for(int i=begin[p];i;i=next[i])
			dfs(to[i]);
	}

	void solve()
	{
		scanf("%d%d",&n,&m);
		for(int i=1,u,v,w;i<=m;i++)
			scanf("%d%d%d",&u,&v,&w),add(u,v);

		int ans=0;
		for(int i=1;i<=n;i++)
			if(!vis[i])ans++,dfs(i);
		printf("%d\n",ans);
	}
}

int main()
{
	nyg::solve();
	return 0;
}


Measured memory_bytes: 3840
S = input()
T = input()

S_len = len(S)
T_len = len(T)
A_sum = []
count = 0

for i in range(S_len - T_len + 1):
    for j in range(T_len):
        if S[i+j] == T[j]:
            count += 1
    A_sum.append(count)
    count = 0

ans = T_len - max(A_sum) 

print(ans)

Measured memory_bytes: 9112
class Node():
    def __init__(self, parent, left, right, sibling, degree):
        self.parent = parent
        self.left = left
        self.right = right
        self.sibling = sibling
        self.degree = degree

def GetDepth(T, u):
    d = 0
    n = T[u]

    while n.parent != -1:
        n = T[n.parent]
        d += 1

    return d

def GetHight(T, u, d):

    if T[u].left != -1:
        h1 = GetHight(T, T[u].left, d + 1)
    else:
        h1 = d

    if T[u].right != -1:
        h2 = GetHight(T, T[u].right, d + 1)
    else:
        h2 = d

    return max(h1, h2)

def Main():

    n = int(input())

    T = [Node(-1, -1, -1, -1, -1) for i in range(n)]
    D = [0 for i in range(n)]
    H = [0 for i in range(n)]

    for i in range(n):
        node_id, left, right = map(int, input().split())

        if left != -1 and right != -1:
            degree = 2
        elif left == -1 and right == -1:
            degree = 0
        else:
            degree = 1

        T[node_id].left = left
        T[node_id].right = right
        T[node_id].degree = degree

        if left != -1 and right != -1:
            T[left].sibling = right
            T[right].sibling = left

        if left != -1:
            T[left].parent = node_id
        if right != -1:
            T[right].parent = node_id

    for i in range(len(T)):

        if T[i].parent == -1:
            node_type = "root"
        elif T[i].left == -1 and T[i].right == -1:
            node_type = "leaf"
        else:
            node_type = "internal node"

        print("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(i, T[i].parent, T[i].sibling, T[i].degree, GetDepth(T, i), GetHight(T, i, 0), node_type))

Main()


Measured memory_bytes: 5624
S = input()
l = len(S)
c1 = ''.join(['0' if i %2 == 0 else '1' for i in range(l)])
c2 = ''.join(['1' if i %2 == 0 else '0' for i in range(l)])
x = sum(a == b for a, b in zip(S, c1))
y = sum(a == b for a, b in zip(S, c2))
if x > y :
    print(y)
else :
    print(x)

Measured memory_bytes: 4068
#define _USE_MATH_DEFINES

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

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

    long double ratioH = (60.0 * H + M) / (12.0 * 60.0);
    long double ratioM = M / 60.0;
    long double diff = abs(ratioH - ratioM);
    long double theta = diff * M_PI * 2.0;

    long double C = sqrtl(A * A + B * B - 2.0 * A * B * cosl(theta));
    cout << setprecision(10) << C;
}


Measured memory_bytes: 4124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int num_N = int.Parse(Console.ReadLine());

            switch (num_N % 10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;

                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;

                case 3:
                    Console.WriteLine("bon");
                    break;

                default:
                break;
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27148
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<ll> rotateS(vector<ll> arg) {
  vector<ll> ans = arg;
  ll tmp = ans[0];
  ans[0] = ans[4];
  ans[4] = ans[5];
  ans[5] = ans[1];
  ans[1] = tmp;
  return ans;
}

vector<ll> rotateE(vector<ll> arg) {
  vector<ll> ans = arg;
  ll tmp = ans[0];
  ans[0] = ans[3];
  ans[3] = ans[5];
  ans[5] = ans[2];
  ans[2] = tmp;
  return ans;
}

bool same(vector<ll> foo, vector<ll> bar) {
  rep (k, 10) {
    rep (i, 10) {
      rep (j, 4) {
        if (foo == bar) {
          return true;
        }
        bar = rotateS(bar);
      }
      bar = rotateE(bar);
    }
    bar = rotateS(bar);
  }
  return false;
}

void solve() {
  ll N;
  cin >> N;
  vector<vector<ll> > vec(N, vector<ll>(6));
  rep (i, N) rep (j, 6) cin >> vec[i][j];
  for (ll i = 0; i < N; i++) for (ll j = i + 1; j < N; j++) {
    if (same(vec[i], vec[j])) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	ll t,n,m,k,i,j,z,a,b;
	str s;
	cin >> n >> m;
	cin >> a >> b;
	cin >> t;
	if(a>n)
	{
		i=n+m*t;
		j=a+b*t;
	if(j-i>0)
		cout << "NO\n";
	else
		cout << "YES\n";
	}
	else
	{
		i=n-m*t;
		j=a-b*t;
		if(j-i<0)
		cout << "NO\n";
	else
		cout << "YES\n";
	}
	// cout << s[0] << s[1] << s[2] << "\n";
	return 0;
}

Measured memory_bytes: 3632
N,M = readline.split.map(&:to_i)

require 'prime'
primes = Prime.prime_division(M)

$max = 1
def find_largest(primes, i, x)
  if i>=primes.size
    $max = x if x > $max
  else
    b,emax = primes[i]
    #pp primes, i, emax
    (0..emax).each do |e|
      div = x * (b**e)
      #pp "div: #{div}, i:#{i} e:#{e}"
      break if div > M/N
      find_largest(primes, i+1, div)
    end
  end
end

find_largest(primes, 0, 1)
puts $max


Measured memory_bytes: 2172
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
typedef long long int tint;

int preguntar(int a){
  cout << a << "\n";
  fflush(stdout);
  string res;
  cin >> res;
  if(res == "Male"){
    return -1;
  } else if(res == "Female"){
    return 1;
  } else {
    return 0;
  }
}

void swap(int &a, int &b){
  int temp = a;
  a = b;
  b = temp;
}

bool hayVacio(int a, int b, int rA, int rB){
  return !((a%2 == b%2) == (rA == rB));
}

int main(){
  int N;
  cin >> N;
  int ini = 0;
  int fin = N/2;
  
  int rtaIni = preguntar(ini);
  if(rtaIni == 0){
    return 0;
  }
  int rtaFin = preguntar(fin);
  if(rtaFin == 0){
    return 0;
  }
  if(!hayVacio(ini, fin, rtaIni, rtaFin)){
    ini = N;
    swap(ini, fin);
    swap(rtaIni, rtaFin);
  }
  
  while(fin - ini > 1){
    int prom = (ini + fin) / 2;
    int rta = preguntar(prom);
    if(rta == 0){
      return 0;
    } else {
      if(hayVacio(ini, prom, rtaIni, rta)){
        fin = prom;
        rtaFin = rta;
      } else {
        ini = prom;
        rtaIni = rta;
      }
    }
  }
}



Measured memory_bytes: 852
// B - Kleene Inversion
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	vector<ll> A(N);
	ll L = 0, M = 0;
	for(int i=0; i<N; i++){
		cin>>A[i];
		for(int j=i-1; j>=0; j--) if(A[i]<A[j]) L++;
	}

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) if(i!=j && A[i]>A[j]) M++;

	ll K2 = K%2? (K-1)/2: K/2;
	K2 = K%2? K2 * K % MOD: K2 * (K-1) % MOD;

	ll a = L*K % MOD;
	ll b = M*K2%MOD;
	cout<< (a+b) % MOD << endl;
}

Measured memory_bytes: 256
//2018.9.21 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e6+10;
namespace MAIN{
    int a[N],n,k;
    namespace Segtree{
        int mn[N<<2];
        inline void pushup(const res &rt){
            mn[rt]=_min(mn[rt<<1],mn[rt<<1|1]);
        }
        void build(const res &rt,const res &l,const res &r){
            mn[rt]=inf;
            if(l==r)return;
            res mid=(l+r)>>1;
            build(rt<<1,l,mid),build(rt<<1|1,mid+1,r);
        }
        void update(const res &rt,const res &l,const res &r,const res &p,const res &va){
            if(l==r){mn[rt]=va;return;}
            res mid=(l+r)>>1;
            if(p<=mid)update(rt<<1,l,mid,p,va);
            else update(rt<<1|1,mid+1,r,p,va);
            pushup(rt);
        }
        int query(const res &rt,const res &l,const res &r,const res &L,const res &R){
            if(L>R)return 0;
            if(L<=l&&r<=R)return mn[rt];
            res mid=(l+r)>>1,ans=inf;
            if(L<=mid)ans=_min(ans,query(rt<<1,l,mid,L,R));
            if(R>mid)ans=_min(ans,query(rt<<1|1,mid+1,r,L,R));
            return ans;
        }
    }
    struct E{
        int next,to;
        E() {}
        E(res next,res to):next(next),to(to) {}
    }edge[N];
    int head[N],cnt,du[N];
    inline void addedge(const res &u,const res &v){
        edge[++cnt]=E(head[u],v),head[u]=cnt,du[v]++;
    }
    int x;
    priority_queue<int,vector<int>,greater<int> >Q;
    int id[N],idx;
    inline void topsort(){
        for(res i=1;i<=n;i++)if(!du[i])Q.push(i);
        while(!Q.empty()){
            res u=Q.top();
            Q.pop();
            id[u]=++idx;
            for(res i=head[u];~i;i=edge[i].next){
                res tox=edge[i].to;
                if(--du[tox]==0)Q.push(tox);
            }
        }
    }
    inline void MAIN(){
        memset(head,-1,sizeof(head));
        n=read(),k=read();
        for(res i=1;i<=n;i++)a[read()]=i;
        Segtree::build(1,1,n);
        for(res i=n;i;i--){
            x=Segtree::query(1,1,n,a[i]+1,_min(a[i]+k-1,n));
            if(x>=1&&x<=n)addedge(a[i],a[x]);
            x=Segtree::query(1,1,n,_max(1,a[i]-k+1),a[i]-1);
            if(x>=1&&x<=n)addedge(a[i],a[x]);
            Segtree::update(1,1,n,a[i],i);
        }
        topsort();
        for(res i=1;i<=n;i++)printf("%d\n",id[i]);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 32632
#include <stdio.h>
int main(void){

  int	N, A, B;
  int	train;
  int	taxi;
  
  scanf("%d %d %d", &N, &A, &B);
  
  train = N*A;
  taxi  = B;
  
  if( train < taxi ){ printf("%d",train); }
  else if( train > taxi ){ printf("%d",taxi); }
  else{ printf("%d",train); }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<unordered_map>
using namespace std;

#define mod 1000000007

int n, k, ans;

int qpow(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1)res = (long long)res * a % mod;
		a = (long long)a * a % mod;
		b >>= 1;
	}
	return res;
}

int main()
{
	scanf("%d%d", &n, &k);
	set<int> v;
	unordered_map<int, int> s;
	for (int i = 1; i * i <= n; ++i)
		if (n % i == 0)
		{
			v.insert(i);
			if (i * i != n)v.insert(n / i);
		}
	for (auto x : v)
	{
		int res = qpow(k, (x + 1) / 2);
		for (int i = 1; i * i <= x; ++i)
			if (x % i == 0)
			{
				res -= s[i];
				if (res < 0)res += mod;
				if (i * i != x)
				{
					res -= s[x / i];
					if (res < 0)res += mod;
				}
			}
		s[x] = res;
		ans += (long long)res * (x % 2 ? x : x / 2) % mod;
		if (ans >= mod)ans -= mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

struct LazySegtree {
private:
	int size_;
	string type;
	P dat[1000000];
	void init_RUQ() {
		int x = size_; size_ = 1;
		while (x > size_)size_ *= 2;
		rep(i, size_ * 2 - 1) {
			dat[i] = { ((int)1 << 31) - 1,inf };
		}
	}
	void eval_RUQ(int k, int l, int r) {
		if (dat[k].second != inf) {
			dat[k].first = dat[k].second;
			if (r - l > 1) {
				dat[2 * k + 1].second = dat[k].second;
				dat[2 * k + 2].second = dat[k].second;
			}
			dat[k].second = inf;
		}
	}
	void update_RUQ(int a, int b, int x, int k, int l, int r) {
		eval_RUQ(k, l, r);
		if (b <= l || r <= a)return;
		if (a <= l && r <= b) {
			dat[k].second = x;
			eval_RUQ(k, l, r);
		}
		else {
			update_RUQ(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update_RUQ(a, b, x, 2 * k + 2, (l + r) / 2, r);
		}
	}
public:
	LazySegtree(int x, string s) {
		size_ = x; type = s;
		if (type == "RUQ")init_RUQ();
	}
	void update(int l, int r, int x) {
		if (type == "RUQ")update_RUQ(l, r, x, 0, 0, size_);
	}
	int query_RUQ(int a, int k, int l, int r) {
		eval_RUQ(k, l, r);
		if (r - l == 1) {
			return dat[k].first;
		}
		if (a < (l + r) / 2)return query_RUQ(a, k * 2 + 1, l, (l + r) / 2);
		else return query_RUQ(a, k * 2 + 2, (l + r) / 2, r);
	}
	int query(int x) {
		return query_RUQ(x, 0, 0, size_);
	}
};
signed main() {
	int n, q;
	cin >> n >> q;
	LazySegtree segtree(n, "RUQ");
	rep(i, q) {
		int a; cin >> a;
		if (!a) {
			int s, t, x; cin >> s >> t >> x;
			segtree.update(s, t + 1, x);
		}
		else {
			int x; cin >> x;
			cout << segtree.query(x) << endl;
		}
	}
}


Measured memory_bytes: 18852
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int n;
int masu[9][9];
bool wrong[9][9];

int main()
{
	cin >> n;

	while (n--)
	{
		memset(wrong, 0, sizeof(wrong));

		rep(i, 9) rep(j, 9)	cin >> masu[i][j];
	
		//横
		rep(i, 9) rep(j, 9) rep(k, 9)
		{
			if (masu[i][j] == masu[i][k] && j != k) wrong[i][j] = wrong[i][k] = true;
		}

		//縦
		rep(i, 9) rep(j, 9) rep(k, 9)
		{
			if (masu[j][i] == masu[k][i] && j != k) wrong[j][i] = wrong[k][i] = true;
		}

		//ブロック
		for (int i=0; i<9; i+=3)
		{
			for (int j=0; j<9; j+=3)
			{
				for (int k=i; k<i+3; k++)
				{
					for (int l=j; l<j+3; l++)
					{
						for (int m=i; m<i+3; m++)
						{
							for (int n=j; n<j+3; n++)
							{
								if (masu[k][l] == masu[m][n] && k != m && l != n)
								{
									wrong[k][l] = wrong[m][n] = true;
								}
							}
						}
					}
				}
			}
		}

		rep(i, 9)
		{
			rep(j, 9)
			{
				if (wrong[i][j]) cout << "*";
				else cout << " ";
				cout << masu[i][j];
			}
			cout << endl;
		}

		if (n != 0) cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#素因数分解をする
from fractions import gcd
import numpy as np
a,b = [int(i) for i in input().split()]
g = gcd(a,b)

primes = []
n=1

#約数に関して、常に、これが言える。
while n**2 <=g:
    n += 1
    q,r = divmod(g,n)
    if r!=0:
        continue
    while r==0:
        g = q
        q,r = divmod(g,n)
    primes.append(n)

#最後に素数が余るケース    
if g != 1:
    primes.append(g)
    
print(len(primes)+1)



Measured memory_bytes: 13548
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                int h,w;
                scanf("%d %d",&h,&w);
                if(!h) break;
                for(int i=0;i<w;i++){
                    printf("#");
                }
                printf("\n");
                for(int i=0;i<h-2;i++){
                        printf("#");
                        for(int j=0;j<w-2;j++){
                                printf(".");
                        }
                        printf("#");
                        printf("\n");
                }
                for(int i=0;i<w;i++){
                    printf("#");
                }
            printf("\n");
            printf("\n");

        }
        return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int a[210],b[210],la,lb,i=100;
int main()
{
    long long n;
    scanf("%lld",&n);
    n++;
    while(n>1)
    {
        if(n&1)n--,a[++la]=i--;
        else n>>=1,b[++lb]=i--;
    }
    printf("%d\n",(la+lb)*2);
    for(int j=1;j<=la;j++)
        printf("%d ",a[j]-i);
    for(int j=lb;j>=1;j--)
        printf("%d ",b[j]-i);
    for(int j=100-la-lb+1;j<100;j++)
        printf("%d ",j-i);
    printf("%d\n",100-i);
    return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(int(a) / int(b)))
    elif op == "?":
        break


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ll long long
#define N 200005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll c[N];
ll ans;
main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        c[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        ans+=(c[i]*(c[i]-1))/2;
    }
    for(int i=0;i<n;i++)
    {
        ll temp=ans;
        ll p=(c[a[i]]*(c[a[i]]-1))/2;
        c[a[i]]--;
        ll q=(c[a[i]]*(c[a[i]]-1))/2;
        c[a[i]]++;
        cout<<ans+q-p<<'\n';
    }
}


Measured memory_bytes: 3968
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
using namespace std;

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

	if (s.length() <= k)
		cout << s;
	else
	{
		for (int i = 0; i < k; i++)
			cout << s[i];
		cout << "...";
	}
}

Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int i,max=0,c=0;
  for(i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') c++;
    else c=0;

    if(c>max) max=c;
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364;
const int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};

int main(){
    int w,h;
    while(cin>>w>>h&&w){
        int c[h][w]; rep(i,h)rep(j,w) cin>>c[i][j];
        int cnt=1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(c[i][j]==1){
                    cnt++;
                    queue<pair<int,int>> q;
                    c[i][j]=cnt;
                    q.push({i,j});
                    while(q.size()){
                        pair<int,int> p=q.front(); q.pop();
                        int cy=p.first,cx=p.second;
                        rep(k,8){
                            int ny=cy+dy[k],nx=cx+dx[k];
                            if(0<=ny&&ny<h&&0<=nx&&nx<w&&c[ny][nx]==1){
                                c[ny][nx]=cnt;
                                q.push({ny,nx});
                            }
                        }
                    }
                }
            }
        }
        cout<<cnt-1<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
long long h;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> h;
	int lg2 = 0;
	while((1ll << lg2) <= h) lg2++;
	if((1ll << lg2) == h) cout << (1ll << (lg2 + 1)) - 1;
	else cout << (1ll << lg2) - 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int a,b; cin >> a >> b;
    string ans;
    if(a == 0 || b == 0) ans = "Zero";
    if(a<0&& b>0) ans = "Zero";
    if(a>0&& b<0) ans = "Zero";
    if(a>0&& b>0) ans = "Positive";
    if(a<0&& b<0){
        if((b-a)%2 == 0) ans = "Negative";
        else ans = "Positive";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    string l; cin>>l;
    int n=l.size();
    ll dp[2][100010]={};
    dp[1][0]=1;
    dp[0][0]=2;
    for(int i=1; i<n; i++){
        dp[1][i]+=3*dp[1][i-1];
        if(l[i]=='0'){
            dp[0][i]+=dp[0][i-1];
        }else{
            dp[0][i]+=2*dp[0][i-1];
            dp[1][i]+=dp[0][i-1];
        }
        dp[0][i]%=MOD;
        dp[1][i]%=MOD;
    }
    cout<<(dp[1][n-1]+dp[0][n-1])%MOD<<endl;
    return 0;
}

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

int main()
{
    string arr;
    cin>>arr;
    reverse(arr.begin(),arr.end());
    int n=arr.size()-1;
    long long sum=0;
    for(int i=0;i<pow(2,n);i++)
    {
        vector<int>v;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))v.push_back(j);
        }
       long long flag=0;
       int index =0;
       for(int u=0;u<v.size();u++)
       {
           int k = v[u];
           long long num=0,r=1;
           for(int p=index;p<=k;p++)
           {
               num+=((char)(arr[p]-'0'))*r;
               r*=10;
           }
           flag+=num;
           index=k+1;
       }
       long long num=0,r=1;
           for(int p=index;p<arr.size();p++)
           {
               num+=((char)(arr[p]-'0'))*r;
               r*=10;
           }
           flag+=num;
           sum+=flag;
           //cout<<flag<<" "<<sum<<endl;
    }
    cout<<sum<<endl;
}


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

void Calc( string &str, int sum, int trans, int &move_up )
{
    if( sum > 9 )
    {
        str += sum - 10 + trans;                       // Integer to String
        move_up = 1;
    }
    else
    {
        str += sum + trans;                            // Integer to String
        move_up = 0;
    }
}

int main()
{
    int n, trans = 48;                                 //48は文字としての0を整数に変換したときの値。ex) '6' - 48 = 6
    int move_up = 0;
    string str1, str2, strr = "";

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> str1 >> str2;

        int s1 = str1.size(), s2 = str2.size();                     // while分を回す回数を決定
        int j = s1 - 1, k = s2 - 1, sum = 0;                        // sumは位ごとの合計値
        while( j >= 0 && k >= 0 )                                   // 最後の桁まで繰り上がり等計算
        {
            sum = str1[j] + str2[k] - 2 * trans + move_up;          // String to Integer
            Calc( strr, sum, trans, move_up );                      // 繰り上がりの計算
            j--;
            k--;
        }
        while( j >= 0 )                                             // 余った桁を順次格納(繰り上がり情報は保持)
        {
            sum = str1[j] - trans + move_up;
            Calc( strr, sum, trans, move_up );
            j--;
        }
        while( k >= 0 )
        {
            sum = str2[k] - trans + move_up;
            Calc( strr, sum, trans, move_up );
            k--;
        }
        if( move_up == 1 )                                          // 最後の桁での繰り上がり処理
            strr += 1 + trans;

        int sr = strr.size();
        if( sr <= 80 )
        {
            for( int i = sr - 1; i >= 0; i-- )                      // 100という文字列strは、str[0] = 1, str[1] = 0, str[2] = 0という順番で格納される。　
                cout << strr[i];
            cout << endl;
        }
        else
            cout << "overflow" << endl;

        strr = "";                                                  // strrの値をクリア
        move_up = 0;
    }
    return 0;
}


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

struct node {
  int key;
  struct node *parent, *left, *right;
};

struct node *tree, *z;

void insert(struct node *T, struct node *z);
void find(int key);
void inorder(struct node *p);
void preorder(struct node *p);

int main(int argc, char*argv[])
{
  int m, i, key;
  char cmd[6 + 1];

  tree = NULL;

  scanf("%d", &m);

  for (i = 0; i < m; i++) {
    scanf("%s", cmd);

    if (!strcmp(cmd, "insert")) {
      z = (struct node *)malloc(sizeof(struct node));
      scanf("%d", &(z->key));
      z->parent = NULL;
      z->left = NULL;
      z->right = NULL;
      insert(tree, z);
    } else if (!strcmp(cmd, "print")) {
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    } else if (!strcmp(cmd, "find")) {
      scanf("%d", &key);
      find(key);
    }
  }

  return 0;
}

void insert(struct node *T, struct node *z)
{
  struct node *x, *y;

  y = NULL;
  x = tree;
  while (x != NULL) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if (y == NULL) tree = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void find(int key)
{
  struct node *x = tree;

  if (x == NULL) {
    printf("no\n");
    return;
  }
  
  while (x != NULL) {
    if (x->key == key) {
      printf("yes\n");
      return;
    } else if (x->key < key) x = x->right;
    else x = x->left;
  }
  printf("no\n");
}

void inorder(struct node *p)
{
  if (p->left != NULL) inorder(p->left);
  printf(" %d", p->key);
  if (p->right != NULL) inorder(p->right);
}

void preorder(struct node *p)
{
  printf(" %d", p->key);
  if (p->left != NULL) preorder(p->left);
  if (p->right != NULL) preorder(p->right);
}

Measured memory_bytes: 19364
import math
import fractions
import sys
import itertools
import numpy as np
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


S=str(input())
date=["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(len(date)):
	if date[i]==S:
		print(7-i)













Measured memory_bytes: 13548
// V - Subtree
// https://atcoder.jp/contests/dp/tasks/dp_v
// https://www.youtube.com/watch?v=r9hbdyVkz-I
#include <bits/stdc++.h>
using namespace std;

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll n;
    cin>>n;
    n--;
    string s;
    do{
        s+=char(n%26+'a');
        n/=26;
        n--;
//        cout<< n;
    }while(n>=0);
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <queue>

using namespace std;

struct point{
    int x,y,dis;
}tmp_p,now_p;
int x[4]={1,-1,0,0},y[4]={0,0,1,-1};
queue< point > q;

int main()
{
    int h,w;scanf("%d%d",&h,&w);
    bool flag[h+2][w+2];
    for (int i=0;i<h+2;++i)
    for (int j=0;j<w+2;++j)
        flag[i][j]=0;
    for (int i=1;i<=h;++i)
    for (int j=1;j<=w;++j){
        char ch=getchar();
        while (ch!='.' &&ch!='#') ch=getchar();
        if (ch=='.') flag[i][j]=1;
    }
    int ans=0;
    for (int i=0;i<=h;++i)
    for (int j=0;j<=w;++j)
    if (flag[i][j]){
        bool flag2[h+2][w+2];
        for (int ii=1;ii<=h;++ii)
        for (int jj=1;jj<=w;++jj)
            flag2[ii][jj]=1;
        while (!q.empty()) q.pop();
        tmp_p.x=i;tmp_p.y=j;tmp_p.dis=0;
        flag2[i][j]=0;
        q.push( tmp_p );
        while (!q.empty()){
            now_p= q.front();q.pop();
            if (now_p.dis>ans) ans=now_p.dis;
            for (int dir=0;dir<4;++dir){
                tmp_p=now_p;
                tmp_p.x+=x[dir];tmp_p.y+=y[dir];tmp_p.dis+=1;
                if (flag[tmp_p.x][tmp_p.y] && flag2[tmp_p.x][tmp_p.y]){
                    flag2[tmp_p.x][tmp_p.y]=0;q.push(tmp_p);
                }
            }
        }
    }
    printf("%d\n",ans);


}


Measured memory_bytes: 256