akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc050/tasks/arc066_a
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int MOD = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) {
        int t;
        cin >> t;
        v[t]++;
    }
    bool flag = true;
    if (n % 2 == 1) {
        if (v[0] != 1) {
            flag = false;
        }
        for (int i = 2; i < n; i += 2) {
            if (v[i] != 2) {
                flag = false;
                break;
            }
        }
    } else {
        for (int i = 1; i < n; i += 2) {
            if (v[i] != 2) {
                flag = false;
                break;
            }
        }
    }
    if (flag) {
        int t = 1;
        REP(i, n / 2) {
            t *= 2;
            t %= MOD;
        }
        cout << t << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
s = input()
k = 'abcdefghijklmnopqrstuvwxyz'
if len(s) < 26:
  for v in k:
    if not v in s:
      print(s+v)
      exit()
if s == k[::-1]:
  print(-1)
  exit()
for i in range(1,len(s)+1):
  t = s[-i:]
  if t != ''.join(sorted(t, reverse=True)):
    t = t[1:]
    break
for p in t[::-1]:
  if p > s[-i]:
    print(s[:-i]+p)
    exit()

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-25 13:57:00 +0900
# LastModified: 2020-06-25 14:12:29 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    count = 0
    for _ in range(n):
        a = list(map(int, input().split()))
        total = sum(a[i]*b[i] for i in range(m))+c
        if total>0:
            count+=1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    cin>>n;
    int m = 0;
    for(int i = 1; i<n + 1; i++){
        if(i < 10){
            m++;
        }else if(i >= 100 && i < 1000){
            m++;
        }else if(i >= 10000 && i < 100000){
            m++;
        }
    }cout<<m<<endl;
}


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

using namespace std;

long long a, b;
long long int gcd, lcm;

void GCD(){

	int big, small;

	big = a;
	small = b;

	while (big) {
		if (small > big) swap(big, small);
		big = big % small;
	}
	gcd = small;

}

void LCM() {
	lcm = a * b / gcd;
}




int main(){
	while (cin >> a >> b) {

		GCD();
		LCM();
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

int main(void){
  string s; cin >> s;
  int one=0,zero=0;
  rep(i,s.size()){
    if(s[i] == '0'){
      zero++;
    }
    else one++;
  }
  cout << s.size()-abs(one-zero) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    ll A, B, C; cin >> A >> B >> C;

    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
        cout << 0 << endl;
    } else {
        if (A > C) {
            swap(A, C);
        }
        if (B > C) {
            swap(B, C);
        }
        cout << A*B << endl;
    }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	string s, t;
	cin >> s >>t;
	int l= s.size();
	for (int i = 0; i < l;i++) {
		int count = 0;
		for (int j = 0; j < l;j++) {
			if (t[j] == s[(j + i) % l]) {
				count++;
			}
		}
		if (count==l) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <cassert>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
 
    int simple_sum = x * a + y * b;
    int c_sum = max(x, y) * c * 2;
 
    int ab_amount;
    int a_amount;
    int b_amount;
 
    if (x < y){
 
        //int xquot = x / 2;
        //int yquot = y / 2;
 
        //int amod = x % 2;
        //int bmod = y - 2 * xquot;
        int bmod = y - x;

 
        ab_amount = c * x * 2;
        a_amount = a * 0;
        b_amount = b * bmod;
 
    } else {
 
        int amod = x - y;
 
        ab_amount = c * y * 2;
        a_amount = a * amod;
        b_amount = b * 0;
 
    }
    int opt_sum = ab_amount + a_amount + b_amount;
 
    cout << min(min(simple_sum, c_sum), opt_sum) << endl;
}


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

void display(int* A, int size);

int main() {
  int size;
  int A[100];
  cin >> size;
  for(int i=0; i<size; i++) {
    cin >> A[i];
  }

  // Insertion sort
  for(int i=0; i<size; i++) {
    int key = A[i];
    int j=i-1;
    while(j>=0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;

    display(A,size);
  }

  return 0;
}

void display(int* A, int size) {
  cout << A[0];
  for(int i=1; i<size; i++) {
    cout << " " << A[i];
  }
  cout << endl;
}

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

using namespace std;


int main() {
	vector<vector<int>> matrix(3, vector<int>(3, 0));

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> matrix[i][j];
		}
	}

	vector<int> rows(3);
	vector<int> cols(3);

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++) {
				if (matrix[j][k] == num) {
					rows[j]++;
					cols[k]++;
					if (rows[j] == 3 || cols[k] == 3) {
						cout << "Yes";
						return 0;
					}
					matrix[j][k] = -1;
				}
			}
		}
	}

	if (matrix[0][0] == -1 && matrix[1][1] == -1 && matrix[2][2] == -1) {
		cout << "Yes";
	}
	else if (matrix[2][0] == -1 && matrix[1][1] == -1 && matrix[0][2] == -1) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
# import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m, k = ns()

    friend = UnionFind(n)

    myfriend = [0 for _ in range(n)]
    blocks = {}
    for i in range(n):
        blocks[i] = set()

    for _ in range(m):
        ai, bi = ns()
        ai -= 1
        bi -= 1
        friend.union(ai, bi)
        myfriend[ai] += 1
        myfriend[bi] += 1

    for _ in range(k):
        ci, di = ns()
        ci -= 1
        di -= 1

        blocks[ci].add(di)
        blocks[di].add(ci)

    tmp = 0
    for i in range(n):
        tmp_block = 0
        for j in blocks[i]:
            if friend.same(i, j):
                tmp_block += 1

        ans = friend.size(i) - 1 - myfriend[i] - tmp_block
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 121708
mask = {'N':(1, 5, 2, 3, 0, 4), 'E':(3, 1, 0, 5, 4, 2), 'S':(4, 0, 2, 3, 5, 1), 'W':(2, 1, 5, 0, 4,3)}

dice = input().split()

for c in input():
    dice = [dice[i] for i in mask[c]]

print(dice[0])

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

using namespace std;

int mp[10][10];
int ans;
bool check(int a, int b, int c, int d, int e,
		int oa, int ob, int oc, int od, int oe){
	if( a==oa && b==ob && c==oc && d==od && e==oe ) return 0;
	return mp[ mp[ mp[ mp[ mp[0][a] ][b] ][c] ][d] ][e] == 0;
}

int main(){
	ans = 0;
	rep(i,10) rep(j,10){
		cin >> mp[i][j];
	}

	rep(a,10) rep(b,10) rep(c,10) rep(d,10){
		int e = mp[ mp[ mp[ mp[0][a] ][b] ][c] ][d];
		bool f = false;
		rep(i,10) if(i!=a) f |= check(i,b,c,d,e,a,b,c,d,e);
		rep(i,10) if(i!=b) f |= check(a,i,c,d,e,a,b,c,d,e);
		rep(i,10) if(i!=c) f |= check(a,b,i,d,e,a,b,c,d,e);
		rep(i,10) if(i!=d) f |= check(a,b,c,i,e,a,b,c,d,e);
		rep(i,10) if(i!=e) f |= check(a,b,c,d,i,a,b,c,d,e);
		f |= check(b,a,c,d,e,a,b,c,d,e);
		f |= check(a,c,b,d,e,a,b,c,d,e);
		f |= check(a,b,d,c,e,a,b,c,d,e);
		f |= check(a,b,c,e,d,a,b,c,d,e);
		if( f ) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=inf
count=0

n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
# print(h)
for i in range(n-k+1):
    # print(i,k+i-1)
    # print(h[k+i-1]-h[i])
    ans=min(ans,h[k+i-1]-h[i])
print(ans)


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

#define endl '\n'
#define sz(x) ((int)(x.size()))

string s[55];
long long C[55];

long long dist[55][22][55][22];

bool pal(string s) {
	for(int i=0; i<sz(s); i++) if(s[i] != s[sz(s)-1-i]) return 0;
	return 1;
}

bool pal(string x, string y) {
	for(int i=0; i<min(sz(x), sz(y)); i++) {
		if(x[i] != y[sz(y)-1-i]) return 0;
	}
	return 1;
}

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

	string s;
	cin >> s;
	if(s[1] == 'S') {
		cout << (s[0] == 'R' || s[2] == 'R') << endl;
	}
	else {
		cout << 1 + (s[0] == 'R') + (s[2] == 'R') << endl;
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n+1);
    A[n] = (1<<30);
    int maxi = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        A[i] = a;
        maxi = max(maxi, a);
    }
    // cout << maxi << endl;
    sort(A.begin(), A.end());
    // for (int i = 0; i <= n; i++) {
    //     cout << A[i] << " ";
    // }
    // cout << endl;
    int index = 0, ans = 0;
    for (int i = 0; i <= maxi; i++) {
        if(index>=n)break;
        if(!(A[index] == i-1 || A[index] == i || A[index] == i+1)) continue;
        int cnt = 0;
        while(A[index] == i-1){
            cnt++;
            index++;
        }
        int index2 = index;
        while(A[index2] == i || A[index2] == i+1){
            cnt++;
            index2++;
        }
        // cout <<"i: " << i << "  cnt: " << cnt << endl;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

void dfs(int u, int time, vector<vector<int> >& adj, vector<int>& visited,
         vector<int>& d, vector<int>& low, vector<int>& parent,
         vector<pair<int, int> >& bridges)
{
  visited[u] = 1;
  d[u] = low[u] = time;
  ++time;
  for (int v : adj[u]) {
    if (not visited[v]) {
      parent[v] = u;
      dfs(v, time, adj, visited, d, low, parent, bridges);
      low[u] = min(low[u], low[v]);
      if (d[u] < low[v]) { bridges.push_back(make_pair(u, v)); }
    }
    else {
      if (v != parent[u]) {
        // back edge
        low[u] = min(low[u], d[v]);
      }
    }
  }
}

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int> > adj(n, vector<int>());
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  vector<int> visited(n, 0);
  vector<int> d(n, INF), low(n, INF), parent(n, -1);
  vector<pair<int, int> > bridges;
  dfs(0, 0, adj, visited, d, low, parent, bridges);
  // fprintf(stderr, "DEBUG: (d, low)=");
  // for (int i = 0; i < n; ++i) {
  //   fprintf(stderr, "(%d, %d), ", d[i], low[i]);
  // }
  // fprintf(stderr, "\n");
  int ans = bridges.size();
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

A_C = (A - 1)// C
A_D = (A - 1) // D
A_CD = (A - 1) // lcm(C, D)
a = A_C + A_D - A_CD
B_C = B // C
B_D = B // D
B_CD = B // lcm(C, D)
b = B_C + B_D - B_CD

print(B - A + 1 - (b - a))

Measured memory_bytes: 5076
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	ll i, j, q;
	ll n, m, k,t;
	ll a, b, c, d;
	ll x, y, z;
	ll one = 1,zero=0;
	ll ans;


	string st;
	cin >> st;
	c = st.size();
	forn(i, c - 8)
		cout << st[i];
	
	cout <<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]

for edge in edges:
    A[edge[0]].append([edge[1],edge[2]])
    A[edge[1]].append([edge[0],edge[2]])

depth = [-1] * (N+1)
depth[1] = 0

def dfs(A,s):
    for v in A[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

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




int main() {
  string S;
  cin >> S;
  
  int ans = 0;
  
  int start = -1;
  int endi = -1;
  auto hit = [&](char c){
    if(c=='A') return true;
    if(c=='T') return true;
    if(c=='C') return true;
    if(c=='G') return true;
    return false;
  };
  for (int i = 0; i < S.size(); i++) {
    if(hit(S[i])&&start==-1){
      start = i;
      endi = i;
    } else if(hit(S[i])&&start!=-1){
      endi = i;
    } else if(!hit(S[i])&&start!=-1){
      ans = max(ans, endi - start + 1);
      start = -1;
      endi = -1;
    }
  }
  if(start!=-1) ans = max(ans, endi - start + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int main(){
    string str;
    cin>>str;
    long long key=str.length();
    cout<<str[0]<<key-2<<str[key-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
a,b=gets.chomp.split.map(&:to_i)
if a > 0
  puts 'Positive'
elsif a == 0
  puts 'Zero'
else
  if b >= 0
    puts 'Zero'
  else
    puts (b-a) % 2 == 0 ? "Negative" : "Positive"
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

ll nexts[200010];
ll stops[200010];
bool visited[200010];
bool visited2[200010];

int main(){
    ll i,n,k;
    cin>>n>>k;
    for(i = 1; i<=n; i++){
        cin>>nexts[i];
    }
    for(i = 1; i<=n; i++) visited[i] = false;
    visited[1] = true;
    ll nxt = nexts[1];
    ll stp = 1;
    while(!visited[nxt]){
        stops[stp] = nxt;
        visited[nxt] = true;
        nxt = nexts[nxt];
    }
    ll cy = nxt;
    //cout<<"cy:"<<cy<<endl;
    for(i = 1; i<=n; i++) visited2[i] = false;
    vector<ll> cycle;
    cycle.push_back(cy);
    visited2[cy] = true;
    nxt = nexts[cy];
    while(!visited2[nxt]){
        cycle.push_back(nxt);
        visited2[nxt] = true;
        nxt = nexts[nxt];
    }
    //cout<<"cycle:";
    //for(ll asd: cycle) cout<<asd<<" ";
    //cout<<endl;
    ll cy_sz = cycle.size();
    ll curr = 1;
    while(k > 0 && curr != cy){
        k--;
        curr = nexts[curr];
    }
    if(curr == cy){
        curr = cycle[k % cy_sz];
    }
    cout<<curr<<endl;
}


Measured memory_bytes: 7256
#62b
h,w = map(int,input().split())
a=['#'*(w+2),'#'*(w+2)]
for i in range(h):
    temp = '#'+ input() +'#'
    a.insert(i+1,temp)

for i in range(len(a)):
    print(a[i],end='\n')
    

Measured memory_bytes: 3060
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    x=parseMap(split(readline()))
    sx=sort(x)
    med1=sx[div(n,2)]
    med2=sx[div(n,2)+1]
    for i in 1:n
        if x[i]<=med1
            println(med2)
        else
            println(med1)
        end
    end
end
main()

Measured memory_bytes: 153356
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    ll n;
    cin >> n;
    ll a=sqrt(n);
    cout << a*a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int func(int money , int n);

int main(void)
{
	int n;
	scanf("%d",&n);
	printf("%d\n",f(100000,n));
	return 0;
}

int f(int money , int n){
	int m;

	m = money * 1.05;

	if(m % 1000 > 0){
		m = m - (m % 1000);
		m += 1000;
	}

	if(n > 1){
		return f(m,n-1);
	}else{
		return m;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b&&b<c){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3088
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int x;
    cin >> x;

    cout << lcm(x, 360) / x << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 3632
l = []
min_s = 10
check = 0

for i in range(5):
    a = int(input())
    l.append(a)
    s = int(str(a)[-1])

    if s == 0:
        s = 10
    if s < min_s:
        min_s = s
        check = i

ans = 0
for i in range(len(l)):
    if i == check:
        ans += l[i]
    else:
        if int(str(l[i])[-1]) != 0:
            ans += l[i] + (10-int(str(l[i])[-1]))
        else:
            ans += l[i]

print (ans)


Measured memory_bytes: 9220
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()

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

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, ans = 0;
	vector<string> a(3);
	cin >> n;
	rep(i, 3)
		cin >> a[i];
	rep(i, n) {
		map<char, int> c;
		rep(j, 3)
			c[a[j][i]]++;
		int mc = 0;
		for (auto &p : c)
			mc = max(mc, p.second);
		ans += 3 - mc;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	set<string> st;
	rep(i, n) {
		cin >> s[i];
		st.insert(s[i]);
	}
	if (n != st.size()) {
		cout << "No" << endl;
		return 0;
	}
	char M = s[0][s[0].size() - 1];
	for (int i = 1; i < n; i++) {
		if (M != s[i][0]) {
			cout << "No" << endl;
			return 0;
		}
		M = s[i][s[i].size() - 1];
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n, x, m = list(map(int, input().split()))
dp = [False]*(m+1)
a = [0]*(m+1)
d = defaultdict(lambda: set())
flag = False
for i in range(1, min(m+1, n+1)):
    if i == 1:
        a[i] = x
        dp[x] = True
    else:
        a[i] = a[i-1]**2 % m
        if not dp[a[i]]:
            d[a[i-1]] = a[i]
            dp[a[i]] = True

        else:
            startv = a[i]
            flag = True

            break
start_idx = a[1:].index(a[i])+1
loop_haba = i-start_idx
loop_sum = sum(a[start_idx:i])
if not flag:
    print(sum(a[:n+1]))
else:
    ans = sum(a[:(start_idx)])

    ans += ((n-start_idx)//loop_haba)*loop_sum
    ans += sum(a[start_idx: start_idx+((n-start_idx) % loop_haba)+1])
    print(ans)


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

int main(void){
	long ans=0,part=0;
	int n,i,data;

	cin>>n;
	while(n!=0){
		for(i=0;i<n;i++){
			cin>>data;
			if(i==0){
					ans=data;
					if(data>0)
						part+=data;
			}
			else{
				part+=data;
				if(part<0)
					part=0;
				else{
					if(ans<part)
						ans=part;
				}
			}
		}
		cout<<ans<<endl;
		part=0;
		cin>>n;
	}

	return 0;
}

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

data = [0, 0]  # [, ] = num of ( and )
temp = -1
for i in range(n):
    temp += 1
    tar = s[temp]
    if (tar == '('):
        data[0] += 1

    else:
        if (data[0] > data[1]):
            data[0] -= 1
        else:
            s = '(' + s
            temp += 1


add = ')' * data[0]
s = s + add

print(s)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl h(n);
  rep(i, n) cin >> h[i];
  vl dp(n, 0);
  for(ll i = n - 2; i >= 0; i--)
    if(h[i] >= h[i + 1]) dp[i] = dp[i + 1] + 1;
  cout << *max_element(all(dp)) << endl;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    int cnt = 0;
    for(int i=a;i<=b;++i){
        string tmp = to_string(i);
        string tmptmp = tmp;
        reverse(tmptmp.begin(),tmptmp.end());
        if(tmp==tmptmp) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
using namespace std;

uint64_t K, N;

struct sushi
{
	uint64_t kind;
	uint64_t value;
	bool use_flag;

	sushi(uint64_t k, uint64_t v)
	{
		kind = k;
		value = v;
		use_flag = false;
	}

	bool operator<(const sushi &another) const
	{
		return value < another.value;
	}

	bool operator>(const sushi &another) const
	{
return value > another.value;
	}

};

int main()
{
	uint64_t max_ans = 0;
	vector<sushi> s;

	// データ読み込み
	cin >> N >> K;

	uint64_t a, b;

	for (uint64_t i = 0; i < N; i++)
	{
		cin >> a >> b;
		s.push_back(sushi(a, b));

	}

	// value順に並び替え
	sort(s.begin(), s.end(), greater<>());

	// 暫定topを計算：種類MAXで最大のvalueを選択
	uint64_t c = 0;
	map<uint64_t, bool> eat_kind;
	vector<uint64_t> eat;

	for (uint64_t i = 0; i < N; i++)
	{
		// すべて違う種類の寿司を食べる
		if (eat_kind.find(s[i].kind) == eat_kind.end())
		{
			s[i].use_flag = true;
			eat_kind[s[i].kind] = true;
			eat.push_back(i);
			c++;
		}

		if (c >= K)
		{
			break;
		}
	}

	// c>=Kの場合、価値の高いものをc>=Kとなるまで設定する
	for (uint64_t i = 0; i < N; i++)
	{
		if (s[i].use_flag == false)
		{
			s[i].use_flag = true;
			eat.push_back(i);
			c++;
		}

		if (c >= K)
		{
			break;
		}
	}
	sort(eat.begin(), eat.end());
	// max_ans = eval_oishisa(s, eat);

	// 得点計算
	uint64_t ans1 = 0;
	map<uint64_t, uint32_t> kind;

	for (auto itr = eat.begin(); itr != eat.end(); itr++)
	{
		ans1 += s[*itr].value;
		if (kind.count(s[*itr].kind) == 0)
		{
			kind[s[*itr].kind] = 1;
		}
		else
		{
			kind[s[*itr].kind]++;
		}

	}
	max_ans = ans1 + kind.size() * kind.size();

	// valueの高いものを採用し、暫定topより高くなれば続ける。高くならなければEND
	uint64_t tmp_ans = 0;
	for (uint64_t i = 0; i < N; i++)
	{
		if (s[i].use_flag == false)
		{
			s[i].use_flag = true;
			s[eat.back()].use_flag = false;
			ans1 = ans1 - s[eat.back()].value + s[i].value;
			kind[s[eat.back()].kind]--;
			if (kind[s[eat.back()].kind] == 0)
			{
				kind.erase(s[eat.back()].kind);
			}

			eat.pop_back();
			eat.insert(eat.begin(), i);
			// eat.push_back(i);
			// sort(eat.begin(), eat.end());
			// tmp_ans = eval_oishisa(s, eat);
			tmp_ans = ans1 + kind.size() * kind.size();
			if (max_ans > tmp_ans)
			{
				break;
			}
			max_ans = tmp_ans;
		}
	}

	cout << max_ans << endl;
}

Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0,k=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    m=max(m,a[i]);
  }
  for(int i=0;i<n;i++){
    if(a[i]!=m&&min(k,m-k)<=min(a[i],m-a[i])) k=a[i];
  }
  cout<<m<<" "<<k;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
const ll MOD = 1000000007;

int n;
int X, Y, Z;
int XYZ;
int maxi;
// typedef pair<int,deque<int> > K;
typedef pair<int, ll> K;

bool isPossible(const deque<int>& vs) {
  int as[] = {X, Y, Z};
  int i = 0;
  for(int v : vs) {
    if(i >= 3) {
      return false;
    }
    as[i] -= v;
    if(as[i] < 0) {
      return false;
    } else if(as[i] == 0) {
      ++i;
    }
  }
  return i <= 3;
}

ll mypow(ll x, ll n) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 0){
    return mypow(x*x%MOD, n/2);
  } else {
    return mypow(x*x%MOD, n/2)*x%MOD;
  }
}

ostream& operator<<(ostream& out, const deque<int>& vs) {
  out << "{";
  for(int v : vs) {
    out << v << ",";
  }
  return out << "}";
}

ll encode(const deque<int>& vs) { // 解説読んで、コンパクトなエンコード方法を知った
  ll res = 0;
  for(int v : vs) {
    res = ((res << 1) | 1) << (v-1);
  }
  return res;
}

ll memo[42][1<<17];
ll solve(int rest, const deque<int>& vs, int sum) {
  K key(rest, encode(vs));
  ll& res = memo[key.first][key.second];
  if(res < 0) {
    res = 0;
    if(rest > 0) {
      for(int cur = 1; cur <= 10; ++cur) {
        deque<int> nextVs = vs;
        int nextSum = sum;
        nextVs = vs;
        nextSum = sum;
        nextVs.push_back(cur);
        nextSum += cur;
        while(!nextVs.empty() && (nextSum > XYZ || !isPossible(nextVs))) {
          nextSum -= nextVs.front();
          nextVs.pop_front();
        }
        if(nextSum == XYZ) {
          res = (res + mypow(10, rest-1)) % MOD;
        } else {
          res = (res + solve(rest-1, nextVs, nextSum)) % MOD;
        }
      }
    }
  }
  return res;
}

int main(void) {
  int n;
  memset(memo, -1, sizeof memo);
  scanf("%d%d%d%d", &n, &X, &Y, &Z);
  maxi = max(max(X, Y), Z);
  XYZ = X + Y + Z;
  deque<int> vs;
  ll res = solve(n, vs, 0);
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 43264
#https://atcoder.jp/contests/abc142/tasks/abc142_d

def prime_factorize(n):
    a = []
    a.append(1)
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    
    b = []
    cnt = 1
    for i in range(len(a)+1):
        if i > 0 and i < len(a):
            if a[i] != a[i-1]:
                b.append(a[i-1])
        if i == len(a) and i > 0:
            b.append(a[i-1])
        elif i == len(a) and i == 0:
            b.append(a[i])
    return b


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

ap = prime_factorize(a)
bp = prime_factorize(b)

c = []

for i in range(len(ap)):
    for j in range(len(bp)):
        if ap[i] == bp[j]:
            c.append(ap[i])
            break

print(len(c))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int,int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;


int main() {
    ll s, c, cnt = 0;
    cin >> s >> c;
    if (2 * s <= c) {
        c -= 2 * s;
        cnt += s;
        cnt += c / 4;
    }
    else {
        cnt = c / 2;
    }
    cout << cnt << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
T = int(input())

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

ans = []
for _ in range(T):
    A, B, C, D = map(int, input().split())

    if A < B:
        ans.append('No')
        continue

    if B > D:
        ans.append('No')
        continue

    if C >= B:
        ans.append('Yes')
        continue

    # A >= B, B <= D, C < B
    G = gcd(D, B)
    maxMod = B - G + A % G
    if C < maxMod:
        ans.append('No')
    else:
        ans.append('Yes')

print(*ans, sep='\n')

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = map(int,readline().split())

#g = [[] for _ in range(n)]

ans = 0
for i in range(n):
    ans += (i+1)*(n-i)

#print(ans)

for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    #g[a-1].append(b-1)
    #g[b-1].append(a-1)
    if a > b: a,b = b,a
    
    ans -= (a)*(n-b+1)
    #print(a,b,ans)

print(ans)






Measured memory_bytes: 9168
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    char n[4];

    for (int i = 0; i < sizeof(n); i++) {
        cin >> n[i];
    }

    sort(n, n + 4);

    if (n[0] == '1' && n[1] == '4' && n[2] == '7' && n[3] == '9')
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long a,b=2;
int main(){
    cin>>a;
    for(int i=0;i<a;i++)b=(b+1)*2;
    cout<<b<<endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    ll a[55], b[55], c[55], d[55];
    rep(i, n){
        cin >> a[i];
        cin >> b[i];
    }
    rep(i, m){
        cin >> c[i];
        cin >> d[i];
    }
    rep(i, n){
        ll M = 1e+10;
        int ans = 0;
        for(int j = m - 1; j >= 0; j--){
            ll tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (tmp <= M){
                ans = j + 1;
                M = tmp;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

inline bool isdig(const char &c)
{
	return c>='0'&&c<='9';
}

inline bool islow(const char &c)
{
	return c>='a'&&c<='z';
}

inline char gc(void)
{
	#ifndef local_lwq
	static char buf[100000],*p1=buf,*p2=buf;

	if(p1!=p2) return *p1++;

	p1=buf;
	p2=p1+fread(buf,1,100000,stdin);

	return p1==p2?EOF:*p1++;
	#else
	return getchar();
	#endif
}

template<typename T> inline T read(void)
{
	T ret=(T)0;
	bool neg=false;
	char c=gc();

	while(!isdig(c))
	{
		neg|=(c=='-');
		c=gc();
	}
	while(isdig(c))
	{
		ret=ret*10+c-'0';
		c=gc();
	}
	ret=neg?-ret:ret;

	return ret;
}

int n,m,tcnt[30],mcnt[5];

bool judge(void)
{
	if(!mcnt[1]&&!mcnt[2]&&!mcnt[3]) return true;
	if(mcnt[1])
	{
		if(mcnt[3]) return false;
		if(mcnt[1]!=1) return false;
		if(!(n&1)||!(m&1)) return false;
		if(mcnt[2]>(n>>1)+(m>>1)) return false;
		return true;
	}
	if(mcnt[3])
	{
		if(mcnt[1]) return false;
		if(mcnt[3]!=1) return false;
		if(!(n&1)||!(m&1)) return false;
		if(mcnt[2]+1>(n>>1)+(m>>1)) return false;
		return true;
	}
	if(n&1)
	{
		if(mcnt[2]>(m>>1)) return false;
		return true;
	}
	if(m&1)
	{
		if(mcnt[2]>(n>>1)) return false;
		return true;
	}
	
	return false;
}

int main()
{
	memset(tcnt,0,sizeof(tcnt));
	memset(mcnt,0,sizeof(mcnt));
	
	n=read<int>();
	m=read<int>();
	for(register int i=1;i<=n*m;++i)
	{
		char c=gc();
		
		while(!islow(c)) c=gc();
		++tcnt[c-'a'];
	}
	
	for(register int i='a'-'a';i<='z'-'a';++i) ++mcnt[tcnt[i]%4];
	if(judge()) puts("Yes");
	else puts("No");
	
	return 0;
}
/*
1
2 2
aa
bb

5
3 4
aabb
aabb
aacc
2 2
aa
bb
5 1
t
w
e
e
t
2 5
abxba
abyba
1 1
z
*/

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

#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    int n;cin >>n;
    int ans = 0;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                ans += __gcd(i+1, __gcd(j+1, k+1));
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
string ask(int x)
{
    cout.flush();
    cout<<x<<endl;
    cout.flush();
    string ans;
    cin>>ans;
    if(ans=="Vacant")
        exit(0);
    return ans;
}
int main () {
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    int l=0;
    int r=n-1;
    string sl=ask(l);
    string sr=ask(r);
    int mid=0;
    while (l<r-1) {
        mid=(l+r)/2;
        string sm=ask(mid);
        if(l%2==mid%2)
        {
            if(sl==sm)
            {
                l=mid;
                sl=sm;
            }
            else
            {
                r=mid;
                sr=sm;
            }
        }
        else
        {
            if(sl!=sm)
            {
                l=mid;
                sl=sm;
            }
            else
            {
                r=mid;
                sr=sm;
            }
        }
    }
    ask(l);
    ask(r);
    ask(mid);
    return 0;
}


Measured memory_bytes: 852
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
   int u,minv;
   int d[MAX], p[MAX],color[MAX];

   for(int i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while( 1 ){
   minv = INFTY;
   u = -1;
   for(int i = 0; i < n;i++){
   if(minv > d[i] && color[i] != BLACK){
   u = i;
   minv = d[i];
   }
 }
 if( u == -1) break;
 color[u] = BLACK;
 for(int v = 0; v < n; v++){
  if(color[v] != BLACK && M[u][v] != INFTY){
    if(d[v] > M[u][v]){
       d[v] = M[u][v];
       p[v] = u;
    color[v] = GRAY;
   }
  }
 }
}
 int sum = 0;
 for(int i = 0; i < n; i++){
   if(p[i] != -1) sum += M[i][p[i]];
   }

   return sum;
}
   
int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
   for(int j = 0; j < n; j++){
     int e; cin >> e;
     M[i][j] = (e == -1) ? INFTY : e;
   }
  }

  cout << prim() << endl;

  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
using namespace std;
typedef long long ll;
int t;
ll n;
string s;

int main()
{
    ll yen=100,cnt=0;
    cin>>n;
    while(yen<n){
        yen+=(yen*.01);
        cnt++;
        if(yen>=n)
            break;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

const int INF = 19191919;

int root;
int v[N];
int d[N],par[N];

using pi = pair<int,int>;
pi r[N];
int ans[N];

void dfs(int now, pi range, int p)
{
    if(v[now]>=0)
    {
        if(d[now]%2==abs(v[now]-v[root])%2)
        {
            if(p==-1 || abs(v[now]-ans[p])==1) ans[now] = v[now];
        }
    }
    else
    {
        int L = max(range.fi, r[now].fi);
        int R = min(range.se, r[now].se);
        if(L<=R) ans[now] = L;
    }

    if(ans[now]==-INF) return;
    // dbg(now);
    // dbg(ans[now]);
    for(int nx:G[now])if(nx!=p) dfs(nx,{ans[now]-1,ans[now]+1},now);
}

int main()
{
    int n;
    cin >>n;
    rep(i,n-1)
    {
        int a,b;
        cin >>a >>b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    int k;
    cin >>k;

    fill(v,v+N,-1);
    while(k--)
    {
        int idx,p;
        cin >>idx >>p;
        --idx;
        v[idx]=p;
        root = idx;
    }

    fill(d,d+N,INF);
    fill(par,par+N,-1);
    d[root] = 0;
    queue<int> que;
    que.push(root);
    vector<int> vis;
    while(!que.empty())
    {
        int now = que.front();
        que.pop();
        vis.pb(now);

        for(int nx:G[now])
        {
            if(d[nx]>d[now]+1)
            {
                d[nx] = d[now]+1;
                par[nx] = now;
                que.push(nx);
            }
        }
    }

    reverse(all(vis));
    rep(i,n) r[i] = {-INF,INF};
    for(int now:vis)
    {
        if(v[now]!=-1) r[now]={v[now],v[now]};
        int p = par[now];
        if(p!=-1)
        {
            r[p].fi = max(r[p].fi,r[now].fi-1);
            r[p].se = min(r[p].se,r[now].se+1);
        }
    }

    fill(ans,ans+N,-INF);
    dfs(root,{-INF,INF},-1);

    string s = "Yes";
    rep(i,n)if(ans[i]==-INF) s = "No";
    cout << s << endl;
    if(s=="Yes") rep(i,n) cout << ans[i] << endl;
    return 0;
}


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

using namespace std;

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

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

  int n;
  cin >> n;
  int ara[n];
  int mx = -101;
  int mi = 101;
  for(int i = 0;i<n;i++){
    cin >> ara[i];
    mx = max(mx,ara[i]);
    mi = min(mi,ara[i]);
  }
  long long final = LLONG_MAX;
  for(;mx>= mi;mx--){
    long long temp = 0;
    for(int i = 0;i<n;i++){
      long long t = abs(ara[i]-mx);
      temp += (t*t);
    }
    final = min(final,temp);
  }
  cout << final << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int h,r; cin >> h >> r;
    if(h<=0 and abs(h)-r>0)cout << -1 << endl;
    else if(-1*h == r )cout << 0 << endl;
    else cout << 1 << endl;
}





Measured memory_bytes: 3112
import java.util.Scanner;

class Main{
	static int[] dh = {0, 0, 1, -1, -1, -1, 1, 1};
	static int[] dw = {-1, 1, 0, 0, -1, 1, -1, 1};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		char[][] map = new char[H][W];
		for(int i = 0; i < H; i++) {
			String S = sc.next();
			for(int j = 0; j < W; j++) {
				map[i][j] = S.charAt(j);
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(map[i][j] == '#') continue;
				int cnt = 0;
				for(int k = 0; k < 8; k++) {
					if(i + dh[k] < 0 || j + dw[k] < 0 || i + dh[k] >= H || j + dw[k] >= W) continue;
					if(map[i + dh[k]][j + dw[k]] == '#') cnt++;
				}
				map[i][j] = (char)('0' + cnt);
			}
		}
		for(int i = 0; i < H; i++) {
			System.out.println(String.valueOf(map[i]));
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int x,y=0,t,n,ans=0;
    cin >> n >> x >> t;
    
    while(1){
        ans += t;
        y += x;
        if(y >= n){
           cout << ans << endl;
           return 0;
        }
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    vector<char> op(3);
    for (int t = 0; t < (1 << 3); t++) {
        int cnt = s[0] -'0';
        for (int i = 0; i < 3; i++) {
            if (t & (1 << i)) {
                cnt += s[i+1] - '0';
                op[i] = '+';
            } else {
                cnt -= s[i+1] - '0';
                op[i] = '-';
            }
        }
        if (cnt == 7) {
            cout << s[0];
            for (int i = 0; i < 3; i++) {
                cout << op[i] << s[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
/*
	author : SAMRAT DE
	username : Alucard_01
	NIT Durgapur
*/

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>*/
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define pi(x,y) pair<x,y>
#define mpp(x,y) map<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order
#define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

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

using namespace std;
//using namespace __gnu_pbds;

int32_t main()
{
	fastio;
	//best of luck don't loose hope man	
		
	string s;
	cin>>s;
    int c=0,ans=0;
    string k="",t="";
    while(c<s.size()){
        k+=s[c];
        if(k!=t){
        	//cout<<k<<" ";
        	t=k;
            ans++;
            k="";
        }
        c++;
    }
    cout<<ans<<endl;

    //a | aa | a | a

    //aa | a | aa
	return 0;
}

Measured memory_bytes: 720