akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    long long N; cin >> N;
    int ans = 1;
    for(long long i=2;i<N;i++){
        if(i*i>N){
            break;
        }
        if(N%i==0){
            long long temp = N;
            while(temp%i==0){
                temp /= i;
            }
            ans += (temp%i==1);
            temp = N;
            long long a = N/i;
            if(a != i){
                while(temp%a==0){
                    temp /= a;
                }
                ans += (temp%a ==1);
            }
        }
        if((N-1)%i==0){
            long long a = (N-1)/i;
            if(a!=i){
                ans += 2;
            }
            else{
                ans += 1;
            }
        }
    }
    if(N==2){
        cout << 1;
    }
    else{
        cout << ans+1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  priority_queue<int, vector<int>, greater<int>> que;
  rep(i,9){
    que.push(i+1);
  }
  int ans, ans1;
  rep(i,N){
    ans = que.top();
    que.pop();
    ans1 = ans * 10 + (ans%10);
    if(ans % 10 != 0){
      que.push(ans1-1);
    }
    que.push(ans1);
    if(ans % 10 != 9){
      que.push(ans1+1);
    }
  }
  cout << ans<< endl;
}

Measured memory_bytes: 2420
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

d = defaultdict(int)
n, m = map(int, input().split())
for i in range(n):
    a = list(map(int, input().split()))
    count = 0
    for j in a:
        if count == 0:
            count += 1
            continue
        d[j] += 1
count = 0
for i in d:
    if (d[i] == n):
        count += 1

print(count)

Measured memory_bytes: 7880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,k,i,j,a[10];
    cin>>n>>k;
    for(i=0; i<k; i++)
        cin>>a[i];
    for(i=n; i>0; i++)
    {
        int t=i,flag=0;
        while(t)
        {
            for(j=0; j<k; j++)
            {
                if(a[j]==t%10)
                {
                    flag=1;
                    break;
                }
            }
            if(flag) break;
            t/=10;
        }
        if(!flag) break;
    }
    cout<<i;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll n; cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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() {
    ll N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vl a(N);
    ll mn = INF;
    ll res = 0;
    rep(i, 0, N) {
        ll p;
        cin >> p;
        if (chmin(mn, p)) {
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int n;cin>>n;
  vector<int> vec(n);
  int cnt=0;
  rep(i,n){
    cin>>vec[i];
  cnt+=vec[i];
  }
  int m;cin>>m;
  rep(i,m){
    int p,x;cin>>p>>x;
    cout<<cnt-vec[p-1]+x<<endl;
  }
}

Measured memory_bytes: 3612
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def warshall_floyd(): # 全点対最短路問題O(N^3)
    n,w = inpm() #n:頂点数　w:辺の数
    d = [[10**10 for i in range(n)] for i in range(n)] 
    #d[u][v] : 辺uvのコスト(存在しないときはinf)
    xyz=[]
    for i in range(w):
        x,y,z = inpm()
        x -= 1
        y -= 1
        xyz.append((x,y,z))
        d[x][y] = z
        d[y][x] = z
    for i in range(n):
        d[i][i] = 0 #自身のところに行くコストは0
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return n,w,d,xyz

def main():
    n,w,d,edge=warshall_floyd()
    cnt=0
    for i in range(w):
        flag = False
        x=edge[i][0]
        y=edge[i][1]
        z=edge[i][2]
        for j in range(n):
            if d[j][x] + z == d[j][y]:
                flag = True
                break
            if d[j][y] + z == d[j][x]:
                flag = True
                break
        if not flag:
            cnt+=1
    print(cnt)





if __name__ == "__main__":
    main()

Measured memory_bytes: 40304
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    dp = [False] * (A[-1] + 1)
    r = 0

    for i, a in enumerate(A):
        if dp[a]:
            continue
        dp[a::a] = [True] * len(dp[a::a])
        if i < N - 1 and A[i + 1] == a:
            continue
        r += 1
    return r


print(main())


Measured memory_bytes: 39420
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll f[30000010];
int a[3][2];
ll n;
int main()
{
	n=read();
	for(int i=0;i<2;i++)
		for(int j=0;j<3;j++)
			a[j][i]=read();
	memset(f,0,sizeof(f));
	for(int i=0;i<3;i++){
		int v=a[i][0],w=a[i][1]-a[i][0];
		for(int j=v;j<=n;j++)
			f[j]=std::max(f[j],f[j-v]+w);
	}
	n+=f[n];
	memset(f,0,sizeof(f));
	for(int i=0;i<3;i++){
		int v=a[i][1],w=a[i][0]-a[i][1];
		for(int j=v;j<=n;j++)
			f[j]=std::max(f[j],f[j-v]+w);
	}
	n+=f[n];
	writeln(n);
	return 0;
}

Measured memory_bytes: 234496
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         double res = 0.0;
         for(int a: arr)
            res += 1.0/a;
         res = 1/res;
         System.out.println(res);
      }
   }

Measured memory_bytes: 21332
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

const ll MODULO = 1000000007;
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

int main() {
    ll N, K;
    cin >> N >> K;

    ll total = 0;
    for (ll i = K; i <= N + 1; i++) {
        ll v = mod((N * (N + 1) / 2) - ((N - i) * (N - i + 1) / 2) - (i * (i - 1) / 2) + 1);
        total = mod(total + v);
    }
    print(total);
}


Measured memory_bytes: 3568
n = input()

ans = ''

if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9' :
    ans = 'hon'
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8' :
    ans = 'pon'
else :
    ans = 'bon'

print(ans)

Measured memory_bytes: 8996
#include <stdio.h>

int main(){
  int h, w;  scanf("%d %d", &h, &w);
  char field[102][102];
  for(int i=0; i<h; i++)
    scanf("%s", field[i]);

  int rows[101] = {0};
  int columns[101] = {0};
  int i, j;
  
  for(i=0; i<h; i++){
    for(j=0; j<w; j++)
      if(field[i][j] == '#')
	break;
    if(j == w)
      rows[++rows[0]] = i;
  }

  for(j=0; j<w; j++){
    for(i=0; i<h; i++)
      if(field[i][j] == '#')
	break;
    if(i == h)
      columns[++columns[0]] = j;
  }


  for(i=0; i<h; i++){
    int rowflag = 0;
    for(int r=1; r<=rows[0]; r++)
      if(i == rows[r])
	rowflag = 1;
    if(rowflag)  continue;

    for(j=0; j<w; j++){
      int columnflag = 0;
      for(int c=1; c<=columns[0]; c++)
	if(j == columns[c])
	  columnflag = 1;
      if(columnflag)  continue;

      printf("%c", field[i][j]);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int n; cin >> n;
  int a[100100]; 
  rep(i, n) {
      cin >> a[i];
  }
 
  sort(a, a + n);
  int x = a[n - 1];
  rep(i, n) a[i] *= 2;
 
  int b = *lower_bound(a, a + n, x);
  int c = b;
  if(b != a[0]) c = *(lower_bound(a, a + n, x) - 1);
  b /= 2; c /= 2;
  if(b == x) b = c;
  if(abs(x - 2 * b) > abs(x - 2 * c)) {
      cout << x << " " << c << "\n";
  } else {
      cout << x << " " << b << "\n";
  }
 
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

bool isprime(int N) {
    if (N == 2) return true;
    if (N%2 == 0) return false;
    for(int i = 3; i <= sqrt(N); i+=2) {
        if (!(N%i)) return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    int c = 0;
    REP(i,N) {
        int k;
        cin >> k;
        if (isprime(k)) c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 1160
#include<iostream> 
using namespace std; 
int main(){
    int x,y;
    while(1){
        cin>>x >>y;
        if(x==0 && y==0)break;
        if(x>=y)cout<<y<<" "<<x<<endl;
        else cout<<x<<" "<<y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define lli long long int
#define MAX 100000000
int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> answer;
    int test = 1;
    while (test != min(A, B) + 1)
    {
        if ((A % test == 0) && (B % test == 0))
        {
            answer.push_back(test);
        }
        test++;
    }
    cout << answer[answer.size() - K] << endl;
    return 0;
}

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

int main() {
    int64_t a, b, n;
    cin >> a >> b >> n;

    int64_t max = 0;
    
    max = a * n / b - a * ( n / b);
    for(int i = n / b - 1; i >= 0; i--){
        int64_t tmp = (b - 1)*(i+1)*a/b - a * i;
        if (max < tmp){
            max = tmp;
        }
    }

    cout << max << endl;
}


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

using namespace std;

int main(void){

	int n;
	scanf("%d",&n);
	int l[n];
	int max=0,sum=0;
	for(int i = 0; i < n; i++){
		scanf("%d",&l[i]);
		if(max<l[i]){
			max = l[i];
		}
	}
	int cnt=0;
	for(int i = 0; i < n; i++){
		if(max == l[i] && cnt==0){
			cnt =1;
		}else{
			sum += l[i];
		}
	}

	if(max >= sum){
		printf("No\n");
	}else{
		printf("Yes\n");
	}



	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    int flag = 0;
    if(a > b) swap(a,b);
    if(a+v*t >= b+w*t)yn;
    return 0;
}




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

/* nC2 */
ll choose2(ll n){
  return n*(n-1)/2;
}

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
 
	ll a,h=0;
  cin>>a;
  h += int(a/500)*1000;
  a %= 500;
  h += int(a/5)*5;
  cout<<h;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[401][401];
void hantei(int m,int d,int n,int num){
	for(int i = 200-n;i < 200+n;i++){
		for(int j = 200-n;j < 200+n;j++){
			if(a[i][j] == m+1){
				if(d == 0){
					a[i][j-1] = num;
				}
				else if(d == 1){
					a[i+1][j] = num;
				}
				else if(d == 2){
					a[i][j+1] = num;
				}
				else if(d == 3){
					a[i-1][j] = num;
				}
			}
		}
	}
}
int main() {
	int n = 0,m,d,ue,sita,migi,hidari;
	while(1){
		for(int i = 200 - n;i < 200 + n;i++){
			for(int j = 200 - n;j < 200 + n;j++){
				a[i][j] = 0;
			}
		}
		ue = sita = migi = hidari = 200;
		cin >> n;
		if(n == 0)break;
		a[200][200] = 1;
		for(int i = 0;i < n-1;i++){
			cin >> m >> d;
			hantei(m,d,n,i+2);
		}
		
	for(int i = 200-n;i < 200+n;i++){
		for(int j = 200-n;j < 200+n;j++){
			if(a[i][j] != 0){
				if(ue > i)ue = i;
				if(sita < i)sita = i;
				if(migi < j)migi = j;
				if(hidari > j)hidari = j;
			}
		}
	}
	cout << migi - hidari + 1 << " " << sita - ue + 1<< endl;
	}
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector< pair<string, int> > songs;
	for(int i=0;i<n;i++){
		string str;
		int len;
		cin>>str>>len;
		songs.pb( mp(str,len) );
	}
	string neru;
	cin>>neru;
	int coef = 0;
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += songs[i].second * coef;
		if( songs[i].first == neru ) coef = 1;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define NIL NULL

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

typedef struct node * Node;

Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

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

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 25116
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

cnt = [0] * N
for Ai in A:
    cnt[Ai - 1] += 1

for i in range(N):
    if K - (Q - cnt[i]) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


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

int x[200005];
int y[200005];

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) 
	{
		scanf("%d", &x[i]);
		y[i] = x[i];
	}
	sort(y + 1, y + 1 + n);
	int temp = (y[n / 2] + y[n / 2 + 1]) / 2;
	for(int i = 1; i <= n; i++)
	{
		if(x[i] > temp) printf("%d\n", y[n / 2]);
		else printf("%d\n", y[n / 2 + 1]);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

template <typename T>
struct RollingHash
{
	T& ary;
	int size;
	int n;
	vector<ll> factor;
	ll b = 0;
	ll mod = 0;
	ll hash = 0;
	int index = -1;

	RollingHash(T& _ary, int _size, int _n, ll _b = (ll)1e8 + 7, ll _mod = (ll)1e9 + 7) : ary(_ary)
	{
		size = _size;
		n = _n;
		b = _b;
		mod = _mod;
		auto temp = 1ll;
		for (auto i = 0; i < n; ++i)
		{
			factor.push_back(temp);
			temp = temp * b % mod;
		}
		for (auto i = 0; i < n; ++i)
		{
			hash = (hash + ary[i] * factor[n - i - 1] % mod) % mod;
		}
	}

	bool moveNext() {
		if (index + n >= size)
		{
			return false;
		}
		if (index < 0)
		{
			++index;
			return true;
		}

		hash = (((hash - ary[index] * factor[n - 1]) % mod) + mod) % mod;
		hash = hash * b % mod;
		hash = (hash + ary[index + n]) % mod;
		++index;
		return true;
	}

	ll getHash() { return hash; }
	int getIndex() { return index; }
};

int main()
{
	int N;
	string S;
	cin >> N >> S;

	vector<ll> listB = { (ll)1e5 + 7, (ll)1e8 + 7 };
	int low = 1;
	int high = N;
	while (low <= high)
	{
		auto foundAll = true;
		auto mid = (low + high) / 2;
		for (auto b : listB)
		{
			RollingHash<string> r1(S, N, mid, b);
			RollingHash<string> r2(S, N, mid, b);
			vector<ll> hashList;
			map<ll, int> hashMap;

			while (r1.moveNext() != false)
			{
				if (r1.getIndex() < mid)
				{
					continue;
				}

				hashList.push_back(r1.getHash());
				++hashMap[r1.getHash()];
			}

			auto found = false;
			auto i = 0;
			while (r2.moveNext() != false)
			{
				auto it = hashMap.find(r2.getHash());
				if (it != hashMap.end() && it->second > 0)
				{
					found = true;
					break;
				}

				if (i < (int)hashList.size())
				{
					--hashMap[hashList[i]];
				}
				++i;
			}

			if (!found)
			{
				foundAll = false;
				break;
			}
		}

		if (foundAll)
		{
			low = mid + 1;
		}
		else
		{
			high = mid - 1;
		}
	}

	cout << high << endl;

	return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

struct edge {
  ll to, cost;
  edge(ll to, ll cost) : to(to), cost(cost) {}
};

int V, E;
vector<vector<edge>> G;
vector<ll> dist;

typedef pair<ll, int> P;  // <最短距離, 頂点の番号>

/* 負閉路の検出はできない。O(E logV) */
/* 負の辺があってもダメ */
void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(dist.begin(), dist.end(), LINF);
  dist[s] = 0;
  que.push(P(0, s));

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N - 1), b(N - 1), c(N - 1);
  rep(i, N - 1) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  int Q, K;
  cin >> Q >> K;
  K--;
  vector<int> x(Q), y(Q);
  rep(i, Q) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  V = N;
  E = N - 1;
  G = vector<vector<edge>>(V);
  dist = vector<ll>(V);

  for (int i = 0; i < E; i++) {
    G[a[i]].pb(edge(b[i], c[i]));
    G[b[i]].pb(edge(a[i], c[i]));
  }

  dijkstra(K);
  rep(j, Q) {
    cout << dist[x[j]] + dist[y[j]] << endl;
  }
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int cnt[100010] = {};

    rep(i, n) {
        int a;
        cin >> a;
        if (a == 0) {
            cnt[0]++;
            cnt[1]++;
        } else {
            cnt[a]++;
            cnt[a - 1]++;
            cnt[a + 1]++;
        }
    }

    int Max = 0;

    rep(i, 100002) {
        Max = max(Max, cnt[i]);
    }

    cout << Max << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi t(n), a(n);
    rep(i,n) cin >> t.at(i) >> a.at(i);
    ll x=t.at(0), y=a.at(0);
    for(ll i=1; i<n; i++){
        ll r = max((x+t.at(i)-1)/t.at(i), (y+a.at(i)-1)/a.at(i));
        x = t.at(i)*r;
        y = a.at(i)*r;
    }
    cerr << "x:" << x << endl;
    cerr << "y:" << y << endl;
    cout << x+y << endl;
}

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

#define N 11

int main(){
  char s[N];
  int n, cnt=0, cntMax=0;
  scanf("%s", s);
  n = strlen(s);
  
  for(int i=0; i<n; i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }
    else{
      if(cntMax<cnt){
        cntMax = cnt;
      }
      cnt = 0;
    }
  }
  if(cntMax<cnt){
    cntMax = cnt;
  }
  
  printf("%d",cntMax);  
  return 0;
}

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

#define debug(args...) fprintf(stderr, args);

typedef long long ll;

ll x, y;

int solve() {
    int ans = 0;

    while(x <= y) {
	++ans;
	x *= 2LL;
    }
    
    return ans;
}

int main() {
    cin >> x >> y;

    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, C;
const int MAX_T = 2e5+1;
const int MAX_C = 30;

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

  vector<vector<int>> timeTable(MAX_C, vector<int>(MAX_T, 0));

  int s, t, c;
  rep(i,N) {
    cin >> s >> t >> c;
    c--;
    timeTable[c][2*s-1]++;
    timeTable[c][2*t]--;
  }

  rep(c,C) rep(t,MAX_T) {
    if(t+1 < MAX_T) timeTable[c][t+1] += timeTable[c][t];
    timeTable[c][t] = min(timeTable[c][t], 1);
  }
  rep(c,C-1) rep(t,MAX_T) timeTable[c+1][t] += timeTable[c][t];

  cout << *max_element(all(timeTable[C-1])) << endl;

  return 0;
}


Measured memory_bytes: 24576
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

count = 0
#count second conditions satisfied
for i in range(n):
    for j in range(i+1,n):
        #search j - i = k - j ⇔ k = 2 * j - i
        k = 2 * j - i
        if k >= n: break
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]: count += 1
print((r * g * b) - count)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const int A = 2e5 + 2;
const int mod = 998244353;
int add(ll x, ll y) {
    return (x + y + mod) % mod;
}
int n, k;
int l[11], r[11];
int dp[A], freq[A];
int solve() {
    dp[1] = freq[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            int up = max(0, i - l[j]), low = max(1, i - r[j]);
            dp[i] = add(dp[i], add(freq[up], -freq[low - 1]));
        }
        freq[i] = add(dp[i], freq[i - 1]);
//        cout << dp[i] << '\n';
    }
    return dp[n];
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < k; i++)
        cin >> l[i] >> r[i];
    cout << solve();
    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	long long a, b, n ,s ,A , B;
	cin >> n; 
	for ( a = 1; a < n; a++) {
		b = n - a;
		A =a%1000000/100000+ a % 100000/10000 + a % 10000 / 1000 + a % 1000 / 100 + a % 100 / 10 + a % 10;
		B =b%1000000/100000+ b %100000/ 10000 + b % 10000 / 1000 + b % 1000 / 100 + b % 100 / 10 + b % 10;
		if (a == 1)s = A + B;
		if (s > A + B)s = A + B;
	}
	cout << s << endl;
	int x;
	cin >> x;
	return 0;
}


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

int main() {
  int N,K; cin >> N >> K;
  if ( N % 2 == 0 ) {
    if ( N / 2 >= K ) {
      cout <<"YES" << endl;
    }else {
      cout << "NO" << endl;
    }
  }else {    
      if ( N/2 + 1 >= K ) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  
  return 0;
}


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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    ll m = INF;
    for(ll i = 1; i*i <= N; i++ ){
        if( N%i == 0 ){
            m = min(m, (i-1)+(N/i-1));
        }
    }
    cout << m << endl;
}


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

int main()
{
    int N;
    double M;

    cin >> N;

    if(N%2==0){
        M = 1 / 2.0;
        cout << M << endl;
    }
    else{
        M = ((N + 1) / 2.0) / N;
        cout << M << endl;
    }
}

Measured memory_bytes: 256
using System;

namespace abc166_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string retStr;

            if(a == "ABC")
            {
                retStr = "ARC";
            }
            else
            {
                retStr = "ABC";
            }
            Console.WriteLine(retStr);
        }
    }
}


Measured memory_bytes: 25880
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>
class cDie
{
  private:
    std::array<int64_t, 6> aEye;

  public:
    cDie(std::array<int64_t, 6> aEye)
    {
        cDie::aEye = aEye;
    }
    void fE()
    {
        int64_t t = aEye[0];
        aEye[0] = aEye[3];
        aEye[3] = aEye[5];
        aEye[5] = aEye[2];
        aEye[2] = t;
    }
    void fW()
    {
        fE();
        fE();
        fE();
    }
    void fN()
    {
        int64_t t = aEye[0];
        aEye[0] = aEye[1];
        aEye[1] = aEye[5];
        aEye[5] = aEye[4];
        aEye[4] = t;
    }
    void fS()
    {
        fN();
        fN();
        fN();
    }
    size_t top()
    {
        return aEye[0];
    }
    void top(size_t i)
    {
        aEye[0] = i;
    }
};
int main()
{
    std::cout << std::setprecision(16);
    int64_t i1, i2, i3, i4, i5, i6;
    std::cin >> i1 >> i2 >> i3 >> i4 >> i5 >> i6;
    cDie die({i1, i2, i3, i4, i5, i6});

    std::cin >> i1;
    while (i1 != 0)
    {
        size_t q1, q2;
        std::cin >> q1 >> q2;
        for (auto it : std::string("EEENNN"))
        {
            if (die.top() == q1)
            {
                break;
            }
            if (it == 'S')
            {
                die.fS();
            }
            else if (it == 'E')
            {
                die.fE();
            }
            else if (it == 'N')
            {
                die.fN();
            }
            else if (it == 'W')
            {
                die.fW();
            }
        }

        [&] {
            cDie tDie = die;
            tDie.fS();
            if (tDie.top() == q2)
            {
                die.fE();
                return ;
            }
            tDie.fN();
            tDie.fN();
            if (tDie.top() == q2)
            {
                die.fW();
                return ;
            }
            tDie.fS();
            tDie.fW();
            if (tDie.top() == q2)
            {
                die.fS();
                return ;
            }

            die.fN();
        }();
        std::cout << die.top() << "\n";
        i1--;
    }

    return 0;
}


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

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double minute = h * 60 + m;

    pair<double, double> posh, posm;

    double htheta = ((2 * PI) / 720) * minute - (PI / 2);
    double mtheta = ((2 * PI) / 60) * minute - (PI / 2);

    /*
    cout << htheta << endl;
    cout << mtheta << endl;
    */
    posh.first = (double)a*cos(htheta);
    posh.second = (double)a*sin(htheta);
    //cout << posh.first << " " << posh.second << endl;

    posm.first = (double)b*cos(mtheta);
    posm.second = (double)b*sin(mtheta);

    double dist = sqrt((posh.first -posm.first)*(posh.first -posm.first) + (posh.second -posm.second)*(posh.second -posm.second));
    cout << fixed << setprecision(20) << dist << endl;
    return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 140000;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, ch[MAXN][2];
LL dep[MAXN], mid;

struct Node {
	LL in, out;
	Node() {}
	Node(LL _in, LL _out): in(_in), out(_out) {}
	bool operator < (const Node &rhs) const {
		return (in == rhs.in)? (out < rhs.out) : (in < rhs.in);
	}
};
vector<Node> dp[MAXN], q;

bool DFS(int u) {
	dp[u].clear();
	if (!ch[u][0]) {
		dp[u].push_back(Node(dep[u], dep[u]));
		return 1;
	}
	int lc = ch[u][0], rc = ch[u][1];
	if (!DFS(lc)) return 0;
	if (!DFS(rc)) return 0;
	
	q.clear();
	int ln = dp[lc].size(), rn = dp[rc].size();
	for (int i = 0, j = 0; i < ln; ++i) {
		while (j < rn && dp[lc][i].in + dp[rc][j].out - dep[u] * 2 > mid) {
			++j;
		}
		if (j >= rn) break;
		q.push_back(Node(dp[rc][j].in, dp[lc][i].out));
	}
	for (int i = 0, j = 0; i < rn; ++i) {
		while (j < ln && dp[rc][i].in + dp[lc][j].out - dep[u] * 2 > mid) {
			++j;
		}
		if (j >= ln) break;
		q.push_back(Node(dp[lc][j].in, dp[rc][i].out));
	}
	
	sort(q.begin(), q.end());
	for (int i = 0, sz = q.size(); i < sz; ++i) {
		if (i == 0 || q[i].out < dp[u].back().out) {
			dp[u].push_back(q[i]);
		}
	}
	return (dp[u].size() > 0);
}

void solve() {
	LL L = 0, R = 0, ans;
	read(n);
	for (int i = 2, fa, d; i <= n; ++i) {
		read(fa); read(d);
		(ch[fa][0]? ch[fa][1] : ch[fa][0]) = i;
		dep[i] = dep[fa] + d;
		R += d;
	}
	while (L <= R) {
		mid = (L + R) >> 1;
		if (DFS(1)) {
			ans = mid;
			R = mid - 1;
		} else {
			L = mid + 1;
		}
	}
	printf("%lld\n", ans);
}

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



Measured memory_bytes: 30196
#include<iostream>
using namespace std;
int sum1[100005],sum2[100005],n;
int main(){
	cin>>n;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		if(i%2==1) sum1[x]++;
		else sum2[x]++;
	}
	int maxv1=0,maxin1=0,maxv2=0,maxin2=0;
	for(int i=1;i<=100000;i++){
		if(sum1[i]>maxv1){
			maxv1=sum1[i];
			maxin1=i;
		}
	}
	for(int i=1;i<=100000;i++){
		if(sum2[i]>maxv2){
			maxv2=sum2[i];
			maxin2=i;
		}
	}
	if(maxin1==maxin2){
		int maxin3=0,maxv3=0,maxv4=0,maxin4=0;
		for(int i=1;i<=100000;i++){
			if(i==maxin1) continue;
			if(sum1[i]>maxv3){
				maxv3=sum1[i];
				maxin3=i;
			}
		}
		for(int i=1;i<=100000;i++){
			if(i==maxin2) continue;
			if(sum2[i]>maxv4){
				maxv4=sum2[i];
				maxin4=i;
			}
		}
		cout<<n-max(maxv1+maxv4,maxv2+maxv3);
	}
	else{
		cout<<n-maxv1-maxv2;
	}
}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h, n;
	cin >> w >> h >> n;
	map<pi, vector<pi>> down, right;
	vector<tuple<int,int,int>> in;
	vi last;
	
	rep(i, n){
		int x, y; char d;
		cin >> x >> y >> d;
		in.emplace_back(x, y, d);
		if(d == 'S') down[pi(x + y, x & 1)].emplace_back(x, i);
		else right[pi(x + y, x & 1)].emplace_back(x, i);
		last.pb(i);
	}
	
	for(auto p : down){
		vector<pi> &d = p.second;
		
		pi o = p.first;
		if(o.first & 1) o.second ^= 1;
		if(!right.count(o)) continue;
		
		vector<pi> &r = right[o];
		sort(all(d));
		sort(all(r));
		int idx = 0;
		for(pi i : d){
			int k = lower_bound(all(r), pi(i.first, 0)) - r.begin();
			if(k >= d.size() - idx) last[i.second] = r[k - (d.size() - idx)].second;
			else last[i.second] = d[idx + k].second;
			idx++;
		}
		idx = 0;
		for(pi i : r){
			int k = d.end() - lower_bound(all(d), pi(i.first + 1, 0));
			if(k > idx) last[i.second] = d[d.size() - k + idx].second;
			else last[i.second] = r[idx - k].second;
			idx++;
		}
	}
	//dbg(last);
	
	vector<pi> ans;
	rep(i, n){
		int x, y, d; tie(x, y, d) = in[last[i]];
		bool down = d == 'S';
		ans.emplace_back(down ? h - y :  w - x, i);
	}
	sort(all(ans));
	for(pi i : ans) cout << i.second + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 31556
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    vector<int> ans(0);
    for(;;){
        int n,l,r; cin >> n >> l >> r;
        if (n == 0 && l == 0 && r == 0) break;
        int a[n+1];
        fill(a,a+n+1,0);
        for(int i = 1; i < n+1; i++){
            cin >> a[i];
        }
        bool flg;
        int cnt = 0;
        for(int i = l; i <= r; i++){
            int x = i;
            flg = false;
            for(int num = 1; num < n+1; num++){
                if (x % a[num] == 0){
                    flg = true;
                    if (num % 2 == 1){
                        cnt++;
                        break;
                    }
                }
                if(flg) break;
            }
            if (!flg){
                if (n % 2 == 0) cnt++;
            }
        }
        ans.push_back(cnt);
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3112
n = int(input())
prime = [3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123, 1153, 1163, 1193, 1213, 1223, 1283, 1303, 1373]
ans = prime[1:n+1]
print(*ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};



int main(){
    ll a;
    double b;
    cin >> a >> b;
    int bb = b*100+0.5;
    ll ans = a*bb/100;
    cout << ans << endl;

}

Measured memory_bytes: 3748
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
static long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
static long[] positions = new long[n];//それぞれの数字が左から何番目か
static long[] bits = new long[n+2];
static long middleNum = 0;
static long answer = 0;

	static void Main()
	{
    for(int i = 0; i < n; i++)
    {
      positions[nums[i]-1] = i;
    }

    for(int i = 0; i < n; i++)
    {
      middleNum = positions[i];
      long leftCount = SearchLeft(0,positions[i]);
      long rightCount = SearchRight(0,n-1-positions[i]);
      //Console.WriteLine(leftCount+" "+rightCount +" "+ answer);
      answer += (i+1)*(leftCount+1)*(rightCount+1);//数　×　数が加算される部分列の個数
      BitAdd(positions[i]+1,1);//使用位置を1にする
    }
    
		Console.WriteLine(answer);
	}

  static void BitAdd(long i, long x)//BITでiだけにx加算
  {
    while(i <= n)
    {
      bits[i] += x;
      i += i&-i;
    }
  }

  static long BitSum(long i)//BITでi以下の総和を計算
  {
    long sum = 0;
    while(i > 0)
    {
      sum += bits[i];
      i -= i&-i;
    }
    return sum;
  }

  static long SearchLeft(long min, long max)//二分探索法で最大値を求める
  {
    while (true)
    {
      long mid = min + (max - min) / 2;
      if(CheckLeft(mid)) min = mid;//さらに大きくても成り立つかも
      else max = mid;

      if(max - min <= 1)
      {
        if(CheckLeft(max)) 
        {
          return max;//最大値で成り立つかの確認を優先
        }
        else
        {
          return min;
        }
      break;
      }  
    }
  }

  static long SearchRight(long min, long max)//二分探索法で最大値を求める
  {
    while (true)
    {
      long mid = min + (max - min) / 2;
      if(CheckRight(mid)) min = mid;//さらに大きくても成り立つかも
      else max = mid;

      if(max - min <= 1)
      {
        if(CheckRight(max)) 
        {
          return max;//最大値で成り立つかの確認を優先
        }
        else
        {
          return min;
        }
      break;
      }  
    }
  }

  static bool CheckLeft(long testNum)
  {
    if(BitSum(middleNum) - BitSum(middleNum-testNum) == 0) return true;
    return false;
  }

  static bool CheckRight(long testNum)
  {
    if(BitSum(middleNum+1+testNum) - BitSum(middleNum+1) == 0) return true;
    return false;
  }
  
}

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

int main() {
  int n;
  cin >> n;
  bool r = true;
  while (n--) {
    int a;
    cin >> a;
    r = r && (a % 2 != 0 || a % 3 == 0 || a % 5 == 0);
  }
  cout << (r ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int p[] = new int[55556];
		p[0] = -1;
		p[1] = -1;
		p[2] = 1;
		for(int i = 2; i < p.length; ++i) {
			if(p[i] == 0) {
				p[i] = 1;
				for(int j = 2; j * i < p.length; ++j) {
					p[j * i] = -1;
				}
			}
		}
		int ans[] = new int[n];
		int t = 1;
		for(int i = 0; i < n; ++i) {
			for(int j = t; j < p.length; j += 5) {
				if(p[j] == 1) {
					ans[i] = j;
					t = j + 5;
					break;
				}
			}
		}
		for(int i:ans)
		System.out.print(i + " ");
		System.out.println();
	}

}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n%10==3){
    cout << "bon" << endl;
  }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := readBigLine()
	spl := intSprit(line)

	N := spl[0]
	K := spl[1]

	x := intSprit(readBigLine())

	res := 1 << 30
	for i := 0; i < N-K+1; i++ {
		l := x[i]
		r := x[i+K-1]

		lr := intAbs(l) + intAbs(l-r)
		rl := intAbs(r) + intAbs(r-l)

		if res > lr {
			res = lr
		}
		if res > rl {
			res = rl
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 6400
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<list>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  string s;
  list<char> ans;
  ll cmd,f;
  ll q;
  char c;
  bool is_rev=false;
  cin >> s >> q;
  for(auto ch:s){
    ans.push_back(ch);
  }
  for(int i=0;i<q;i++){
    cin >> cmd;
    if(cmd==1){
      is_rev = !is_rev;
    }else{
      cin >> f >> c;
      if(is_rev ^ (f==2)){
        ans.push_back(c);
      }else{
        ans.push_front(c);
      }
    }
  }
  if(is_rev){
    reverse(ans.begin(),ans.end());
  }
  for(auto ch:ans){
    cout << ch;
  }
  cout<<endl;
}


Measured memory_bytes: 10064