akhauriyash/Code-Regression huggingface dataset:
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
// find_by_order(), order_of_key() 

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

int f1(int a, int b, int x){
	return (a * x) / b;
}
int f2(int b, int x){
	return x/b;
}

void solve(){
	int a, b, n;
	cin >> a >> b >> n;
	int x = min(b - 1, n);
	cout << f1(a, b, x) - a * f2(b, x) << '\n';	
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc){
		//cout << "Case #"<< tc <<": ";
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 3656
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 2e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

ll n, q, a[N], ans[N];
vi g[N];

void test();
void dfs(int s, int p, ll cur);

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    cin >> n >> q;
    for (int i = 0, x, y; i < n - 1; ++i) {
        cin >> x >> y;
        g[x].eb(y);
        g[y].eb(x);
    }
    while (q--) {
        ll u, val;
        cin >> u >> val;
        a[u] += val;
    }
    dfs(1, -1, 0);
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

void dfs(int s, int p, ll cur) {
    ans[s] = a[s] + cur;
    for (auto &x: g[s]) {
        if (x != p) {
            dfs(x, s, cur + a[s]);
        }
    }
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

ll calc1(ll h, ll w){
    ll ans=INF;
    for(ll i=0; i<=h; i++){
        ll S1=i*w;
        ll W=w/2;
        ll S2=(h-i)*W;
        ll S3=(h-i)*(w-W);
        ll MAX=max({S1, S2, S3}), MIN=min({S1, S2, S3});
        ans=min(ans, MAX-MIN);
    }
    return ans;
}

ll calc2(ll h, ll w){
    ll ans=INF;
    for(ll i=0; i<=h; i++){
        ll S1=i*w;
        ll H=(h-i)/2;
        ll S2=H*w;
        ll S3=(h-i-H)*w;
        ll MAX=max({S1, S2, S3}), MIN=min({S1, S2, S3});
        ans=min(ans, MAX-MIN);
    }
    return ans;
}

int main(){
    ll h, w; cin>>h>>w;
    cout << min({calc1(h, w), calc1(w, h), calc2(h, w), calc2(w, h)}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<ll, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n, s, t;
vector<vector<pint>> gm (100005);
vector<vector<pint>> gs (100005);
ll c1[100005], c2[100005];

void dijkstras() {
    // bool seen[n] = {};
    rep (i, n) c1[i] = INF;
    c1[s] = (ll)0;
    // seen[s] = 1;
    priority_queue<pint, vector<pint>, greater<pint>> pq;
    pq.push ({0, s});

    while (!pq.empty()) {
        pint now = pq.top();
        pq.pop();
        int u = now.second;
        if (now.first > c1[u]) continue;
        // seen[u] = 1;
        rep (i, gm[u].size()) {
            int v = gm[u][i].second;
            if (c1[v] > c1[u] + gm[u][i].first) {
                c1[v] = c1[u] + gm[u][i].first;
                pq.push ({c1[v], v});
            }
        }
    }
    // rep (i, n) cout << c1[i] << "\n";
}

void dijkstrat() {
    // bool seen[n] = {};
    rep (i, n) c2[i] = INF;
    c2[t] = (ll)0;
    // seen[t] = 1;
    priority_queue<pint, vector<pint>, greater<pint>> pq;
    pq.push ({0, t});

    while (!pq.empty()) {
        pint now = pq.top();
        pq.pop();
        int u = now.second;
        if (now.first > c2[u]) continue;
        // seen[u] = 1;
        rep (i, gs[u].size()) {
            ll v = gs[u][i].second;
            if (c2[v] > c2[u] + gs[u][i].first) {
                c2[v] = c2[u] + gs[u][i].first;
                pq.push ({c2[v], v});
            }
        }
    }
    // rep (i, n) cout << c2[i] << "\n";
}

int main() {
    int m;
    cin >> n >> m >> s >> t;
    s--, t--;
    rep (i, m) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        gm[--u].push_back ({a, --v});
        gm[v].push_back ({a, u});
        gs[v].push_back ({b, u});
        gs[u].push_back ({b, v});
    }
    dijkstras();
    dijkstrat();
    ll ans[n], mi = c1[n - 1] + c2[n - 1], money = 1e15;
    for (int i = n - 1; i >= 0; i--) {
        mi = min (mi, c1[i] + c2[i]);
        ans[i] = money - mi;
    }
    rep (i, n) cout << ans[i] << "\n";
}


Measured memory_bytes: 19200
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int D[1000001];
    for(int i=1;i<1000001;i++) D[i] = i;
    for(int i=2;i<1001;i++){
        if(D[i]!=i) continue;
        int j = i + i;
        while(j <= 1000000){
            D[j] = i;
            j += i;
        }
    }
    map<int,bool> m;
    int N;cin>>N;
    vector<int> A(N);
    bool pair = true;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N&&pair;i++){
        int j = A[i];
        int f = 0;
        while(j!=1){
            if(f!=D[j]){
                if(m[D[j]]){
                    pair = false;
                    break;
                }
                else m[D[j]] = true;
                f = D[j];
            }
            j /= D[j];
        }
    }
    if(pair) cout << "pairwise coprime" << endl;
    else{
        int set = A[0];
        for(int i=1;i<N;i++) set = __gcd(set,A[i]);
        if(set==1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }
    return 0;
}

Measured memory_bytes: 11184
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<int> vi(2*N);
		for(int& t : vi) cin >> t;
		sort(vi.begin(), vi.end());
		int res = 0;
		for(int i=0;i<N;i++) res += vi[2*i];
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int n;
	int v[4][13];
	int i,j;
	char mark;
	int num;
	int marknum;
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			v[i][j]=0;
		}
	}
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf(" %c",&mark);
		scanf("%d",&num);
		
		switch(mark){
			case 'S'  : marknum=0; break;
			case 'H'  : marknum=1; break;
			case 'C'  : marknum=2; break;
			case 'D'  : marknum=3; break;
		}
			
		v[marknum][num-1]=1;
	}

	for(i=0;i<13;i++){
		if(v[0][i]==0)
		printf("S %d\n",i+1);
	}
	
	for(i=0;i<13;i++){
		if(v[1][i]==0)
		printf("H %d\n",i+1);
	}
	
	for(i=0;i<13;i++){
		if(v[2][i]==0)
		printf("C %d\n",i+1);
	}
	
	for(i=0;i<13;i++){
		if(v[3][i]==0)
		printf("D %d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 596
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",if a%2<1{a}else{a*2})
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int X,Y,Z;
multiset<string>S; 
int main(){
	scanf("%d%d%d",&X,&Y,&Z);
	while (X--) S.insert("a");
	while (Y--) S.insert("b");
	while (Z--) S.insert("c");
	while (S.size()>1){
		string t=*S.begin()+*(--S.end());
		S.erase(S.begin());S.erase(--S.end());
		S.insert(t);
	}
	cout<<*S.begin();
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n>>l;
        ll tt=0;
        for(i=1;i<=n;i++){
                tt+=l+i-1;
        }
        if(n==1){
                cout<<0<<endl;
                return;
        }
        ll ans=-100000;
        for(i=1;i<=n;i++){
                ll t1=tt-l+1-i;
                if(abs(t1-tt)<abs(tt-ans)){
                        ans=t1;
                }
        }
        cout<<ans<<endl;
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int [] hArray = new int [n];
		int num = 0;
		double tem = 0, dif = 0, mindif = Double.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			hArray[i] = sc.nextInt();
			tem = t - hArray[i] * 0.006;
			if(tem >= a) dif = tem - a;
			else dif = a - tem;
			if(mindif >= dif) {
				mindif = dif;
				num = i + 1;
			}
		}
		System.out.println(num);
		
	sc.close();
	}

}


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

int a, b, c ,d;
int main () {
	cin >> a >> b >> c >> d;
	if (a * b < c * d){
		cout << c * d << endl;
	}else if (a * b > c * d){
		cout << a * b << endl;
	}else 
		cout << a * b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  ll ans=llINF;
  ll num=0;
  ll summ=0;
  for(int i=1;i<=a;i++)num+=b+i-1;
  for(int i=1;i<=a;i++){
    ll sum=0;
    for(int j=1;j<=a;j++){
      if(i==j)continue;
      sum+=b+j-1;
    }
    //cout<<num<<" "<<sum<<endl;
    if(ans>abs(num-sum)){ans=abs(num-sum);summ=sum;}
   
  }
  cout<<summ<<endl;
  return 0;
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce
from collections import Counter


class Osa_k:
    def __init__(self, maximum):
        self.table = [-1] * (maximum+1)
        for i in range(2, maximum+1):
            if self.table[i] != -1:
                continue
            self.table[i] = i
            for k in range(i*i, maximum+1, i):
                if self.table[k] == -1:
                    self.table[k] = i

    def factorize(self, n):
        res = Counter()
        b = n
        while 1:
            if self.table[b] == -1:
                break
            res[self.table[b]] += 1
            b //= self.table[b]
        if b != 1:
            res[b] += 1
        return res


N = int(input())
*A, = map(int, input().split())
def f():
    cnt = Counter()
    ins = Osa_k(max(A))
    for i in A:
        res = ins.factorize(i)
        for j in res.keys():
            cnt[j] += 1
            if cnt[j] >= 2:
                return False
    return True

cond1 = f()
cond2 = (reduce(gcd, A)==1)

if cond1:
    print("pairwise coprime")
elif cond2:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 230976
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	ll l,r; cin >> l >>r;
	ll m=l/2019;
	ll n=r/2019;
	if(m<n){
		cout << 0 << endl;
		return 0;
	}
	else{
		m=l%2019;
		n=r%2019;
		int  ans=2019;
		for(int i=m;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				ans=min(ans,i*j%2019);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;

const int N = 50;
int n, a;
ll dp[N + 1][N + 1][(N + 1) * (N + 1)], x[N + 1];
void solve(){
    cin >> n >> a;
    for (int i = 1; i <= n; i++) cin >> x[i];  
    
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i - 1; j++){
            for (int sum = 0; sum <= N * N; sum++){
                dp[i][j][sum] += dp[i - 1][j][sum];
                if (sum + x[i] <= N * N)
                    dp[i][j + 1][sum + x[i]] += dp[i - 1][j][sum];
            }
        }
    }
    
    
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += dp[n][i][a * i];
    cout << ans;    
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
	step = 1;
    for (int i = 1; i <= step; i++){
         solve();
    }
}

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

int main() {
    string S;
    cin >> S;
    int can = false;
    if (S[2] == S[3] && S[4] == S[5]) can = true;
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    a = a<c ? c : a;
    b = b<d ? b : d;
    if(a<b)printf("%d\n", b-a);
    else printf("0\n");
    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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  rep(i, sz(s)) putchar('x');
  cout  << endl;
  return 0;
}


Measured memory_bytes: 3572
n, k = map(int, input().split())
p = list(map(int, input().split()))

total = [0]
for i in range(1, 200000):
    total.append(total[i-1]+i)

ans_index = 0
cur = sum(p[0:k])
max_p = cur
for i in range(n-k+1):
    cur = cur + p[i+k-1] - p[i-1]
    if cur > max_p:
        max_p = cur
        ans_index = i
ans = 0
for i in range(k):
    ans += total[p[ans_index+i]] / p[ans_index+i]
print(ans)


Measured memory_bytes: 24804
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	for(int i=0;i<365;i++) cout<<1<<endl;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
d,t,s = MI()
if t*s >= d:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
int n, k;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(12) << fixed;

    cin >> n >> k;

    int dp[k];
    int j = k - 1;
    while (j * 2 >= k) {
        dp[j] = 1;
        j--;
    }
    for (int i = j; i >= 0; --i) {
        dp[i] = dp[i * 2] + 1;
    }

    double res = 0;
    for (int i = 1; i <= n; ++i) {
        if (i < k) {
            res += 1.0L / pow(2, dp[i]) / n;
        } else {
            res += 1.0L / n;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
int n,m,k;
int f[maxn];
int qpow(int base,int p)
{
	int res = 1;
	while(p)
	{
		if(p&1)
			(res*=base)%=mod;
		(base*=base)%=mod;
		p>>=1;
	}
	return res;
}
signed main()
{
	ios::sync_with_stdio(0);
	int n,m,k;
	cin >> n >> m >> k;
	f[0] = 1;
	for(int i=1;i<=n;i++)
		(f[i] = f[i-1]*i)%=mod;
	int ans = 0;
	for(int i=0;i<=k;i++)
		(ans += m*qpow(m-1,n-1-i)%mod*f[n-1]%mod*qpow(f[i],mod-2)%mod*qpow(f[n-i-1],mod-2)%mod)%=mod;
	cout << ans % mod;
	return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>

using namespace std;

int Energy;

int main()
{
        while(cin >> Energy) {
                if (Energy == 0) {
                        break;
                }

                int temp_min;
                int min = -1;

                for (int i = 0; i * i * i <= Energy; ++i) {
                        for (int j = 0; j * j <= Energy - i * i * i; ++j) {
                                temp_min = i + j + Energy - i * i * i - j * j;
                                if(min < 0) min = temp_min;
                                else if(min > temp_min) min = temp_min;
                        }
                }

                cout << min << endl;
        }
        return 0;
}

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


int main()
{
	int n;
	string s;
	cin>>n>> s;
	int cnt = 0;
	for(int i=0;i<n;i++)if(s[i]=='R'){
		cnt++;
	}
	if(cnt > n-cnt){
		cout<<"Yes"<<endl;
	}else{

		cout<<"No"<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    string s;
    cin >> s;
  	string r = s;
  	REVERSE(r);
  	if (r == s)
      ECHO("Yes")
     else
      ECHO("No")
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

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

//解説AC

int main() {
    // 入力
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) cin >> P[i] >> Y[i], --P[i];
    
    // vals[v] := P[i] = v であるような i についての Y[i] の値を集めたもの
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) vals[P[i]].push_back(Y[i]);
    
    // 各 p の値に対して
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        
        // 今回は不要だが、通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    // 答え
    for (int i = 0; i < m; ++i) {
        int v = P[i];
      cout <<setw(6) << setfill('0') << v + 1;
        
        // 座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 7808
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
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--)
typedef long long ll;

template <class T> struct FenwickTree {

    vector<T> node;
    FenwickTree (int n) : node(n,0) {}

    void add(int idx, T val) {
        for (int i = idx; i < node.size(); i |= i + 1) {
            node[i] += val;
        }
    }

    T sum(int idx) {
        T ret = 0;
        for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
            ret += node[i];
        }
        return ret;
    }

};

ll N,K;
vector<ll> a;
map<ll,ll> trans;

int main() {

    cin >> N >> K;
    a.resize(N);
    REP(i,N) cin >> a[i];

    vector<ll> S;
    ll sum = 0;
    S.push_back(0);
    REP(i,N) {
        sum += a[i];
        ll val = sum - (ll)(i + 1) * K;
        S.push_back(val);
        trans[val] = 0;
    }
    trans[0] = 0;

    int cnt = 1;
    for (auto itr = trans.begin(); itr != trans.end(); itr++) {
        itr -> second = cnt++;
    }

    FenwickTree<ll> inst(200010);

    ll ans = 0;
    REP(i,S.size()) {
        ans += inst.sum(trans[S[i]] + 1);
        inst.add(trans[S[i]], 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17392
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, y, z) = listOfInt()
    if (x % (y + z) >= z) {
        println(x / (y + z))
    } else {
        println((x / (y + z)) - 1)
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
const int N = 3e5 + 10;

int main() {
    fast;
    string s, t; cin >> s >> t;
    int n = s.size(), ans = 0;
    for(int i = 0; i < n; i++)
        if(s[i] != t[i])ans++;
    cout << ans;
    return 0;
}



Measured memory_bytes: 3776
_N = gets.to_i
v = gets.chomp.split.map(&:to_i).sort
i = 0
res = 0
loop do
  break if v.count == 1
  res = (v[0] + v[1]).to_f / 2.0
  v.slice!(0, 2)
  v.unshift(res)
  i += 1
end
puts res


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

int main() {
	int N, M;
	cin >> N >> M;
	double T,S,n;
	T = 1900 * M + 100 * (N - M);
	n = 1;
	for (int i = 0; i < M; i++) {
		n = n*2;
	}
	S = n * T;
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<char> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int result = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == s[i + 1]){
            continue;
        }
        else{
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 384
using System;
using static System.Console;
using static Atcoder_Template_NetCore3.MyUtil;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atcoder_Template_NetCore3
{
    

    class Program
    {
        static void Main()
        {
            ValueTuple<int,int> ReadInput()
            {
                var input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                return (input[0], input[1]);
            }

            var (day, count) = ReadInput();
            var times = ReadintArray();

            var dif = day - times.Sum();
            if (dif < 0) dif = -1;
            WriteLine(dif);
        }
    }

    static class MyUtil
    {
        /// <summary>
        /// 指定の桁のビットを取得します。
        /// </summary>
        /// <param name="num"></param>
        /// <param name="count">取得する桁。</param>
        /// <returns></returns>
        public static int GetBit(this int num, int count)
        {
            int mask = (int)Math.Pow(2, count - 1);
            return (num & mask) == 0 ? 0 : 1;
        }

        /// <summary>
        /// <c>int</c>を2進数ビット配列に変換します。
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public static int[] ToBitArray(this int num)
        {
            const int size = sizeof(int) * 8;
            var array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = num.GetBit(size - i);
            }
            return array;
        }

        public static long[] ReadlongArray()
        {
            return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        }

        public static int[] ReadintArray()
        {
            return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }

        /// <summary>
        /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ts"></param>
        public static void WriteToConsole<T>(this IEnumerable<T> ts)
        {
            StringBuilder stringBuilder = new StringBuilder();
            foreach (T t in ts)
            {
                stringBuilder.Append(t.ToString());
                stringBuilder.Append(" ");
            }
            stringBuilder.Remove(stringBuilder.Length - 1, 1);
            Console.WriteLine(stringBuilder.ToString());
        }
    }
}


Measured memory_bytes: 29244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	s += 'T';
	int x, y; cin >> x >> y;
	vector<int>dx, dy;
	int is = 0, cnt = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'F') {
			cnt++;
		}
		else if (is % 2 == 0) {
			dx.push_back(cnt);
			cnt = 0;
			++is;
		}
		else {
			dy.push_back(cnt);
			cnt = 0;
			++is;
		}
	}
	map<int, int>dp;
	dp[0] = 0;
	bool t = (s[0] == 'F' ? true : false);
	rep(i, 0, dx.size()) {
		auto mp = dp;
		for (auto j : mp) {
			if (j.second == i ) {
				dp[j.first + dx[i]] = i + 1;
				if (t && i == 0)continue;
				dp[j.first - dx[i]] = i + 1;
			}
		}
	}
	bool ans = false;
	if (dp[x] == dx.size()) {
		ans = true;
	}
	dp.clear();
	dp[0] = 0;
	rep(i, 0, dy.size()) {
		auto mp = dp;
		for (auto j : mp) {
			if (j.second == i) {
				dp[j.first + dy[i]] = i + 1;
				dp[j.first - dy[i]] = i + 1;
			}
		}
	}
	if (ans && dp[y] == dy.size()) {
		cout << "Yes" << "\n";
	}
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 1024
import math
n, d, a = [int(i) for i in input().split()]

xh = []
for i in range(n):
    xh.append([int(i) for i in input().split()])

# 座標でソート
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [math.ceil(xh[i][1]/a) for i in range(n)]

# i番目のモンスターに、i-k番目で使った爆弾が届いた場合の最小のi-k
# bisectより尺取り法のほうが速いと思ったんだけど…
bomb_syakutori = [0 for i in range(n)]
l = 0
r = 0
flag = 0
while r <= n - 1:
    if x[r] <= x[l] + 2*d:
        bomb_syakutori[r] = l
        r += 1
    else:
        l += 1


bomb_ruisekiwa = [0 for i in range(n)]
# 左から貪欲に爆弾を使用
for i in range(n):
    bomb = 0
    if i == 0:
        bomb = h[i]
        bomb_ruisekiwa[i] = bomb
    else:
        if bomb_syakutori[i] == i:
            damage = 0
        elif bomb_syakutori[i]-1 < 0:
            damage = bomb_ruisekiwa[i-1]
        else:
            damage = bomb_ruisekiwa[i-1] - bomb_ruisekiwa[bomb_syakutori[i]-1]
        if h[i] - damage > 0:
            bomb = h[i] - damage
        bomb_ruisekiwa[i] = bomb + bomb_ruisekiwa[i-1]

print(bomb_ruisekiwa[-1])

Measured memory_bytes: 67020
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
    
    string s;cin>>s;
    rep(i,0,sz(s))if(s[i]=='?')s[i]='D';
    cout<<s;
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x,y;
};
vector<P> v[33110];

int a,b,c,i,k,d,n,m,e,dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};
int l[111111][1111];
int o[5333222];
//int dx[10]={1,0,1,-1,-1,0},dy[10]={0,1,1,1,-1,-1};

long long x,y,z[555555];
P u[1222];
int j[512111];
priority_queue<int,vector<int>,greater<int> > q,q1;
stack<int> s,s1;


//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
string r,r1;
//char r[10010];

bool as(P a,P b)
{

    return a.y>b.y;
}



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        p[o[t]]++;
    }
    for(int t=1;t<=a;t++)
        if(p[o[t]]!=o[t]) p[o[t]]--,k++;
    printf("%d",k);
}


Measured memory_bytes: 9088
//temp
#include<stdio.h>
#include<stdlib.h>


int main() {
	int i, j, k, f = 0, n, s, t;
	int mp = 0, a, b, c, d, e, x, y0, z;
	scanf("%d %d %d", &a, &b, &c);
	d = b / a;
	if (d > c) {
		d = c;
	}


	printf("%d", d);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 5e2+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
ll dp[maxn][maxn];
ll sum[maxn][maxn];
ll mi[maxn];
int n,c;
int a[maxn],b[maxn];
void getSum(){
    for(int i = 1;i <= n;i++){
        for(int j = a[i];j <= b[i];j++)
            mi[j] = 1,sum[i][0]++;
        for(int j = 1;j <= c;j++){
            for(int k = a[i];k <= b[i];k++)
                mi[k] = mi[k]*k % modn,sum[i][j] = (sum[i][j] + mi[k]) % modn;
        }
    }
}
int main(){
    scanf("%d%d",&n,&c);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    for(int i = 1;i <= n;i++)
        scanf("%d",&b[i]);
    getSum();
    dp[0][0] = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= c;j++){
            for(int k = 0;k <= j;k++){
                dp[i][j] = (dp[i][j] + dp[i-1][k]*sum[i][j-k]) % modn;
            }
//            printf("dp[%d][%d]: %lld\n",i,j,dp[i][j]);
        }
    }
    printf("%lld\n",dp[n][c]);
}


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <functional>
using namespace std;

typedef long long ll;

int n, m;
bool f[200001], l[200001];

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		f[i] = l[i] = false;
	}
	int a, b;
	bool flag = false;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		if (a > b) {
			swap(a, b);
		}
		if (a == 1) {
			if (f[b]) {
				flag = true;
				break;
			}
			else {
				l[b] = true;
			}
		}
		if (b == n) {
			if (l[a]) {
				flag = true;
			}
			else {
				f[a] = true;
			}

		}
	}
	if (flag) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    string S,T,U;
    cin>>S>>T;
    int A,B;
    cin>>A>>B>>U;
    if(S==U){
        A--;
    }else{
        B--;
    }
    cout<<A<<" "<<B<<endl;

    return 0;
}

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

int n;
char s;

int main() {
	cin >> n;
	string ans = "Three";
	for(int i = 0; i < n; i++) {	
		cin >> s;
		if(s == 'Y')
			ans = "Four";
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  string k = "keyence";
  bool ans = false;
  rep(i, 8) {
    string k1 = k.substr(0, i);
    string k2 = k.substr(i, 7 - i);
    string s1 = s.substr(0, i);
    string s2 = s.substr(n - 7 + i, 7 - i);
    if(s1 == k1 && s2 == k2) ans = true;
  }
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3632
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);

    int dp[K+1];
    fill(dp, dp+K+1, 0);
    for (int i = 0; i < A[0]; i++) {
        dp[i] = -1;
    }

    for (int i = A[0]; i <= K; i++) {
        bool lose = true;
        for (int j = 0; j < N; j++) {
            if (i - A[j] >= 0 && dp[i-A[j]] == -1) {
                dp[i] = 1;
                lose = false;
                break;
            }
        }
        if (lose) dp[i] = -1;
    }

    cout << (dp[K] == 1 ? "First" : "Second") << endl;

    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  map<int, int> mp;
  vector<P> v(n);
  vector<int> rem(n);
  queue<int> que;
  REP(i, n) {
    int x; cin >> x;
    x--;
    rem[i] = n - i - 1;
    mp[x] = i+1;
    v[i] = {x, i};
  }
  sort(ALL(v));
  REP(i, n) {
    REP(j, v[i].second) {
      que.push(v[i].second);
    }
  }

  vector<int> cnt(n);

  vi ans;
  bool ok = true;
  REP(i, n*n) {
    if(mp[i]) {
      if(cnt[mp[i]-1] < mp[i] - 1) {
        ok = false;
        break;
      }
      ans.push_back(mp[i]-1);
      REP(j, rem[mp[i]-1]) {
        que.push(mp[i]-1);
      }
    } else {
      if(que.empty()) {
        ok = false;
        break;
      } else {
        ans.push_back(que.front());
        cnt[que.front()]++;
        que.pop();
      }
    }
  }

  if(ok) {
    cout << "Yes" << endl;
    REP(i, n*n) {
      cout << ans[i]+1 << " ";
    }
    cout << endl;
  } else {
    cout << "No" << endl;
  }


}
























Measured memory_bytes: 13940
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int i, count = 0;
		Scanner sc = new Scanner(System.in);
		while(true){
			i = sc.nextInt();
			count++;
			if(i == 0)
				break;
			else
				System.out.println("Case " + count + ": " + i);
		}
	}

}

Measured memory_bytes: 32956
def calculate_digit_num(num):
    z = num / 10
    if z == 0:
        return 1
    else:
        return 1 + calculate_digit_num(z)

while True:
    try:
        num_list = [int(num) for num in raw_input().split(' ')]
        print calculate_digit_num(sum(num_list))
    except:
        break


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

vector<int> x = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
vector<int> y = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
vector<int> z = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

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

  vector<long long> num(5, 0);
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    switch (s[0])
    {
      case 'M':
        num[0]++;
        break;
      case 'A':
        num[1]++;
        break;
      case 'R':
        num[2]++;
        break;
      case 'C':
        num[3]++;
        break;
      case 'H':
        num[4]++;
        break;
      default:
        break;
    }
  }

  long long ans = 0;
  for (int i = 0; i < 10; i++)
  {
    ans += num[x[i]] * num[y[i]] * num[z[i]];
  }

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

Measured memory_bytes: 256