akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ha 1000000007
using namespace std;

const int N=3010;
int f[N][N][2];

void Add(int &x,const int &y){x=(x+y>=ha)?(x+y-ha):(x+y);}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) f[1][i][0]=1;
	f[1][0][1]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<=n;j++)
		{
			if(j>=1)
			{
				Add(f[i+1][j-1][1],f[i][j][1]);
				if(j==1) Add(f[i+1][j-1][1],f[i][j][0]);
				else Add(f[i+1][j-1][0],f[i][j][0]);
			}
			if(j<n)
			{
				Add(f[i+1][j+1][1],f[i][j][1]);
				Add(f[i+1][j+1][0],f[i][j][0]);
			}
			if(j>=1)
			{
				Add(f[i+1][j][1],f[i][j][1]);
				if(j==1) Add(f[i+1][j][1],f[i][j][0]);
				else Add(f[i+1][j][0],f[i][j][0]);
			}
			if(j<n)
			{
				Add(f[i+1][j][1],f[i][j][1]);
				Add(f[i+1][j][0],f[i][j][0]);
			}
		}
	int ans=0;
	for(int i=0;i<=n;i++) Add(ans,f[m+1][i][1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70784
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	function Dice(labels){
		this.t = labels[0];
		this.s = labels[1];
		this.e = labels[2];
		this.w = labels[3];
		this.n = labels[4];
		this.b = labels[5];
	}
	Dice.prototype.roll = function(dir){
		var temp;
		if(dir == "N"){
			temp = this.t;
			this.t = this.s;
			this.s = this.b;
			this.b = this.n;
			this.n = temp;
		}
		else if(dir == "S"){
			temp = this.t;
			this.t = this.n;
			this.n = this.b;
			this.b = this.s;
			this.s = temp;
		}
		else if(dir == "W"){
			temp = this.t;
			this.t = this.e;
			this.e = this.b;
			this.b = this.w;
			this.w = temp;
		}
		else if(dir == "E"){
			temp = this.t;
			this.t = this.w;
			this.w = this.b;
			this.b = this.e;
			this.e = temp;
		}
	};
	Dice.prototype.isSame = function(other){
		var dice1 = new Dice([this.t, this.s, this.e, this.w, this.n, this.b]);
		var dice2 = new Dice([other.t, other.s, other.e, other.w, other.n, other.b]);
		var dirs = "EEEENEEEENEEEENEEENEEEENNEEEE";
		for(var i=0;i<dirs.length;i++){
			if(dice1.t == dice2.t && dice1.s == dice2.s && dice1.e == dice2.e && dice1.w == dice2.w && dice1.n == dice2.n && dice1.b == dice2.b){
				return true;
			}
			dice2.roll(dirs[i]);
		}
		return false
	};

	var dice1 = new Dice(lines[0].split(" "));
	var dice2 = new Dice(lines[1].split(" "));
	console.log(dice1.isSame(dice2) ? "Yes" : "No");
	
}

Measured memory_bytes: 15580
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int h[N];
  for(int i = 0; i < N; i++) cin >> h[i];

  //足場iまでの最小コスト
  int dp[N];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for(int i = 2; i < N; i++){
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

int64 lcm(int64 a, int64 b) {
		return a / gcd(a, b) * b;
}


//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int f(int x) {
	int res = 0;
	while (x % 2 == 0) {
		x /= 2;
		res++;
	}
	return res;
}

void solve() {
		int64 n, m; cin >> n >> m;
		vector<int64> a(n);
		rep (i, n) cin >> a[i];
		rep (i, n) {
			if (a[i] % 2 == 1) {
				cout << 0 << endl;
				return;
			}
			a[i] /= 2;
		}
		// a' -> a''
		int t = f(a[0]);
		rep (i, n) {
			if (f(a[i]) != t) {
				cout << 0 << endl;
				return;
			}
			a[i] >>= t; // a[i] /" 2^t
		}
		m >>= t;

		int64 l = 1;
		rep (i, n) {
			l = lcm(l, a[i]);
			if (l > m) {
				cout << 0 << endl;
				return;
			}
		}
		m /= l;
		int ans = (m + 1) / 2;
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
 
#define MOD (long long int)(1e9+7)
#define ll long long int


int main(void){
	int run=0;
	string s;
	cin>>s;
	for(int i=0;i<6;i++){
		if(s[i]=='1'){
			run++;
		}
	}
	cout<<run<<endl;
	return 0;	
}


Measured memory_bytes: 256
class UnionFind
  def initialize
    @parent = Hash.new
    @rank = Hash.new
    @size = Hash.new
  end
  def make(x)
    @parent[x] = x
    @rank[x] = 0
    @size[x] = 1
  end
  def union(a, b)
    x, y = find(a), find(b)
    return if x == y
    x, y = y, x if @rank[x] < @rank[y]
    @size[x] += @size[y]
    @parent[y] = x
    @rank[x] += 1 if @rank[x] == @rank[y]
  end
  def find(x)
    @parent[x] == x ? x : @parent[x] = find(@parent[x])
  end
  def same(a, b)
    x, y = find(a), find(b)
    x == y
  end
  def size(x)
    @size[find(x)]
  end
end

N,M=gets.split.map(&:to_i)
uf=UnionFind.new
1.upto(N) do |v| uf.make(v) end
sum=N*(N-1)/2
res=[sum]
M.times.map{gets.split.map(&:to_i)}.reverse_each do |a,b|
  next res<<sum if uf.same(a,b)
  sum-=uf.size(a)*uf.size(b)
  res<<sum
  uf.union(a,b)
end
puts res[0...-1].reverse


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int a,b;

    Scd2(a,b);

    int ans = -1;
    Rep(i,111111){
        if( i*8/100 == a && i/10 == b ) {
            ans = i;
            break;
        }
    }

    printf ("%d\n", ans );

    return 0;
}



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

int main(){
	int cnt=0;
	vector<int>t(3);
	cin>>t.at(0)>>t.at(1)>>t.at(2);
	sort(t.begin(),t.end());
	while(1){
		if(t.at(0)==t.at(1)&&t.at(0)==t.at(2))
			break;
		cnt++;
		if(t.at(0)==t.at(1)){
			t.at(0)++;
			t.at(1)++;
		}
		else
			t.at(0)+=2;
		sort(t.begin(),t.end());
	}
	cout << cnt << endl;
}

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

const int INF = 1001001001;

int a[12][12];

int main() {
 string S;
 cin>>S;

while(true){
   S.pop_back();
   if(S.substr(0,S.size()/2)==S.substr(S.size()/2)){
     cout<<S.size()<<endl;return 0;}
 }
  return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon";
	} else if (n == 3) {
		cout << "bon";
	} else {
		cout << "pon";
	}
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;
struct node{
	bool vis;
	ll r,c;
}a[1001]; 
ll row[1001],col[1001],dia[1001],log[1001];
ll n;
main(){
	register int i,j;
	for(i=1;i<=3;i++)
	for(j=1;j<=3;j++){
		ll x;
		cin>>x;
		a[x].vis=true;
		a[x].r=i;
		a[x].c=j;
	}
	cin>>n;
	for(i=1;i<=n;i++){
		ll x;
		cin>>x;
		if(a[x].vis==true){
		    row[a[x].r]++;
		    col[a[x].c]++;
		    if(a[x].r-a[x].c<0)dia[a[x].r-a[x].c+501]++;
		    else dia[a[x].r-a[x].c]++;
		    log[a[x].r+a[x].c]++;
		    if(row[a[x].r]>=3||col[a[x].c]>=3||log[a[x].r+a[x].c]>=3){
			    cout<<"Yes"<<endl;
			    return 0;
		    }
		    else if(a[x].r-a[x].c<0&&dia[a[x].r-a[x].c+501]>=3){
			    cout<<"Yes"<<endl;
			    return 0;
		    }
		    else if(dia[a[x].r-a[x].c]>=3){
			    cout<<"Yes"<<endl;
			    return 0;
		    }
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

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

int main(){
	int a,b,c,g;
	while(cin>>a>>b>>c){
		g=0;
		for(int i=1;i<=10;i++)
			if(i!=a&&i!=b&&i!=c&&a+b+i<=20)g++;
		if(g>3.5)cout<<"YES"<<endl;else cout<<"NO"<<endl;
		}
	return 0;
}
	
	

Measured memory_bytes: 1152
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N);
    PI(N % 2 ? (N-1) * (N-1) / 2 : N * (N-2) / 2);
    REP1(i, 1, N) {
        REP1(j, i+1, N) {
            if (N % 2) {
                if (i + j != N) {
                    PIS(i); PI(j);
                }
            } else {
                if (i + j != N + 1) {
                    PIS(i); PI(j);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, x = list(map(int, input().split()))
M = N * 2 - 1

if x == 1 or x == M:
  print("No")
  exit()

L = [i + 1 for i in range(M)]

n = N - 1
L[n], L[x - 1] = L[x - 1],L[n]
L[n - 1], L[0] = L[0], L[n - 1]
L[n + 1], L[M - 1] = L[M - 1], L[n + 1]

print("Yes")
for i in L:
  print(i)

Measured memory_bytes: 87352
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll x;cin >> x;
	ll sum = x / 11 * 2;
	if (x % 11 < 7 && x % 11 != 0) sum += 1;
	else if (x % 11 != 0) sum += 2;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

int isPrime[1000000];


void era(){
    for(int i=2;i<1000000;i++){
        if( isPrime[i]==1 ){
            int k = 2;
            while(k*i<1000000){
                isPrime[k*i]=0;
                k++;
            }
        }
    }
}


int main(){
    for(int i=0;i<1000000;i++){
        isPrime[i]=1;
    }
    isPrime[0]=isPrime[1]=0;
    
    era();
    
    int n;
    while(cin>>n){
        int count=0;
        for(int i=0;i<=n;i++){
            if( isPrime[i] )count++;
        }
        cout<<count<<endl;
    }
    
    
    
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int b[n];
  b[0]=0;
  b[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    b[i]=INT_MAX;
    for(int j=1;j<=k;j++){
      if(i-j>=0){
      b[i]=min(b[i],b[i-j]+abs(a[i]-a[i-j]));
      }
    }
    //b[i]=min;
    }
  cout<<b[n-1];
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 10000000007;



int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;


	VP p(n), q(n);

	int a = 0, b = 0;
	REP(i, n) {
		if (s[i] == 'R')a++;
		else b++;
		p[i] = { a,b };
	}
	a = 0, b = 0;

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'R')a++;
		else b++;
		q[i] = { a,b };
	}

	ll ans = min(n - a, n - b);

	REP(i, n - 1) {
		ans = min(ans, p[i].second + q[i + 1].first - min(p[i].second , q[i + 1].first));
	}
	cout << ans << endl;


	return 0;
}

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

import re

def abc154b(s):
    t = re.sub('[a-z]', 'x', s)
    return(t)

###
# main
if(__name__ == '__main__'):
    # input
    s = input()

    t = abc154b(s)

    # output
    print(t)
# else:
    # do nothing


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 9000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int N=5005;
vector<int> v[N];
ll n,k;
ll a[N],p[N];
bool vis[N];
vector<int> x;

void dfs(int s)
{
    vis[s]=true;
    x.pb(s);
    for(int j:v[s])
    {
        if(!vis[j])
            dfs(j);
    }
}

int _runtimeTerror_()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        cin>>p[i];
        v[i].pb(p[i]);
    }
    for(int i=1;i<=n;++i)
        cin>>a[i];
    ll ans=-INF;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
            vis[j]=false;
        x.clear();
        dfs(i);
        //for(auto j:x)
        //    cout<<j<<" ";
        //cout<<"\n";
        vector<ll> sum(x.size(),0);
        for(int j=1;j<x.size();++j)
        {
            sum[j]=sum[j-1]+a[x[j]];
        }
        ll u=sum[sz(x)-1];
        u+=a[x[0]];
        if(k<sz(x))
        {
            for(int j=1;j<=k;++j)
                amax(ans,sum[j]);
        }
        else
        {
            ll kk=k;
            ll val=0;
            ll cycles = k/sz(x);
            --cycles;
            if(u<=0)
            {
                for(int j=1;j<x.size();++j)
                    amax(ans,sum[j]);
            }
            else
            {
                val+=cycles*u;
                for(int j=1;j<x.size();++j)
                    amax(ans,sum[j]+val);
                val+=u;
                amax(ans,val);
                k%=sz(x);
                for(int j=1;j<=k;++j)
                    amax(ans,val+sum[j]);
            }
            k=kk;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,m;
  cin >> n >> m;
  if(n==1&&m==1) cout << 1 << endl;
  else if(2<n&&2<m) cout << (n-2)*(m-2) << endl;
  else if(n==1||m==1) cout << max(n,m)-2 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String s[] = {"Sunny","Cloudy","Rainy"};
		
		for (int i = 0 ; i < 3 ; i++) {
			if (i == 2) {
				System.out.println(s[0]);
				break;
			}
			if(str.equals(s[i])) {
				System.out.println(s[i + 1]);
				break;
			}
			
			
		}
		
		
		
	}	
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool turn = true;
    while (a > 0 && c > 0)
    {
        if (turn)
        {
            c -= b;
        }
        else
        {
            a -= d;
        }
        turn = !turn;
    }
    if (a > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3616
function PriorityQueue(){
    this.heap = [];
}

PriorityQueue.prototype = {
    push : function(x){
        var h = this.heap, i = h.length++, j;
        while(i){
            j = i-1 >> 1;
            if(h[j] <= x)break;
            h[i] = h[j];
            i = j;
        }
        h[i] = x;
    },
    pop : function(){
        var h = this.heap, r = h[0], x = h.pop();
        var i = 0, k = h.length >> 1, j;
        while (i < k) {
            j = (i << 1) + 1;
            if(h[j+1] < h[j])++j;
            if(x <= h[j])break;
            h[i] = h[j];
            i = j;
        }
        if(h.length)h[i] = x;
        return r;
    },
    size : function(){return this.heap.length;},
    top : function(){return this.heap[0];},
};

function Main(arg) {
 
    var N = arg.split("\n")[0].split(" ")[0]-0;
    var M = arg.split("\n")[0].split(" ")[1]-0;

    var A = arg.split("\n")[1].split(" ");

    for (var i = 0; i < N; i++){
        A[i] = A[i] - 0;
    }

    var pq = new PriorityQueue();

    for (var i = 0; i < N; i++){
        pq.push(-A[i]);
    }

    for (var i = 0; i < M; i++) {
        var max = -pq.pop();
        pq.push(-Math.floor(max / 2));
    }

    var ans = 0;
    while(pq.size() > 0){
        ans += -pq.pop();
    }

    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 18184
#include<iostream>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)

int main(){

  string s, t; cin>> s>> t;

  int j=0;
  while(j<t.size()){
    cout<< s[j]<< t[j];
    j++;
  }

  if(s.size()!=t.size()) cout<< s.back();
  cout<< endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N;
    cin >>N;
    vi tmp(N-1,0);

    rep(i,0,N-1){
        cin>>tmp[i];
    }

    ll ans=0;

    ans+=tmp[N-2];
    ans+=tmp[0];

    rep(i,0,N-2){
        ans+=min(tmp[i],tmp[i+1]);
    }

    cout<<ans<<endl;


    
    return 0;
}


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

int cnt[200010];
int main(){
  int N, K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    cnt[a-1]++;
  }
  sort(cnt, cnt+N);
  
  int ans = 0;
  for(int i = 0; i < N-K; i++) ans += cnt[i];

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


Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto pf = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        pf[i] = pf[i-1] + a[i-1];
    }

    long dif(int k, int btm, int top) {
        return abs(pf[top] - pf[k] - (pf[k] - pf[btm]));
    }

    int l, r;
    long ans = 10L^^18;

    foreach (i ; 0 .. n) {
        if (i < 2 || (n - i) < 2) {
            continue;
        }

        while (dif(l, 0, i) >= dif(l + 1, 0, i)) {
            l++;
        }

        while (r < i || dif(r, i, n) >= dif(r + 1, i, n)) {
            r++;
        }

        long p1 = pf[l] - pf[0];
        long p2 = pf[i] - pf[l];
        long p3 = pf[r] - pf[i];
        long p4 = pf[n] - pf[r];
        long mx = max(p1, p2, p3, p4);
        long mn = min(p1, p2, p3, p4);
        ans = min(ans, mx - mn);
    }

    writeln(ans);
}






































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 10672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_NM 100000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }


class DisjointSet {
    private:
    class Node {
        public: 
        int parent = -1;
        int rank = 0;
        int degree = 1;
    };
    
    Node *nodes;
    
    void make_set(int x) {
        ++count;
        nodes[x].parent = x;
        nodes[x].rank = 0;
        nodes[x].degree = 1;
    }

    public:
    int count = 0;

    DisjointSet(){}
    DisjointSet(int length) {
        nodes = (Node *)malloc(sizeof(Node) * length);
        for(int i = 0; i < length; ++i)
            make_set(i);
    }

    ~DisjointSet() {
        free(nodes);
    }

    int find_set(int x) {
        if(nodes[x].parent == x)
            return x;

        return nodes[x].parent = find_set(nodes[x].parent);
    }

    int get_degree(int x) {
        return nodes[find_set(x)].degree;
    }

    void unite(int x, int y) {
        int set_x = find_set(x);
        int set_y = find_set(y);
        if(set_x == set_y) return;
        --count;

        if(nodes[set_x].rank < nodes[set_y].rank) {
            nodes[set_x].parent = set_y;
            nodes[set_y].degree += nodes[set_x].degree;
        } else if(nodes[set_x].rank > nodes[set_y].rank) {
            nodes[set_y].parent = set_x;
            nodes[set_x].degree += nodes[set_y].degree;
        } else {
            nodes[set_y].parent = set_x;
            nodes[set_x].rank++;
            nodes[set_x].degree += nodes[set_y].degree;
        }
    }

    bool is_same(int x, int y) {
        int set_x = find_set(x);
        int set_y = find_set(y);
        return set_x == set_y;
    }
};

llong N, M;
ipair bridges[MAX_NM];
llong res[MAX_NM];

int main(int argc, char **argv) {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        cin >> bridges[i].first >> bridges[i].second;
        bridges[i].first--;
        bridges[i].second--;
    }

    auto dset = new DisjointSet(N);
    llong cur = N * (N - 1) / 2;

    for(int i = M - 1; i >= 0; --i) {
        res[i] = cur;
        ipair br = bridges[i];
        if(!dset->is_same(br.first, br.second)) {
            cur -= (llong)dset->get_degree(br.first) * dset->get_degree(br.second);
            dset->unite(br.first, br.second);
        }
    }

    for(int i = 0; i < M; ++i)
        cout << res[i] << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;

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

    string right_s = "CODEFESTIVAL2016";

    int answer = 0;
    for (int i = 0; i < int(s.size()); i++)
    {
        if (s.at(i) != right_s.at(i))
            answer++;
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  char a;
  int b;
  rep(i,h)rep(j,w){
    string s;
    cin>>s;
    if(s=="snuke"){
      a='A'+j;
      b=i+1;
    }
  }
  cout<<a<<b<<endl;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e7 + 5;

typedef long long ll;

int n, a[N], pos;
vector <int> vec;

int main()
{
      cin >> n;

      for(int i = 1; i <= n; i ++)
      {
            for(int j = 1; j <= i; j ++)
            {
                  if(pos > n) break;
                  pos ++;
                  a[pos] = i;
            }
            if(pos > n) break;
      }

      while(n >= 1)
      {
            vec.pb(a[n]);
            n -= a[n];
      }

      reverse(vec.begin(), vec.end());

      for(int i : vec)
            cout << i << endl;
}


Measured memory_bytes: 39424
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
double p[3001];
double dp[3001][3001];

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

	dp[1][0] = 1 - p[1];
	dp[1][1] = p[1];

	for (int i = 2;i <= n;i++) {
		dp[i][0] = dp[i - 1][0] * (1 - p[i]);
		dp[i][i] = dp[i - 1][i - 1] * p[i];

		for (int j = 1;j < i;j++) {
			dp[i][j] =  dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
		}
	}

	double ans = 0;
	for (int i = 0;i <= n;i++) {
		if ( i > (n / 2) ) ans += dp[n][i];
	}

	cout << fixed << std::setprecision(9) << ans << endl;

	return 0;
}


Measured memory_bytes: 68992
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N,K;	cin>>N>>K;
	vl A(N);
	rep(i,0,N){
		cin>>A[i];
	}
	vl sum(N);
	ll tmp=0;
	rep(i,0,K){
		tmp+=A[i];
	}
	sum[K-1]=tmp;
	rep(i,K,N){
		sum[i]=sum[i-1]+A[i]-A[i-K];
		if(sum[i]>sum[i-1]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
ll M;
vector<int> E[100000];
ll dp[100000];
ll ans[100000];
int par[1000000];
bool used[100000];
vector<ll> l[100000];
vector<ll> r[100000];
void dfs1(int x, int y){
    par[y]=x;
    if(sz(E[y])==1){
        dp[y]=1;
    }
    else{
        ll res=1;
        rep(i,0,sz(E[y])){
            if(E[y][i]!=x){
                dfs1(y, E[y][i]);
                res*=(dp[E[y][i]]+1);
                res%=M;
            }
        }
        dp[y]=res;
    }
}
void dfs2(int x){
    ans[x]=dp[x];
    if(sz(E[x])!=1){
        vector<int> v;
        rep(i,0,sz(E[x])){
            if(E[x][i]!=par[x]) v.pb(i);
        }
        rep(i,0,sz(v)){
            if(i==0) l[x].pb(dp[E[x][v[i]]]+1);
            else l[x].pb(l[x][i-1]*(dp[E[x][v[i]]]+1)%M);
        }
        rer(i,sz(v),0){
            if(i==sz(v)-1) r[x].pb(dp[E[x][v[i]]]+1);
            else r[x].pb(r[x].back()*(dp[E[x][v[i]]]+1)%M);
        }
        rev(r[x]);
        ll ori1=dp[x];
        int p=par[x];
        rep(i,0,sz(E[x])){
            if(par[x]!=E[x][i]&&used[E[x][i]]==0){
                ll ori2=dp[E[x][i]];
                /*cout<<l[x][0]<<"\n";
                cout<<l[x][1]<<"\n";
                cout<<l[x][2]<<"\n";*/
                dp[x]=(i>=1?l[x][i-1]:1)*(i<=sz(E[x])-2?r[x][i+1]:1)%M;
                dp[E[x][i]]*=dp[x]+1;
                dp[E[x][i]]%=M;
                par[E[x][i]]=-1;
                par[x]=E[x][i];
                used[E[x][i]]=1;
                dfs2(E[x][i]);
                dp[x]=ori1;
                dp[E[x][i]]=ori2;
                par[x]=p;
                par[E[x][i]]=x;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N>>M;
    if(N==1){
        cout<<1<<"\n";
        return 0;
    }
    rep(i,0,N-1){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        E[x].pb(y);
        E[y].pb(x);
    }
    rep(i,0,N){
        if(sz(E[i])!=1){
            dfs1(-1,i);
            used[i]=1;
            dfs2(i);
            break;
        }
    }
    rep(i,0,N){
        cout<<ans[i]<<"\n";
    }
}

Measured memory_bytes: 32256
import sys
input=sys.stdin.readline
a,b=map(int,input().split())
import fractions
c=fractions.gcd(a,b)
res=[]
i=2
while i**2<=c:
    if c%i==0:
        c=c//i
        res.append([i,1])
    while c%i==0:
        c=c//i
        res[-1][1]+=1
    i=i+1
if not c==1:
    res.append([c,1])
m=len(res)
ans=m+1
print(ans)





Measured memory_bytes: 65768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		System.out.println((a+b>=c)? "Yes":"No");
	}
}

Measured memory_bytes: 21844
O = input()
E = input()

Z = []
if len(O) > len(E):
    for i in range(len(O) -1):
        Z.append(O[i])
        Z.append(E[i])
    Z.append(O[-1])

else:
    for i in range(len(O)):
        Z.append(O[i])
        Z.append(E[i])
    

print("".join(Z))



Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e,f;
	float x,y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		x=(float)(c*e-f*b)/(a*e-d*b);
		y=(float)(c*d-f*a)/(b*d-e*a);
		if(x==-0.0){
			x=0.0;
		}
		if(y==-0.0){
			y=0.0;
		}
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
#define MAX 1000
using namespace std;
int n,m;
string v[MAX+1];
int sp[MAX+1][MAX+1];
int movex[] = {-1,+1,0,0};
int movey[] = {0,0,-1,+1};
int a,b;
bool valid(int x,int y)
{
	return (x>=0&&x<n&&y>=0&&y<m&&v[x][y]=='.');
}
int dijsktra(int x,int y)
{
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			sp[i][j] = INT_MAX;
	set<pair<int,pair<int,int>>> st;
	st.insert({0,{x,y}});
	sp[x][y] = 0;
	int cost;
	while(!st.empty())
	{
		pair<int,pair<int,int>> p = *(st.begin());
		x = p.second.first, y = p.second.second, cost = p.first;
		st.erase(st.begin());
		for(int i=0;i<4;++i)
		{
			int r = x+movex[i], c = y+movey[i];
			if(valid(r,c))
			{
				if(sp[r][c]>sp[x][y]+0)
				{
					set<pair<int,pair<int,int>>>::iterator it = st.find({sp[r][c],{r,c}});
					if(it!=st.end())
						st.erase(it);
					sp[r][c] = sp[x][y];
					st.insert({sp[r][c],{r,c}});
				}
			}
		}
		for(int r=x-2;r<=x+2;++r)
		{
			for(int c=y-2;c<=y+2;++c)
			{
				if(valid(r,c))
				{
					if(sp[r][c]>sp[x][y]+1)
					{
						set<pair<int,pair<int,int>>>::iterator it = st.find({sp[r][c],{r,c}});
						if(it!=st.end())
							st.erase(it);
						sp[r][c] = sp[x][y]+1;
						st.insert({sp[r][c],{r,c}});
					}
				}
			}
		}
	}
	return (sp[a][b]==INT_MAX?-1:sp[a][b]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	int x,y;
	cin>>x>>y;
	x--,y--;
	cin>>a>>b;
	a--,b--;
	for(int i=0;i<n;++i)
		cin>>v[i];
	cout<<dijsktra(x,y)<<endl;
	return 0;
}

Measured memory_bytes: 8812
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "next", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);

    auto fac = iota(cast(long) sqrt(m.to!(real))).map!(x => x + 1)
        .filter!(x => !(m % x)).array();
    
    fac ~= fac.dup.reverse().map!(x => m / x).array();

    // fac.writeln();
    long ok = fac.length, ng = -1;
    while (abs(ok - ng) > 1)
    {
        auto mid = (ok + ng) / 2;
        if (fac[mid] >= n)
            ok = mid;
        else
            ng = mid;
    }

    writeln(m / fac[ok]);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2816
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, k;
	cin >> n >> k;
	
	Array sum(1e5 + 10, 0);
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		sum[a] += b;
	}

	ll con = 0;
	ll ans = 0;
	REP(i, 1e5 + 10) {
		con += sum[i];
		if (con >= k) {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 1024
list_1 = [int(input()) for i in range(5)]
list_2 = []

for k in list_1:
    num_to_10 = 0
    if k % 10 == 0:
        list_2.append(0)
        continue
    while k % 10 != 0:
        k += 1
        num_to_10 += 1
    list_2.append(num_to_10)

last_dish_ind = list_2.index(max(list_2))
last_dish_time = list_1[last_dish_ind]
del list_1[last_dish_ind]
del list_2[last_dish_ind]
time = sum(list_1) + sum(list_2) + last_dish_time
print(time)

Measured memory_bytes: 3064
from fractions import gcd
from functools import reduce 
def lcm_base(x, y):
  return(x * y) // gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
min = lcm_list(a)
sum = 0
for i in range(n):
  sum = sum + (min//a[i])
  
print(sum%mod)



Measured memory_bytes: 6136
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL Vs[n], Cs[n];
	rep(i, 0, n)	Vs[i] = scanLong();
	rep(i, 0, n)	Cs[i] = scanLong();
	LL maxDiff = 0;
	rep(i, 0, n)	maxDiff += max(0ll, Vs[i] - Cs[i]);
	pll(maxDiff); nl;
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    vector<ll> still(n, -1);
    rep(i, n) cin >> a[i];
    ll now = 1;
    ll L = 0;
    ll rest = 0;
    for(ll i = 1; i <= k; i++){
        L++;
        now = a[now-1];
        // cout << "now=" << now << endl;
        if(still[now-1] > 0){
            // cout << "still" << still[now-1] << endl;
            L -= still[now-1]-1;
            // cout << "L" << L << endl;
            rest = (k - i) % L;
            break;
        }else{
            still[now-1] = i+1;
        }
    }
    for(ll i = 0; i < rest; i++){
        now = a[now-1];
        // cout << "now1=" << now << endl;
    }
    cout << now << endl;
}

Measured memory_bytes: 6328
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val al = Vector.fill(n)(sc.nextInt)

  val res =
    al.zipWithIndex
      .sortWith{case (t1, t2) => t1._1 < t2._1}
      .map(t => t._2 + 1)
      .mkString(" ")

  println(res)

}

Measured memory_bytes: 57488
#include<stdio.h>
int main(){
	int a,b,c,yakusu=0;
	scanf("%d %d %d",&a,&b,&c);
	for(;;){
		if(c%a==0){
			yakusu++;
		}
		a++;
		if(a>b){
			break;
		}
	}
	printf("%d\n",yakusu);
	
	
	return 0;
}

Measured memory_bytes: 596
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >

const int maxn = 4005;
int a[maxn], dp[maxn][maxn], w[maxn][maxn], b[maxn][maxn], wx[maxn], bx[maxn];
char c[maxn];

int32_t main(){
    int n;
    cin >>n;
    for(int i = 0; i < 2* n; i ++){
        cin >>c[i] >>a[i];
        if(c[i] == 'W')
            wx[a[i]] = i;
        else
            bx[a[i]] = i;
    }
    for(int k = 0; k <= n; k ++){
        int cn = 0;
        for(int i = 0; i < 2* n; i ++){
            if(c[i] == 'W' and a[i] > k)
                cn ++;
            w[i][k] = cn;
        }
        cn = 0;
        for(int i = 0; i < 2* n; i ++){
            if(c[i] == 'B' and a[i] > k)
                cn ++;
            b[i][k] = cn;
        }
    }
    for(int i = 1; i <= n; i ++)
        dp[i][0] = dp[i - 1][0] + w[wx[i]][i] + b[wx[i]][0];
    for(int j = 1; j <= n; j ++)
        dp[0][j] = dp[0][j - 1] + b[bx[j]][j] + w[bx[j]][0];
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= n; j ++){
            dp[i][j] = min(
            dp[i - 1][j] + w[wx[i]][i] + b[wx[i]][j],
            dp[i][j - 1] + b[bx[j]][j] + w[bx[j]][i]);
        }
    }
    cout <<dp[n][n] <<endl;
    return false;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 1000001;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll inv(ll base) {
        int g = MOD, r = base, x = 0, y = 1;
        while (r != 0) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }
        return x < 0 ? x+MOD : x;
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, inv(b));
    }
}

using namespace Modop;

int N;
ll sum;
map<ll, ll> factorCnt;
vl primes;
bitset<100000> isPrime;

void sieve() {
    isPrime.set();
    FOR(i, 2, 100000) {
        if (isPrime[i]) {
            primes.pb(i);
            for(int j = i * 2; j < 100000; j += i) isPrime[j] = 0;
        }
    }
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    sieve();
    
    cin >> N;
    vl a(N); 
    F0R(i, N) {
        cin >> a[i];
        ll v = a[i];
        
        trav(prime, primes) {
            ll cnt = 0;
            while (v % prime == 0) {
                v /= prime;
                cnt++;
            }
            if (cnt > 0) factorCnt[prime] = max(factorCnt[prime], cnt);
        }
        
        // In case it's prime
        if (v > 1) factorCnt[v] = 1;
    }
    
    ll LCM = 1;
    trav(i, factorCnt) {
        LCM *= modExp(i.f, i.s);
        LCM %= MOD;
    }
    // cout << LCM << "\n";
    
    ll ans = 0;
    F0R(i, N) {
        ans += inv(a[i]); ans %= MOD;
    }
    // cout << ans << "\n";
    ans *= LCM; ans %= MOD;
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 1024