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

int main()
{
  int64_t n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  std::vector<int64_t> vec;
  int cnt=1;
  for (int i = 1; i < n; ++i)
  {
    if(s[i-1]!=s[i]){
      vec.emplace_back(cnt);
      cnt=1;
    }
    else cnt++;
  }
  vec.emplace_back(cnt);
  if(s[0]=='0'&&vec.size()<=k*2) {
    cout<<n;
    return 0;
  }
  if(s[0]=='1'&&vec.size()<=2*k+1){
    cout<<n;
    return 0;
  }
  if(s[0]=='0') vec.insert(vec.begin(),0);
  if(s[1]=='0') vec.insert(vec.end(),0);
  std::vector<int64_t> ans;
  int64_t tmp=vec[0];
  int j=1;
  for (int i = 0; i <k ; ++i)
  {
    tmp+=vec[j]+vec[j+1];
    j+=2;
  }
  ans.emplace_back(tmp);
  for (int i = 0; i <=vec.size()-2*k-1 ; i+=2)
  {
    tmp+=vec[j]+vec[j+1];
    tmp-=(vec[i]+vec[i+1]);
    ans.emplace_back(tmp);
    j+=2;
  }
  cout<<*max_element(ans.begin(), ans.end());
  
}

Measured memory_bytes: 2036
#include "bits/stdc++.h"

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

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 == 0) {
		string str1 = S.substr(0, N / 2);
		string str2 = S.substr(N / 2);
		//cout << str1 << " " << str2 << endl;
		if (str1 == str2)cout << "Yes";
		else cout << "No";
	}
	else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}


Measured memory_bytes: 3780
import math
import sys
input = sys.stdin.readline
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)

        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i

    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num

    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret

sofe = Sieve_of_Eratosthenes(M)

judge = set([])

for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 132720
#include <stdio.h>
int main(){
   int n;
   scanf("%d",&n);
   int h[n];
   for(int a=0;a<n;a++){
       scanf("%d",&h[a]);
   }
   int max;
   for(int b=0;b<n-1;b++){
       if(h[b]<h[b+1]){max=h[b+1];h[b+1]--;}
       else if(h[b]==h[b+1]){}
       else{printf("No\n");return 0;}
   }
   printf("Yes\n");
   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int arr[N], temp[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> vec;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    vector<int> res;
    for (int i = n; i > 0; i--) {
        int tot = 0;
        for (int j = 2; j * i <= n; j++) {
            tot += temp[i * j];
        }
        if (tot % 2 != arr[i]) temp[i]++, res.push_back(i);
    }
    cout << res.size() << '\n';
    for (auto x: res) cout << x << ' ';
    return 0;
}

Measured memory_bytes: 5240
N = int(input())
P = [int(_) for _ in input().split()]
P_true = [int(i) for i in range(1,N+1)]

n = 0
for j in range(N):
    if(P[j] != P_true[j]):
        n += 1
    if n > 2:
        print('NO')
        break
else:
    print('YES')
    

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
cout<<dp[n-1]<<endl;


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	vector<int>a(h*w);
	vector<int>q;
	vector<int>next_q;
	char tmp;
	for(int i=0;i<h*w;i++){
		cin>>tmp;
		if(tmp=='#'){
			a[i]=0;
			q.push_back(i);
		}else{
			a[i]=1;
		}
	}
	int n,i,j,cnt=0;
	while(!q.empty()){
		while(!q.empty()){
			//for(int k=0;k<q.size();k++) cout<<q[k]<<" ";cout<<endl;
			n=q[q.size()-1];
			q.pop_back();
			i=n/w;
			j=n%w;
			if(i!=0&&a[n-w]==1){
				a[n-w]=0;
				next_q.push_back(n-w);
			}
			if(i!=h-1&&a[n+w]==1){
				a[n+w]=0;
				next_q.push_back(n+w);
			}
			if(j!=0&&a[n-1]==1){
				a[n-1]=0;
				next_q.push_back(n-1);
			}
			if(j!=w-1&&a[n+1]==1){
				a[n+1]=0;
				next_q.push_back(n+1);
			}
		}
	q=next_q;
	next_q.clear();
	cnt++;
	}
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 9196
"""

入れる場所とそこから波及する場所の最大距離が魔法使用回数

魔法使用回数を決め打ちしてdp？

魔法をp回使うとすると、左p箇所のうち最小の場所から入れるのが最適になる
heapを使うか～

2000 * 2000 * log(2000)
間に合うかなぁ～

4*10**7かぁ

各項からn個左を見た時のaの最小値を求めておく!!!
"""

lis = []

N,x = map(int,input().split())

a = list(map(int,input().split()))

ans = [x * i for i in range(N)]

for i in range(N):

    nmin = float("inf")
    cnt = 0

    for j in range(i,i-N,-1):

        nmin = min(nmin,a[j])
        ans[cnt] += nmin

        cnt += 1

print (min(ans))

#heapq解(TLE)

"""
import heapq

N,x = map(int,input().split())

a = list(map(int,input().split()))

ans = float("inf")

maxi = 0

for p in range(N):

    now = x * p

    q = []

    for i in range(-1*p , 0):
        heapq.heappush(q,[a[i] , i])

    for i in range(N):

        heapq.heappush(q , [a[i] , i])

        while q[0][1] < i - p:
            heapq.heappop(q)

        now += q[0][0]
        maxi = max(maxi , i - q[0][1]) 

    ans = min(ans , now)

print (ans)
"""

Measured memory_bytes: 42732
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
        Set<Integer> set = new TreeSet<Integer>();
      
        for(int i = a; i < a + k; i++) {
          if (i <= b) {
            set.add(i);
          }
        }
        for(int i = b - k + 1; i <= b; i++) {
          if (i >= a) {
            set.add(i);
          }
        }
        
        for(Integer value : set) {
          // 出力
		  System.out.println(value);
        }

	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,m;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i,m){
    string s;
    cin >> s;
    mp[s]--;
  }
  int ans=0;
  for(auto p: mp){
    ans=max(max(0,ans),mp[p.first]);
  }
  cout << ans;
}
  
    

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,a,b;
int f[N][N],lima[N],limb[N];
void pan(int ans1,int ans2){
		memset(f,0,sizeof(f));
		for (int i=1;i<=ans1;i++) lima[i]=min(a,m-a);
		for (int i=ans1+1;i<=n;i++) lima[i]=max(a,m-a);
		for (int i=1;i<=ans2;i++) limb[i]=min(b,n-b);
		for (int i=ans2+1;i<=m;i++) limb[i]=max(b,n-b);
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=m;j++)
			 if (lima[i]&&limb[j]) {
			 	lima[i]--; limb[j]--;
			 	f[i][j]=1;
			 } 
		}
		for (int i=1;i<=n;i++) if (lima[i]) return;
		for (int i=1;i<=m;i++) if (limb[i]) return;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++) printf("%d",f[i][j]);
			if (i!=n) printf("\n");
		}
		exit(0);
}
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	int ans1=-1,ans2=-1;
	for (int i=0;i<=n;i++) 
	 for (int j=0;j<=m;j++){
	  if ((i*a+(n-i)*(m-a))==(j*b+(m-j)*(n-b))) {
	  	pan(i,j);
	  }
	  }
	  puts("-1");
}

Measured memory_bytes: 5248
m=(""+require("fs").readFileSync(0)).split`
`;n=m[a=0];s=m[1];for(b=1<<n;b--;m[u]=-~m[u])for(u=i=n;i--;)u=b&(1<<i)?s[i]+u:u+s[i];for(b=1<<n;b--;a+=~~m[u])for(u=i=n;i--;)u=b&(1<<i)?s[2*n+~i]+u:u+s[2*n+~i];console.log(a)

Measured memory_bytes: 67016
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

c=[0]
d=[0]

for i in range(n):
  c.append(c[-1]+a[i])
  
for j in range(m):
  d.append(d[-1]+b[j])

ans=0
for x in range(n+1):
  l=c[x]
  B=0
  if l<=k:
    h=k-l
    mi=0
    ma=m+1
    while ma-mi>1:
      mid=(mi+ma)//2
      if d[mid]<=h:
        mi=mid
      elif d[mid]>h:
        ma=mid
    B=mi
    
    ans=max(ans,x+B)
        
  
    
print(ans)


Measured memory_bytes: 48700
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))

cur = 0     # 現在地
period = 0  # 繰り返し周期
rest = 0    # 繰り返し周期に入らない最初のテレポート回数
counter = defaultdict(int)   # 2回目を通るときの検出用
first_index = defaultdict(int)  # 1回目に通ったテレポート回数

counter[0] = 1
first_index[0] = 0
for i in range(1, N):
    cur = A[cur] - 1
    counter[cur] += 1
    if counter[cur] == 2:
        period = i - first_index[cur]
        rest = first_index[cur]
        break
    else:
        first_index[cur] = i
if K <= rest:
    cur = 0
    for i in range(K):
        cur = A[cur] - 1
    print(cur+1)
else:
    for i in range((K - rest) % period):
        cur = A[cur] - 1
    print(cur+1)

Measured memory_bytes: 55448
#include<stdio.h>
#include<stdlib.h>

struct Tr{
  int id;
  char value[2];
};

int main(){

  int N,i,j,minj,M=1;
  struct Tr *C, *C2,K;

  scanf("%d",&N);

  C = (struct Tr *)malloc(sizeof(struct Tr) * N);
  C2 = (struct Tr *)malloc(sizeof(struct Tr) * N);

  for(i=0; i<=N-1; i++){
    scanf("%s",&C[i].value);
    C[i].id = i;
    C2[i] = C[i];
  }
  //BubbleSort(C2, N)
  for(i=0; i<=N-1; i++){
    for(j=N-1; j>=i+1; j--){
      if(C2[j].value[1] < C2[j-1].value[1]){
        K = C2[j];
        C2[j] = C2[j-1];
        C2[j-1] = K;
      }
    }
  }


  //SelectionSort(C, N)

  for(i=0; i<=N-1; i++){
    minj = i;
    for(j=i; j<=N-1; j++){
      if (C[j].value[1] < C[minj].value[1])
        minj = j;
    }
    K = C[i];
    C[i] = C[minj];
    C[minj] = K;
  }

  printf("%s",C2[0].value);
  for(i=1; i<=N-1; i++){
    printf(" %s",C2[i].value);
  }
  for(i=1; i<=N-1; i++){
    if(C2[i].value[1] == C2[i-1].value[1]){
      if(C2[i].id < C2[i-1].id){
        M = 0;
        break;
      }
      else M = 1;
    }
  }
  if(M == 1) printf("\nStable\n");
  else if(M == 0) printf("\nNot stable\n");

  printf("%s",C[0].value);
  for(i=1; i<=N-1; i++){
    printf(" %s",C[i].value);
  }
  for(i=1; i<=N-1; i++){
    if(C[i].value[1] == C[i-1].value[1]){
      if(C[i].id < C[i-1].id){
        M = 0;
        break;
      }
      else M = 1;
    }
  }  
  if(M == 1) printf("\nStable\n");
  else if(M == 0) printf("\nNot stable\n");
  return 0;
}


Measured memory_bytes: 2140
import heapq
n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)
while len(v) > 1:
  num1 = heapq.heappop(v)
  num2 = heapq.heappop(v)
  heapq.heappush(v, (num1 + num2) / 2)
print(v[0])

Measured memory_bytes: 3060
//abc174_b.cpp
//Sat Sep 12 10:34:52 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	ll x[n],y[n];
	ll ans = 0;
	rep(i,n){
		cin >> x[i] >> y[i];
		if (sqrt(x[i]*x[i]+y[i]*y[i])<=d){
			ans++;
		}
	} 

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
  int N;
  cin >> N;
  int A;
  A=0;
  
  for (int i=100000000; 1<=i; i /=10) {
    A += N/i%10;
  }
  
  if (N%A == 0) {
    cout << "Yes" ;
  }
  else {
    cout << "No" ;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N;
map<ll, int> mp;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    ll n = N;
    for(ll i = 2; i*i <= N; i++){
        while(n%i == 0){
            if(mp.count(i) == 0){
                mp[i] = 1;
            }else{
                mp[i]++;
            }
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    int ans = 0;
    for(auto i : mp){
        int c = i.second;
        for(int i = 1; ; i++){
            if((i*(i+1))/2 > c){
                ans += i-1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

ll s(ll a,ll b){
  if(a>b) return s(b,a);
  if(a<1) return -b;
  return s(b-a*(b/a),a)+2*a*(b/a);
}

int main(){
  ll n,x;
  cin>>n>>x;
  cout<<s(x,n-x)+n<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

submission = []
for i in range(n):
    submission.append([])

for i in range(m):
    pi, si = input().split()
    submission[int(pi) - 1].append(si)
    
n_ac = 0
n_penalty = 0
for i in range(n):
    if "AC" in submission[i]:
        n_ac += 1
        ac_index = submission[i].index('AC')
        n_penalty += ac_index
print(n_ac, n_penalty)

Measured memory_bytes: 20272
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s, t; cin >> s >> t;

	int c = 0;
	FOR_LT(i, 0, 3) {
		if (s[i] == t[i]) c++;
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll mod=1000000007;
ll add(ll a,ll b){
    return (a+b)%mod;
}
ll mul(ll a, ll b){
    return (a*b)%mod;
}
struct node
{
    ll x,y;    
};
int main() {

    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
        ll a,b;cin>>a>>b;
        ll c=a*b;
        ll h=__gcd(a,b);
        c=c/h;
        cout<<c;
    }
    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define IOS() ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
string s[1000000];
signed main()
{
	//cout<<1e18<<"\n";
	int t;
	while(cin>>t)
	{
		int k,n=1;
		int p=pow(10,18);
		int d=1;
		//cout<<p<<"p\n";
		//priority_queue<int> pq;
		bool f=0;
	//	string s;
		int len=18;
		for(int i=0;i<t;i++)
		{
			cin>>s[i];
			if(s[i][0]=='0')
			{
				cin.ignore(1000000000,'\n');
				n=0;
				break;
			}
			len-=(s[i].length()-1);
			d*=(s[i][0]-'0');
		}
		if(!n) cout<<0<<"\n";
		else if(len<0||(len==0&&d!=1))
		{
			cout<<-1<<"\n";
		}
		else
		{
			for(int i=0;i<t;i++)
			{
				if(n>p)
				{
					break;
				}
				stringstream ss(s[i]);
				int d;
				ss>>d;
				n*=d;
			}
			if(n>p) cout<<"-1\n";
			else cout<<n<<"\n";
		}
		//else cout<<n<<"\n";
		
	}
} 

Measured memory_bytes: 39532
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 400005;
const i64 MAXM = 20;


i64 n;
i64 a[MAXN];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s;
    cin >> s;
    map<i64, i64> q;
    for (auto c : s) {
        q[c] += 1;
    }
    if (q.size() == 1) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string a, b, c; cin >> a >> b >> c;
  cout << a.front() << b.front() << c.front() << '\n';
  
  return (0);
}

Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)




int main() {
	int n;
	cin >> n;
	switch (n % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 6:
	case 1:
	case 8:
		cout << "pon" << endl;
		break;
	default:
		cout << "bon" << endl;
		break;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, x;
    int i, j, k;
    int c;
    
    while(1){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0){
            break;
        }
        c = 0;
        for(i=1; i<=n-2; i++){
            for(j=i+1; j<=n-1; j++){
                for(k=j+1; k<=n; k++){
                    if(x == i+j+k){
                        c++;
//                        printf("%d + %d + %d = %d\n", i, j, k, i+j+k);
                    }
                }
            }
        }
        printf("%d\n", c);
    }
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    int count = 0;
    vector<int> k(M);
    vector<int> p(M);
    vector<vector<int>> s(11,vector<int> (11,0));
    for (int i = 0; i < M; i++){
        cin >> k.at(i);
        for (int j = 0; j < k.at(i); j++){
            cin >> s.at(i).at(j);
        }
    }
    for (int i = 0; i < M; i++){
        cin >> p.at(i);
    }
    
    vector<int> temp(M);
    int check;
    vector<int> reallamp(N);
    int lamptemp;
    int maxlamp = 1;
    for (int i = 0; i < N; i++) maxlamp = maxlamp*2;
    for (int lamp = 0; lamp < maxlamp; lamp++){
        //初期化
        check = 0;
        for (int i = 0; i < M; i++){
            temp.at(i) = p.at(i);
        }
        lamptemp = lamp;
        
        //今のスイッチの状態
        for (int i = 0; i < N; i++){
            reallamp.at(i) = lamptemp % 2;
            lamptemp = lamptemp / 2;
        }
        
        for (int i = 0; i < M; i++){
            for (int j = 0; j < k.at(i); j++){
                temp.at(i) += reallamp.at( s.at(i).at(j) - 1 );
            }
        }
        
        for (int i = 0; i < M; i++){
            check += temp.at(i) % 2;
        }
        if (check == 0) {
            count++;
        }
    }
    
    printf("%d\n",count);

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long int cnt;

void digit(long int n, int k)
{
    long int a;

    if (n < k) {
        return;
    }

    a = n / k;
    cnt++;
    digit(a, k);
}

int main()
{
    int i, j;
    long int n;
    int k;

    cnt = 1;
    cin >> n >> k;
    digit(n, k);

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length() - 7;
		boolean pos = false;
		for (int i = 0; i <= 7; i++) {
			String ans = s.substring(0, i) + s.substring(i + len);
			if (ans.equals("keyence")) {
				pos = true;
				break;
			}
		}
		if (pos) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22996
n,k = map(int, input().split())

graph = [[] for i in range(n)]
if k > ((n-1)*(n-2))//2:
    print(-1)
else:
    for i in range(1,n):
        graph[0].append(i+1)
    
    remain = ((n-1)*(n-2))//2 - k
    for i in range(1,n):
        if remain <= 0:
            break
        for j in range(i+1,n):
            if remain > 0:
                graph[i].append(j+1)
                remain -= 1
            else:
                break

    print(((n-1)*(n-2))//2 - k + (n-1))
    for i in range(len(graph)):
        for j in range(len(graph[i])):
            print(i+1, graph[i][j])




Measured memory_bytes: 42992
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN(){T d;cin>>d;return d;}
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b){ return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b){ return a / gcd(a, b) * b; }

// ------------------- include, typedef, define END. -------------------

int main(){
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;
	
	//??????????????????????????????.
	int L=0;
	while(cin>>L,L){
		int ans = 0;
		LL nowChochiku = 0;
		FOR(i,0,12){
			int M=0,N=0;
			cin>>M>>N;
			nowChochiku += (M-N);

			if(ans == 0 && nowChochiku>=L){
				ans = i+1;
			}
		}
		// ans??????
		if(ans)	cout << ans << endl;
		else	cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>

using namespace std;
int A[100000], B[100000], NA, NB;

int binarysearch(int key)
{
	int left = 0, right = NA - 1;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (A[mid] == key)
			return 1;
		else if (A[mid] < key)
			left = mid + 1;
		else
			right = mid-1;
	}
	return 0;
}

int main()
{
	int sum = 0;
	cin >> NA;
	for (int i = 0; i < NA; i++)
	{
		cin >> A[i];
	}
	cin >> NB;
	for (int i = 0; i < NB; i++)
	{
		cin >> B[i];
		if (binarysearch( B[i]))
			sum++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3568
# -*- coding: utf-8 -*-
def get_num():
    return int(input())


def get_numbers():
    return map(int, input().split())


n = get_num()
h = list(get_numbers())

dp = [0 for _ in range(n)]

dp[0] = max(h[0] - 1, 0)
res = True
for i in range(1, n):
    dp[i] = max(dp[i - 1], h[i] - 1)
    if h[i] < dp[i] or h[i] > dp[i] + 1:
        res = False
        break

if res:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 64356
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define MAX_H 50
#define MAX_W 50

const int MAX_MATERIAL = 26; // A-Z

struct xy {
    int ax, bx, ay, by;
};

char box[MAX_H][MAX_W];

bool check_rect(const vector<xy>& rect) {
    REP(i, rect.size()) {
        auto r = rect[i];
        FOR(y, r.ay, r.by+1) FOR(x, r.ax, r.bx+1) {
            if (box[y][x] == '.') {
                return false;
            }
        }
    }
    return true;
}

bool update_top_rect(const xy& r, char c) {
    FOR(y, r.ay, r.by+1) FOR(x, r.ax, r.bx+1) {
        if (box[y][x] != c && box[y][x] != '#') {
            return false;
        }
    }
    FOR(y, r.ay, r.by+1) FOR(x, r.ax, r.bx+1) {
        box[y][x] = '#';
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    REP(i, n) {
        int h, w;
        cin >> h >> w;
        fill_n((char *)box, MAX_H*MAX_W, '.');

        vb seen(MAX_MATERIAL, false);
        vector<xy> rect(MAX_MATERIAL, {MAX_W, 0, MAX_H, 0});

        REP(y, h) REP (x, w) {
            cin >> box[y][x];
            // ????????¢?????????????±???????
            if (box[y][x] != '.') {
                int idx = box[y][x] - 'A';
                seen[idx] = true;
                rect[idx].ax = min(rect[idx].ax, x);
                rect[idx].bx = max(rect[idx].bx, x);
                rect[idx].ay = min(rect[idx].ay, y);
                rect[idx].by = max(rect[idx].by, y);
            }
        }

        // ????????¢???????????????'.'????????£??????????????????
        if (!check_rect(rect)) {
            cout << "SUSPICIOUS" << endl;
            continue;
        }

        bool updated;
        do {
            updated = false;
            REP(i, rect.size()) {
                auto r = rect[i];
                // '#'????????????????????????
                if (seen[i] && update_top_rect(r, i + 'A')) {
                    seen[i] = false;
                    updated = true;
                }
            }
        } while (updated);
        cout << (find(ALL(seen), true) != seen.end() ? "SUSPICIOUS" : "SAFE") << endl;
    }
}

Measured memory_bytes: 1188
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    ll n, a[5];
    ll m = LINF;
    cin >> n;
    rep(i, 0, 5)
    {
        cin >> a[i];
        m = min(m, a[i]);
    }
    ll ans = n / m + 4;
    if (n % m != 0)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(i*4+j*7==N){
        N=0;break;
      }
    }
    if(N==0)break;
  }
  if(N==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}     

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

map<ll, ll> mp;

void prime_factorize(ll n) {
    while (n % 2 == 0) mp[2]++, n /= 2;

    for (ll i = 3; i <= sqrt(n); i+=2) {
        while (n % i == 0) n /= i, mp[i]++;
    }
    if (n > 2) mp[n]++;
}

int main()
{
    ll N; cin >> N;
    for (ll i = 1; i <= N; i++) prime_factorize(i);

    ll o3 = 0, o5 = 0, o15 = 0, o25 = 0, o75 = 0;
    for (auto p : mp) {
        //cout << p.first << " " << p.second << endl;
        if (p.second + 1 >= 75) o75++;
        if (p.second + 1 >= 25) o25++;
        if (p.second + 1 >= 15) o15++;
        if (p.second + 1 >= 5) o5++;
        if (p.second + 1 >= 3) o3++; 
    }

    ll ans = 0;
    ans += o75;
    ans += o25 * (o3 - 1);
    ans += o15 * (o5 - 1);
    ans += (o5 * (o5 - 1) / 2 * (o3 - 2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
use proconio::input;
use proconio::marker::{Chars};

fn main() {
    input!(h: usize, w: usize, k: u32, c: [Chars; h]);

    let mut ans = 0;
    for mask_h in 0..1<<h {
        for mask_w in 0..1<<w {
            let mut count = 0;
            for i in 0..h {
                for j in 0..w {
                    if mask_h >> i & 1 == 0 && mask_w >> j & 1 == 0 && c[i][j] == '#' {
                        count = count + 1;
                    }
                }
            }
            if count == k {
                ans = ans + 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n){
        cin>>a[i];
    }
    int cnt=0;
    REP(i,n){
        if(a[i]==(cnt+1)) cnt++;
    }
    int ans=n-cnt;
    if(cnt==0) ans=-1;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = str(input())
acc_e = [0]
acc_w = [0]
for c in s:
  acc_e.append(acc_e[-1])
  acc_w.append(acc_w[-1])
  if c == 'E': acc_e[-1] += 1
  else: acc_w[-1] += 1
ans = n
for i in range(n):
  turn = acc_w[i] + acc_e[-1] - acc_e[i+1]
  ans = min(ans, turn)
print(ans)

Measured memory_bytes: 17644
# AOJ 0009 Prime Number
# Python3 2018.6.9 bal4u

MAX = 1000000
SQRT = 1000     # sqrt(MAX)

prime = [True for i in range(MAX)]
def sieve():
	for i in range(2, MAX, 2):
		prime[i] = False
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False

sieve()
cnt = [0 for i in range(MAX+1)]
cnt[2] = 1
f = 1
for i in range(3, MAX, 2):
	if prime[i] is True:
		f += 1;
	cnt[i] = f
	cnt[i+1] = f
	
while True:
    try:
        print(cnt[int(input())])
    except EOFError:
        break


Measured memory_bytes: 23568
using System;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var answer = string.Empty;

            foreach(var item in S)
            {
                if(item=='B')
                {
                    if (!answer.Any()) continue;
                    answer = answer.Remove(answer.Length - 1);
                    continue;
                }
                answer += item;
            }
            Console.WriteLine(answer);
        }
    }

Measured memory_bytes: 11220
#include <stdio.h>

int main()
{
	
	int a, b;
	scanf("%d%d", &a, &b);

	printf("%d %d %lf\n", a/b, a%b, (double)a/(double)b);

/*scanf("%d%d", &a, &b);
	printf("%d %d %lf\n", a/b, a%b, (double)a/b);*/
	
    return 0;
}




Measured memory_bytes: 2104
#include <vector>
#include <iostream>
#define ll long long
using namespace std;

struct UnionFind{
  vector< pair<int, ll int> > data;
  UnionFind(int n) : data(n, pair<int,ll int>(-1,0LL)) {}
  bool unite(int x, int y, ll int w){//weight(y)-weight(x) = w;
    int x_ = find(x), y_ = find(y);
    if(x_ == y_){
      
      return true;
    }
    if(data[y_].first < data[x_].first){
      swap(x_,y_);
      swap(x,y);
      w *= -1LL;
    }
    data[x_].first += data[y_].first;//高さを更新
    data[y_].first = x_;//親を更新
    data[y_].second += w + rel_weight(x) - rel_weight(y);
    return true;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x].first < 0) return x;
    int p = find(data[x].first);
    data[x].second += data[data[x].first].second;
    data[x].first = p;
    return data[x].first;
  }
  ll int rel_weight(int x){
    return data[x].second;
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  int l, r, d;
  for(int i = 0; i < M; ++i){
    cin >> l >> r >> d;
    --l;--r;
    if(uf.same(l,r)){
      if(d !=  uf.rel_weight(r) - uf.rel_weight(l)){
        cout << "No" << endl;
        return 0;
      }
    }else{
      uf.unite(l,r,d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<tuple<int,int,int>> vt;
    int res = 0;
    rep(i,n){
        vector<int> p(3,0);
        rep(i,3)cin >> p[i];
        sort(p.begin(),p.end());
        int q = p[0];
        int r = p[1];
        int s = p[2];
        tuple<int,int,int> t = make_tuple(q,r,s);
        if(find(vt.begin(),vt.end(),t) == vt.end())vt.push_back(t);
        else ++res;
    }
    cout << res << endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll k;cin>>k;
    ll ans=0;
    int a;
    FOR(i,1,k){
        FOR(j,1,k){
            FOR(s,1,k){
                a = __gcd(i,j);
                a = __gcd(a,s);
                ans+=a;
                // cout<<a<<endl;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
def merge(A, left, mid, right):
  global count
  L = A[left:mid] + [10**9 + 1]
  R = A[mid:right] + [10**9 + 1]
  
  i = 0
  j = 0

  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1
  count += right - left

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = (left + right) // 2
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

N = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, N)
print(*A)
print(count)
    

Measured memory_bytes: 63720
N,X,Y=map(int,input().split())
def shortest(x,y,a,b):
    ans=min(y-x,abs(y-b)+1+abs(a-x),abs(y-a)+1+abs(b-x))
    return ans
distance=[0]*N
for x in range(1,N+1):
    for y in range(1,N+1):
        if y<=x:
            continue
        else:
            a=shortest(x,y,X,Y)
            distance[a-1]+=1
for i in range(N-1):
    print(distance[i])

Measured memory_bytes: 3444
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll factor(ll x) {
	ll ret = 1;
	ll tmp = 0;
	for (ll p = 2;;p++) {
		if (x == 1) {
			ret *= tmp + 1;
			break;
		}
		if (x % p == 0) {
			tmp += 1;
			x /= p;
			p--;
			continue;
		}
		ret *= tmp + 1;
		tmp = 0;
	}
	return ret;
}

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

	ll N;
	cin >> N;
	ll ans = 0;

	for (ll i = 1; i <= N; i++) {
		ll ret = factor(i);
		ll tmp = ret;
		ans += i * tmp;
	}

	cout << ans << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}


*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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


	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3100
from operator import itemgetter

N = int(input())
S = []
P = []
idx = []
for i in range(N):
    s,p = input().split()
    p = int(p)
    S.append(s)
    P.append(p)
    idx.append(i)

A = zip(idx,S,P)
A = sorted(A, key=itemgetter(2),reverse=True)
A = sorted(A, key=itemgetter(1))

idx, S, P = zip(*A)

for i in range(N):
    print(idx[i]+1)

Measured memory_bytes: 3064
//Using vim
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;


void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int answer = 0;
	answer = min(k, a);
	if(k >= a)
		k -=a;
	if(k)
		k -= min(k, b);
	if(k)
		answer -= min(k, c);
	cout << answer << endl;
	
}


int main() {
	int cases = 1;
	//cin >> cases;
	while(cases--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;

    const unsigned long long MOD = 1000000007;
    unsigned long long val = 0;
    bool d;

    int i = 0;
    if( s1[i] != s2[i] )
    {
        d = true;
        val = 6;
        i += 2;
    }
    else
    {
        d = false;
        val = 3;
        i++;
    }

    while( i < N )
    {
        if( s1[i] != s2[i] )
        {
            val *= d? 3 : 2;
            d = true;
            i += 2;
        }
        else
        {
            val *= d? 1 : 2;
            d = false;
            i++;
        }
        val %= MOD;
    }

    cout << val << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  int N;
  int one7;
  int ten7;
  int hnd7;
  
  cin >> N;

    one7 = N % 10;
    ten7 = N % 100 - one7;
    hnd7 = N - ten7 - one7;

    if(one7 == 7){
        cout << "Yes";
    }
    else if(ten7 == 70){
        cout << "Yes";
    }
    else if(hnd7 == 700){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
      return 0;
}

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

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int ans = p + q;
    ans = min(ans, q+r);
    ans = min(ans ,r+p);
    cout << ans << endl;
    return 0;
}

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

static const int MAX_LENGTH = 1000;

void nreplace(char *input, int start, int end, char *target);
void nswap(char *input, int start, int end);
void nprint(char *input, int start, int end);

int main(void) {
    char *input = new char[MAX_LENGTH+1];
    char *target = new char[MAX_LENGTH+1];
    string command;
    int N, s, e;
    cin >> input;
    cin >> N;

    while(N-- > 0) {
        cin >> command >> s >> e;
        if(command == "replace") {
            cin >> target;
            nreplace(input, s, e, target);
        }
        if(command == "reverse") nswap(input, s, e);
        if(command == "print") nprint(input, s, e);
    }

    return 0;
}

void nreplace(char *input, int start, int end, char *target) {
    for(int i=start; i<=end; i++)
        input[i] = target[i-start];
}

void nswap(char *input, int start, int end) {
    char *st = input;
    char *ed = input;
    char tmp;

    for(int i=0; i<start; i++) st++;
    for(int i=0; i<end; i++) ed++;

    while(st < ed) {
        tmp = *st;
        *st++ = *ed;
        *ed-- = tmp;
    }
}

void nprint(char *input, int start, int end) {
    for(int i=start; i<=end; i++) cout << input[i];
    cout << endl;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

int n;
vector<int> v;

signed main(){
  cin>>n;
  rep(i,n+1){
    int a;
    cin>>a;
    v.push_back(a);
  }

  sort(all(v));

  int ans = v[1]-v[0];

  rep(i,n){
    ans = __gcd(ans,v[i+1]-v[i]);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1400
N = int(input())
S = input()
 
r = S.count('R')
g = S.count('G')
b = S.count('B')
 
counter = 0
for i in range(N):
    for j in range(i+1, N):
        k = 2 *j - i
        if k >= N:
            break
        elif S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            counter += 1
 
print(r * g * b - counter)

Measured memory_bytes: 9208
import java.util.*

fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val prev= Array(n){0}
    val hash = HashMap<Long , Int>()
    val c = Array(n){
        val ci =readLine()!!.toLong()
        prev[it]= hash[ci]?:-1
        hash[ci]=it
        ci
    }
    val result = Array<Long>(n){0}
    result[0]=1
    if(n>1)result[1]=1
    for (i in 2 until n){
        result[i]+=result[i-1]
        result[i] %=1000000007.toLong()
        if( prev[i]>=0&&prev[i]!=i-1){
            result[i]+=result[prev[i]]
        }
        result[i] %=1000000007.toLong()
    }
    print(result[n-1])
}

Measured memory_bytes: 85044
#include <iostream>
#include <vector>
#include <algorithm>

int N;

int main() {
  std::cin >> N;

  int nn = N - (N / 100) * 100;
  int n = nn - (nn / 10) * 10;

  switch (n) {
    case 0:
      std::cout << "pon";
      break;
    case 1:
      std::cout << "pon";
      break;
    case 6:
      std::cout << "pon";
      break;
    case 8:
      std::cout << "pon";
      break;
    case 3:
      std::cout << "bon";
      break;
    default:
      std::cout << "hon";
      break;
  }

  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 3636
n = int(input())
p = list(map(int,input().split()))
seconds = []
for a in range(0,n-2):
    num = [p[a],p[a+1],p[a+2]]
    if (num[0]<num[1]<num[2])or(num[2]<num[1]<num[0]):
        seconds.append(p[a+1])
    else : pass

print(len(set(seconds)))

Measured memory_bytes: 3064
s=input()
from collections import Counter
c=Counter(s)
a_cnt=c["a"]
b_cnt=c["b"]
c_cnt=c["c"]
if abs(a_cnt-b_cnt)<=1 and abs(b_cnt-c_cnt)<=1 and abs(c_cnt-a_cnt)<=1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3444
object Main {
  def main(args: Array[String]): Unit = {
    import collection._
    val n = io.StdIn.readLine()
    val str = io.StdIn.readLine()

    val (l, r) = str.foldLeft((0,0)){
      case ((lacc, acc), c) => {
        c match {
          case '(' => (lacc, acc + 1)
          case ')' if acc == 0 => (lacc + 1, 0)
          case _ => (lacc, acc - 1)
        }
      }
    }

    val left = Seq.fill(l)('(')
    val right = Seq.fill(r)(')')
    println(left.mkString + str + right.mkString)
  }
}

Measured memory_bytes: 27312
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String W[] = new String[N];
		Set<String> se = new HashSet<String>();
		for (int i = 0; i < N; i++) {
			W[i] = sc.next();
		}
		se.add(W[0]);
		sc.close();

		for (int i = 1; i < N; i++) {
			char c1 = W[i - 1].charAt(W[i - 1].length() - 1);
			char c2 = W[i].charAt(0);
			if (c1 != c2) {
				System.out.println("No");
				return;
			}
			if (se.contains(W[i])) {
				System.out.println("No");
				return;
			}
			se.add(W[i]);
		}
		System.out.println("Yes");
	}
}


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

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll g = c * d / gcd(c,d);
  ll cc = ((a%c==0)? b/c - a/c + 1 : b/c -a/c);
  ll dd = ((a%c==0)? b/d - a/d + 1 : b/d -a/d);
  ll gg = ((a%c==0)? b/g - a/g + 1 : b/g -a/g);
  // printf ("%d, %d %d, %d\n", g, cc, dd, gg);
  cout << b - a + 1  - (cc + dd - gg)  << endl;
  return 0;
}


Measured memory_bytes: 256