akhauriyash/Code-Regression huggingface dataset:
def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N, M = map(int, input().split())
S = input()
T = input()

d = dict()
for num, pow in factorize2(N):
    d[num] = pow
for num, pow in factorize2(M):
    if d.get(num) is None:
        d[num] = pow
    elif d[num] < pow:
        d[num] = pow
ans = 1
for num, pow in d.items():
    ans *= num ** pow

c = dict()
for i in range(N):
    c[i * ans // N] = S[i]
for i in range(M):
    val = c.get(i * ans // M)
    if val is not None and val != T[i]:
        print(-1)
        exit(0)
print(ans)

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

int main() {
  string S, T;
  cin >> S >> T;
  int N=S.size();
  bool J=true;
  for (int i=0; i<N; i++) {
    if (S[i] != T[i]) {
      J = false;
    }
  }
  if (J) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int MAXV = 100010;
int N;
vector<int> G[2 * MAXV];
bool checked[2 * MAXV];

void dfs(int v, int n[2])
{
	n[v / MAXV]++;
	checked[v] = true;
	for (auto e : G[v])
	{
		if (!checked[e])
		{
			dfs(e, n);
		}
	}
}

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

	cin >> N;
	int x, y;
	rep(i, 0, N)
	{
		cin >> x >> y;
		x--, y;;
		G[x].push_back(MAXV + y);
		G[MAXV + y].push_back(x);
	}

	int ans = 0;
	rep(i, 0, 2 * MAXV)
	{
		if (checked[i])continue;
		int n[2] = { 0 };
		dfs(i, n);
		ans += n[0] * n[1];
	}

	cout << ans - N << endl;

	return 0;
}



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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    string s;
    cin>>s;
    
    sort(all(s));
    
    if(s[0]==s[1] and s[1]!=s[2] and s[2]==s[3])
        cout<< "Yes";
    else cout<< "No";


    return 0;
}


Measured memory_bytes: 3648
#include "stdio.h"

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);

    if (N % 2 == 1)
    {
        if (N / 2 + 1 >= K)
        {
            printf("YES");
            return 0;
        }
        else
        {
            printf("NO");
            return 0;
        }
    }

    if (N / 2 >= K)
        printf("YES");
    else
        printf("NO");
}

Measured memory_bytes: 128
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, m = wi()
a = wi()
bc = mi(m)
a.sort()
de = deque()
for i in range(n):
    de.append(a[i])
bc.sort(key=ig(1), reverse=True)

for i in range(m):

    def isOK(mid):
        if de[mid] > bc[i][1]:
            return False
        else:
            return True


    #汎用的な二分探索のテンプレ
    def binary_search(n):
        ok = -1 #「index = 0」が条件を満たすこともあるので、初期値は -1
        ng = n #「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

        #ok と ng のどちらが大きいかわからないことを考慮
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2

            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ok

    bs = binary_search(n)

    if bs + 1 > bc[i][0]:
        ans += bc[i][0] * bc[i][1]
        for _ in range(bc[i][0]):
            de.popleft()
    else:
        ans += (bs + 1) * bc[i][1]
        for _ in range(bs + 1):
            de.popleft()
    n -= min(bs + 1, bc[i][0])

ans += sum(de)

print(ans)

Measured memory_bytes: 36184
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

vector<ll> prime;

void sieve(ll n)
{
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p << " "; 
}

int main()
{
   FAST/**/
   
   ll a,b;
   cin>>a>>b;
   
   a = __gcd(a,b);
   //sieve(a);
   
   unordered_map<ll,ll> ma;
   while(a%2 == 0)
   {
       a/=2;
       ma[2]++;
   }
   
   for(ll i=3;i<=sqrt(a);i+=2)
   {
       while(a%i == 0)
       {
           ma[i]++;
           a/=i;
       }
   }
   
   if(a>2)
        ma[a]++;
  ma[1]++;
  cout<<ma.size();
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int A, B;
    cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (A <= 5) cout << 0 << endl;
    else cout << B / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll row[n] = {};
    int stk[n][2];
    int c = 0;

    ll ans = 0;

    rep(i,n){
        if(i==0){
            row[i] = a[i];
            stk[c][0] = a[i];
            stk[c][1] = 1;
            c++; 
        } else {
            row[i] = row[i-1] + a[i];
            int c_ = 1;
            while(0 < c && a[i] < stk[c-1][0]){
                row[i] -= (stk[c-1][0] - a[i]) * stk[c-1][1];
                c_ += stk[c-1][1];
                c--;
            }
            stk[c][0] = a[i];
            stk[c][1] = c_;
            c++;
        }
        ans += row[i];
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 4992
#include <stdio.h>
#define maxn 200010
int head[maxn],tot,n,m,d[maxn],pre[maxn],q[maxn*10],vis[maxn];
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
void init(){
	int i,u,v;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
}
void spfa(){
	int h,t,i,u,v,b;
	for(i=1;i<=n;i++)d[i]=maxn;
	d[1]=0,h=t=1,q[t]=1,t++,vis[1]=1;
	while(h<t){
		u=q[h];
		for(b=head[u];b;b=e[b].next){
			v=e[b].to;
			if(d[v]>d[u]+1){
				pre[v]=u;
				d[v]=d[u]+1;
				if(!vis[v])vis[v]=1,q[t]=v,t++;
			}
		}
		h++;
		vis[u]=0;
	}
	for(i=1;i<=n;i++)
		if(d[i]==maxn){printf("No\n");return;}
	printf("Yes\n");
	for(i=2;i<=n;i++)printf("%d\n",pre[i]);
}
int main(){
	init();
	spfa();
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  map<string,int> dic;
  for(int i=0;i<N;i++){
    string c;
    cin>>c;
    if(!dic.count(c))dic[c]=i;
  }
  cout<<dic.size()<<endl;
}





Measured memory_bytes: 19228
#include <iostream>
using namespace std;
int main(){
  char s1,s2,s3,s4;
  cin>>s1>>s2>>s3>>s4;
  
  if(s1==s2||s2==s3||s3==s4){
    cout<<"Bad"<<endl;
  }
  else {
    cout<<"Good"<<endl;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin() (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  if (a > b) {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }
  if (a > b) {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second

          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          int n;
          cin >> n;
          bool ok = 0;
          for(int i = 1; i <= 9; i++)
          {
               for(int j = 1; j<=9; j++)
               {
                    if(i*j==n)
                    {
                         ok = 1;
                    }
               }
          }
          if(ok)
               cout << "Yes\n";
          else
               cout <<"No\n";


          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)
x = n.times.map{|_| gets.split.map(&:to_i)}

ans = 0
(0...n-1).each do |i|
  (i+1...n).each do |j|
    dist = 0
    d.times do |k|
      dist += (x[i][k] - x[j][k]) ** 2
    end
    dist = Math.sqrt(dist)
    if dist.floor == dist.ceil
      ans += 1
    end
  end
end
p ans

Measured memory_bytes: 14340
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int a=0;
	if (k<n) a+=k*x+(n-k)*y;
	else a+=n*x;
	cout << a;
}

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

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C, X, Y = read_h()

    min_price_ab = min(A + B, C * 2)
    base_cnt = min(X, Y)
    ans = min_price_ab * base_cnt

    rem_a, rem_b = X - base_cnt, Y - base_cnt
    if rem_a > 0:
        ans += rem_a * min(A, C * 2)
    if rem_b > 0:
        ans += rem_b * min(B, C * 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()

A_acc = list(accumulate(A))
A_acc_mod = [x%M for x in A_acc]

dic = defaultdict(int)
for i in A_acc_mod:
	dic[i] += 1

ans = 0
for val in dic.values():
	if val >= 2:
		ans += val*(val-1)//2
ans += dic[0]
print(ans)


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

using namespace std;


// string^ÅÁZðs¢AÊðÔ·
string add(string &str1,string &str2){
  string str;
  int carry = 0;
  for(int i = 0; i < max(str1.size(),str2.size()); i++){
    if(i >= str1.size()){
      int ret = carry + str2[str2.size()-1-i] - '0';
      carry = ret / 10;
      str += (ret % 10) + '0';
    }
    else if(i >= str2.size()){
      int ret = carry + str1[str1.size()-1-i] - '0';
      carry = ret / 10;
      str += (ret % 10) + '0';
    }
    else{
      int ret = str1[str1.size()-1-i] + str2[str2.size()-1-i] - '0' - '0' + carry;
      carry = ret / 10;
      str += (ret % 10) + '0';
    }
  }
  str+=(carry+'0');
  // jóIÏX
  reverse(str.begin(),str.end());
  // æªÌ0ðÁ·
  int idx;
  for(int i = 0; i < str.size(); i++){
    idx=i;
    if(str[i]!='0'||str.size()-1==i)
      break;
  }
  return str.substr(idx);
}

int main(){

	string str;
	while(cin>>str){
		int p=-1;
		int e=-1;
		for(int i = 0; i < str.size(); i++){
			if(str[i]=='+'){
				p=i;
			}
			else if(str[i]=='='){
				e=i;
			}
		}
		string opr1=str.substr(0,p);
		string opr2=str.substr(p+1,e-p-1);
		string obj=str.substr(e+1,str.size()-e-1);

		bool ok=false;
		for(int i = 0; i <= 9; i++){
			if(i==5){
			//	cout<<endl;
			}

			bool fl=false;
			string o1=opr1;
			string o2=opr2;
			string oj=obj;
			for(int j = 0; j < o1.size(); j++){
				if(o1[j]=='X'){
					if(j==0&&i==0&&o1.size()!=1)
						fl=true;
					o1[j]='0'+i;
				}
			}
			for(int j = 0; j < o2.size(); j++){
				if(o2[j]=='X'){
					if(j==0&&i==0&&o2.size()!=1)
						fl=true;
					o2[j]='0'+i;
				}
			}
			for(int j = 0; j < oj.size(); j++){
				if(oj[j]=='X'){
					if(j==0&&i==0&&oj.size()!=1)
						fl=true;
					oj[j]='0'+i;
				}
			}
			if(fl)
				continue;
			if(add(o1,o2)==oj){
				ok=true;
				cout<<i<<endl;
				break;
			}
		}
		if(!ok){
			cout<<"NA"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#! /usr/bin python3
import math
A, B, H, M = map(int,input().split())

#角度求める
short = H * 30 + M * (30/60)
loong = M * 6
deg = abs(short - loong)
if deg > 180:
    deg= 360 - deg
#print(deg, short, loong)
#print(A * A + B * B - 2 * A * B * math.cos(math.radians(deg)))
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(deg))))

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

int main(){
    ll n,m;
    cin>>n;
    m=n;
    vector<ll> v;
    map<ll,ll> mp;
    for(int i=2;i<=sqrt(m);i++){
        if(n%i==0){
            if(v.empty()){
                v.push_back(i);
            }else{
                if(*prev(v.end())!=i){
                    v.push_back(i);
                }
            }
            mp[i]++;
            n/=i;
            i--;
        }
    }
    if(n!=1){
        v.push_back(n);
        mp[n]++;
    }
    if(m==1){
        cout<<0<<endl;
        return 0;
    }
    if(n==m){
        cout<<1<<endl;
        return 0;
    }
    ll ans=0;
    for(auto a:v){
        ll c=mp[a];
        for(int i=2;i<100;i++){
            if(i*(i+1)/2<=c)continue;
            ans+=i-1;
            break;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
using namespace std::chrono;
#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;

ll n,m,T,k,q;
ll R,C;

vector<ll> X1;
vector<ll> Y1;
vector<ll> X2;
vector<ll> Y2;
vector<ll> A;
vector<ll> ind;

ll bound(ll i, ll j){
    if(i == 0)return 0;
    if(i == R)return 2;
    if(j == 0)return 3;
    if(j == C)return 1;
    return -1;
}

bool comp(ll i, ll j){
    ll b1 = bound(X1[i],Y1[i]);
    ll b2 = bound(X1[j],Y1[j]);
    if(b1 == 0 && b2 == 0){
        return Y1[i] < Y1[j];
    }
    if(b1 == 1 && b2 == 1){
        return X1[i] < X1[j];
    }
    if(b1 == 2 && b2 == 2){
        return Y1[i] > Y1[j];
    }
    if(b1 == 3 && b2 == 3){
        return X1[i] > X1[j];
    }
    return b1 < b2;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    cin >> R >> C >> n;

    for(ll c1 = 0; c1 < n; c1++){
        cin >> a >> b >> c >> d;
        if(bound(a,b) != -1 && bound(c,d) != -1){
            X1.push_back(a);
            Y1.push_back(b);
            X1.push_back(c);
            Y1.push_back(d);
            A.push_back(c1);
            A.push_back(c1);
            ind.push_back(ind.size());
            ind.push_back(ind.size());
        }

    }

    sort(all(ind),comp);
    vector<ll> ST;

    for(ll c1 = 0; c1 < ind.size(); c1++){
        a = A[ind[c1]];
        //cout << a <<  "\n";
        if(ST.size() == 0){
            ST.push_back(a);
        }
        else{
            if(ST[ST.size()-1] == a){
                ST.pop_back();
            }
            else{
                ST.push_back(a);
            }
        }
    }

    if(ST.size() == 0){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }

    return 0;
}


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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x; cin >> x;
    ll mo = 100;
    ll ans = 0;
    while(mo<x){
        mo *= 1.01;
        ans++;
    }
    cout << ans << endl;
}

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

int main(int argc, char** argv)
{
	while (true)
	{
		std::string deck;
		std::cin >> deck;
		if (deck == "-")
		{
			break;
		}

		int cutTime = 0;
		std::cin >> cutTime;
		for (int i = 0; i < cutTime; ++i)
		{
			int cut = 0;
			std::cin >> cut;

			deck = deck.substr(cut) + deck.substr(0, cut);
		}

		std::cout << deck << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3160
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let cnt = s.take(n).fold(std::collections::BTreeMap::new(), |mut r, a|{
		let a = a.parse::<i32>().unwrap();
		*r.entry(a).or_insert(0) += 1;
		r
	});
	let mut ans = 0;
	for (k, v) in cnt {
		if k == v { continue; }
		if k > v { ans += v as i64; }
		else { ans += (v - k) as i64; }
	}
	println!("{}", ans);
}

Measured memory_bytes: 6396
def selection_sort(a, n):
    counter = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        if i != minj:
            counter += 1
            tmp = a[i]
            a[i] = a[minj]
            a[minj] = tmp
    return counter


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])

counter = selection_sort(a, n)
print_list_split_whitespace(a)
print(counter)


Measured memory_bytes: 5604
n,k = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]

for x in range(n, 100000):
    ans = 100000
    tmp = True
    for y in str(x):
        if int(y) in d:
            tmp = False
            break
    if tmp:
        ans = min(ans,x)
        break

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
int main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int cnt=0;
  FOR(i,0,A+1){
    FOR(j,0,B+1){
      FOR(k,0,C+1){
        if(i*500+j*100+k*50==X){
          cnt++;
        }
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}


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

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

    vector<int> a(N);
    for(int i{0}; i<N; ++i)
        cin >> a[i];

    int sum, sum_min;

    for(int j{-100}; j<=100; ++j){
        sum = 0;
        for(int i{0}; i<N; ++i){
            sum += (a[i]-j)*(a[i]-j);
        }
        if(j==-100 or sum<sum_min)
            sum_min = sum;
    }

    cout << sum_min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    ll ans = 0;
    for (ll i = 0; i < 3; i++)
    {
        if (s1[i] == s2[i]) {
            ans += 1;
        }
    }
    cout << ans << endl;
}

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

namespace AtCoder.D
{
    public class Program
    {

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var s = ReadText();

            for (int i = 0; i < 26; i++)
            {
                var alpha = (char)('a' + i);
                for (int j = 0; j < s.Length; j++)
                {
                    if (s[j] == alpha)
                    {
                        if (j + 1 < s.Length && s[j + 1] == alpha)
                        {
                            // インデックスを添え字にずらす
                            return $"{j + 1} {j + 1 + 1}";
                        }
                        if (j + 2 < s.Length && s[j + 2] == alpha)
                        {
                            // インデックスを添え字にずらす
                            return $"{j + 1} {j + 2 + 1}";

                        }
                    }
                }
            }

            return "-1 -1";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 26192
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int sum=0,A,B;
  cin >> A >> B;
  for(int i=A; i<=B; i++){
    if(i/10000 == i%10 && i/1000%10 == i/10%10){
      sum += 1;
    }
  }cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.length();i+=2){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 592
minC = 1001
N, T = input().split()
N = int(N)
T = int(T)
for i in range(N):
    c, t = input().split()
    c = int(c)
    t = int(t)
    if(t<=T):
        if(minC > c):
            minC = c
if(minC == 1001):
    print("TLE")
else:
    print(minC)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		int t=i,cnt=0;
		while(t){
			t=t/10;
			cnt++;
		}
		if(cnt%2!=0) c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n = int(input())
G1 = [0]*n
G2 = [[0]*n for i in range(n)]
d = [0]*n
f = [0]*n
for i in range(n):
    inp = tuple(map(int, input().split()))
    G1[inp[0]-1]=sorted(inp[2:])
time=0

def dfs(vertex):
    if d[vertex]:return
    global time
    time+=1
    d[vertex]=time
    for v in G1[vertex]:
        if not d[v-1]:
            dfs(v-1)
    time+=1
    f[vertex]=time
    return

for i in range(n):
    dfs(i)
for i in range(n):
    print(i+1,d[i],f[i])
    
    



Measured memory_bytes: 5808
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	cin >> s;
	if (s == "Sunny")puts("Cloudy");
	else if (s == "Cloudy")puts("Rainy");
	else puts("Sunny");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2;
  int y = y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  for (int i=0; i<2; i++) {
    swap(dx,dy);
    dx = -dx;
    x += dx;
    y += dy;
    cout << x << " " << y << " ";
  }
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


def main():
    N= int_raw()
    ps = ints_raw()
    ans =0
    for i in range(1,N-1):
        p = ps[i]
        p_sub = ps[i-1:i+2]
        if(min(p_sub)!=p and max(p_sub)!=p):
            ans+=1
    return ans

print(main())


Measured memory_bytes: 38256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var book = [(Int, String, Int)]()
var citys = [String]()
for i in 1...N {
    let input = readStringSplit(by: " ")
    book += [(i, input[0], Int(input[1])!)]
    if !citys.contains(input[0]) {
        citys += [input[0]]
    }
}
citys.sort()
book = book.sort{$0.2 > $1.2}
for s in citys {
    for i in 0..<N {
        if book[i].1 == s {
            print(book[i].0)
        }
    }
}


Measured memory_bytes: 9576
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> P;


typedef struct
{
	int head[5000];
	VI to;
	VI next;
	VI cost;
} G;

int N, K;
int C[5000], R[5000];
G road;
G taxi;
int d[5000];
int range[5000];

void SearchTaxi()
{
	for (int i = 0; i < N; i++){
		memset(range, -1, sizeof(range));
		
		range[i] = R[i];
		
		while (true){
			bool update = false;
			
			for (int i = 0; i < N; i++){
				for (int e = road.head[i]; e != -1; e = road.next[e]){
					if (range[road.to[e]] < range[i] - 1){
						range[road.to[e]] = range[i] - 1;
						update = true;
					}
				}
			}
			
			if (!update) break;
		}
		
		for (int j = 0; j < N; j++){
			if (range[j] != -1){
				taxi.next.push_back(taxi.head[i]);
				taxi.head[i] = taxi.next.size() - 1;
				taxi.to.push_back(j);
				taxi.cost.push_back(C[i]);
			}
		}
	}
}

void SearchMinCost()
{
	for (int i = 1; i < N; i++){
		d[i] = INF;
	}
	
	while (true){
		bool update = false;
		
		for (int i = 0; i < N; i++){
			for (int e = taxi.head[i]; e != -1; e = taxi.next[e]){
				if (d[i] != INF && d[taxi.to[e]] > d[i] + taxi.cost[e]){
					d[taxi.to[e]] = d[i] + taxi.cost[e];
					update = true;
				}
			}
		}
		
		if (!update) break;
	}
}

int main()
{
	memset(road.head, -1, sizeof(road.head));
	memset(taxi.head, -1, sizeof(taxi.head));
	
	scanf("%d %d", &N, &K);
	
	for (int i = 0; i < N; i++){
		scanf("%d %d", &C[i], &R[i]);
	}
	
	for (int i = 0; i < K; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		
		road.next.push_back(road.head[a]);
		road.head[a] = road.next.size() - 1;
		road.to.push_back(b);
		
		road.next.push_back(road.head[b]);
		road.head[b] = road.next.size() - 1;
		road.to.push_back(a);
	}
	
	SearchTaxi();
	SearchMinCost();
	
	printf("%d\n", d[N - 1]);
	
	return 0;
}

Measured memory_bytes: 167260
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N,K,ans=10000000000,temp;
  cin >>N>>K;
  long C[N+1],CS[N-K+1];
  for(long i = 0;i<N;i++){
    cin >>C[i];
  }
  for(long i =0;i<N-K+1;i++){
    if(abs(C[i])+abs(C[i]-C[i+K-1])>abs(C[i+K-1])+abs(C[i]-C[i+K-1])){
      temp = abs(C[i+K-1])+abs(C[i]-C[i+K-1]);
    }
    else{temp = abs(C[i])+abs(C[i]-C[i+K-1]);}
    if(ans>temp){ans = temp;}
    temp = 0;
  }
  cout << ans << endl;
  return 0;
}
    
  


Measured memory_bytes: 1024
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int A, B, C, X, ans = 0;
        cin >> A >> B >> C >> X;
        rep(i, A+1)
        {
                rep(j, B+1)
                {
                        int wa = 10 * i + 2 * j;
                        if (0 <= (X / 50 - wa) && (X / 50 - wa) <= C)
                        {
                                ans++;
                        }
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import numpy as np
# from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

#### input
# a, b, c, d = map(int, input().split())
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))
# a = list(map(lambda x: int(x)*(-1), a))  # 各要素を-1倍


# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')

#### functions
# @lru_cache(maxsize=10000)

#### process
# if em: embed()
score = 0
tmp_A = -2
for A in As:
  score = score + Bs[A - 1]
  if A == tmp_A + 1:
    score = score + Cs[tmp_A - 1]
  tmp_A = A

print(score)
## heapsort, O(logN)
# import heapq
# heapq.heapify(A)
# min = heapq.heappop(A)
# heapq.heappush(A, new_element)


Measured memory_bytes: 12504
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

//縦に見る物を横に見る

void solve() {
	int n; cin >> n;
    int ans = 0;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i];
        b[a[i] - 1] = i;
    }
    set<int> se;
    se.insert(-1);
    se.insert(n);
    rep(j, n) {
        int x = b[j];
        int ma = *se.upper_bound(x);
        auto ite = se.upper_bound(x);
        --ite;
        int mi = *ite;
        ans += (j + 1) * ((ma - x - 1) * (x - mi - 1) + (ma - x - 1) + (x - mi - 1) + 1);
        se.insert(x);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 12800
N = int(input())
line = list(input())
rw = {"R": [], "W": []}
ans = N


def replace(c):
    left = -1
    right = len(rw["R"])
    while right - left > 1:
        idx = (right + left) // 2
        if rw["R"][idx] > c:
            right = idx
        else:
            left = idx
    req = len(rw["R"]) - right
    return req


for cnt, i in enumerate(line):
    if i == "R":
        if len(rw["R"]) == 0:
            rw["R"] = [cnt]
        else:
            rw["R"].append(cnt)
    else:
        if len(rw["W"]) == 0:
            rw["W"] = [cnt]
        else:
            rw["W"].append(cnt)
ans = min(len(rw["R"]), len(rw["W"]))
ans = min(ans, replace(len(rw["R"])-1))
print(ans)


Measured memory_bytes: 18684
#include<algorithm>
#include<cmath>
#include<functional> //sortのgreater
#include<iostream>
#include<numeric> //iota(整数列の生成),gcdとlcm(c++17)
#include<string> //文字列
#include<vector>

using namespace std;
typedef long long ll;

int main()
{
    // Input
    int a, b;
    cin >> a >> b;

    if (a <= b) {
        cout << "unsafe";
    } else {
        cout << "safe";
    }

    return 0;
}


Measured memory_bytes: 3104
n = int(input())
A = [int(a) for a in input().split()]

pos = [-1]*n
for i in range(n+1):
    if pos[A[i]-1] >= 0:
        idx1 = pos[A[i]-1]
        idx2 = i
        break
    pos[A[i]-1] = i

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 2 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = [0]*(n+2)
for k in range(1, n+2):
    ans[k] = cmb(n+1, k, mod)
    

print(n)
for k in range(2, n+2):
    c = cmb(idx1+n-idx2, k-1, mod)
    print((ans[k]-c)%mod)

Measured memory_bytes: 29628
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 19:45:18 2020

@author: harsh
"""

#%%
import math
x=int(input())
rate=100
i=1
while(True):
    if(rate>=x):
        print(i-1)
        break
    else:
        rate=int(rate*1.01)
        i+=1
#print((math.log(x/100))/(math.log(1.01)))


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] != s[n-1-i]) {
            cout << "No\n";
            return 0;
        }
    }

    string t = s.substr(0, (n-1)/2);
    string t1 = t;
    reverse(t1.begin(), t1.end());

    string t2 = s.substr((n+3)/2-1);
    string t3 = t2;
    reverse(t3.begin(), t3.end());
    
    

    if (t2 != t3 || t != t1) cout << "No\n";
    else cout << "Yes\n";
    
    return 0;
}



Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import product
def I(): return [int(iI) for iI in input().split()]
n,m=I() ; a=[]
for i in range(m):
    a.append(I()[1:])
p=I()
l=[list(p) for p in product([0,1], repeat=n)]
ans=0
for i in l:
    flag=0
    for j in range(len(a)):
        s=0
        for k in a[j]:
            if i[k-1]==1: s+=1
        if s%2!=p[j]%2:
            flag=1
            break
    if flag==0:
        ans+=1
print(ans)
            
            
    

Measured memory_bytes: 40944
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N, H;
	cin >> H >> N;
	vll A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}


	ll total = 0;
	for (int i = 0; i < N; i++) {
		total += A[i];
	}


	if (total >= H) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}


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

int main(){
  int num[12] =  {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int a, b;
  cin >> a >> b;
  cout << (num[a-1] == num[b-1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		pr.println(Math.max(a + b, Math.max(a + a - 1, b + b - 1)));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<int, int>> vp(n);
	vector<int> h(n);
	rep(i, n){
		int x, y, ht;
		cin >> x >> y >> ht;
		vp.at(i) = make_pair(x, y);
		h.at(i) = ht;
	}
	int gh, gx, gy;
	gh = gx = gy = -1;
	rep(i, n){
		if(h.at(i) != 0){
			gh = h.at(i);
			gx = vp.at(i).first;
			gy = vp.at(i).second;
			break;
		}
	}
	rep(i, 101){
		rep(j, 101){
			int ah = gh + fabs(gx - i) + fabs(gy - j);
			bool flag = true;
			rep(k, n){
				int dh = fabs(vp.at(k).first - i) + fabs(vp.at(k).second - j);
				int hk = ah - dh;
				hk = max(hk, 0);
				if(hk != h[k]){
					flag = false;
					break;
				}
			}
			if(flag == true){
				cout << i << " " << j << " " << ah << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256