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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n, m, k;
long long a[21234];
long long dp[21234];

int main(){
    cin >> n >> m >> k;
    REP(i, n) cin >> a[i];
    REP(i, n){
        dp[i] = INF;
        long long mx = a[i], mn = a[i];
        for(int j = 0; j < min(i + 1, m); ++j){
           mx = max(mx, a[i - j]);
           mn = min(mn, a[i - j]);
           dp[i] = min(dp[i], dp[i - j - 1] + (mx - mn) * (j + 1) + k);
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 3412
import sys
from collections import defaultdict
input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = sorted(A)
    d = defaultdict( int)
    for i in range(N):
        d[B[i]] = i
    odd = 0
    for i in range(N):
        if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
            odd += 1
    print(odd)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 20212
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = N // 3
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10100
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ma = 0
for i in range(n - 1):
    tmp = a[i + 1] - a[i]
    if ma < tmp:
        ma = tmp
print(k - max(ma, a[0] + (k - a[-1])))


Measured memory_bytes: 77388
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=1000
etemp=1
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.9:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(5)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)

Measured memory_bytes: 10548
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    white = []
    white.append(0)
    cur = 0
    for c in S:
        if c == '.':
            cur += 1
        white.append(cur)
    black = []
    black.append(0)
    cur = 0
    for c in S[::-1]:
        if c == '#':
            cur += 1
        black.append(cur)
    black.reverse()
    #print(white)
    #print(black)
    ret = float('inf')
    for i in range(N + 1):
        ret = min(ret, N - (white[i] + black[i]))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13108
in_str = input()
in_str2 = input()

if (not in_str.isnumeric()) :
    print("error: 1st arg must be integer")
    exit()

num = int(in_str)
str = in_str2
str_len = len(in_str2)

if num > 100 :
    print("error: 1st arg must be under 100")
    exit()
if str_len> 100 :
    print("error: size of 2nd arg must be under 100")
    exit()

if num >= str_len :
    print(str)
else :
    print(str[0:num] + "...")




Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int min = 0;
    int index = 0;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] < min)
        {
            min = a[i];
            index = i;
        }
    }

    for (int i = 0; i < n; i++)
    {
        a[i] -= min;
    }
    sort(a, a + n);
    cout << a[n - 1] - a[0];
    return 0;
}


Measured memory_bytes: 888
b1,b2,b3=map(int,input().split())
if b1==1 and b2==0 and b3==0 :
    print('Close')
elif b1==0 and b2==1 and b3==0 :
    print('Close')
elif b1==1 and b2==1 and b3==0 :
    print('Open')
elif b1==0 and b2==0 and b3==1 :
    print('Open')
else:
    print('Close')


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

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

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h+2,vector<char> (w+2));

    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w + 1;j ++){
            cin >> s.at(i).at(j);
        }
    }

    vector<vector<int> > ans(h+2,vector<int>(w+2));

    for(int i = 0;i < h+2;i ++){
        for(int j = 0;j < w + 2;j ++){
            ans.at(i).at(j) = 100000;
        }
    }

    if(s.at(1).at(1) == '.') ans.at(1).at(1) = 0;
    else ans.at(1).at(1) = 1;

    for(int x = 0;x < 10000;x ++){
        for(int i = 1;i < h+1;i ++){
            for(int j = 1;j < w+1;j ++){
                
                if(s.at(i).at(j) == '.'){
                    ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i).at(j-1));
                    ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i-1).at(j));
                }else if(s.at(i).at(j) == '#'){
                    if(s.at(i).at(j-1) == '.'){
                        ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i).at(j-1)+1);
                    }else if(s.at(i).at(j-1) == '#'){
                        ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i).at(j-1));
                    }

                    if(s.at(i-1).at(j) == '.'){
                        ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i-1).at(j)+1);
                    }else if(s.at(i-1).at(j) == '#'){
                        ans.at(i).at(j) = min(ans.at(i).at(j),ans.at(i-1).at(j));
                    }
                }
            }
        }
    }

    cout << ans.at(h).at(w) << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN];
int N;
int main() {
	while (scanf("%d", &N) != EOF) {
		int sum = 0, count = 0;
		for (int i = 1; i <= N; i++) {
			scanf("%d", &a[i]);
			if (a[i] % 4 == 0) sum++;
			if (a[i] % 2 == 0 && a[i] % 4 != 0) count++;
		}
		//bool flag = true;
		if (count > 0) N -= (count - 1);
		if (sum >= N / 2) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

}



Measured memory_bytes: 68636
S = input()

def calcfunc(s) :
    total = 0
    cond = 1

    for c in s :
        if c == "+" :
            cond = 1
        elif c == "-" :
            cond = -1
        else :
            total += cond * int(c)
            
    return total

res = "Nil"
def addinput(s, i) :
    global res
    # do eval
    if len(s) == 7 : 
        if calcfunc(s) == 7:
            res = s

    else :
        str_plus = s[:i] + "+" + s[i:]
        str_minus = s[:i] + "-" + s[i:]

        addinput(str_plus, i + 2)
        addinput(str_minus, i + 2)
    
addinput(S, 1)
print(res + "=7")

Measured memory_bytes: 3064
S = input()

if S == 'MON':
    print("6")

elif S == 'TUE':
    print("5")

elif S == 'WED':
    print("4")

elif S == 'THU':
    print("3")

elif S == 'FRI':
    print("2")

elif S == 'SAT':
    print("1")

elif S == 'SUN':
    print("7")

Measured memory_bytes: 9104
N = int(input())
AS = map(int, input().split())

odd = filter(lambda x: x % 2 == 0, AS)
result = filter(lambda x: not (x % 3 == 0 or x % 5 == 0), odd)

if len(list(result)) == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
            // main
        Scanner sc = new Scanner(System.in);
        int N = nextInt(sc);
        int K = nextInt(sc);
        String S = getLine(sc);

        show(calc(N, K, S));

    }

    private static String calc(int N, int K, String S) {
        StringBuilder str;
        str = new StringBuilder();

        char[] charArray = S.toCharArray();
        for (int i = 0; i < N; i++) {
            char c = charArray[i];

            if (i + 1 == K) c = toLower(c);

            str.append(c);

        }
        return str.toString();
    }

    private static String getLine(Scanner sc) { return sc.next(); }
    private static int nextInt(Scanner sc) { return Integer.parseInt(sc.next()); }
    private static void show(String answer) {
        System.out.println(answer);
    }
    private static char toLower(char c) { return (char)(c + 32); }
}

Measured memory_bytes: 21588
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    if (n % 2 == 1) {
        println("No")
        return
    }
    val a = s.take(n / 2)
    val b = s.takeLast(n / 2)
    println(
        if (a == b) {
            "Yes"
        } else {
            "No"
        }
    )
}


Measured memory_bytes: 31888
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
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;}

#define INF 1120000000

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

  int ans = 1;
  int m = 0;
  repl(i,1,n+1){
    int x = i;
    int y = 0;
    while(x%2==0){x/=2; y++;}
    if(y>m){ans = i; m = y;}
  }

  cout << ans << endl;
  return 0;
}


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

int main() 
{
   char s[11];
   cin>>s;
   int prevcount=0,i;
   int count=0;
   int arrSize = sizeof(s)/sizeof(s[0]);
   for(i=0;i<arrSize;i++)
   {
       if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
       {
           count++;
       }
       else
       {
           if(count>prevcount)
           {prevcount=count;}
           count=0;
       }
   }
   if(count>prevcount)
   {prevcount=count;}
   
   
   cout<<prevcount;
   return 0;
   
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
int n;
string s;
char t[d5];
bool ok(char t[d5]){
    for(int i=1;i<n;i++){
        if((s[i]=='o'&&t[i]=='S')||(s[i]=='x'&&t[i]=='W')){
            t[i+1]=t[i-1];
        }
        else{
            if(t[i-1]=='S')t[i+1]='W';
            else t[i+1]='S';
        }
    }

    if(t[0]!=t[n])return false;
    if((s[0]=='o'&&t[0]=='S')||(s[0]=='x'&&t[0]=='W')){
        if(t[1]==t[n-1])return true;
        else return false;
    }
    else{
        if(t[1]!=t[n-1])return true;
        else return false;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);    
    cin>>n>>s;
    t[0]='S';t[1]='S';
    if(ok(t)){
        for(int i=0;i<n;i++)cout<<t[i];
        cout<<endl;
        return 0;
    }
    t[0]='S';t[1]='W';
    if(ok(t)){
        for(int i=0;i<n;i++)cout<<t[i];
        cout<<endl;
        return 0;
    }
    t[0]='W';t[1]='S';
    if(ok(t)){
        for(int i=0;i<n;i++)cout<<t[i];
        cout<<endl;
        return 0;
    }
    t[0]='W';t[1]='W';
    if(ok(t)){
        for(int i=0;i<n;i++)cout<<t[i];
        cout<<endl;
        return 0;
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    long long a[n],s[200001]={0};
    s[0]=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        s[i+1]=s[i]+a[i];
    }
    long long cnt=1;
    long long ans=0;
    qsort(s,n+1,sizeof(long long),compare);
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            cnt++;
        }else{
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    ans+=(cnt*(cnt-1)/2);
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 4860
"use strict";

function main(input) {
  input = input.trim();
  let X = Number(input);
  while (true) {
    let flag = false;
    for (let i = 2; i < X; i++) {
      if (X % i == 0) {
        X++;
        flag = true;
        break;
      }
    }
    if (!flag) {
      console.log(X);
      break;
    }
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 32188
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var sum = 0
    var out:Int
    var i = 1
    while (true) {
        sum += i
        if(sum>n){
            out = sum - n
            break
        }
        i++
    }

    for(j in 1..i){
        if(j!=out){
            println(j)
        }
    }
}

Measured memory_bytes: 31876
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
int n;
int a[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	int ans = 0;
	while(n--) {
		int x;
		scanf("%d", &x);
		if (x >= N) {
			ans++;
			continue;
		}
		a[x]++;
	}
	for (int i = 1; i < N; i++) {
		if (a[i] < i)
			ans += a[i];
		else
			ans += a[i] - i;
	}
	printf("%d\n", ans);

	return 0;
}


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

int main(){
  int x,y,g,a,b;
  cin>>x>>y>>g;
  for(int i=x;0<i;i--){
    if(x%i==0 && y%i==0){a=x/i; b=y/i; break;}
    }
  cout<<a*b*g<<endl;
  
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
const int N=1e9+7;
using namespace std;
ll n,k,ans,ans1,ans2,a,b;
int main(){
	cin>>n>>k;
	for(a=1;a<=k-1;a++) ans1+=a;
	for(b=n;b>=n+1-k;b--) ans2+=b;
	ans+=ans2-ans1+1;
	ans%=N;
	for(int i=k+1;i<=n+1;i++)
	{
		ans1+=a;
		a++;
		ans2+=b;
		b--;
	    ans+=(ans2-ans1+1);
	    ans%=N;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    vector<long long> array;
    long long  x,N,ans = 0;
    cin >>N;
    for(int i=0;i<5;i++){
    cin >>x;
    array.push_back(x);
    }
    sort(array.begin(),array.end());
    if(N % array[0]){
        ans += 1;
    }
      x = N / array[0];
      ans += 5 + x-1;
      cout << ans;
}

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

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

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

	int A,B,X; cin >> A >> B >> X;

	if(A <= X && X <= A+B) cout << "YES" << endl;
	else cout << "NO" << endl;;

	return 0;

}


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

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var n = s.Length;

            var ans = 0L; //左からB1e5個、W1e5個とかだと、Σ[i=1→1e5]i * 1e5 ～1e10になって、intだとオーバーフローする
            var Wcounter = 0;

            for(int i = 0; i < n; i++)
            {
                if(s[i] == 'W')
                {
                    Wcounter++;
                    ans += i - Wcounter + 1; 
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 26600
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, M = (int(_) for _ in input().split())
    d = [[1e10 for _ in range(N)] for _ in range(N)]
    a = []
    b = []
    c = []
    for i in range(M):
        ai, bi, ci = (int(_) for _ in input().split())
        d[ai-1][bi-1] = ci
        d[bi-1][ai-1] = ci
        a.append(ai-1)
        b.append(bi-1)
        c.append(ci)
        
    for i in range(N):
        d[i][i] = 0       
        
    for i in range(N):
        for j in range(N):
            for k in range(N):
                d[j][k] = min(d[j][i]+d[i][k],d[j][k])

    ans = M
    for i in range(M):
        is_shortest = False
        for j in range(N):
            if(d[j][a[i]]+c[i] == d[j][b[i]]):
                is_shortest = True
        if is_shortest:
            ans -= 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 4068
n = int(input())
ns = list(map(int, input().split()))
sum_i = 0
cnt = 0
for i in range(n):
    sum_i += ns[i]
    if i % 2 == 0:
        if sum_i > 0:
            continue
        elif sum_i < 0:
            cnt += abs(sum_i) + 1
            sum_i = 1
        else:
            cnt += 1
            sum_i = 1
    else:
        if sum_i > 0:
            cnt += sum_i + 1
            sum_i = -1
        elif sum_i < 0:
            continue
        else:
            cnt += 1
            sum_i = -1
min_cnt = cnt
cnt = 0
sum_i = 0
for i in range(n):
    sum_i += ns[i]
    if (i+1) % 2 == 0:
        if sum_i > 0:
            continue
        elif sum_i < 0:
            cnt += abs(sum_i) + 1
            sum_i = 1
        else:
            cnt += 1
            sum_i = 1
    else:
        if sum_i > 0:
            cnt += sum_i + 1
            sum_i = -1
        elif sum_i < 0:
            continue
        else:
            cnt += 1
            sum_i = -1
print(min(min_cnt, cnt))

Measured memory_bytes: 63088
#include <iostream>

using namespace std;

int main()
{
    int n, a, b;

    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else if (n == 2) {
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int result;
  
  for (int i=0; i<900; ++i) {
    if ((n+i)%111==0) {
      result =n+i;
      break;
    }
  }
  cout <<result;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
long long n,a,b;
long long ar[1000006];
bool check(long long x)
{
    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        long long t=ar[i]-x*b;
        if(t>0)
        {
            sum+=(long long)ceil(t*1.0/(a-b));
            if(sum>x||sum<0)return false;
        }
    }
    return true;
}
int main()
{
    cin>>n>>a>>b;
    for(long long i = 1;i<=n;i++)
        cin>>ar[i];
    sort(ar+1,ar+1+n);
    long long l=1,r=ar[n]+1,mid;
    while(l<r)
    {
        mid=(r+l)/2;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);

    ll ans=0;

    if(k<=abs(x)/d){
        if(x>0) ans=x-k*d;
        else ans=x+k*d;
    }
    else {
        ans=x-x/d*d;
        if((k-(abs(x)/d))%2){
            if(ans<0) ans+=d;
            else ans-=d;
        }
    }

    printf("%lld",abs(ans));
}


Measured memory_bytes: 3788
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 100000;	//100,000yen
		for(int i=0; i<n; i++){
			sum += Main.DeptMaker(sum);
		}
		System.out.println(sum);
	}
	private static int DeptMaker(int sum){
		int dept = (int) Math.ceil((sum * 0.05)/1000)*1000;
		return  dept;
	}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	std::vector<int> a(n);
	for (auto &i : a) i = ri();
	
	auto ok = [&] (int x) {
		int64_t cnt = 0;
		for (int i = 0; i < n; i++) cnt += (a[i] - 1) / x + 1;
		return cnt - n <= k;
	};
	
	int l = 0;
	int r = 1000000001;
	while (r - l > 1) {
		int m = l + ((r - l) >> 1);
		if (ok(m)) r = m;
		else l = m;
	}
	printf("%d\n", r);
	return 0;
}


Measured memory_bytes: 4060
import kotlin.math.*

fun main(args: Array<String>) {
    val (A, B, H, M) = readLine()!!.split(" ").map { it.toDouble() }

    val longHandAngle: Double = if (M == 0.0) 0.0 else 6 * M
    val shortHandAngle: Double = ((H * 60 + M) / 2)

    val angleMax = max(longHandAngle, shortHandAngle)
    val angleMin = min(longHandAngle, shortHandAngle)

    val tmp = angleMax - angleMin
    val angle = if (tmp > 180) {
        angleMin + 360 - angleMax
    } else {
        tmp
    }

    val result = sqrt(A * A + B * B - (2 * A * B * cos(angle * PI / 180)))
    println(result)
}


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

int main() {
  int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
  cout << min(2*c*max(x,y),a*x+b*y+min(2*c-a-b,0)*min(x,y)) << '\n';
}

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


int main(void){
    int N, K, sum;
    cin >> N >> K;
    sum = 2;  //１回目の操作は1*2。
    for(int i=0; i<N-1; i++){
        sum = min(sum*2, sum+K);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*Infor {{{
    > File Name: b.cpp
    > Author: samcompu
    > Mail: a1592710567@126.com
    > Website: https://www.samcompu.com
    > Created Time: 2018年08月25日 星期六 20时02分56秒
}}}*/
#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for (int i = (int)(a); i >= (int)(b); i--)
#define FORLINE(i, t) for (int i = fi[t]; i; i = ne[i])
typedef long long ll;
typedef unsigned long long int ull;
/*}}}*/

/*Constant {{{*/
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
bool book[101][101];
char s[101];
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  FOR(i, 1, n) {
    cin >> s;
    FOR(j, 1, m) {
      if (s[j - 1] == '#') book[i][j] = true;
    }
  }
  FOR(i, 1, n) {
    bool all1 = true;
    FOR(j, 1, m) {
      if (book[i][j]) {
        all1 = false;
        break;
      }
    }
    if (all1) continue;
    FOR(j, 1, m) {
      bool all2 = true;
      FOR(k, 1, n) {
        if (book[k][j]) {
          all2 = false;
          break;
        }
      }
      if (all2) continue;
      if (book[i][j]) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    System.out.println((100 * (N - M) + 1900 * M) * (int)Math.pow(2, M));
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <list>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n;
    cin>>n;
    int tmp;
    list<int> ls;
    REP(i,n){
        cin>>tmp;
        if(tmp>i+1){
            cout << -1 << endl;
            return 0;
        }else{
            ls.push_front(tmp);
        }
    }

    auto itr = ls.begin();
    list<int> result;

    DEFOR(i,n,0){
        tmp = i+1;
        for (itr = ls.begin(); itr != ls.end();itr++){
           
            if(*itr==tmp){
                result.push_front(*itr);
                ls.erase(itr);
                break;
            }
            tmp--;
        }
    }

    for(auto x:result){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      String s = sc.next();

      s = s.replace("B", "");
      int count = s.length();

      if (count > n/2) {
         System.out.println("Yes");
      }
      else {
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans = 1;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> X >> Y >> Z;

    cout << Z << space << X << space << Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N, X, Y;
int main() {
	cin >> N >> X >> Y;
	for (int k = 1; k <= N - 1; k++) {
		int ANS = N - (Y - X - 1) - (k);
		ANS = max(0, ANS);
		if (k == 1)ANS--;
		
		if (k == (Y - X + 1) / 2 && (Y - X + 1) % 2 == 0) {
			ANS += (Y - X + 1) / 2;
		}
		else if (k <= (Y - X + 1) / 2) {
			ANS += (Y - X + 1);
		}
		

		for (int i = X + 1; i <= Y - 1; i++) {
			int toX = min(i - X, Y - i + 1);
			int toY = min(Y - i, i - X + 1);

			if (1 <= k - toX && k - toX <= X - 1) {
				ANS++;
			}
			if (1 <= k - toY && k - toY <= N - Y) {
				ANS++;
			}
		}

		cout << ANS << endl;
	}
}

Measured memory_bytes: 256
gets
h = {}
t = gets.chomp.split(" ").map{|u|u.to_i}
t.each do |d|
  h[d] = 1
end
gets
t = gets.chomp.split(" ").map{|u|u.to_i}
ans = 0
t.each do |d|
  ans += 1 if h[d] == 1 
end
p ans

Measured memory_bytes: 9052
line = STDIN.gets.chomp

for i in 0..line.length - 1 do
  if line[i].ord >= 65 && line[i].ord <=90 then
    line[i] = (line[i].ord + 32).chr
  elsif line[i].ord >=97 && line[i].ord <= 122 then
    line[i] = (line[i].ord - 32).chr
  end
end

puts line

Measured memory_bytes: 6100
n=gets.to_i
xys=n.times.map{gets.split.map(&:to_i)}
dist=Array.new(n).map{Array.new(n,0)}
pattern=(1..n).to_a.inject(1){|f,i| f*i}
ans=0

for i in 0..n-1
  for j in 0..n-1
    dis_x=(xys[i][0]-xys[j][0])**2
    dis_y=(xys[i][1]-xys[j][1])**2
    ans+=(dis_x+dis_y)**(1/2.0)*(pattern/n)
  end
end

puts ans/pattern


Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	total := 0.0
	for i := 1; i <= n; i++ {
		prob := 1.0 / float64(n)
		value := i
		for value < k {
			prob *= 0.5
			value *= 2
		}
		total += float64(prob)
	}
	fmt.Println(float64(total))
}


Measured memory_bytes: 512
import copy
H, N, K = map(int, input().split())
a = []
for i in range(H):
    b = list(input())
    a.append(b)

cnt = 0
for i in range(2**N):
    ans = []
    for co in a:
        ans.append(copy.copy(co))
    for j in range(N):
        if((i >> j) & 1):
            for k in range(len(ans)):
                ans[k][j] = 'r'
    for l in range(2**H):
        ans2 = []
        for co2 in ans:
            ans2.append(copy.copy(co2))
        for n in range(H):
            if((l >> n) & 1):
                for m in range(len(ans[n])):
                    ans2[n][m] = 'r'
        temp = 0
        for o in range(len(ans2)):
            for p in range(len(ans2[o])):
                if(ans2[o][p] == '#'):
                    temp += 1
        if(temp == K):
            cnt += 1
print(cnt)




Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,a,b,i,ans=0;
  multiset<int> s;
  map<int,multiset<int>> mp;
  cin>>n>>m;
  for(i=0;i<n;i++){
    cin>>a>>b;
    if(a<=m){
      if(mp.count(a)) mp.at(a).insert(b);
      else mp[a].insert(b);
    }
  }
  for(i=1;i<=m;i++){
    if(mp.count(i)) for(auto j:mp[i]) s.insert(j);
    if(s.size()>0){
      auto it=prev(s.end(),1);
      ans+=*it;
      s.erase(it);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 14080
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
# from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

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

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

x = RI()
for i in range(len(x)):
    if x[i]==0:
        print(i+1)
        exit()
    else:
        pass

Measured memory_bytes: 68236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100000];

int main()
{
	int N, ans = 1, st = 0;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N) {
		if (i == 0) continue;

		if (A[i - 1] == A[i]) continue;
		else if (A[i - 1] < A[i]) {
			if (st == 0) st = 1;
			else if (st == 1) continue;
			else {
				ans++;
				st = 0;
			}
		}
		else {
			if (st == 0) st = 2;
			else if (st == 2) continue;
			else {
				ans++;
				st = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, K, sum, a[MAX];

int main(int argc, char** argv) {
	scanf("%d%d", &N, &K);
	rep(i, 0, N) scanf("%d", a+i);
	sort(a, a + N);
	rep(i, 0, K) sum += a[i];
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 3820
// checklist
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

ll const mxn=2e5+5;

ll fact[mxn],ifact[mxn];

ll modpow(ll a, ll b) // put b = mod-2, calc for (x!)^(mod-2) % mod only
{
	ll r=1;
	while(b)
	{
		if(b&1)r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans = modpow(2,n)-1;
	fact[0]=1; ifact[0]=1;
	for(int i=1; i<=max(a,b); i++){
		ifact[i] = modpow(i,MOD-2)%MOD;
	}
	ll ctot=1;
	for(int i=1; i<=a; i++){
		ctot=(ctot*(n-i+1))%MOD;
		ctot=(ctot*ifact[i])%MOD;
	}
	ans -= ctot; ans %= MOD;
	if(ans<0)ans+=MOD;
	ctot=1;
	for(int i=1; i<=b; i++){
		ctot=(ctot*(n-i+1))%MOD;
		ctot=(ctot*ifact[i])%MOD;
	}
	ans -= ctot; ans %= MOD;
	if(ans<0)ans+=MOD;
	cout << ans%MOD << endl;
}	


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
friends = [set() for i in range(n)]


def dfs(i):
    ans[-1] += 1
    flg[i] = 1
    for j in friends[i]:
        if not flg[j]:
            dfs(j)
    return


for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    friends[a].add(b)
    friends[b].add(a)

flg = [0]*n
ans = []

for i in range(n):
    ans.append(0)
    if not flg[i]:
        dfs(i)

print(max(ans))


Measured memory_bytes: 239468
/*******************************
Author:galaxy yr
LANG:C++
Created Time:2019/08/10 13:13:56
*******************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int a,b,ans;
int main()
{
        //freopen("a.in","r",stdin);
        //freopen("a.out","w",stdout);
        cin>>a>>b;
        ans=max(a+b,a-b);
        ans=max(ans,a*b);
        cout<<ans<<endl;
        return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll x;
    cin >> x;

    ll a = 100;
    int ans = 0;
    while(a < x){
        a += a / 100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
  a = list(map(int,input().split()))
  sum = 0
  for j in range(m):
    sum += (a[j]*b[j])
  sum += c
  if sum > 0:
    cnt += 1
  else:
    pass
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };



//sizeによる実装
class UnionFind {
public:
	vector<int> s, p;

	UnionFind() {}
	UnionFind(int size) {
		s.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		s[x] = 1;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		x = findSet(x);
		y = findSet(y);

		if (x == y)return;
	
		if (s[x] < s[y])swap(x, y);

		p[y] = x;
		s[x] += s[y];
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}

	int size(int x) {
		return s[findSet(x)];
	}
};


int main() {

	ll n, m;
	cin >> n >> m;

	UnionFind un = UnionFind(n);

	vector<pair<ll, ll>>e;
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		e.pb({ a,b });
	}

	reverse(all(e));

	vector<ll>ans;
	ans.pb(n*(n - 1) / 2);
	rep(i, 0, e.size()-1) {
		if (!un.same(e[i].first,e[i].second)) {
			ll n1 = un.size(e[i].first);
			ll n2 = un.size(e[i].second);
			ans.pb(ans[i]-n1*n2);
			un.unite(e[i].first,e[i].second);
		}
		else {
			ans.pb(ans[i]);
		}
	}

	reverse(all(ans));
	fore(i, ans)cout << i << endl;



	return 0;
}

Measured memory_bytes: 5488
import java.util.*;

public class Main{
	public static void search(int x,int y,int w,int h,String[][] map,Boolean[][] memo){
		if(x < 0 || x > w-1 || y < 0 || y > h-1 || map[x][y].equals("#")) return;
		if(memo[x][y]) return;
		memo[x][y] = true; 
		//System.out.println(x+","+y+"true");
		search(x+1,y,w,h,map,memo);
		search(x,y-1,w,h,map,memo);
		search(x-1,y,w,h,map,memo);
		search(x,y+1,w,h,map,memo);
	} 
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int w = scan.nextInt();
			int h = scan.nextInt();
			int count = 0;
			if(w == 0 && h == 0) break;
			String[][] map = new String[w][h];
			Boolean[][] memo = new Boolean[w][h];
			for(int i=0;i<h;i++){
				String str = scan.next(); 
				for(int j=0;j<w;j++){
					memo[j][i] = false;
					map[j][i] = String.valueOf(str.charAt(j));
				}
			}
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(map[j][i].equals("@")){
						search(j,i,w,h,map,memo);
						break;
					}
				}
			}
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					//System.out.print(map[j][i]);
					//System.out.println();
					if(memo[j][i] == true) count++;
				}
				//System.out.println("");
			}
			System.out.println(count);
			/*
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print(memo[i][j]);
				}
				System.out.println("");
			}
			*/
		}
	}
}

Measured memory_bytes: 39728
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int m,n,k;
  static int mp[3][1001][1001];
  scanf("%d%d%d",&m,&n,&k);
  for(int i=0;i<1001;i++) for(int j=0;j<3;j++) mp[j][i][0] = 0;
  for(int i=0;i<1001;i++) for(int j=0;j<3;j++) mp[j][0][i] = 0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      char c,nf;
      scanf(" %c",&c);
      if(c=='J') nf = 0;
      else if(c=='O') nf = 1;
      else if(c=='I') nf = 2;
      for(int k=0;k<3;k++){
        if(k==nf){
          mp[k][i][j] = mp[k][i][j-1] + mp[k][i-1][j] - mp[k][i-1][j-1] + 1;
        }else{
          mp[k][i][j] = mp[k][i][j-1] + mp[k][i-1][j] - mp[k][i-1][j-1];
        }
      }
    }
  }
  for(int i=0;i<k;i++){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(int j=0;j<3;j++){
      printf("%d",mp[j][c][d] + mp[j][a-1][b-1] - mp[j][a-1][d] - mp[j][c][b-1]);
      if(j==2) printf("\n");
      else printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 14500
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if(i==0):
    ans+=a[0]
  elif(i==n-1):
    ans+=a[n-2]
  else:
    ans+=min(a[i-1],a[i])
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(abs(a-b)==1){
    if(a+b==3){
    cout<<"3"<<endl;}
    else{
        cout<<"1"<<endl;
    }
}
else{
    cout<<"2"<<endl;
}

    return 0;
}

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

int main() {
	static long long N, A[100000] = {}, ANS[100000], COUNT = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i % 2 == 0) COUNT += A[i];
		else COUNT -= A[i];
	}
	ANS[0] = COUNT / 2;
	for (int i = 1; i < N; i++) {
		ANS[i] = A[i - 1] - ANS[i - 1];
	}
	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << ANS[i] * 2;
	}
	cout << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  c-=a;
  c-=b;
  if(c<0){
    cout<<"No"<<endl;
    return 0;
  }
  ll x;
  x=4*a*b;
  c*=c;
  if(x<c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	double r1, r2;
	cin >> r1 >> r2;
	printf("%.10f\n", r1 * r2 / (r1 + r2));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	int ans = 1;
	bool f = false;
	for (int i = 0; i < n; i++) {
		for (int wi = 0; wi < i; wi++) {
			if (v[i] < v[wi])f = false;
		}
		if (f)ans++;
		f = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256