akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}


int pow_mod(ll a, int b) {
	ll pow = 1;
	while (b > 0) {
		if (b & 1) pow = pow * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return pow;
}

ll inv_mod(ll n) {
	return pow_mod(n, MOD - 2);
}

int fact_mod(int n) {
	ll fact = 1;
	for (int i = n; i > 0; --i) fact = (fact * i) % MOD;
	return (int)fact;
}

ll comb_mod(ll n, ll r) {
  //nCk = nCk-1 * n-k+1/k
	ll comb = 1;
	if (n / 2 < r) return comb_mod(n, n - r);
	else {
		for (ll i = 0; i < r; ++i)
			comb = comb * (n - i) % MOD;
		return comb * inv_mod(fact_mod(r)) % MOD;
	  }
	}

void setComb_mod(vector<ll> &combs, ll n, ll r) {
	//nCk = nCk-1 * n-k+1/k
	// combs[i] = nCi
	ll comb = 1;
	combs[0] = combs[n] = comb;
	if (n / 2 < r) setComb_mod(combs, n, n - r);
	else {
		for (ll i = 1; i <= r; ++i) {
			comb = comb * (n - i + 1) % MOD * inv_mod(i) % MOD;
			combs[i] = combs[n-i] = comb;
		}
	}
}

int main() {
  ll k, n;
	cin >> n >> k;

	if (n-1 <= k) {
		cout << comb_mod(2*n-1,n-1) << endl;
	}
	else {
	  vector<ll> combs1(n+1), combs2(n);
		setComb_mod(combs1, n  , (n+1)/2);
		setComb_mod(combs2, n-1, n/2);
	  ll ans = 0;
		rep(i, k + 1) {
		  ans += combs1[i] * combs2[n - i - 1] % MOD;
			ans %= MOD;
		}
		cout << ans << endl;
	}
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll x,y;cin>>x>>y;
    ll res=0;
    for(ll tmp=x;tmp<=y;tmp*=2) res++;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	const int Mod=1e9+7;
	int t;
	while(cin>>t)
	{
		int n[t],m[t];
		cin>>n[0];
		m[0]=n[0];
		for(int i=1;i<t;i++) 
		{
			cin>>n[i];
			m[i]=n[i]+m[i-1];
		}
		int sum=0;
		for(int i=0;i<t-1;i++)
		{
			sum=(m[t-1]-m[i])%Mod*n[i]+sum;
			sum%=Mod;
		}
		cout<<sum<<"\n";
	}
}
/*
1,2,3,4,5
1*(2+3+4+5)
2*(3+4+5)
*/

Measured memory_bytes: 6672
#include <iostream>
#include <string>
using namespace std;
//---------------------------------------
void print(string str, int n1, int n2);
void reverse(string &str, int n1, int n2);
void replace(string &str, int n1, int n2, string replace_str);
//---------------------------------------

int main(void)
{
	string str;  //?????????str
	int commands;   //????????°
	
	//??????????????\???
	cin >> str;
	
	//????????°q?????\???
	cin >> commands;
	
	for(int i = 0; i < commands; i++){
		
		string command;
		int n1, n2;
		
		cin >> command;
		cin >> n1;
		cin >> n2;
		
		if(command == "print"){ //??????????????????
			print(str, n1, n2);
		}
		else if(command == "reverse"){  //??????????????????
			reverse(str, n1, n2);
		}
		else{  //????????¬????????????
			string replace_str;
			cin >> replace_str;
			replace(str, n1, n2, replace_str);
		}
	}
	
	
	return 0;
}

//------------------------------------------------------------
void print(string str, int n1, int n2)
{
	for(int i = n1; i <= n2; i++){
		cout << str[i];
	}
	cout << endl;
}

//------------------------------------------------------------
void reverse(string &str, int n1, int n2)
{
	string copy = str;
	int j = 0;
	
	for(int i = n1; i <= n2; i++){
		str[i] = copy[n2 - j];
		j++;
	}
}

//------------------------------------------------------------
void replace(string &str, int n1, int n2, string replace_str)
{
	int j = 0;
	for(int i = n1; i <= n2; i++){
		str[i] = replace_str[j];
		j++;
	}
}

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

int foo(const int N, const int K, char* S)
{
  int ct=0;
  for(int i=0; i<N-1; i++){
    ct+= S[i]==S[i+1];
  }
 
  //cout<< min(ct+2*K,N-1)<<"\n";
  return min(ct+2*K,N-1);
}

int main()
{ 
  int N,K;
  cin >> N>>K;
 
  string S;
  cin>>S;
  cout << foo(N, K, (char*)S.c_str()) << endl;

  return 0;
}


Measured memory_bytes: 512
#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];

    auto partition=[&](int l,int r)
    {
        int i=l;
        for(int j=l;j<r;j++){
            if(a[j]<=a[r]) swap(a[i++],a[j]);
        }
        swap(a[i],a[r]);
        return i;
    };

    int idx=partition(0,N-1);
    for(int i=0;i<N;i++){
        if(i>0) printf(" ");
        if(i==idx) printf("[%d]",a[i]);
        else printf("%d",a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3168
/* ITP1_9_D */
#include <stdio.h>
#include <string.h>

#define MAX_LENGTH 1001
#define ORDER_LENGTH 8

/* ?????????????????? */
typedef enum {
	PRINT = 0,
	REVERSE,
	REPLACE
} order_type;

/* ????????????????????????????????¢??° */
void init_char_array(char array[], short length);
/* ??????????????????????????? */
order_type get_order_type(char order_array[]);
/* ?????????????????¨??¨???????????¢??° */
void print(char ch_array[], short start_pos, short end_pos);
/* ?????????????????¨???????????\??????????????¢??° */
void reverse(char ch_array[], short start_pos, short end_pos);
/* ?????????????????¨?????????????????¢??° */
void replace(char ch_array[], short start_pos, short end_pos, char rep_array[]);

int main(void)
{
	char input_ch[MAX_LENGTH];
	init_char_array(input_ch, MAX_LENGTH);
	scanf("%s", input_ch);
	
	short order_cnt = 0;
	scanf("%hd", &order_cnt);
	
	char order_ch[ORDER_LENGTH];
	order_type type = PRINT;
	short start_pos = 0, end_pos = 0;
	char replace_ch[MAX_LENGTH];
	
	short ii;
	for( ii = 0; ii < order_cnt; ii++ )
	{
		init_char_array(order_ch, ORDER_LENGTH);
		start_pos = 0;
		end_pos = 0;
		
		// ????????????????§?????´??????????????´??????????
		scanf("%s %hd %hd", order_ch, &start_pos, &end_pos);
		
		// ??????????¨?????????????
		type = get_order_type(order_ch);
		
		// ??????????¨??????????????????????????????????
		switch( type )
		{
		case PRINT:		// ?????¢??¨???
			print(input_ch, start_pos, end_pos);
			break;
		case REVERSE:	// ??????????????????
			reverse(input_ch, start_pos, end_pos);
			break;
		case REPLACE:	// ?????????????????????
			init_char_array(replace_ch, MAX_LENGTH);
			scanf("%s", replace_ch);
			replace(input_ch, start_pos, end_pos, replace_ch);
			break;
		}
	}
	return 0;
}

/* ????????????????????????????????¢??° */
void init_char_array(char array[], short length)
{
	short ii;
	for( ii = 0; ii < length; ii++ )
	{
		array[ii] = '\0';
	}
}

/* ??????????????????????????? */
order_type get_order_type(char order_array[])
{
	order_type type = PRINT;

	if( 0 == strcmp(order_array, "print"))
	{
		type = PRINT;
	}
	else if( 0 == strcmp(order_array, "reverse"))
	{
		type = REVERSE;
	}
	else if( 0 == strcmp(order_array, "replace"))
	{
		type = REPLACE;
	}

	return type;
}

/* ?????????????????¨??¨???????????¢??° */
void print(char ch_array[], short start_pos, short end_pos)
{
	short ii;
	for( ii = start_pos; ii <= end_pos; ii++ )
	{
		printf("%c", ch_array[ii]);
	}
	printf("\n");
}

/* ?????????????????¨???????????\??????????????¢??° */
void reverse(char ch_array[], short start_pos, short end_pos)
{
	short temp_len = end_pos - start_pos;
	char temp[temp_len];
	init_char_array(temp, temp_len);
	
	short ii, temp_idx = 0;
	for( ii = end_pos; ii >= start_pos; ii-- )
	{
		temp[temp_idx++] = ch_array[ii];
	}
	
	temp_idx = 0;
	for( ii = start_pos; ii <= end_pos; ii++ )
	{
		ch_array[ii] = temp[temp_idx++];
	}
}

/* ?????????????????¨?????????????????¢??° */
void replace(char ch_array[], short start_pos, short end_pos, char rep_array[])
{
	short ii, rep_idx = 0;
	for( ii = start_pos; ii <= end_pos; ii++ )
	{
		ch_array[ii] = rep_array[rep_idx++];
	}
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0;
	int a[105],b[105];
	cin >> n; 
	for(int i=1;i<=n-1;i++) scanf("%d",&b[i]);
	a[n]=b[n-1];
	for(int i=n-1;i>1;i--)
	{
		a[i]=min(b[i],b[i-1]);
	}
	a[1]=b[1];
	for(int i=1;i<=n;i++) sum+=a[i];
	cout<<sum;
	return 0;
}

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


int main()
{
	int age,e_cost;
  cin>>age>>e_cost;
  if(age>=13)
  {
  	cout<<e_cost;
  }
  else if(age<=12 && age>=6)
  {
  	e_cost=e_cost/2;
  	cout<<e_cost;
  }
  else if(age<=5)
  {
  	cout<<0;
  }
  return 0;
}


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

using namespace std;

void Main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << '\n';
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >>n;
    vector<ll>a(n);
    vector<ll>za(n,0);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n;i++){
        ll d = a.at(i)-1;
        ll next = d*(-1);
        next = i+next;
        if(next<0||next>=n)continue;
        za.at(next)++;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        int next = a.at(i)+1+i;
        if(next>=n)continue;
        ans+=za.at(next);
    }
    cout << ans << endl;
}
    



Measured memory_bytes: 6424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
string s[2];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s[0]>>s[1];
    ll ans=1;
    int next=3;
    for(int i=0;i<s[0].size();i++){
        if(s[0][i]==s[1][i]){
            ans*=next;
            ans%=MOD;
            next=2;
        }
        else{
            if(next==1){
                ans*=3;
                ans%=MOD;
            }
            else if(next==3){
                ans*=6;
                next=1;
            }
            else{
                ans*=2;
                ans%=MOD;
                next=1;
            }
            i++;
        }
        //cout<<i<<"\n";
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
def solve():
    mod = 10 ** 9 + 7

    def cmb(n, r):
        def build():
            fs = [1]
            t = 1
            for x in range(1, h * w):
                t = (t * x) % mod
                fs.append(t)

            invs = [1] * (h * w)
            t = pow(t, mod - 2, mod)
            invs[-1] = t
            for x in range(h * w - 2, 0, -1):
                t = (t * (x + 1)) % mod
                invs[x] = t
            return fs, invs

        if r < 0 or r > n:
            return 0
        if r > (n - r):
            return cmb(n, n - r)
        if r == 0:
            return 1
        if r == 1:
            return n

        fs, invs = build()
        return fs[n] * invs[n - r] * invs[r] % mod

    h, w, k = map(int, input().split())
    c = cmb(h * w - 2, k - 2)
    ret = (pow(w, 2) * sum((h - d) * d for d in range(h))
           + pow(h, 2) * sum((w - d) * d for d in range(w))) * c % mod

    return ret


print(solve())

Measured memory_bytes: 54128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    
    ll D,c;
    vector<ll> C;
    vector<vector<ll>> S;
    
    cin >> D;
    REP(i,26){
        cin >> c;
        C.push_back(c);
    }
    S.resize(D);
    REP(i,D){
        REP(j,26){
            cin >> c;
            S[i].push_back(c);
        }
    }
    
    REP(i,D){
        cout << 1 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3740
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
S = input()

x = 0
ans = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans,x)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readb(n, k);
    int sum1 = 0, sum2 = 0;

    fori(i, 0, k-1) sum1 += i;
    ford(i, n, n-k+1) sum2 += i;

    int n1 = k-1; int n2 = n-k+1;

    int ans = 0;

    fori(i, k, n+1)
    {
	    int cnt = (sum2-sum1+1);
	    cnt %= mod;
	    ans += cnt;
	   	ans %= mod;
	   	n1++; n2--;
	   	sum1 += n1; sum2 += n2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

//AtCoder Beginner Contest 148
//C	Snack
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = Long.parseLong(sc.next());
		long B = Long.parseLong(sc.next());
		sc.close();

		// ユークリッドの互除法
		long a = A;
		long b = B;
		if (A < B) {
			a = B;
			b = A;
		}
		long r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		long x = A * B;
		System.out.println(x / b);
	}
}


Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    ll n,j;
   scanf("%lld",&n);
   {
    for(ll i=1;i*i<=n;i++)
    {
        j=0;
        j=i*i;
    }
   printf("%lld\n",j);
   }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    D ans = 0.0;
    int dc = 0;
    vector<int> s(n+1, 0);
    rep(i,n) s[i+1] = s[i] + p[i];
    rep(i,n-k+1){
        dc = max(dc, s[i+k] - s[i]);
    }
    ans  = (dc + k) / 2.0;
    printf("%.10f\n", ans);
}


Measured memory_bytes: 1792
/*https://atcoder.jp/contests/abc088/tasks/abc088_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, a[100], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			sum += a[i];
		else
			sum -= a[i];
	}
	cout << sum;
}

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

int main() {
    int n;
    while(cin >> n, n) {
        int ret=0;
        for(int i=1; i<=1000; ++i) {
            for(int j=1000; j>i; --j) {
                if((j+i)*(j-i+1)/2 == n) ret++;
            }   
        }   
        cout << ret << endl;
    }
}


Measured memory_bytes: 3040
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	string s;
	cin >> s;
	string ans = "Good";
	for (int i = 0; i <= 2; i++) {
		if (s[i] == s[i + 1])ans = "Bad";
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

double xs[1010];
double ys[1010];
double rs[1010];

double g[1010][1010];
bool visited[1010];
double dist[1010];

const double EPS = 1e-8;
const double INF = 1e10;

int main(void) {
  scanf("%lf%lf%lf%lf", &xs[0], &ys[0], &xs[1], &ys[1]);

  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lf%lf%lf", &xs[i+2], &ys[i+2], &rs[i+2]);
  }
  n += 2;
  REP(i, n) {
    REP(j, i) {
      double d = hypot(xs[i]-xs[j], ys[i]-ys[j]);
      if(rs[i] + rs[j] + EPS < d) {
        g[i][j] = g[j][i] = d - (rs[i]+rs[j]);
      } else {
        g[i][j] = g[j][i] = 0;
      }
    }
  }
  REP(i, n) {
    dist[i] = INF;
  }
  dist[0] = 0;
  while(!visited[1]) {
    double mini = INF;
    int idx = -1;
    REP(i, n) {
      if(!visited[i] && dist[i] < mini) {
        mini = dist[i];
        idx = i;
      }
    }
    REP(i, n) {
      dist[i] = min(dist[i], dist[idx] + g[idx][i]);
    }
    visited[idx] = true;
  }
  printf("%.10f\n", dist[1]);
  return 0;
}


Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] S = new int[n];
        for(int i = 0; i < n; i++){
            S[i] = Integer.parseInt(s[i]);
        }
        int q = Integer.parseInt(br.readLine());
        String[] t = br.readLine().split(" ");
        int[] T = new int[q];
        for(int i = 0; i < q; i++){
            T[i] = Integer.parseInt(t[i]);
        }

        int ans = 0;

        //??°???T???????´??????????????????°???S??¨?????????????????????????????????Binary search??§)         
        for(int i = 0; i < T.length; i++){
            if(binarySearch(T[i], S)){
                ans++;
            }
        }
        System.out.println(ans);
    }

    public static boolean binarySearch(int key, int[] target){
        int left = 0;
        int right = target.length;
        int middle;

        while(left < right){
            middle = (left + right) / 2;
            if(key < target[middle]) right = middle;
            if(key == target[middle]) return true;
            if(key > target[middle]) left = middle + 1;
        }
        return false;
    }

}

Measured memory_bytes: 47196
#include<stdio.h>
#define N 101
#define BLACK 0
#define WHITE 1
#define INF 20000
#define NIL -1

int w[N][N],d[N],pi[N],color[N],n;
void prim(void);

int main(){

  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&w[i][j]);
      if(w[i][j]==-1)
	w[i][j]=INF;
    }
  }

  prim();

  return 0;
}


void prim(void){
  int i,j,mincost,v,r,u,sum=0;

  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[1]=0;

  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF)
      break;

    color[u]=BLACK;

    for(v=1;v<=n;v++){
      if(color[v]!=BLACK && w[u][v]<d[v]){
	pi[v]=u;
	d[v]=w[u][v];
      }
    }
  }
    for(v=1;v<=n;v++){
      sum+=d[v];
    }
  printf("%d\n",sum);
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int N; cin >> N;
	for(int rou = 0; rou < N; rou++) {
		vector<int> data(10);
		rep(i,10) cin >> data[i];
		bool ans = false;
		for(int i = 0; i < (1<<10); i++) {
			vector<int> b;
			vector<int> c;

			rep(j,10) {
				if(i & (1<<j)) {
					b.pb(data[j]);
				} else {
					c.pb(data[j]);
				}
			}

			bool f = true;
			int bp = 0;
			int cp = 0;
			for(int j = 0, n = b.size(); j < n; j++) {
				if(b[j] < bp) f = false;
				bp = b[j];
			}
			for(int j = 0, n = c.size(); j < n; j++) {
				if(c[j] < cp) f = false;
				cp = c[j];
			}
			if(f) {
				ans = true;
				break;
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<ll> H(N);
    rep(i,N) cin >> H[i];
    sort(all(H)); reverse(all(H));
    ll ans=0;
    rep(i,N){
        if (i<K) continue;
        ans+=H[i];
    }
    cout << ans << endl;
}

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

int main(){
  int N; cin >> N;
  vector<long long> A(N+1);
  for(int i=0; i<=N; i++) cin >> A[i];
  
  //木成立条件　上から
  long long rem=1;
  bool s=true;
  for(int i=0; i<=N; i++){
    if(rem>=A[i]){
      rem=min((long long)500000000,(rem-A[i])*2);
    }else{
      s=false;
    }
  }
  
  if(s==false){
    cout << -1 << endl;
    return 0;
  }
  
  //できるならとにかく分岐したほうがいいが
  //maxはそれ以下の葉の和で抑えられる
  long long Asum=0;
  for(int i=0; i<=N; i++){
    Asum+=A[i];
  }
  
  long long result=0;
  long long v=1;
  for(int i=0; i<=N; i++){
    result+=v;
    v-=A[i];
    Asum-=A[i];
    v=min(Asum,v*2);
  }
  
  cout << result << endl;
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a-b >= c) cout << 0 << endl;
  else cout << c - (a - b) << endl;
  
}


Measured memory_bytes: 256
bingo = [0]*3
for i in range(3):
  bingo[i] = [int(x) for x in input().split()]

bingo_check = [[False]*3 for i in range(3)]

n = int(input())
for i in range(n):
  key = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == key:
        bingo_check[j][k] = True

ans = "No"
for i in range(3):
  if bingo_check[i][0] and bingo_check[i][1] and bingo_check[i][2]:
    ans = "Yes"
for i in range(3):
  if bingo_check[0][i] and bingo_check[1][i] and bingo_check[2][i]:
    ans = "Yes"
if bingo_check[0][0] and bingo_check[1][1] and bingo_check[2][2]:
  ans = "Yes"
if bingo_check[2][0] and bingo_check[1][1] and bingo_check[0][2]:
  ans = "Yes"
print(ans)

Measured memory_bytes: 3064
INF = float('inf')
n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [2, 5, 5, 4, 5, 6, 3, 7, 6]
l = [[x, cost[x-1]] for x in a]
l = sorted(l, key = lambda x: x[1]*10-x[0])
r = l[0]
_max = [0] + [-INF]*n
for i in range(1, n+1):
  if 42 < i < n-42:
    _max[i] = max(_max[i], _max[i-r[1]]*10 + r[0])
  else:
    for x in l:
      ind = i-x[1]
      if ind >= 0:
        _max[i] = max(_max[i], _max[ind]*10 + x[0])
ans = str(_max[n])
print(ans)

Measured memory_bytes: 14452
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int N;
	int ret[4] = { 0, 0, 0, 0 };
	cin >> N;
	for (auto i = 0; i < 4; i++){
		int den = (int)pow(10,3-i);
		ret[i] = N / den;
		N = N % den;
	}
	if (ret[0]==ret[1] && ret[1] == ret[2]){
		cout << "Yes" << endl;
	}
	else if (ret[1] == ret[2] && ret[2] == ret[3]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[10000];

int main() {
	clr(d,0);
	ll n,m;
	cin>>n>>m;
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		d[a]++;
		d[b]++;
	}
	rep(i,0,n){
		cout << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  s=min(s,2*h);
  s=min(s,4*q);
  d=min(d,2*s);
  ll n;
  cin>>n;
  ll ans = (n/2)*d + (n%2)*s;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

void solve(int a, int b, int c) {
    if((a+b+c) <= 21)
        cout << "win";
    else
        cout << "bust";
}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    solve(a,b,c);
    return 0;
}


Measured memory_bytes: 256
// AOJ 2787 Pipe Fitter and the Fierce Dogs
// 2018.4.15 bal4u

#include <stdio.h>
#include <string.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
int dp[10002];
char dog[5002][10002];
 
int main()
{
	int W, H, K, N, x, y, s, t, ans;

	W = in(), H = in(), K = in(), N = in();
	H >>= 1;
	K -= (W>>1)+1; if (K < 0) { puts("-1"); return 0; }
	while (N--) {
		x = in()-1, y = in()-1;
		if (y & 1) dog[y>>1][x] = 1;
	}

	s = 0;
	for (y = 0; y < H; y++) {
		memset(dp, INF, (W+1)<<2);
		dp[0] = 0;
		for (x = 0; x < W; x++) {
			if (x & 1) dp[x+1] = dp[x];
			else {
				t = dp[x] + dog[y][x];
				if (dp[x+1] > t) dp[x+1] = t;
				if (x >= 2) {
					t = dp[x-2] + (dog[y][x-1]<<1);
					if (dp[x+1] > t) dp[x+1] = t;
				}
			}
		}
		s += dp[W];
	}
	ans = H*((W>>1)+1) + s;
	if (s > K) s = K;
	ans -= s<<1, K -= s;
	if (ans > K) ans -= K; else ans = 0;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 50708
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

def cumsum(it):
    """
    累積和
    :param collections.Iterable it:
    """
    cs = 0
    ret = []
    for v in it:
        cs += v
        ret.append(cs)
    return ret


# 解説
N = int(sys.stdin.buffer.readline())
CA = [sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(N * 2)]
C = []
A = []
for c, a in CA:
    C.append(c)
    A.append(int(a))

pos_w = [IINF] * (N + 1)
pos_b = [IINF] * (N + 1)
for i, (c, a) in enumerate(list(zip(C, A))):
    if c == 'W':
        pos_w[a] = i
    else:
        pos_b[a] = i

# count_b[k][i]: i より左に、k 以下の黒が何個あるか
# count_w[k][i]: i より左に、k 以下の白が何個あるか
bc = [0] * (N * 2 + 1)
wc = [0] * (N * 2 + 1)
count_b = [[0] * (N * 2 + 1)]
count_w = [[0] * (N * 2 + 1)]
for k in range(1, N + 1):
    wc[pos_w[k] + 1] = 1
    bc[pos_b[k] + 1] = 1
    count_b.append(cumsum(bc))
    count_w.append(cumsum(wc))

# dp[b][w]: B を b 回、W を w 回使ったときの転倒数の最小値
dp = [[INF] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 0
# for i in range(N * 2):
#     b = i
#     w = 0
#     if b > N:
#         w = b - N
#         b -= w
#
#     while w <= min(i, N):
#         if b < N:
#             # b + 1 を使う。
#             # 位置の写像が与えられたときのスワップの回数だから転倒数
#             # もともといた位置より右にあったやつで、既に使ってるのが何個か
#             orig_pos = pos_b[b + 1]
#             inv = i - count_b[b + 1][orig_pos] - count_w[w][orig_pos]
#             dp[b + 1][w] = min(dp[b + 1][w], dp[b][w] + inv)
#         if w < N:
#             orig_pos = pos_w[w + 1]
#             inv = i - count_b[b][orig_pos] - count_w[w + 1][orig_pos]
#             dp[b][w + 1] = min(dp[b][w + 1], dp[b][w] + inv)
#         b -= 1
#         w += 1


# もらう
for b, w in itertools.product(range(N + 1), repeat=2):
    if b > 0:
        # 最後に b を使う
        orig_pos = pos_b[b]
        inv = b - count_b[b][orig_pos] + w - count_w[w][orig_pos] - 1
        dp[b][w] = min(dp[b][w], dp[b - 1][w] + inv)
    if w > 0:
        # 最後に w を使う
        orig_pos = pos_w[w]
        inv = b - count_b[b][orig_pos] + w - count_w[w][orig_pos] - 1
        dp[b][w] = min(dp[b][w], dp[b][w - 1] + inv)
print(dp[N][N])

# import numpy as np
#
# print(np.array(dp))


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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    double N;
    cin >> N;
    cou(2 * pi * N);
}

Measured memory_bytes: 3824
N = map(int, raw_input().split(' '))
L = map(int, raw_input().split(' '))

X = N[1]
N = N[0]

sum = 0
ans = 1
for i in range(N):
      sum += L[i]
      if sum <= X:
            ans += 1
      else:
            break

print(ans)
      


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	if(s.size()+1==t.size())
	{
		if(s==t.substr(0,s.size()))
		 cout<<"Yes";
		else
		 cout<<"No";
	}
	else
	 cout<<"No";
	return 0;
}

Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int m = Console.ReadLine().Split().Select(int.Parse).ToArray()[1];
        int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        int[] moda = new int[m];
        int[] paircount = new int[m];
        int res = 0;
        int last = -10;
        for (int i = 0; i < a.Length; i++)
        {
            if (last == a[i])
            {
                paircount[a[i] % m]++;
                last = -1;
            }
            else
            {
                last = a[i];
            }
            moda[a[i] % m]++;
        }

        if (m % 2 == 0)
        {
            res += moda[m / 2] / 2;
        }

        res += moda[0] / 2;
        
        for (int i = 0; i < m / 2 - (m % 2 == 0 ? 1 : 0); i++)
        {
            res += Math.Min(moda[i + 1], moda[m - i - 1]);
            res += Math.Min((moda[i + 1] > moda[m - i - 1] ? paircount[i + 1] : paircount[m - i - 1]) ,Math.Abs(moda[i + 1] - moda[m - i - 1]) / 2);
            //Console.WriteLine(res);
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 22112
n = int(input())
a = list(map(int, input().split()))
money = 1000
for i in range(1, n):
    if a[i] > a[i-1]:
        stocks = money // a[i-1]
        money = money - a[i-1] * stocks + a[i] * stocks
    else:
        continue
print(money)


Measured memory_bytes: 9116
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;
 
int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
 
int max(int a,int b){return (a>b?a:b);}
 
int min(int a,int b){return (a<b?a:b);}
 
struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};
 
struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 100005;
vector<int>g[nax];
int dist[2][nax], n, u, v;

void dfs(int x,int p,int cnt,int type){
    dist[type][x] = cnt;
    for(int i:g[x]){
        if(i == p){
            continue;
        }
        dfs(i,x,cnt+1,type);
    }
}

int32_t main(){
    IOS
    cin >> n >> u >> v;
    
    int mx = 0;
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(u,u,0,0);
    dfs(v,v,0,1);
    if(g[u].size() == 1 && dist[1][g[u][0]] == 1){
        mx = 1;
    }
    for(int i=1;i<=n;i++){
        if(i == v){
            continue;
        }
        if(dist[0][i] < dist[1][i]){
            int ans = dist[1][i]-1;
            mx = max(mx,ans);
        }
    }
    cout<<mx<<endl;
} 

Measured memory_bytes: 15908
N = int(input())
cards = list(map(int,input().split(" ")))
cards.sort()
cards.reverse()
# print(cards)

sum_A = 0
sum_B = 0

for i in range(N):
	if i % 2 == 0:
		sum_A += cards[i]
	else:
		sum_B += cards[i]

ans = sum_A - sum_B

print(ans)

Measured memory_bytes: 3060
N = int(input())
S = input()

Wnum = []
Wnum.append(0)
for c in S:
        if c == 'W':
                Wnum.append(Wnum[-1]+1)
        else:
                Wnum.append(Wnum[-1])

Enum = [0]*(N)
for i in range(1,N):
        if S[N-i] == 'E':
                Enum[N-i-1] = Enum[N-i] + 1
        else:
                Enum[N-i-1] = Enum[N-i]

ans = N
for i in range(N):
        ans_temp = Wnum[i]+Enum[i]
        if ans_temp < ans:
                ans = ans_temp

print(ans)

Measured memory_bytes: 17824
N, A, B = map(int,input().split())
H = [int(input()) for _ in range(N)]

def solve(k):
    cnt = 0
    for i in range(N):
        if H[i] > B * k:
            cnt += (H[i] - B * k - 1) // (A - B) + 1
    return cnt <= k


left = 0
right = 10 ** 9 + 1

while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 13072
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def time(n):
  t = 0
  if n % 10 == 0:
    t = 0
  else:
    t = 10 - n % 10
  return t

arr = [[a, time(a)], [b, time(b)], [c, time(c)], [d, time(d)], [e, time(e)]]
arr.sort(key=lambda x: x[1], reverse=False)
arr = list(itertools.chain.from_iterable(arr))
print(sum(arr[:-1]))

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

struct Combination
{
    using type = long long;
    vector<type> fact, inv;
    type mod;
    int size;
    bool initiated;
    Combination(type sz, type m) : fact(sz + 1, 1), inv(sz + 1, 1), mod(m), size(sz)
    {
        initiated = false;
    }
    type mypow(type a, type b)
    {
        if (b == 0)
            return 1;
        type tmp = mypow(a, b / 2);
        if (b % 2)
            return (((tmp * tmp) % mod) * a) % mod;
        else
            return (tmp * tmp) % mod;
    }
    void init()
    {
        for (int i = 2; i <= size; i++)
        {
            fact[i] = fact[i - 1] * i;
            fact[i] %= MOD;
            inv[i] = mypow(fact[i], mod - 2);
        }
    }
    type comb(type p, type q)
    {
        if (!initiated)
        {
            initiated = true;
            init();
        }
        if (p < q)
            return 0;
        if (q < 0)
            return 0;
        type ret = fact[p];
        ret *= inv[q];
        ret %= mod;
        ret *= inv[p - q];
        ret %= mod;
        return ret;
    }
    type getFact(int index)
    {
        return fact[index];
    }
    type getInv(int index)
    {
        return inv[index];
    }
};

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

    int N;
    cin >> N;
    Combination C(1000000, MOD);
    ll res = 0, sum = 0;
    for (int i = 1; i <= N; i++)
    {
        ll tmp = C.getFact(i) * C.getFact(N - i - 1);
        tmp %= MOD;
        tmp *= C.comb(i - 1, N - i - 1);
        tmp %= MOD;
        if (tmp == 0)
            continue;
        res += i * ((tmp + MOD - sum) % MOD);
        sum = tmp;
        res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 15872