akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
pm = 0
ans = 1

for i in range(N - 1):
    if pm == 0:
        if A[i + 1] > A[i]:
            pm = 1
        elif A[i + 1] == A[i]:
            pm = 0
        else:
            pm = -1
    elif pm == 1:
        if A[i + 1] < A[i]:
            ans += 1
            pm = 0
    else:
        if A[i + 1] > A[i]:
            ans += 1
            pm = 0

print(ans)

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

	string ans = "Yes";
	rep(i, S.size()) {
		if( ((i%2==1) && (S[i]=='R')) || ((i%2==0) && (S[i]=='L')) ){
            ans = "No";
        }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main()  {
	var input int

	fmt.Scan(&input)

	var n int

	n = input - (input / 10) * 10

	if n == 3 {
		fmt.Println("bon")
	} else if n == 0 || n == 1 || n == 6 || n == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

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

ll n, m;
vector <ll> adjlist[200010];

int main() {
	cin>>n>>m;
	ll x, y;
	set < pair<ll, ll> > s;
	for (int i=0; i<m; i++) {
		cin>>x>>y;
		if (x>y) swap(x, y);
		if (s.count(make_pair(x, y))==0) {
			adjlist[x].push_back(y);
			adjlist[y].push_back(x);
			s.insert(make_pair(x, y));
		}
	}
	ll ans=0, temp=0;
	bool vis[n+1];
	memset(vis, 0, sizeof(vis));
	for (int i=1; i<=n; i++) {
		if (!vis[i]) {
			ans=max(temp, ans);
			temp=0;
			queue <ll> q;
			vis[i]=1;
			q.push(i);
			while (!q.empty()) {
				temp++;
				for (auto j: adjlist[q.front()]) {
					if (!vis[j]) {
						vis[j]=1;
						q.push(j);
					}
				}
				q.pop();
			}
		}
	}
	ans=max(temp, ans);
	cout<<ans<<endl;
}

Measured memory_bytes: 30192
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    
    int N;
    cin >> N;
    
    long long A[N+2];
    A[0]=0;
    A[N+1]=0;
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    
    long long sum=0;
    int now=0;
    
    for(int i=1; i<=N+1; i++){
        sum+=abs(now-A[i]);
        now=A[i];
    }
    
    
    
    for(int i=1; i<=N; i++){
        long long cost;
        
        if((A[i-1]<=A[i] && A[i]<=A[i+1]) || (A[i+1]<=A[i] && A[i]<=A[i-1])){
            cost=sum;
        }
        
        else if(A[i]<=A[i-1] && A[i]<=A[i+1]){
            cost=sum- (min(A[i-1],A[i+1])-A[i]) *2 ;
        }
        
        else if(A[i+1]<=A[i] && A[i-1]<=A[i]){
            cost=sum- (A[i]-max(A[i-1],A[i+1]))*2 ;
        }
        
        cout<<cost<<endl;
    }
    
    return 0;
}


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

int main(){
    int n, a, i;
    cin >> n;
    vector<int> v;
    map<int, int> m;
    for(i = 1; i <= n; i++){
        cin >> a;
        m[a] = i;
    }

    cout << m[1];
    for(i = 2; i <= n; i++){
        cout << " " << m[i];
    }
    cout << endl;
}

Measured memory_bytes: 5504
//インスパイアされていこう
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[200001], P1[200001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}
int Find1(int A) {
	if (P1[A] < 0) return A;
	return P1[A] = Find1(P1[A]);
}

int to[100001], ne[100001], he[200001];
int cnt[200001];
void sagasu(int v) {
	cnt[Find1(v)]++;
	for (int i = he[v]; i; i = ne[i]) {
		cnt[Find1(to[i])]++;
	}
	P[v] = cnt[Find1(v)];
	for (int i = he[v]; i; i = ne[i]) {
		P[to[i]] = cnt[Find1(to[i])];
	}
	cnt[Find1(v)] = 0;
	for (int i = he[v]; i; i = ne[i]) {
		cnt[Find1(to[i])] = 0;
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint(), K = getint(), L = getint();
	rep1(i, N) {
		P[i] = -1;
		P1[i] = -1;
	}
	rep(i, K) {
		int p = getint(), q = getint();
		p = Find(p);
		q = Find(q);
		if (p != q) {
			if (P[p] > P[q]) swap(p, q);
			P[p] += P[q];
			P[q] = p;
		}
	}

	int k = 1;
	rep1(i, N) {
		if (P[i] >= 0) {
			to[k] = i;
			ne[k] = he[Find(i)];
			he[Find(i)] = k++;
		}
	}

	rep(i, L) {
		int p = getint(), q = getint();
		p = Find1(p);
		q = Find1(q);
		if (p != q) {
			if (P1[p] > P1[q]) swap(p, q);
			P1[p] += P1[q];
			P1[q] = p;
		}
	}

	rep1(i, N) if (P[i] < 0) sagasu(i);
	rep1(i, N) putint(P[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5120
N = int(input())
s = "0" + str(N)
n = len(str(N))
K = int(input())

dp = [[[0] * (K+2) for _ in range(2)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(1, n + 1):
    for k in range(K + 1):
        num = int(s[i])
        if num == 0:
            dp[i][0][k] += dp[i-1][0][k]
        else:
            dp[i][0][k] += dp[i-1][0][k-1]
            dp[i][1][k] += dp[i-1][0][k-1] * (num-1)
            dp[i][1][k] += dp[i-1][0][k]

        dp[i][1][k] += 9 * dp[i-1][1][k-1]
        dp[i][1][k] += dp[i-1][1][k]

print(dp[n][0][K] + dp[n][1][K])

Measured memory_bytes: 62104
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().split())
S = readline().decode('utf8').rstrip()
T=S[:A]+S[A+1:]
bl = S[A] == '-' and T.find('-')==-1
print('Yes' if bl else 'No')


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a,b,tmp;
    scanf("%d%d",&a,&b);
    tmp=a*b;
    if(tmp%2==1 || (tmp*3)%2==1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

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

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;

/** Problem0587 : Tunnel **/
int main()
{
	int n, num, max=0;
	
	cin >> n;
	cin >> num;
	max = num;
	rep(k, n) {
		int in, out;
		cin >> in >> out;
		num += in;
		num -= out;
		if (num > max)
			max = num;
		else if (num < 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>

int main(void){
	int w, h, n, i;
	int x[1000], y[1000];
	int now=0;
	long ans=0;

	scanf(" %d %d %d", &w, &h, &n);
	for(i=0; i<n; i++) scanf(" %d %d", &x[i], &y[i]);
	
	int nx=x[0], ny=y[0];
	
	while(now<n-1){
		if(x[now+1] > nx && y[now+1] > ny){
			while(x[now+1] != nx && y[now+1] != ny){
				++nx;
				++ny;
				++ans;
			}
			
			if(x[now+1] == nx){
				while(y[now+1] != ny) {
					++ny;
					++ans;
				}
			}
			else if(y[now+1] == ny){
				while(x[now+1] != nx) {
					++nx;
					++ans;
				}
			}	
		}
		else if(x[now+1] < nx && y[now+1] < ny){
			while(x[now+1] != nx && y[now+1] != ny){
				--nx;
				--ny;
				++ans;
			}
			
			if(x[now+1] == nx){
				while(y[now+1] != ny) {
					--ny;
					++ans;
				}
			}
			else if(y[now+1] == ny){
				while(x[now+1] != nx) {
					--nx;
					++ans;
				}
			}	
		}
		else{
			ans += fabs(nx-x[now+1]) + fabs(ny-y[now+1]);
			nx = x[now+1];
			ny = y[now+1];
		}
	
		now++;
		//printf("%d %d, %ld\n", nx, ny, ans);
	}
	
	printf("%ld\n", ans);

	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

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

  vec h(n);
  rep(i,n){
    cin >> h[i];
  }

  int ans=0;
  int temp=0;

  rep(i,n){
    if(temp<=h[i]){
      ans++;
      temp = h[i];
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
program sample
	implicit none
    integer :: N,i,count1,count2,a
    integer, allocatable :: x(:)
    
    read(*,*) N
    
    allocate(x(N))
    

  	read(*,*) x
    
    count1 = 3**N
    count2 = 1
    
    
    do i=1,N
    	if (mod(x(i),2) == 0) then
        	count2 = count2 * 2
        else
        	count2 = count2 * 1
     	end if
   	end do
    
    write(*,*) count1 - count2
    
    deallocate(x)
    
    stop
end program sample

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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];

            var As = new int[M];
            var Bs = new int[M];
            var conns = new Dictionary<int, List<int>>();
            //var depth = new Dictionary<int, List<int>>(); // key = depth, value = list of room num;
            //depth.Add(0, new List<int>() { 1 });

            for (int i = 0; i < M; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                As[i] = read[0];
                Bs[i] = read[1];

                if (!conns.ContainsKey(As[i]))
                    conns[As[i]] = new List<int>() { Bs[i] };
                else
                    conns[As[i]].Add(Bs[i]);

                if (!conns.ContainsKey(Bs[i]))
                    conns[Bs[i]] = new List<int>() { As[i] };
                else
                    conns[Bs[i]].Add(As[i]);

            }


            var depth = Enumerable.Repeat<int>(-1, N + 1).ToArray();
            var que = new Queue<int>();
            var res = new int[N + 1];

            que.Enqueue(1);
            depth[1] = 0;

            while(que.Count() > 0)
            {
                var nowPoint = que.Dequeue();
                foreach(var nextPoint in conns[nowPoint])
                {
                    if (depth[nextPoint] != -1) continue;
                    res[nextPoint] = nowPoint;
                    depth[nextPoint] = depth[nowPoint] + 1;
                    que.Enqueue(nextPoint);
                }
            }

            Console.WriteLine("Yes");
            for (int i = 2; i < N + 1; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}


//var roomList = Enumerable.Range(2, N - 1).ToList();
//var depthTemp = 1;
//while (roomList.Count() > 0)
//{
//    depth.Add(depthTemp, new List<int>());
//    foreach (var room in roomList)
//    {
//        if (depth[depthTemp - 1].Any(x => conns[room].Contains(x)))
//        {
//            depth[depthTemp].Add(room);
//            roomList.Remove(room);
//        }
//    }
//    depthTemp++;
//}

//for (int i = 1; i <= depth.Keys.Max(); i++)
//{

//}

//var thisNums = new List<int>() { 1 };
//var nextNums = new List<int>() { };
//var detedRooms = new List<int>() { 1 };
//var res = new Dictionary<int, int>();
//while (detedRooms.Count() < N - 1)
//{
//    nextNums = new List<int>();
//    foreach(var room in thisNums)
//    {
//        if(conns.Keys.Contains(room))
//        {
//            foreach (var r in conns[room].Where(x => !detedRooms.Contains(x)))
//            {
//                detedRooms.Add(r);
//                res[r] = room;
//                nextNums.Add(r);
//            }
//        }
//    }
//    thisNums = nextNums.ToList();
//}


Measured memory_bytes: 58284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2][100010],d[100010],INF=1<<29;
vector<ll> v[100010];
ll n,m,s,t;

void bfs(ll s,ll k) {
  fill(d,d+n+1,INF);
  d[s]=0;
  c[k][0]++;
  queue<ll> que;
  que.push(s);
  while(!que.empty()) {
    ll x=que.front();que.pop();
    for(int i=0; i<v[x].size(); i++) {
      ll y=v[x][i];
      if(d[y]<=d[x]+1) continue;
      d[y]=d[x]+1;
      c[k][d[y]]++;
      que.push(y);
    }
  }
}
  

int main() {
  cin >> n >> m >> s >> t;
  for(ll i=0; i<m; i++) {
    ll x,y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  memset(c,0,sizeof(c));
  bfs(s,0);
  bfs(t,1);
  ll z=d[s],ans=0;
  for(ll i=0; i<z-1; i++) ans+=c[0][i]*c[1][z-i-2];
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 3044
fun main(args: Array<String>) {
    abc064a()
}

fun abc064a() {
    val (r, g, b) = readLine()!!.split(" ").map { it.toInt() }

    val answer = if ((r * 100 + g * 10 + b) % 4 == 0) "YES" else "NO"

    println(answer)
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<vector<vector<lli>>> cube;
typedef vector<unordered_map<lli,lli>> graph;

lli v,e;
graph g;
vll visit;
lli f;
lli s,t;
lli ans;

lli bfs(){
  queue<vll> q;
  q.push(vll({s,-1,LONG_MAX}));
  visit = vll(v,-1);
  while(!q.empty()){
    vll x = q.front();
    q.pop();
    if(visit[x[0]] >= 0) continue;
    visit[x[0]] = x[1];
    if(x[0] == t) return x[2];
    for(auto itr = g[x[0]].begin();itr != g[x[0]].end();itr++){
      if(visit[itr->first] < 0 && itr->second > 0)
        q.push(vll({itr->first,x[0],min(itr->second,x[2])}));
    }
  }
  return -1;
}

int main(){
  cin >> v >> e;
  t = v-1;s = 0;
  g = graph(v);
  for(lli i = 0;i < e;i++){
    lli u,v,c;
    cin >> u >> v >> c;
    g[u][v] = c;
    g[v][u] = 0;
  }
  while(true){
    lli f = bfs();
    if(f < 0) break;
    ans += f;
    lli x = t;
    while(x != 0){
      lli y = visit[x];
      g[y][x] -= f;
      g[x][y] += f;
      x = y;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

int main(int argc, char const *argv[])
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  
  X -= Z;
  
  cout << X / (Y + Z) << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
MOD = 10**9+7
ans = 0
def wa(s,e):
  return int((0.5)*e*(e+1) - (0.5)*(e-s)*(e-s+1))
for i in range(k,n+1):
  ans += (wa(i,n) - wa(i,i-1) + 1)%MOD
ans += 1
print(ans%MOD)


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

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

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();

int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    ll ans= 0;
    for(int i=1; i<=n; i++){
        if(isOdd(numOfDigits(i)))ans++;
    }
    cout<<ans;
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ull POW(ll a, ll b) {
	ull res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N);
  int ret = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) {
      // cerr << a[i] << endl;
      a[i] /= 2;
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    #pragma GCC target("sse,sse2,avx,avx2,popcnt,tune=native")
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(auto i=x;i<=y;i++)
    #define Fdr(i,x,y) for(auto i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 1003
int main(){
    int a,b;in>>a>>b;
    out<<MAX(MAX(a*2-1,b*2-1),a+b)<<ln;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    h, w, m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range(m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi, wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index, hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)

    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()

    print(ans - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 166580
n = int(input())
n_str = str(n)
num = len(n_str)
hikaku = int(str(n_str[0]) + str(9)*(num-1))
atai = int(int(n_str[0]) + int(9)*(num-1))
if n >= hikaku:
    print(atai)
else:
    print(atai-1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int n,m;
    cin>>n>>m;
    vector<bitset<12>> c(m);
    map<vector<int>,int> p;
    vector<int> a(m),b(m);
    rep(i,m){
        bitset<12> s(0);
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            int C;    
            cin>>C;
            C--;
            //c[i].push_back(C);
            s.set(C,1);
        }
        c[i]=s;
    }
    rep(i,m){
        //cout<<c[i]<<endl;
    }
    int k=pow(2,n);
    vector<vector<int>> dp(m+1,vector<int> (k+1,1e9));
    rep(i,m+1){
    dp[i][0]=0;
    }
    for(int i=1;i<=m;i++){
        rep(j,k){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            bitset<12> bi(j);
            //cout<<bi<<"|"<<c[i]<<" ";
            dp[i][(bi|c[i-1]).to_ullong()] = min(dp[i][(bi|c[i-1]).to_ullong()],(min(dp[i-1][(bi|c[i-1]).to_ullong()],dp[i-1][j] + a[i-1]))); 
            //cout<<"dp["<<i<<"]["<<(bi|c[i-1]).to_ullong()<<"]="<<dp[i][(bi|c[i-1]).to_ullong()]<<endl;
        }
    }/*
    rep(i,m+1){
        rep(j,k){
            if(dp[i][j]==1e9){
                cout<<"N"<<" ";
            }
            else{
                cout<<dp[i][j]<<" ";
            }
        }
        cout<<endl;
    }*/
    if(dp[m][k-1]==1e9){
        cout<<-1<<endl;
        return 0;
    }
    cout<<dp[m][k-1]<<endl;
}

Measured memory_bytes: 16384
from sys import stdin

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(str,stdin.readline().rstrip().split()))

for i in range(n,99999):
    yen = str(i)
    frag = 0
    for j in yen:
        if j in li:
            frag = 1
    if frag == 0:
        print(yen)
        exit()

Measured memory_bytes: 3060
import * as readline from 'readline';
const rl = readline.createInterface(process.stdin, process.stdout);

let line = 0;
let n: number;
let k: number;
let s: boolean[] = [];

rl.on("line", input => {
  line++;
  if (line === 1) {
    const ary = input.split(/\s+/).map(val=>parseInt(val));
    n = ary[0];
    k = ary[1];
  } else {
    const ss = input as string;
    s.length = ss.length;
    for (let i = 0; i < ss.length; i++) {
      s[i] = (ss.charAt(i) === 'L');
    }
    let x = _count(s) + k*2;
    if (x > n - 1) x = n - 1;
    console.log(x);
  }
});

function _count(s: boolean[]): number {
  let x = 0;
  for (let i = 0; i < s.length-1; i++) {
    if (s[i] === s[i+1]) x++;
  }
  return x;
}

Measured memory_bytes: 8652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            foreach(var i in Enumerable.Range(0, 10))
            {

            }*/
            var a =int.Parse(Console.ReadLine());
            Console.WriteLine(a * a * a);
        }
    }
}

Measured memory_bytes: 9152
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from fractions import Fraction

c = [0]*4
for i in range(3):
    a, b = map(int, input().split())
    c[a-1] += 1
    c[b-1] += 1
for i in range(4):
    if c[i] > 2:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 66156
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int t;
	t=a-1;
	if(b>=a)
		t++;
	cout<<t<<endl;	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int > A(N), B(N);
  vector<pair<int, int> > C(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A.at(i) >> B.at(i);
    C.at(i) = make_pair(B.at(i), A.at(i));
  }
  sort(C.begin(), C.end());

  int time = 0;
  bool task = true;
  for ( int i = 0; i < N; i++ ) {
    // cout << C.at(i).first << " " << C.at(i).second << endl;
    time += C.at(i).second;
    if ( C.at(i).first < time ) {
      task = false;
      break;
    }
  }
  if ( task ) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#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(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

//繰り返し2乗法を用いたべき乗.x^nを返す.
long long int pow(long long int x,long long int n){
	long long int res = 1;
	while (n)
	{
		if (n&1){
			res *= x;
		}
		n >>= 1;
		x = x * x;
	}
	return res;
}

//素因数分解をする関数.
map<long long int, int>prime_factorization(long long int a) {
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}
//オイラーのファイ関数.1からnまででnと互いに素のものを返す.
int totient(long long int n){
	map<long long int, int> a = prime_factorization(n);
	for (auto x:a)
	{
		n = n / x.first * (x.first - 1);
	}
	return n;
}

int main(){
	int n;
	cin >> n;
	cout << totient(n) << endl;

	return 0;
}




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

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	vector<P> x(M);
	for (int i = 0; i < M; ++i) {
		ll b, c;
		cin >> b >> c;
		x[i] = P(c, b);
	}
	sort(x.rbegin(), x.rend());

	deque<ll> que;
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < x[i].second; ++j) {
			que.push_front(x[i].first);
			if (que.size() >= N) { break; }
		}
		if (que.size() >= N) { break; }
	}


	sort(a.rbegin(), a.rend());
	int idx = 0;
	while ((que.size() < N) && (idx < N)) {
		que.push_back(a[idx]);
		++idx;
	}

	for (int i = idx; i < N; ++i) {
		if (a[i] > que.front()) {
			que.pop_front();
			que.push_back(a[i]);
		} else {
			break;
		}
	}

	ll res = 0;
	while (!que.empty()) {
		res += que.front();
		que.pop_front();
	}

	cout << res << endl;

	return 0;
}


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

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


Measured memory_bytes: 256
deck={"S":[0]*13,"H":[0]*13,"C":[0]*13,"D":[0],"D":[0]*13}
n=input()

for i in range(0,n):
	suit, num=raw_input().split()
	deck[suit][int(num)-1]=1

for i in ["S","H","C","D"]:
	for j in range(0,13):
		if (deck[i][j]==0):
			print "%s %d" %(i,j+1)

Measured memory_bytes: 6360
n = int(input())
a = list(map(int, input().split()))
b = [0,0,0]
for i in a:
  if i % 4 == 0:
    b[2] += 1
  elif i % 2 == 0:
    b[1] += 1
  else:
    b[0] += 1
if b[1] > 0:
  if b[2] >= b[0]:
    print("Yes")
  else:
    print("No")
else:
  if b[2] + 1 >= b[0]:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(b<=c||d<=a){
        printf("0\n");
        return 0;
    }
    if(a<=c&&d<=b){
        printf("%d\n",d-c);
        return 0;
    }
    if(a>=c&&d>=b){
        printf("%d\n",b-a);
        return 0;
    }
    if(a<c){
        printf("%d\n",b-c);
        return 0;
    }
    else{
        printf("%d\n",d-a);
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#define ll long long
using namespace std;

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int diffs = 0;
	for (int i = 0; i < s1.length(); i++) {
		if (s1[i] != s2[i]) {
			diffs++;
		}
	}
	cout << diffs;
}

Measured memory_bytes: 3524
count_val = 1
list1 = []
while True:
    input_x, input_y = list(map(int, input().split()))
    if input_x == input_y == 0:
        break
    else:
        list1.append(input_x)
        list1.append(input_y)
        joined_list1 = " ".join(map(str, sorted(list1)))
        print(joined_list1)
        del list1[:]
exit()


Measured memory_bytes: 5616
#include <stdio.h>

int main(void)
{
	long long K,N,min,a;
	scanf("%lld",&N);
	scanf("%lld",&K);
	min=N%K;
	for(;;){
		if(min-K>0)a=min-K;
		else a=K-min;
		if(a>=min)break;
		else min=a;
	}
	printf("%lld",min);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Hs = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(1, N - 1):
        a = Hs[i - 1]
        b = Hs[i]
        c = Hs[i + 1]
        if a + 1 <= b:
            Hs[i] -= 1
            b = Hs[i]
        if a <= b <= c:
            pass
        else:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <cstdio>
#include <queue>
#include <map>

using namespace std;

const int table[6][6] = {
  {0, 3, 5, 2, 4, 0},
  {4, 0, 1, 6, 0, 3},
  {2, 6, 0, 0, 1, 5},
  {5, 1, 0, 0, 6, 2},
  {3, 0, 6, 1, 0, 4},
  {0, 4, 2, 5, 3, 0},
};

struct Dice {
  int top, front, side;
  Dice(){}
  Dice(int top, int front) : top(top), front(front) {
    side = table[top - 1][front - 1];
  }
  Dice(const Dice& dice) : top(dice.top), front(dice.front), side(dice.side) {}
  void set(int t, int f, int s){
    top = t;
    front = f;
    side = s;
  }
  void rotate(int x){
    x %= 4;
    if (x == 0) set(7 - front, top, side);
    if (x == 1) set(7 - side, front, top);
    if (x == 2) set(front, 7 - top, side);
    if (x == 3) set(side, front, 7 - top);
  }
  int at(int x){
    if (x == 0) return front;
    if (x == 1) return side;
    if (x == 2) return 7 - front;
    if (x == 3) return 7 - side;
  }
};

inline int in(){ int x; scanf("%d", &x); return x; }

struct Info {
  int depth, x, y;
  Info(int depth, int x, int y) : depth(depth), x(x), y(y) {}
  bool operator<(const Info& a) const {
    if (depth != a.depth) return depth < a.depth;
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
};

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

struct Simulator {
  map<Info, Dice> field;
  void fall(Dice& dice, Info info){
    while (info.depth > 0){
      if (field.count(Info(info.depth - 1, info.x, info.y))){
        rotate(dice, info);
        return;
      }
      info.depth -= 1;
    }
    field[info] = dice;
  }

  void rotate(Dice& dice, Info info){
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < 4; i++){
      if (dice.at(i) < 4) continue;
      Info nxt = info;
      nxt.x += dx[i];
      nxt.y += dy[i];
      nxt.depth -= 1;
      if (field.count(nxt)) continue;
      pq.push(make_pair(dice.at(i), i));
    }

    if (pq.empty()) {
      field[info] = dice;
    }
    else {
      int d = pq.top().second;
      dice.rotate(d);
      fall(dice, Info(info.depth - 1, info.x + dx[d], info.y + dy[d]));
    }
  }
};

int main()
{
  int n;
  while (n = in()){
    Simulator sim;
    for (int i = 0; i < n; i++){
      int t = in(), f = in();
      Dice dice(t, f);
      Info info(101, 0, 0);
      sim.fall(dice, info);
    }
    int bucket[8] = {};
    for (auto& kv : sim.field){
      Info over(kv.first.depth + 1, kv.first.x, kv.first.y);
      if (sim.field.count(over)) continue;
      bucket[kv.second.top]++;
    }
    for (int i = 1; i <= 6; i++){
      printf("%d%c", bucket[i], " \n"[i == 6]);
    }
  }
  return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
#define M 55
#define ll long long
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),!isdigit(c));
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),isdigit(c));
}
int a[M];
ll dp[2][2];
int main(){
	int n,p;
	scanf("%d %d",&n,&p);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int cur=0;dp[cur][0]=1;
	for(int i=1;i<=n;i++){
		cur=!cur;
		dp[cur][0]=dp[cur][1]=0;
		dp[cur][a[i]&1]=dp[!cur][a[i]&1]+dp[!cur][0];
		dp[cur][(a[i]+1)&1]=dp[!cur][(a[i]+1)&1]+dp[!cur][1];
	}
	cout<<dp[cur][p]<<'\n';
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.length();
    int ans0 = 0;
    int ans1 = 0;
    REP(i,l){
        int c = s[i]-(int)'0';
        if(i%2==c){
            ans0++;
        }
    }
    REP(i,l){
        int c = s[i]-(int)'0';
        if(i%2!=c){
            ans1++;
        }
    }
    cout << min(ans0,ans1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int sum[20], a[20][20],n,m,k,c[20];
int mini;
void check(int t) {
	for (int i = 0; i < m; i++) {
		if (sum[i] < k) return;
	}
	if (t < mini) mini = t;
}
void work(int dep,int t) {
	if (t > mini) return;
	if (dep >= n) {
		check(t); return;
	}
	for (int i = 0; i < m; i++)
		sum[i] += a[dep][i];
	work(dep + 1, t + c[dep]);
	for (int i = 0; i < m; i++)
		sum[i] -= a[dep][i];
	work(dep + 1, t);
}
int main() {
	mini= 2147483647;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}

	work(0,0);
	if (mini == 2147483647) cout << -1 << endl; else  cout << mini<< endl;
	return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


long long int value(string str, int b, int e) {
	string str1;
	str1 = str.substr(b, e - b);
	return stoll(str1);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	

	long long int X;
	double money = 100;
	cin >> X;
	int i = 1;
	while (true) {
		money = floor(money * 1.01);
		if (money >= X) {
			cout << i;
			break;
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
typedef long long ll;
int n, a[maxn];
int main()
{
    cin >> n;
    int ans = 0;
    for (int i =1 ; i <= n; i++) {
        cin >> a[i];
        if((i&1) && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF (ll)(1e18)
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s; 
	int a = 0 , b = 0 , c = 0 , d = 0;
	rep(i , s.size()) {
		if (s[i] == 'N')
			a++;
		else if (s[i] == 'S')
			b++;
		else if (s[i] == 'E')
			c++;
		else
			d++;
	}

	if (min(a , b) == 0 && max(a , b) != 0)
		cout << "No\n";
	else if (min(c , d) == 0 && max(c , d) != 0)
		cout << "No\n";
	else
		cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 256
A = [[int(i) for i in input().split()] for i in range(3)]

count = 0
for i in range(2):
    if A[i][0] - A[i + 1][0] == A[i][1] - A[i + 1][1] == A[i][2] - A[i + 1][2]:
        count += 1
        
if count == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
from functools import reduce
import numpy as np


def _gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd(*n):
    return reduce(_gcd, n)


def my_bisect(x):

    def find_pos(left, right):
        return left + (right - left - 1) // 2

    def func(left, right, prev):
        if right - left == 1:
            return left
        pos = find_pos(left, right)
        g1 = gcd(*x[left:pos+1])
        g2 = gcd(*x[pos+1:right])
        if prev is not None:
            g1, g2 = gcd(g1, prev), gcd(g2, prev)
        if g1 < g2:
            return func(left, pos + 1, max(g1, g2))
        else:
            return func(pos + 1, right, max(g1, g2))
    return func(0, len(x), None)


N = int(input())
A = list(map(int, input().split()))
print(gcd(*np.delete(A, my_bisect(A))))



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

const int MOD = 1e9 + 7;


LL inv(LL a) {
  LL ans = 1;
  for (LL cur = a, p = MOD - 2; p; cur = cur * cur % MOD, p >>= 1) 
    if (p&1) ans = cur * ans % MOD;
  return ans;
}






int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  LL N, M, K;
  cin >> N >> M >> K;
  LL average = 0;
  for (auto n : {M, N}) {
    auto m = (n == M ? N : M);
    LL partial = 0;
    for (LL a = 0; a < n; ++a) {
      (partial += a * (a + 1) / 2 + (n - a) * (n - a - 1) / 2) %= MOD;
    }
    partial = partial * m % MOD;
    partial = partial * inv(N * M - 1) % MOD * inv(n);
    average = (average + partial) % MOD;
  }
  LL C = 1;
  for (LL u = N * M, l = K; l; --u, --l) {
    C = C * u % MOD * inv(l) % MOD;
  }
  cout << C * average % MOD * (K - 1) % MOD * K % MOD * inv(2) % MOD << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int N, K;
	int index;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp == 1)
			index = i;
	}

	int ans = ceil((double)(index) / (K - 1)) + ceil((double)(N - index - 1) / (K - 1));

	if ((index % (K - 1) != 0 && (index % (K - 1) <= (K - 1)*ceil((double)(N - index - 1) / (K - 1)) - (N - 1 - index)))
		|| ((N - index - 1) % (K - 1) != 0 && ((N - index - 1) % (K - 1) <= (K - 1)* ceil((double)(index) / (K - 1)) - index)))ans--;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC93();
}

void ABC93(){
    string a;
    int i,k=0,l=0,m=0;
    cin>>a;
    for(i=0;i<=2;++i){
        if(a[i]=='a')k++;
        if(a[i]=='b')l++;
        if(a[i]=='c')m++;
    }
    if(k==1&&l==1&&m==1)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,q;
  cin>>n>>m>>q;
  vector<vector<int>>end(n,vector<int>(n,0));
  rep(i,m)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    end[a][b]++;
  }
  for(int i=n-1;i>0;i--)
  {
    rep(j,n)
    {
      end[i-1][j]+=end[i][j];
    }
  }
  rep(i,n)
  {
    rep(j,n-1)
    {
      end[i][j+1]+=end[i][j];
    }
  }
  rep(i,q)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    cout<<end[a][b]<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 1920
class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  MOD = 10 ** 9 + 7

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |i|
      @fac[i] = fac[i - 1] * i % mod
      @inv[i] = mod - inv[mod % i] * (mod / i) % mod
      @finv[i] = finv[i - 1] * inv[i] % mod
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end

  def permutation(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[n - k] % mod) % mod
  end
end

MOD = 10 ** 9 + 7
N, M = gets.split.map(&:to_i)
mc = ModCombination.new(M + 10)

n = 1
ans = 0

0.upto(N) do |c|
  ans += mc.combination(N, c) * n * mc.permutation(M, c) * (mc.permutation(M - c, N - c) ** 2)
  ans %= MOD

  n *= -1
end

puts ans


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

int main()
{
	int N = 0;
	cin >> N;

	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	if (find(A.begin(), A.end(), 0) != A.end()) {
		cout << 0 << endl;
		return 0;
	}

	long long total = A.at(0);
	for (int i = 1; i < N; i++) {
		if (total <= 1000000000000000000 / A.at(i)) {
			total *= A.at(i);
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << total << endl;
	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int k;cin>>k;
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a[k-1]<<endl;

}


Measured memory_bytes: 256