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

using namespace std;

int main(void){
    string s1;
    string s2;
    string s3;
    string tmp1;
    string tmp2;
    string tmp3;
    string ans;

    cin >> s1 >> s2 >> s3;

    tmp1=s1[0];
    tmp2=s2[0];
    tmp3=s3[0];
    
    ans=tmp1+tmp2+tmp3;

    transform(ans.begin(),ans.end(),ans.begin(),::toupper);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let patterns: Vec<Vec<char>> = [
        "dream",
        "dreamer",
        "erase",
        "eraser"
    ]
        .iter()
        .map(|s| s.chars().rev().collect())
        .collect();

    let s: Vec<char> = read::<String>().chars().rev().collect();
    let mut s = &s[..];
    let mut succeeded = true;
    while s.len() > 0 {
        let matched = patterns.iter().find(|&p| s.starts_with(p));
        if let Some(p) = matched {
            s = &s[p.len()..];
        } else {
            succeeded = false;
            break;
        }
    }
    println!("{}", if succeeded { "YES" } else { "NO" });
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x = 0;
  rep(i,n){
    if(i%2) x -= a[i];
    else x += a[i];
  }
  vector<int> ans(n);
  ans[0] = x/2;
  for(int i=0;i<n-1;i++){
    ans[i+1] = a[i] - ans[i];
  }
  rep(i,n) ans[i] *=2;
  
  rep(i,n) printf("%d%c",ans[i],i==n-1 ? '\n' : ' ');
}
  

Measured memory_bytes: 2048
#include <stdio.h>

int main(){
  int stats[5], sum = 0, ave, i;
  for(i = 0; i < 5; i++){
    scanf("%d", &stats[i]);
    if(stats[i] < 40) stats[i] = 40;
    sum = sum + stats[i];
  }
  ave = sum / 5;
  printf("%d\n", ave);
  return 0;
}

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

int main() {
    long N , Q;
    cin >> N >> Q;
    vector <long>  a(N  + 10);
    vector <long>  b(N  + 10);
    vector <long>  p(Q  + 10);
    vector <long>  x(Q  + 10);

    vector <vector <long>> room_list(N + 10, vector<long>(0));
    vector <long> value_list(N + 10, 0);


    for(long i = 0; i < N - 1; i++)
    {
        cin >> a[i] >> b[i];
        room_list[a[i]].emplace_back(b[i]);
    }

    for(long i = 0; i < Q; i++)
    {
        cin >> p[i] >> x[i];
        value_list[p[i]] += x[i];
    }


    queue<long> index_queue;
    index_queue.push(1);
    for(long i = 1; i < N + 1; i++)
    {
        long index = index_queue.front();
        index_queue.pop();
        for(long j = 0;j < room_list[index].size(); j++)
        {
            index_queue.push(room_list[index][j]);
            value_list[room_list[index][j]] += value_list[index];
        }
    }

    for(long i = 1; i < N + 1; i++)
    {
        cout << value_list[i] << " " ;
    }

    cout << endl;

    return 0;  
}

Measured memory_bytes: 21120
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}

int n, m, t, x, y;

bool dp1[20000], dp2[20000];

int main(void) {
	speed();
	int n, x; cin >> n >> x;
	vector<lint> d(n);
	for (int i = 0; i < n; i++) { cin >> d[i]; }
	lint ans = 0;
	if (d[0] + d[1] > x) {
		lint a = d[1];
		d[1] = max(0ll, -d[0] + x);
		ans += a - d[1];
		if (d[0] + d[1] > x) {
			lint a = d[0];
			d[0] = x;
			ans += a - x;
		}
	}
	for (int i = 2; i < n; i++) {
		if (d[i - 1] + d[i] > x) {
			lint a = d[i];
			d[i] = x - d[i - 1];
			ans += a - (x - d[i - 1]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3948
import java.util.*;

public class Main {
	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);
	    String inputStr = scanner.nextLine();
		char[] array = inputStr.toCharArray();
		int result = 0;
		for (char input : array) {
			if (input == '+') {
			    result++;
			} else {
			    result--;
			}
		}
		System.out.print(result);
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;


int main(){
    int n,sum=0;
    cin>>n;
    vector<int> x(n),y(n);
    rep(i,n){
        cin>>x[i];
    }
    rep(i,n){
        cin>>y[i];
        if (x[i]>y[i]) {
            sum += x[i]-y[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n - 1):
    if h[i] < h[i + 1]:
        tmp = 0
    else:
        tmp += 1
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 14252
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(M)]
PQ = [list(map(int, input().split())) for i in range(Q)]

acc = [[0 for i in range(N+1)] for i in range(N+1)]  # acc[i][j] = i以下からスタートしてj以下で終了する電車の数
coordinate = [[0 for i in range(N)] for i in range(N)]
for l, r in LR:
    l -= 1
    r -= 1
    coordinate[l][r] += 1

for i in range(N):
    for j in range(N):
        acc[i+1][j+1] = acc[i][j+1] + acc[i+1][j] - acc[i][j] + coordinate[i][j]

for p, q in PQ:
    p -= 1
    ans = acc[N][q] - acc[p][q]
    print(ans)

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 13 && b == 1)
		cout << "Bob" << endl;
	else if (a == 1 && b == 13)
		cout << "Alice" << endl;
	else if (a > b)
		cout << "Alice" << endl;
	else if (b > a)
		cout << "Bob" << endl;
	else
		cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 256
class Light
  def initialize(switches, p)
    @switches = switches
    @p = p
  end

  def up?(switches)
    (@switches.count { |s| switches[s] } % 2) == @p
  end
end

def switches(switches, lights)
  ans = 0

  recursive = ->(depth) {
    if switches.size <= depth
      ans += 1 if lights.all? { |l| l.up?(switches) }
      return
    end
    switches[depth] = false
    recursive.call(depth + 1)
    switches[depth] = true
    recursive.call(depth + 1)
  }
  recursive.call(0)
  ans
end

n, m = gets.split.map(&:to_i)
switches = Array.new(n) { false }
params = []
m.times do
  param = gets.split.map(&:to_i)
  param.shift
  param.map! { |n| n - 1 }
  params << param
end

p = gets.split.map(&:to_i)
lights = []
params.zip(p).each do |s, p|
  lights << Light.new(s, p)
end

puts switches(switches, lights)


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

#define ff                   first
#define ss                   second
#define ll                  long long int
#define pii                  pair<int,int>
#define pb                   push_back
#define rep(i,a,b)           for(int i=a;i<b;i++)
#define t(x)                 int t; cin>>t; while(t--)
#define vi                   vector<int>
#define mii                  map<int,int>
#define min3(a, b, c)        min(min(a, b), c)
#define min4(a, b, c, d)     min(min(a, b), min(c, d))
#define max3(a, b, c)        max(max(a, b), c)
#define max4(a, b, c, d)     max(max(a, b), max(c, d))
#define ps(x,y)              fixed<<setprecision(y)<<x
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define all(x)               x.begin(),x.end()
#define FIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

ll w, h, n;

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
ll power(ll x, ll y)
{
    int res = 1;      // Initialize result

    // Update x if it is more than or
    // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) ;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) ;
    }
    return res;
}


int main()
{
    FIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif


    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    while (n--)
    {
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            cnt++;
            ans = max(ans, cnt);
        }
        else
            cnt=0;
    }
    if (ans >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define chmax(x, y) x = max(x,y);

int main(){
  map <string,int> m;

  int n;
  vector <pair <int, string>> v;
  cin>>n;
  for (int i=0; i<n; i++){
    string s;
    cin>>s;
    m[s]+=1;
  }
  int cnt=0;

  for (auto i:m){
    v.emplace_back(make_pair(i.second,i.first));
    cnt++;
  }
  sort(v.begin(),v.end());

  int maxnum=v[cnt-1].first;
  int i=0;
  for (int i=0; i<cnt; i++){


    if (v[i].first==maxnum){
      cout<<v[i].second<<endl;
    }
  }
  }


Measured memory_bytes: 29040
a,b,c,d = map(int,input().split())

ans = b-a+1

import fractions
lcm=c * d // fractions.gcd(c, d)

c_mul_nums = b//c - (a-1)//c
d_mul_nums = b//d - (a-1)//d
cd_mul_nums = b//lcm - (a-1)//lcm

print(ans - c_mul_nums - d_mul_nums + cd_mul_nums)

Measured memory_bytes: 5048
#include<stdio.h>

int main(void)
{
    int a;
    int b;
    int iSqaure;
    int iLength;

    scanf("%d%d",&a,&b);
    iSqaure = a * b;
    iLength = 2 * a + 2 * b;
    printf("%d %d\n",iSqaure,iLength);

    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {

    string st;
    cin >> st;
    ll k;
    cin >> k;
    ll ans = 0;
    ll suf = 0;
    ll pref = 0;
    for (int i = 0; i < st.size(); ++i) {
        ll ind = i;
        ll cnt = 0;
        while (ind < st.size() && st[i] == st[ind]) {
            ++ind;
            ++cnt;
        }
        if (i == 0) {
            pref = cnt;
        }
        if (ind == st.size()) {
            suf = cnt;
        }
        i = ind - 1;

        ans += cnt / 2;
    }
    if (pref == st.size()) {
        cout << (k * st.size()) / 2;
        return 0;
    } else if (st[0] == st[st.size() - 1]) {
        if ((pref % 2 == 0 || suf % 2 == 0)) {
            cout << ans * k;
            return 0;
        } else {
            cout << ans * k + k - 1;
        }
    } else {
        cout << ans * k;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
from math import ceil, log2


def main():
    N, K = map(int, input().split())
    prob = 0
    for n in range(1, N+1):
        m = ceil(log2(1.0 * K / n)) if n < K else 0
        prob += (1 / N) * (1 / 2) ** m
    print(prob)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long count=Arrays.asList((new Scanner(System.in)).nextLine().split(""))
				.stream()
				.filter(s->s.equals("o"))
				.count();
		System.out.println(700+100*count);
	}
}

Measured memory_bytes: 26704
def main():
	n, t = map(int, input().split())
	possible_home = False
	min_cost = 10**9
	for _ in range(n):
		c, ti = map(int, input().split())
		if ti <= t:
			possible_home = True
			if c < min_cost:
				min_cost = c

	if possible_home:
		print(min_cost)
	else:
		print("TLE")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = mod;
    for (int i=-100; i<=100; i++) {
        int cost = 0;
        rep(j, n) {
            cost += (i-a[j])*(i-a[j]);
        }
        chmin(ans, cost);
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int N, D, S;

    cin >> D >> N;
    S = 1;
    for (int i = 0; i < D; i++) S *= 100;
    if (N <= 99) {
        cout  << N  * S << endl;
    } else {
        cout << 101 * S << endl;
    }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc119/tasks/abc119_a
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string C, S;
    while( getline( cin, C, '/' ) ){
        S += C;
    }
    cout << ( stoi( S ) <= 20190430 ? "Heisei" : "TBD" ) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextIntLine() []int {
	sc.Scan()
	splitStr := strings.Fields(sc.Text())
	ints := make([]int, len(splitStr))
	for i := 0; i < len(splitStr); i++ {
		n, _ := strconv.Atoi(splitStr[i])
		ints[i] = n
	}
	return ints
}

type satis struct {
	idx      int
	manzokuB int
	manzokuC int
	preEaten int
}

func main() {
	_, _ = strconv.Atoi(nextLine())
	a := nextIntLine()
	b := nextIntLine()
	c := nextIntLine()
	var score int
	preEaten := -1
	for _, v := range a {
		score += b[v-1]
		if preEaten == v-1 {
			score += c[v-2]
		}
		preEaten = v
	}
	fmt.Println(score)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
typedef pair<int,pair<int,int>> pll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,s1,s2,d1,d2;
    cin>>n>>m;
    cin>>s1>>s2;
    cin>>d1>>d2;
    s1--;
    s2--;
    d1--;
    d2--;
    vector<vector<char>> v(n+1,vector<char>(m+1));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>v[i][j];
        }
    }
    priority_queue<pll,vector<pll>,greater<pll>> pq;
    pq.push({0,{s1,s2}});
    vector<vector<bool>> visit(n+1,vector<bool>(m+1,false));
    int flag=0;
    static int x[]={1,0,-1,0};
    static int y[]={0,1,0,-1};
    static int xm[]={2,-2,0,-2,2,-2,0,-2,2,2,-2,2,1,1,-1,-1,-1,1,0,0,1,-1,-1,1};
    static int ym[]={-2,2,2,0,0,-2,-2,-1,2,-1,1,1,-2,2,-2,2,-1,1,-1,1,0,0,1,-1};
    while(!pq.empty()){
        int dis = pq.top().first;
        int a = pq.top().second.first;
        int b = pq.top().second.second;
        //cout<<a<<" "<<b<<endl;
        pq.pop();
        if(a==d1 && b==d2){
            flag=1;
            cout<<dis<<endl;
            break;
        }
        if(visit[a][b]==true)
            continue;
        visit[a][b]=true;
        for(int k=0;k<4;k++){
            int r = a+x[k];
            int s = b+y[k];
            if(r>=0 && r<n && s>=0 && s<m && visit[r][s]==false && v[r][s]!='#'){
                pq.push({dis,{r,s}});
                //visit[r][s]=true;
            }
        }
        for(int k=0;k<24;k++){
            int r = a+xm[k];
            int s = b+ym[k];
            if(r>=0 && r<n && s>=0 && s<m && visit[r][s]==false && v[r][s]!='#'){
                pq.push({dis+1,{r,s}});
                //visit[r][s]=true;
            }
        }
    }
    if(flag==0)
        cout<<-1<<endl;
    return 0;
}


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

main(){
  int D;
  cin >> D;
  if(D==22)cout << "Christmas Eve Eve Eve" << endl;
  if(D==23)cout << "Christmas Eve Eve" << endl;
  if(D==24)cout << "Christmas Eve" << endl;
  if(D==25)cout << "Christmas" << endl;
}


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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int s[n];
    int sums=0;
    int minnd=101;
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        sums+=s[i];
        if(minnd>s[i]&&s[i]%10!=0) minnd=s[i];
    }
    if(sums%10!=0) cout << sums << "\n";
    else{
        if(minnd==101) cout << "0" << "\n";
        else           cout << sums-minnd << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main(int argc, char *argv[])
{
    int a, b, res = 0;
    cin >> a >> b;

    if (a > b)
    {
        res += a;
        a--;
    }
    else
    {
        res += b;
        b--;
    }

    if (a > b)
    {
        res += a;
        a--;
    }
    else
    {
        res += b;
        b--;
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))

a = [ v[i] for i in range(0,n,2)]
b = [ v[i] for i in range(1,n,2)]
A = [0] * 100010
B = [0] * 100010

for i in range(int(n/2)):
    A[a[i]] += 1
    B[b[i]] += 1

if A.index(max(A)) == B.index(max(B)):
    BB = sorted(B)
    cc1 = len(b) - BB[-2] + len(a) - max(A)
    AA = sorted(A)
    cc2 = len(a) - AA[-2] + len(b) - max(B)
    if cc1 > cc2:
        print(cc2)
    else:
        print(cc1)
else:
    print(n - max(A) - max(B))


Measured memory_bytes: 14404
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  vector<ll> idx(n);
  for (int i = 0; i < n; i++) idx[i] = i;
  sort(idx.rbegin(), idx.rend(), [&](auto &x, auto &y){return a[x] < a[y];});

  vector<vector<ll> > dp(n+1, vector<ll>(n+1));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[j+1][i-j] = max(dp[j+1][i-j], dp[j][i-j] + a[idx[i]] * abs(idx[i] - j));
      dp[j][i-j+1] = max(dp[j][i-j+1], dp[j][i-j] + a[idx[i]] * abs(idx[i] - (n-(i-j)-1)));
    }
  }

  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    if (dp[i][n-i] > ans) ans = dp[i][n-i];
  }

  cout << ans << endl;

  return 0;
}


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

int main(){

    int n;
    cin>>n;
    vector<int> check(n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        check[a-1]=i+1;
    }
    for(int i=0;i<n;i++){
        cout<<check[i]<<" ";
    }
    cout<<endl;


    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define S ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std; 
signed main()
{
    S;
    int x,y;
    cin>>x>>y;
    if(y%2==0 && y>=2*x && y<=4*x)
    cout<<"Yes";
    else
    cout<<"No";
}
    

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
using namespace std;
const int N=2e5+5,mo=1e9+7;
struct data
{
	int k,b;
}a[N];
int n,ans;
int ll[N],rr[N],f[N],pre[N];
vector<int> ss[N];
inline int read()
{
	int X=0,w=0; char ch=0;
	while(!isdigit(ch)) w|=ch=='-',ch=getchar();
	while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w?-X:X;
}
inline bool cmp(data x,data y)
{
	return x.k<y.k || x.k==y.k && x.b<y.b;
}
inline int min(int x,int y)
{
	return x<y?x:y;
}
inline int max(int x,int y)
{
	return x>y?x:y;
}
inline void add(int &x,int y)
{
	x=x+y>=mo?x+y-mo:x+y;
}
inline int addv(int x,int y)
{
	return x+y>=mo?x+y-mo:x+y;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i].b=read(),a[i].k=read();
	sort(a+1,a+1+n,cmp);
	f[0]=-mo;
	for(int i=1;i<=n;i++)
	{
		f[i]=max(f[i-1],a[i].b);
		int l=1,r=i,pos=0;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(f[mid]>=a[i].b)
			{
				pos=mid;
				r=mid-1;
			}else l=mid+1;
		}
		ll[i]=pos;
	}
	f[n+1]=mo;
	for(int i=n;i;i--)
	{
		f[i]=min(f[i+1],a[i].b);
		int l=i,r=n,pos=0;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(f[mid]<=a[i].b)
			{
				pos=mid;
				l=mid+1;
			}else r=mid-1;
		}
		rr[i]=pos;
	}
	for(int i=1;i<=n;i++) ss[rr[i]].push_back(ll[i]);
	for(int i=1;i<=n;i++) sort(ss[i].begin(),ss[i].end());
	pre[0]=f[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=0;
		for(int j=0;j<(int)ss[i].size();j++)
		{
			int val=ss[i][j]>1?pre[ss[i][j]-2]:0;
			int sum=((long long)f[i]+pre[i-1]-val+mo)%mo;
			add(f[i],sum);
		}
		pre[i]=addv(pre[i-1],f[i]);
	}
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 15872
N = int(input())
b_list = list(map(int, input().split()))
rev_b = reversed(b_list)

ans = []

while len(b_list) > 0:
    f = -1
    for i in range(len(b_list)):
        if b_list[i] == i + 1:
            f = i
    if f == -1:
        print(-1)
        exit()
    ans.append(b_list[f])
    b_list.pop(f)
ans = reversed(ans)
for a in ans:
    print(a)


Measured memory_bytes: 3064
from collections import deque
n = input()
dq = deque()
arr = map(int,raw_input().split())
dq.append(arr[0])
ff = 1
for i in range(1,n):
	if ff:
		dq.append(arr[i])
		ff ^= 1
	else:
		dq.appendleft(arr[i])
		ff ^= 1
if ff:
	for i in range(n):
		print dq[i],
else:
	for i in reversed(range(n)):
		print dq[i],



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

vector<int> g[200'000];
int cnt[200'000];
int ans[200'000];

void dfs(int v, int from, int add) {
    if(ans[v] != -1) return;
    ans[v] += add + 1;
    for(auto && i : g[v]){
        if(i == from) continue;
        dfs(i, v, add + cnt[i]);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        ans[i] = -1;
    }
    for(int i = 0; i < n-1; ++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q--){
        int p, x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }
    dfs(0, -1, cnt[0]);
    cout << ans[0];
    for(int i = 1; i < n; ++i){
        cout << " " << ans[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 24064
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ULL;

int h, n, c;


int main() {
    scanf("%d%d", &h, &n);
    while(n--) {
        scanf("%d", &c);
        h -= c;
    }
    if(h <= 0)
        printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int N , M;
	cin >> N >> M;
	vector<int> cnt(N , 1);
	vector<int> canBe(N);
	canBe[0] = 1;
	while(M--)
	{
		int x , y;
		cin >> x >> y;
		x--;y--;
		if(canBe[x])
			canBe[y] = 1;
		if(cnt[x] == 1)
			canBe[x] = 0;
		cnt[x]--;
		cnt[y]++;
	}
	int ans = 0;
	for(auto x : canBe)
		ans += x;
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <cmath>
 #include <cstring>
 #include <iostream>
 #include <ostream>
 #include <vector>
   
 using std::cin;
 using std::cout;
 using std::cerr;
 using std::endl;
   
 // n 以下の素数のリストを返す O(nlog(log(n)))
 std::vector<int> eratosthenes(int n) {
   std::vector<int> is_prime(n + 1, 1);
   std::vector<int> primes;
  
   is_prime[0] = is_prime[1] = 0;
   primes.push_back(2);
   for(int i = 3; i <= n; i += 2) {
     if(is_prime[i]) {
       primes.push_back(i);
       for(int j = 3; i * j <= n; j += 2) {
         is_prime[i * j] = 0;
       }
     }
   }
  
   return primes;
 }
   
 int main() {
   int n;
   std::vector<int> primes = eratosthenes(10000);
   
   while(cin >> n, n) {
     int a = 2, b = 3;
     for(int i = 1; i < primes.size(); i++) {
       if (primes[i] > n) break;
  
       if(primes[i] - primes[i - 1] == 2) {
         a = primes[i - 1];
         b = primes[i];
       }
     }
     cout << a << " " << b << endl;
   }
   
   return 0;
 }


Measured memory_bytes: 3108
N, X = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

def kouyaku(a,b):
    aa = max(a,b)
    bb = min(a,b)
    if bb == 0:
        return aa
    else:
        return kouyaku(bb,aa%bb)

res = 0
for i in P:
    if res:
        res = kouyaku(res, abs(X - i))
    else:
        res = abs(X - i)

print(res)

Measured memory_bytes: 14224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, k;
    
    std::cin >> n >> k;
    
    if(n % k == 0) std::cout << 0 << std::endl;
    else std::cout << 1 << std::endl;
    
    return 0;
}


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

const ll INF = (1LL<<31)-1;

template <typename T>
struct RMQ{
    int n = 1;
    vector<T> d;

    RMQ(int sz){
        while(n < sz) n*=2;
        d.resize(n*2);
        for(int i=0;i<n*2-1;i++) d[i] = INF;
    }

    void update(int i, T x){
        i += (n-1);
        d[i] = x;

        while(i>0){
            i = (i-1)/2;
            d[i] = min(d[i*2+1], d[i*2+2]);
        }
    }

    T find(int a, int b, int i, int l, int r){
        if(r<=a || b<=l) return INF;

        if(a<=l && r<=b) return d[i];
        else{
            T vl = find(a,b,i*2+1,l,(l+r)/2);
            T vr = find(a,b,i*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};

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

    RMQ<int> rmq(n);
    int N = 1;
    while(N < n) N*=2;

    rep(i,q){
        int c,x,y; cin >> c >> x >> y;

        if(c==0) rmq.update(x,y);
        else{
            cout << rmq.find(x,y+1,0,0,N) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3852
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    a = sc.intarr()[0]
    print(a**2)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        var s = Console.ReadLine();

        //0と1の数をカウント
        //少ないほうを2倍
        int z = 0;
        int o = 0;

        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '0')
            {
                o++;
            }
            else
            {
                z++;    
            }
        }

        long ans = (long)Math.Min(z,o) * 2;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11360
# INPUT
n = int(input())
W = list(map(int, input().split()))


# PROCESS
cost = 0
W_sorted = sorted(W)
W_min = W_sorted[0]

for i in range(n - 1):
    cycle_min = W_sorted[i]
    cost_cycle_in = 0
    cnt_change = 0

    index_cycle_min = W.index(cycle_min)

    while index_cycle_min != i:
        cycle_change = W_sorted[index_cycle_min]
        index_cycle_change = W.index(cycle_change)

        W[index_cycle_min], W[index_cycle_change] = cycle_change, cycle_min
        cost_cycle_in += cycle_min + cycle_change

        cnt_change += 1
        index_cycle_min = index_cycle_change

    if cnt_change:
        cost_cycle_out = (
            cost_cycle_in
          + (cycle_min + W_min) * 2
          - (cycle_min - W_min) * cnt_change
        )

        cost += min(cost_cycle_in, cost_cycle_out)


# OUTPUT
print(cost)



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    if(n&1)cout<<"No";
    else{
        for(int i = 0;i<n/2;i++)
        {
            if(s[i]!=s[i+n/2])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  bool isOdd = true;
  for(auto c = S.begin(); c!=S.end(); ++c)
  {
    if(isOdd)
    {
      
      if(*c != 'R' & *c != 'U' && *c != 'D')
      {
        cout << "No" << '\n'; return 0;
      }
      isOdd = false;
    }
    else
    {
      if(*c != 'L' & *c != 'U' && *c != 'D')
      {
        cout << "No" << '\n'; return 0;
      }
      isOdd = true;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = LLONG_MAX;
const ll MAX_N = 100000;

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


int main() {
	int n, d, x;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		int a,t=1;
		cin >> a;
		while (t <= d) {
			x++;
			t += a;
		}
	}
	cout << x << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  stack<char> st;
  
  long long i = 0;
  for(auto c:s){
    if(st.empty()){
      st.push(s[i]);
    }
    else if(st.top() == s[i])
      st.push(s[i]);
    else
      st.pop();
    
    i++;
  }
  
  long long stack_count = 0;

  cout << s.size() - st.size() << endl;
}

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}
double dp[3001][3001];

double func(int i,int x,double a[]){
    if(x==0) return 1;
    if(i==0) return 0;

    if(dp[i][x] > -0.9) return dp[i][x];

    return dp[i][x]=(a[i]*func(i-1,x-1,a))+((1-a[i])*func(i-1,x,a));
}

void solve(){
	int n;
    cin>>n;
    double a[n+1];
    int c=0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++) cin>>a[i];
    int x=(n+1)/2;
    cout<<ps(func(n,x,a),10);
}
    

int32_t main()
{
   // FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}


Measured memory_bytes: 74320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
struct UnionFind {
    vector<int> par,siz; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) , siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) siz[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[rx]+=siz[ry];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x){
        return siz[root(x)];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    REP(i,m){
        int x,y,z;cin >> x >> y >> z;
        x--,y--;
        uf.unite(x,y);
    }
    int ans=0;
    REP(i,n){
        if(uf.root(i)==i){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )

static
int getPrimes (
  int x,
  int p
  )
{
  int res = 0;

  while ( !( x % p ) )
  {
    x /= p;
    ++res;
  }

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int n;
    int p2 = 0, p5 = 0;

    scanf ( "%d", &n );
    if ( !n ) break ;

    for ( i = 1; i <= n; ++i )
    {
      p2 += getPrimes ( i, 2 );
      p5 += getPrimes ( i, 5 );
    }

    printf ( "%d\n", MIN( p2, p5 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    vector<string> aa(2);
    aa[0] = ""; aa[1] = "";
    rep(i, b){
        aa[0].insert(aa[0].end(), a+'0');
    }
    rep(i, a){
        aa[1].insert(aa[1].end(), b+'0');
    }
    sort(aa.begin(), aa.end());
    cout << aa[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(a < b) swap(a, b);
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int & i : v) cin >> i;
  vector<int> p(n), s(n);
  int g = 0;
  for(int i = 0; i < n; i++){
    g = gcd(g, v[i]);
    p[i] = g;
  }
  g = 0;
  for(int i = n - 1; i >= 0; i--){
    g = gcd(g, v[i]);
    s[i] = g;
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int now = 0;
    if(i) now = gcd(now, p[i - 1]);
    if(i + 1 < n) now = gcd(now, s[i + 1]);
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int n;
double a[3100], f[3100][3100], ans;

int main()
{
	scanf("%d", &n);
	memset(f, 1.000000000, sizeof(f));
	for (int i = 1; i <= n; ++ i)
		scanf("%lf", &a[i]);
	f[0][0] = 1;
	for (int i = 1; i <= n; ++ i)
	{
		f[i][0] = f[i - 1][0] * (1 - a[i]);
		for (int j = 1; j <= i; ++ j)
		{
			f[i][j] = f[i - 1][j - 1] * a[i] + f[i - 1][j] * (1 - a[i]);
		}
	}
	for (int i = n / 2 + 1; i <= n; ++ i)
		ans += f[n][i];
	printf("%.10lf", ans);
	return 0;
}

Measured memory_bytes: 75392
import itertools
def main():
  S = input()
  K = int(input())
  
  if len(set(S)) == 1:
    print(len(S) * K // 2)
    return
  
  cc = 0
  gg = itertools.groupby(S)
  for key, item in gg:
    cc += len(list(item))//2
  a = b = 0
  if S[0] == S[-1]:
    while a < len(S) and S[a] == S[0]:
      a += 1
    S = S[::-1]
    while b < len(S) and S[b] == S[0]:
      b += 1
  output = K * cc - (K-1) * (a//2 + b//2 - (a+b)//2)
  print(output)
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  string ans;
  int N=s.size();
  for(int i=0;i<N;i+=2){
    ans += s[i];
  }
  cout<<ans<<endl; 
  return 0;
}
//始まりが1オリジンなのがポイント。


Measured memory_bytes: 3600
from heapq import heapify, heappushpop

X, Y, A, B, C = map(int, input().split())
# 大きい順にソートして受け取っておく
p = sorted(list(map(int, input().split())))[::-1]
q = sorted(list(map(int, input().split())))[::-1]
r = sorted(list(map(int, input().split())))[::-1]
ans_list = p[:X] + q[:Y]  # 着色しない場合
heapify(ans_list)
for ri in r:
    if ri > ans_list[0]:
        heappushpop(ans_list, ri)
    else:
        break
print(sum(ans_list))


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long X) {
    ll cnt = 0;
    ll money = 100;
    while (1) {
        cnt++;
        money = ll(money * 1.01);
        if (money >= X) {
            break;
        }
    }
    cout << cnt << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()

int main(){
  string s; int K; cin >> s >> K;
  int n = s.size();

  vector<string> ans;
  rep(i, n) for (int j = 1; i+j <= n && j <= K; j++) {
    ans.pb(s.substr(i,j));
  }
  sort(all(ans));
  ans.erase(unique(all(ans)), ans.end());
  std::cout << ans[K-1] << '\n';
}


Measured memory_bytes: 1660
(defun all-ok (n)
  (loop for i from 1 to n
        do (format t "Yes~%")))

(let ((n (read))
      (k (read))
      (q (read))
      (b 0)
      p)
  (setf b (- k q))
  (if (> b 0)
      (all-ok n)
      (progn 
        (setf p (make-array n))
        (loop for i from 1 to q
              do (let ((a (read)))
                   (incf (aref p (1- a)))))
        (loop for o across p
              do (if (> (+ b o) 0)
                     (format t "Yes~%")
                     (format t "No~%"))))))

Measured memory_bytes: 58088
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll mod = 1e9 + 7;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

int n;
int st[4000005];
int dp[1000005];

int query(int l, int r, int i, int qs, int qe)
{
    if (l > r)
        return -inf;
    if (qs > r or qe < l)
        return -inf;
    if (qs <= l and qe >= r)
        return st[i];
    int m = (l + r) / 2;
    return max(query(l, m, 2 * i + 1, qs, qe), query(m + 1, r, 2 * i + 2, qs, qe));
}

void update(int l, int r, int i, int index, int val)
{
    if (l > r)
        return;
    if (index > r or index < l)
        return;
    if (l == r)
    {
        st[i] = val;
        return;
    }
    int m = (l + r) / 2;
    update(l, m, 2 * i + 1, index, val);
    update(m + 1, r, 2 * i + 2, index, val);
    st[i] = max(st[2 * i + 1], st[2 * i + 2]);
}

int32_t main()
{
    IOS;
    cin >> n;
    int h[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    int dp[n];
    for (int i = 0; i < n; i++)
    {
        int mx = 0;
        if (h[i] > 1)
            mx = query(0, n - 1, 0, 0, h[i] - 2);
        dp[i] = b[i] + mx;
        update(0, n - 1, 0, h[i] - 1, dp[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	int x, y;
	if (N%A == 0)x = B * N / A;
	else x = B * (N / A + 1);
	if (N%C == 0)y = D * N / C;
	else y = D * (N / C + 1);
	if (x <= y)cout << x << endl;
	else cout << y << endl;
	cin >> N;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;
  int A[N];
  rep(i, 0, N) cin >> A[i];

  int ans=0;
  rep(i, 0, N) {
    ans++;
    while (N > i+1 && A[i] == A[i+1]) i++;
    if (N == i+1) break;
    if (A[i] < A[i+1]) {
      while (N > i+1 && A[i] <= A[i+1]) i++;
    } else {
      while (N > i+1 && A[i] >= A[i+1]) i++;
    }
  }
  cout << ans << "\n";
}


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

int main(){
  int64_t n;
  cin >> n;
  int64_t count = 0;
  for(int i = 1; i <= n; i++){
    if(n / i == n - i){
      continue;
    }
    if(i + (n - i) == n){
      count++;
    }
  }
  cout << count / 2 << endl;
}

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

int main() {
    int n; scanf("%d", &n);
    int a[n]; for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int num_query, k; scanf("%d", &num_query);
    for (int i = 0; i < num_query; ++i) {
        scanf("%d", &k);
        int lower_res = lower_bound(a, a + n, k) - a;
        int upper_res = upper_bound(a, a + n, k) - a;
        printf("%d %d\n", lower_res, upper_res);
    }
    return 0;
}


Measured memory_bytes: 3108
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = int
printer = unlines . (:[]) . show

solver x = (1000 - (x `mod` 1000)) `mod` 1000

Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int trees = sc.nextInt();
    int view = sc.nextInt() * 2 + 1;
    System.out.println((int) Math.ceil((double) trees / (double) view));
  }

}

Measured memory_bytes: 21204
#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 <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    double N, D;
    cin >> N >> D;

    vector<vector<double> > X(N, vector<double>(D));

    rep(i, N) {
        rep(j, D) {
            cin >> X[i][j];
        }
    }

    int jj = 0;

    for(int i=0;i<N-1;++i){
        for (int j = i+1; j < N; ++j) {
            double s = 0;
            for (int k = 0; k < D; ++k) {
                s += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            if (ceil(sqrt(s)) == floor(sqrt(s))) { ++jj; }
         }
    }

    cout << jj << endl;
}

Measured memory_bytes: 256