akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
ll n,h,w,result;
ll a[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> h;
  while(h != 0) {
    result++;
    h /= 2;
  }
  cout << (ll)pow(2,result)-1 << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int n, m, a[1001];
    int t = 0;
    int ans = 0;

    cin >> n >> m;

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

        t += a[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (4 * m * a[i] >= t)
            ans++;
    }

    if (ans >= m)
        cout << "Yes";
    else
        cout << "No";

    cout << "\n";

    return 0;
}

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

using namespace std;

int main () {
	char s[10086], t[10086];
	scanf("%s%s", s, t);
	int str = strlen(s);
	for (int i = 0; i < str; i++)
		if (s[i] != t[i]) {
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3700
while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

	
	cnt = 0
	ave = x / 3
    for i in ( 1 .. ave-1 )
        for j in ( i+1 .. n-1 )
        	break if x < i+j
            for k in ( j+1 .. n )
                s = ( i + j + k )
                if x < s
                    break
                elsif x == s
                    cnt += 1
                    break
                end
            end
        end
    end

	puts( cnt )
end

Measured memory_bytes: 6112
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int m;
  cin>>m;
  REP(i,m){
    string str;
    int num[5000]={0};
    char now;
    int out=0;
    char one[5]={'.',',','!','?',' '};
    cin >> str;
    int hoge = str.size();
    REP(i,hoge){
      num[i] = str[i] - '0';
    };
    REP(c,hoge){
      int k=0;
      if(num[c]==1){
	while(num[c]==1){
	  k++;
	  c++;
	}
	out=(k+4)%5;
	cout << one[out];
      }else if(num[c]==2){
	while(num[c]==2){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'a'+out;
	cout << now;
      }else if(num[c]==3){
	while(num[c]==3){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'd'+out;
	cout << now;
      }else if(num[c]==4){
	while(num[c]==4){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'g'+out;
	cout << now;
      }else if(num[c]==5){
	while(num[c]==5){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'j'+out;
	cout << now;
      }else if(num[c]==6){
	while(num[c]==6){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'm'+out;
	cout << now ;
      }else if(num[c]==7){
	while(num[c]==7){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'p'+out;
	cout << now;
      } else if(num[c]==8){
	while(num[c]==8){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 't'+out;
	cout << now;
      }else if(num[c]==9){
	while(num[c]==9){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'w'+out;
	cout << now;
      }
    }
      cout << endl;
  }}


  

Measured memory_bytes: 1228
n, x, y = map(int, input().split())
counter = {i + 1: 0 for i in range(n - 1)}

for i in range(n - 1):
  for j in range(i + 1, n):
    k = min(j - i, abs(x - 1 - i) + abs(y - 1 - j) + 1)
    counter[k] += 1

print(*[counter[i + 1] for i in range(n - 1)], sep='\n')

Measured memory_bytes: 9384
a=list(input())
b=list(input())
c=list(input())
t=a.pop(0)
for x in range(1000):
    if t=="a":
        if len(a)==0:
            print("A")
            break
        else:t=a.pop(0)
    elif t=="b":
        if len(b)==0:
            print("B")
            break
        else:t=b.pop(0)
    elif t=="c":
        if len(c)==0:
            print("C")
            break
        else:t=c.pop(0)

Measured memory_bytes: 3064
import sys

N,Y = map(int,sys.stdin.readline().split(' '))

result = '-1 -1 -1'

for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        sum = 10000*x + 5000*y + 1000*z
        if sum == Y and z >= 0:
            result = f'{x} {y} {z}'
            break

print(result)

Measured memory_bytes: 8936
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int cnt = 0;
  int ind = a[0];
  while(1){
    cnt++;
    if(ind == 2){
      cout << cnt << endl;
      return 0;
    }
    ind = a[ind-1];
    if(cnt > 100000){
      cout << -1 << endl;
      return 0;
    }
  }
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    int max = a[0], ans = 0;
    for(int i=1; i<n; i++){
        if(a[i] < max){
            ans += max - a[i];
        }
        else{
            max = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4768
def bfs(ini, g)
  dist = Array.new(g.length,-1)
  dist[ini] = 0
  queue = [ini]
  while !queue.empty?
    v = queue[0]
    queue.shift
    g[v].each{|des|
      if dist[des] == -1
        dist[des] = dist[v] + 1
        queue.push(des)
      end
     }
   end
   dist.max
end

h,w=gets.chomp.split(" ").map(&:to_i);

wall = "##"
for i in 0..w-1
  wall += "#"
end

s = Array.new(h+2, wall)

for i in 1..h
  s[i] = "#" + gets.chomp + "#"
end

v = h * w
g = Array.new(v).map{Array.new}

for i in 1..h
  for j in 1..w
    if s[i][j] == "."
      if s[i-1][j] == "."
        g[(i-1)*w+(j-1)].push((i-2)*w+(j-1))
      end
      if s[i][j-1] == "."
        g[(i-1)*w+(j-1)].push((i-1)*w+(j-2))
      end
      if s[i][j+1] == "."
        g[(i-1)*w+(j-1)].push((i-1)*w+j)
      end
      if s[i+1][j] == "."
        g[(i-1)*w+(j-1)].push(i*w+(j-1))
      end
    end
  end
end
ans = 0
for i in 0..v-1
  calc_min = bfs(i,g)
  if ans < calc_min
    ans = calc_min
  end
end

p ans

Measured memory_bytes: 3068
class BinaryIndexedTree:
    def __init__(self, N):
        self.N = N
        self.bit = [0] * (self.N+1)

    def sum(self, i):
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & -i
        return res

    def add(self, i, x):
        while i <= self.N:
            self.bit[i] += x
            i += i & -i

MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

N,K,*A=map(int, open(0).read().split())
bit=BinaryIndexedTree(2001)
c=0
for i,a in enumerate(A):
    c+=i-bit.sum(a)
    bit.add(a,1)
d=0
for i,a in enumerate(A):
    d+=N-bit.sum(a)
K=Fp(K)
print(K*c+K*(K-1)//2*d)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    if (2 * i <= y && (y - 2 * i) == 4 * (x - i)) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N+1), dp(N+1, 1 << 30);
  dp[1] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> h[i];
    for (int j = max(1, i-K); j != i; ++j) {
      dp[i] = min(dp[i],dp[j] + abs(h[i]-h[j]));
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 4028
# B * (n + 1) >= C
# D * n < A

# n >= C / B - 1
# n < A / D
# A / D > n >= C / B - 1
# A / D > C / B -1

def battle(A: int, B: int, C: int, D: int) -> str:
    while True:
        C -= B
        if C <= 0:
            return 'Yes'

        A -= D
        if A <= 0:
            return 'No'

if __name__ == '__main__':
    A, B, C, D = map(int, input().split())
    res = battle(A, B, C, D)
    print(res)


Measured memory_bytes: 9184
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    vector<vector<int>> diff(3, vector<int>(2, 0));
    for (int i = 0; i < 3; i++) {
        vector<int> tmp(3);
        for (int j = 0; j < 3; j++) {
            cin >> tmp.at(j);
        }
        diff.at(i).at(0) = tmp.at(1) - tmp.at(0);
        diff.at(i).at(1) = tmp.at(2) - tmp.at(1);
    }
    
    if (diff.at(0).at(0) == diff.at(1).at(0) && diff.at(0).at(0) == diff.at(2).at(0) && diff.at(0).at(1) == diff.at(1).at(1) && diff.at(0).at(1) == diff.at(2).at(1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define mp 					make_pair
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz 					size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif

void gi( int &ret ) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(int)(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 2e5 + 5;
const int MAXLOGN = 20;
const int MAXBIT = (1<<20);

int n, v, x[MAXN], nx[MAXLOGN][MAXN], dst[MAXBIT], skip, aft, no = 0;

bool bfs () {
	queue < int > q;
	q.push(1);
	memset(dst,-1,sizeof(dst));
	dst[1] = 1;
	while (!q.empty()) {
		int bit = q.front(), now = dst[bit]; q.pop();
		if (now==skip) now = aft;
		if (now>n) return 1;
		for (int i=0; i<=no; i++) 
			if (!(bit&(1<<i))) {
				int nexbit = bit | (1<<i);
				if (dst[nexbit]<0) q.push(nexbit);
				dst[nexbit] = max(dst[nexbit], nx[i][now]);
			}
	}
	return 0;
}

int main() {
	gi(n); gi(v);
	for (int i=1; i<=n; i++) gi(x[i]);
	vi sg;
	while (v) {
		int aw = 1, lst = 1;
		while (lst<=n) {
			if (!no) sg.psb(lst);
			while (aw<n && (x[aw+1]-x[aw])<=v) aw++;
			aw++;
			while (lst<aw) nx[no][lst++] = aw;
		}
		no++;
		v >>= 1;
	}
	for (int i=1; i<=n; i++) nx[no][i] = i+1;
	if (sg.sz > MAXLOGN) {
		for (int i=1; i<=n; i++) printf ("Impossible\n");
		return 0;
	}
	for (auto aw : sg) {
		skip = aw; aft = nx[0][aw];
		if (bfs()) {
			while (aw++ < aft) printf ("Possible\n"); 
		} else {
			while (aw++ < aft) printf ("Impossible\n");
		}
	}
	return 0;
}


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

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

    long long p[100010];
    long long x[100010];

    for(int i = 0;i < n;i++){
        cin >> p[i];
        x[p[i]-1] = i;
    }

    long long a[100010];
    a[0] = 40000;
    for(int i = 1;i < n;i++){
        a[i] = a[i-1] + 40000;
    }

    long long b[100010];
    b[n-1] = 40000 + x[n-1];
    for(int j = n-2;j >= 0;j--){
        b[j] = 40000*(n-(j)) + x[j];
    }


    for(int i = 0;i < n;i++){
        cout << a[i];
        if(i != n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }

    for(int i = 0;i < n;i++){
        cout << b[i];
        if(i != n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
int main(){
    string S;
    bool same=0;
    cin >> S;
    sort(&S[0],&S[S.size()]);
    REP(i,S.size()-1){
        if(S[i]==S[i+1]){
            same=1;
        }
    }
    if(same==1){cout << "no" << endl;}else{cout << "yes" << endl;}
 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
int N,S;
ll dp[11][101][1001];
ll solve(int no,int num,int s){
  if(dp[no][num][s]!=-1) return dp[no][num][s];
  if(no==N){
    if(s==S) return 1;
    else return 0;
  }
  if(num>100) return 0;
  if(s>S) return 0;
  ll ret = 0;
  ret = solve(no+1,num+1,s+num) + solve(no,num+1,s);
  return dp[no][num][s] = ret;
}
int main(){
  while(1){
    memset(dp,-1,sizeof(dp));
    scanf("%d %d",&N,&S);
    if(!N && !S) break;
    printf("%lld\n",solve(0,0,0));
  }
}

Measured memory_bytes: 9884
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    String str = scanner.next();
    
    if (a >= 3200) {
    	System.out.println(str);
    } else {
    	System.out.println("red");
    }
  }
}


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

using namespace std;
#define ll long long
int K;
ll ans = 0;

int gcd(int a, int b){
    return b == 0? a : gcd(b, a%b);
}

int main(){
    cin >> K;
    for (int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int k = 1; k <= K; k++){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        s: chars,
    }
    let mut stack = Vec::new();
    let mut ans = 0;
    for v in s {
        if v == 'W' && stack.is_empty() {
            continue;
        }
        if v == 'B' {
            stack.push(v);
        } else {
            ans += stack.len();
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
def abc174_e():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    if k == 0: return max(A)

    lower, upper = 0, 10**9
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for a in A:
            cnt += a // x
            if a % x == 0: cnt -= 1
            if cnt > k: break
        if cnt > k: lower = x
        else: upper = x
    return upper

if __name__ == '__main__':
    print(abc174_e())

Measured memory_bytes: 30800
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;

  for (int i = 0; i < s.length(); ++i) {
    if (i == 4) putchar(' ');
    putchar(s[i]);
  }
  putchar(LF);

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String[] str = (scan.nextLine()).split(",");
            int[] dis = new int[10];
            int sum = 0;
            for(int i = 0;i < 10;i++){
                dis[i] = Integer.parseInt(str[i]);
                sum += dis[i];
            }
            int v1 = Integer.parseInt(str[10]);
            int v2 = Integer.parseInt(str[11]);
            int a = (int)(((double)(sum*v1)/(double)(v1+v2))+0.5);
            sum = 0;
            for(int i = 0;i < 10;i++){
                sum += dis[i];
                if(sum >= a){
                    System.out.println(i+1);
                    break;
                }
            }
        }
    }
}

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

vector<ll> num(1010,0); 
vector<bool> prime(1010,true);//iが素数ならtrue(エラトステネスの篩)
void isprime(){
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=1010;i++){
        if(!prime[i]){continue;}
        for(ll j=i*i;j<=1010;j+=i){
            prime[j]=false;
        }
    }
    return;
}

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

    if(n==1){cout<<1<<endl;return 0;}

    for(ll i=2;i<=n;i++){//n以下の連続整数の素因数個数を数える
        ll number=i;
        for(ll j=2;j<=i;j++){
            if(prime[j]==true){
                while(number%j==0){
                    num[j]++;
                    number/=j;
                }
            }
        }
    }

    ll ans=1;
    for(ll i=2;i<=n;i++){//約数個数を計算
        ans*=(num[i]+1);
        ans%=mod;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
class Queue(object):

    def __init__(self):
        self.queue_list = []

    def enqueue(self, value):
        self.queue_list.append(value)

    def dequeue(self):
        try:
            value = self.queue_list.pop(0)
        except IndexError:
            value = None

        return value

N = int(input())

pair = []
tree = {}

for _ in range(N-1):
    a, b = list(map(int, input().split(" "))) 
    if a in tree.keys():
        tree[a].append(b)
    else:
        tree[a] = [b]
        
    if b in tree.keys():
        tree[b].append(a)
    else:
        tree[b] = [a]
    pair.append([a,b])
    
c = list(map(int, input().split(" ")))
c.sort(reverse=True)
c = c[:N+2]


queue = Queue()
tree_l = {}
for key in tree.keys():
    tree_l[key] = len(tree[key])

ans = {}
max_node = max((v, k) for k, v in tree_l.items())[1]
ans[max_node] = c[0]
used = [max_node]
cnt = 0

candi = {}
for i in tree[max_node]:
    candi[i] = tree_l[i]

for k, v in sorted(candi.items(), key=lambda x: -x[1]):
    queue.enqueue(k)
    used.append(k)

while True:
    node = queue.dequeue()
    cnt += 1
    ans[node] = c[cnt]
    
    if cnt == N-1:
        break
    
    candi = {}
    for i in tree[node]:
        candi[i] = tree_l[i]
    for k, v in sorted(candi.items(), key=lambda x: -x[1]):
        if k not in used:
            queue.enqueue(k)
            used.append(k)
total = 0
for a, b in pair:
    if ans[a] > ans[b]:
        total += ans[b]
    else:
        total += ans[a]
        
print(total)
for i in range(1, N, 1):
    print(ans[i], end=" ")

print(ans[N])

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

#define int long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second

bool used[201];

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

	int x,n;
	cin>>x>>n;
	int a[101];
	for (int i=0; i<n; i++){
		cin>>a[i];
		used[a[i]]=1;
	}
		
	vector<int> v;
	for (int i=0; i<200; i++){
		if (!used[i]){
			v.pb(i);
		}
	}
	for (int i=0; i<v.size(); i++){
		if (v[i]>=x){
			if (v[i]==x){
				cout<<v[i]<<endl;
				return 0;
			}
			if (i==0){
				cout<<v[i]<<endl;
				return 0;
			}
			int a=x-v[i-1],b=v[i]-x;
			if (a==b){
				cout<<v[i-1]<<endl;
				return 0;
			}
			else if (a>b){
				cout<<v[i]<<endl;
				return 0;
			}
			else{
				cout<<v[i-1]<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int64 N;

int main() {
    cin >> N;
    int dig[70], len = 0;
    for (int64 t = N; t > 0; t/=2) {
        dig[len++] = t % 2;
    }
    reverse(dig, dig+len);

    int64 dp[70][3];
    dp[0][0] = dp[0][1] = 1; dp[0][2] = 0;
    for (int j = 1; j < len; ++j) {
        if (dig[j] == 0) {
            dp[j][0] = (dp[j-1][0] + dp[j-1][1]) % MOD;
            dp[j][1] = dp[j-1][1] % MOD;
            dp[j][2] = (dp[j-1][1] + 3*dp[j-1][2]) % MOD;
        } else {
            dp[j][0] = dp[j-1][0] % MOD;
            dp[j][1] = (dp[j-1][0] + dp[j-1][1]) % MOD;
            dp[j][2] = (2*dp[j-1][1] + 3*dp[j-1][2]) % MOD;
        }
    }

    cout << (dp[len-1][0] + dp[len-1][1] + dp[len-1][2]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 256
function main()
	n::Int, x::Int = map(x -> parse(Int, x), split(readline()))
	a::Vector{Int} = map(x -> parse(Int, x), split(readline()))
	b::Vector{Int} = copy(a)

	ans = 10^15
	for i in 1:n
		sm = 0
		for j in 1:n
			sm += b[j]
		end
		ans = min(ans, sm + x*(i-1))
		for j in 1:n
			b[j] = min(b[j], a[mod1(j-i, n)])
		end
	end

	println(ans)
end

main()

Measured memory_bytes: 60084
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <queue>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define fst first
#define snd second
#define SZ(x) ((int)x.size())
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 300300;

int n, A[MAXN], B[MAXN], P[MAXN], R[MAXN], bn, L[MAXN];

int main() {
  //~ freopen("input.in", "r", stdin);
  while( scanf("%d", &n) >= 1 ){
    memset(B, 0, sizeof B);
    memset(R, 0, sizeof R);
    memset(P, 0, sizeof P);
    memset(L, -1, sizeof L);
    bn = 0;
    ll ans = 0;
    
    int len = 0;
    forn(i, n){
      scanf("%d", &A[i]);
      if(A[i]){
        P[bn] = i;
        B[bn++] = A[i];
        if(len){
          //~ printf("len = %d\n", len);
          ans += ((ll)len * len + len) / 2LL;
        }
        len = 0;
      } else {
        len++;
        if(i-len >= 0){
          R[i-len] = i;
        }
      }
    }
    if(len) ans += ((ll)len * len + len) / 2LL;
    
    len = 0;
    dforn(i, n){
      if(A[i]){
        len = 0;
      } else {
        len++;
        if(i+len < n){
          L[i+len] = i;
        }
      }
    }
    
    //~ puts("R = ");
    forn(i, n){
      R[i] = max(i, R[i]);
      if(L[i] == -1) L[i] = i;
      //~ if(i) printf(" ");
      //~ printf("%d", R[i]);
    } 
    //~ puts("");
    
    //~ puts("B = ");
    //~ forn(i, bn){
      //~ printf("%d ", B[i]);
    //~ }
    //~ puts("");
    
    //~ printf("Ans starts at %lld\n", ans);
    
    forn(i, bn){
      ll sum = B[i];
      ll xsum = B[i];
      int l = i;
      int r = i;
      forr(j, i+1, bn){
        sum += B[j];
        xsum ^= B[j];
        //~ printf("j = %d, sum = %lld, xsum = %lld\n", j, sum, xsum);
        if(sum != xsum){
          break;
        } else {
          r = j;
        }
      }
      l = P[l];
      r = P[r];
      //~ printf("Taking %d, %d\n", l, r);
      ll a = (l-L[l]+1);
      ll b = (R[r]-l+1);
      ans += a*b;
    }
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define int long long
int e[111][111],d[111];
int used[111];
signed main(){
  int n;
  cin>>n;
  int INF=1LL<<55LL;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      e[i][j]=INF;
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int v,c;
      cin>>v>>c;
      e[u][v]=min(e[u][v],c);
    }
  }
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++) d[i]=INF;
  d[0]=0;
  while(1){
    int u=-1;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      if(d[i]==INF) continue;
      if(u<0||d[i]<d[u]) u=i;
    }
    if(u<0) break;
    used[u]=1;
    for(int i=0;i<n;i++){
      d[i]=min(d[i],d[u]+e[u][i]);
    }
  }
  for(int i=0;i<n;i++) cout<<i<<" "<<d[i]<<endl;
  return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
typedef long long int ll;
const ll MOD = 1000000007LL;

ll mod_pow(int n, int k, int mod) {
    // ret := ?????????mul := n ??? 2 ?????? (????????? 2^0 ???)
    ll ret = 1, mul = n;
    for(int i=0; i<31; i++) {
        // ?????????????????£?????????????????°???mul ?????????????????????
        if(k >> i & 1) ret = (ret * mul) % MOD;
        // 2 ??????????????? (n ??? 2^x ??? -> n ??? 2^(x+1) ???)
        mul = (mul * mul) % MOD;
    }
    return ret;
}

int main() {
    int N, k; scanf("%d%d", &N, &k);
    printf("%lld\n", mod_pow(N, k, MOD));
    return 0;
}

Measured memory_bytes: 2760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    char S[100000];
    int i = 0, read;
    for(i = 0; i < 100000; i ++){
        S[i] = 0;
    }
    read = scanf("%s", S);
    int num_0 = 0, num_1 = 0;
    for(i = 0; i < 100000; i ++){
        if(S[i] == 48){
            num_0 ++;
        }else if(S[i] == 49){
            num_1 ++;
        }
        /*printf("%d %d\n", S[i], i);*/
    }
    int ans = 0;
    if(num_0 < num_1){
        ans = 2 * num_0;
    }else{
        ans = 2 * num_1;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans,k,goukei;
  goukei=0;
  cin>>n;
  vector<long> vec(n);
  vector<long> ruikei(n);
  for(long i=0; i<n; i++){
    cin>>vec.at(i);
    goukei=goukei+vec.at(i);
  }
  ruikei.at(0)=vec.at(0);
  for(long i=1; i<n; i++){
    ruikei.at(i)=ruikei.at(i-1)+vec.at(i);
  }
  for(long i=0; i<n; i++){
    if(ruikei.at(i)*2>goukei){
      k=i;
      break;
    }
    k=i;
  }
  if(k==0){
    ans=ruikei.at(k)*2-goukei;
  }
  else{
    ans=min(ruikei.at(k)*2-goukei, goukei-ruikei.at(k-1)*2);
  }
  cout<<ans;
}

Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, k := getInt(), getInt(), getInt()

	max := gcd(a, b)
	count := 0
	//fmt.Println(max)
	//fmt.Print(a, b, k)

	for i := max; max > 0; i-- {
		if a%i == 0 && b%i == 0 {
			count++
		}

		if count == k {
			fmt.Print(i)
			break
		}
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
#define ld long double 
#define float long double 
#define ll long long
#define int long long
#define vl vector<ll> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=1e9+7;
int i,j,k;
void solve(){ 
      ll n; cin >> n;
      ll k ;cin >> k;
      ll ans = 0 ;
      while(n){
          n = n / k;
          ans++;
      }
      cout << ans << endl;




    return ;

} 
    signed main(){
    
     //CASET
    solve();
    
   
    return 0;
  }


Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    double a,b,c,d,e,f;
    double x,y;
    while(std::cin >> a >> b >> c >> d >> e >> f){
        y = (a*f - c *d) / (a*e  - d*b);
        x = (c-b * y) / a;
        printf("%.3f %.3f\n",x,y);
    }
   
}

Measured memory_bytes: 3164
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  
  // read problem
  long long int N, K, tmp;
  std::vector<long long int> A;
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }

  //std::cerr << N << K << std::endl;

  //solve problem
  std::sort(A.begin(), A.end());

  /*std::cerr << "A: " << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << A[i] << std::endl;
  }*/

  long long int L = -1e18-1;
  long long int R = 1e18+1;

  long long int MID, count_tmp, l, r, mid;

  while(R - L > 1){
    MID = (R+L)/2;

    //std::cerr << "[" << L << ", " << R << "]" << std::endl;

    // count the number of pairs s.t. A_i * A_j <= MID
    count_tmp = 0;
    for(long long int i = 0; i < N-1; i++){
      if(A[i] < 0){
        if(A[i] * A[N-1] > MID)continue;
        else if(A[i]*A[i+1] <= MID) count_tmp += N-i-1;
        else{
          l = i+1;
          r = N-1;
          while(r-l>1){
            mid = (r+l)/2;
            if(A[i]*A[mid] <= MID){
              r = mid;
            }
            else{
              l = mid;
            }
          }
          count_tmp += N-r;
        }
      }
      else if(A[i] == 0){
        if(MID >= 0){
          count_tmp += N-1-i;
        }
        else{
          continue;
        }
      }
      else{ // if (A[i] > 0)
        if(A[i] * A[N-1] <= MID)count_tmp += N-i-1;
        else if(A[i]*A[i+1] > MID)continue;
        else{
          l = i+1;
          r = N-1;
          while(r-l>1){
            mid = (l+r)/2;
            if(A[i]*A[mid] <= MID){
              l = mid;
            }
            else{
              r = mid;
            }
          }
          count_tmp += l-i;
        }
      }
      //std::cerr << "i:" << i << "count_tmp:" << count_tmp << std::endl;
    }

    //std::cerr << MID << " " << count_tmp << std::endl;

    if(count_tmp >= K){
      R = MID;
    }
    else{
      L = MID;
    }

  }

  std::cerr << "Answer: " << std::endl;
  std::cout << R << std::endl;


  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
vector<vector<int> > V;
int N;
bool comp(vector<int> a,vector<int> b){
      sort(ALL(a),greater<int>());sort(ALL(b),greater<int>());
      if(a.size()!=b.size())a.size()<b.size();
      REP(i,a.size()){
            if(a[i]!=b[i])return a[i]>b[i];
      }
}
void rec(vector<int> a,int sum){
      //cout<<a.size()<<" "<<sum<<endl;
      if(sum>N){return;}
      else if(sum==N){
            V.PB(a);
            return;
      }
      for(int i=a[a.size()-1];i>=1;i--){
            vector<int> b=a;b.PB(i);
            rec(b,sum+i);
      }
      return;
}
int main(){
      while(cin>>N&&N){
            V.clear();
            for(int i=N;i>=1;i--){
                  vector<int> a;
                  a.PB(i);
                  rec(a,i);
            }
            sort(V.begin(),V.end(),comp);
            REP(i,V.size())REP(j,V[i].size())printf("%d%c",V[i][j],j==V[i].size()-1?'\n':' ');
      }
}

Measured memory_bytes: 1796
N = int(input())
ans = 0
count = 0
H = list(map(int,input().split()))
for h in range(len(H)):
  if(h == 0):
    pass
  else:
    tmp = H[h-1]
    tmp2 = H[h]
    if(tmp >= tmp2):
      count += 1
    else:
      count = 0
    ans = max(ans,count)
print(str(ans))

Measured memory_bytes: 14224
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

const int MAX = 3e6 + 5;
int id[MAX];
vector<pair<int, pair<int, int> > > p;

int root(int x){
    while(id[x] != x) id[x] = id[id[x]], x = id[x];
    return x;
}

void union1(int x, int y){
    int pp = root(x);
    int qq = root(y);
    id[pp] = id[qq];
}

ll kruskal(){
    sort(all(p));
    ll minimumCost = 0;
    for(auto i : p){
        auto x = i.ss.ff;
        auto y = i.ss.ss;
        auto cost = i.ff;
        // cout << x << " " << y << " -- " << cost << endl;
        if(root(x) != root(y)) minimumCost += cost, union1(x, y);
    }
    return minimumCost;
}

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    rep(i, 0, MAX) id[i] = i;
    quickio
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int> > u(n);
    rep(i, 0, n) cin >> u[i].ff.ff >> u[i].ff.ss, u[i].ss = i + 1;
    sort(all(u));
    auto v = u;
    rep(i, 0, n) v[i].ff.ss = u[i].ff.ff, v[i].ff.ff = u[i].ff.ss;
    sort(all(v));

    rep(i, 0, n-1) p.pb(u[i+1].ff.ff - u[i].ff.ff, MP(u[i].ss, u[i + 1].ss));
    rep(i, 0, n-1) p.pb(v[i+1].ff.ff - v[i].ff.ff, MP(v[i].ss, v[i + 1].ss));

    // for(auto i : v) cout << i.ff.ff << " " << i.ff.ss << " " << i.ss << endl;
    cout << kruskal();
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 20396
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  int x;
  S(x);
  if(x >= 30) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

template <typename S>
struct sparseTable {
    using T = typename S::T;
    int n;
    vector<int> log2;
    vector<vector<T>> t;

    sparseTable(int nn) {
        n = nn;
        log2.assign(n+1, 0);
        for(int i=2; i<=n; ++i) log2[i] = log2[i >> 1] + 1;
        t = vector<vector<T>>(log2[n]+1, vector<T>(n));
    }
    void init(vector<T> v) {
        for(int i=0; i<n; ++i) t[0][i] = v[i];
        for(int j=1; j<=log2[n]; ++j) {
            int w = 1LL<<(j-1);
            for (int i = 0; i+(w<<1) <= n; ++i) {
                t[j][i] = S::op(t[j-1][i], t[j-1][i+w]);
            }
        }
    }
    // [l, r]
    T query(int l, int r) {
        int j = log2[r - l];
        return S::op(t[j][l], t[j][r-(1 << j)+1]);
    }
};

// 集合T、結合則・可換・冪等律が成り立つ二項演算op
struct minnimum {
    using T = int;
    static T op(const T& a, const T& b) { return min(a, b); }
};
struct maximum {
    using T = int;
    static T op(const T& a, const T& b) { return max(a, b); }
};
struct gcd_struct {
    using T = ll;
    static T op(const T& a, const T& b) { return __gcd(a, b); }
};

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    sparseTable<gcd_struct> st(n);
    st.init(a);

    ll ret = 1;
    REP(i, n) {
        // [0, i-1] と [i+1, n-1]
        ll g;
        if(i==0) g = st.query(i+1, n-1);
        else if(i==n-1) g = st.query(0, i-1);
        else g = __gcd(st.query(0, i-1), st.query(i+1, n-1));
        chmax(ret, g);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 15600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	long double a, b, c; cin >> a >> b >> c;
	if(a+b+2*sqrt(a*b) < c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

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


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

int n;
double xa, ya, xb, yb, xc, yc, x, y, r;

signed main() {
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> xa >> ya >> xb >> yb >> xc >> yc;
		x = ((ya-yb)*(xc*xc+yc*yc-xa*xa-ya*ya)-(ya-yc)*(xb*xb+yb*yb-xa*xa-ya*ya))/(2*((ya-yc)*(xa-xb)-(ya-yb)*(xa-xc)));
		y = ((xa-xb)*(xc*xc+yc*yc-xa*xa-ya*ya)-(xa-xc)*(xb*xb+yb*yb-xa*xa-ya*ya))/(2*((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb)));
		r = sqrt((x-xa)*(x-xa)+(y-ya)*(y-ya));
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<long long> x(N), y(N);
  for (int i = 0; i < N; ++i) cin >> x[i];
  for (int i = 0; i < N; ++i) cin >> y[i];
  long long res = 0;
  for (int i = 0; i < N; ++i) {
    if (x[i] >= y[i]) res += x[i] - y[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 3572
# 2 つの正整数 a, b が与えられます。 
a, b = gets.chomp.split(" ").map(&:to_f)

# a, b の平均値を x とします。 
x = ( (a+b)/2 ).ceil

# x の小数点以下を切り上げて得られる整数を出力してください。
p x

Measured memory_bytes: 1788
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      c: [[i32; 3]; 3]
   }
   let b: Vec<_> = (0..3).map(|i| c[0][i]).collect();
   let a: Vec<_> = (0..3).map(|i| c[i][0] - b[0]).collect();
   for i in 0..3 {
      for j in 0..3 {
         if a[i] + b[j] != c[i][j] {
            println!("No");
            return;
         }
      }
   }
   println!("Yes");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  ll n, m;
  cin >> n >> m;

  ll ans=0;
  if(n>0){
    ans+=min(2*n, m)/2;
    m -= ans*2;
  }
  if(m>3){
    ans+= m/4;
  }
  prt(ans);
}


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 C[] = new int [N-1];
    int S[] = new int [N-1];
    int F[] = new int [N-1];
    
    for(int i=0; i<N-1; i++){
      C[i]=sc.nextInt();
      S[i]=sc.nextInt();
      F[i]=sc.nextInt();
    }
    
    for(int i=0; i<N-1; i++){
      int time = S[i] + C[i];
      for(int j=i+1; j<N-1; j++){
        
        if(S[j] > time){
          time = S[j];
        }
        
        if(time % F[j] != 0){
            time += F[j] -(time % F[j]);
        }
        time += C[j];
      }
      System.out.println(time);
    }
    System.out.println(0);
  }
}
    


Measured memory_bytes: 39624