akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int a;cin>>a;cout<<a*a*a<<endl;
	RE;
}


Measured memory_bytes: 3084
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

solve [] [] ans = ans
solve (v:vs) (c:cs) ans
    | v > c = solve vs cs (ans + v -c)
    |otherwise = solve vs cs ans

main = do
    _ <- getLine
    v <- map read . words <$> getLine
    c <- map read . words <$> getLine
    let answer = solve v c 0
    print answer



Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int value[1010];

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

    sort(value,value+N);
    double ans = value[0];
    for(int i=1; i<N; i++){
        ans = (ans + value[i])/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[1010][1010];


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[1010];
    rep(i, H) cin >> S[i];
    dp[0][0] = 1;
    rep(i, H) {
        rep(j, W) {
            if (i + 1 < H && S[i + 1][j] != '#')
                dp[i + 1][j] += dp[i][j];
            if (j + 1 < W && S[i][j + 1] != '#')
                dp[i][j + 1] += dp[i][j];
            dp[i + 1][j] %= mod;
            dp[i][j + 1] %= mod;
        }
    }
    /*
    rep(i, H + 1) {
        rep(j, W + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp[H - 1][W - 1] <<  endl;


    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define bit(x) (1<<(x))
using namespace std;

int n,m,p;
int a[15][15];

using R=long double;
R dp[1<<14];

int main(void){
	cin >> n >> m >> p;
	rep(i,m){
		int u,v;
		cin >> u >> v;
		a[u-1][v-1]++;
		a[v-1][u-1]++;
	}

	rep(mask,1,1<<n){
		dp[mask]=1.0;		
		if(__builtin_popcount(mask)==1) continue;
		int limit=bit(31-__builtin_clz(mask));
		for(int add=(mask-1)&mask;add>=1;add=(add-1)&mask){
			int root=add^mask;
			if(add<root) break;
			double cur=dp[add];
			rep(i,n)rep(j,n) if(root&bit(i)) if(add&bit(j)) rep(loop,a[i][j]) cur*=1.0*p/100.0; 
			dp[mask]-=cur;	
		}
	}

	cout.precision(20);
	cout << fixed << dp[bit(n)-1] << endl;
	return 0;
}

Measured memory_bytes: 3528
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

sys.setrecursionlimit(10**8)

#メモ化再帰
def rec(x):
    global dp
    if dp[x]!=-1:
        return dp[x]
    num = 0
    for a in adj[x]:
        num = max(num, rec(a)+1)
    dp[x] = num
    return num

#入力受け取り
N, M = mi()
x = li2(M)

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

#メモ化再帰を実行
dp = [-1]*N
for i in range(N):
    rec(i)

print(max(dp))

Measured memory_bytes: 75668
main=do
 [n,t]<-map read.words<$>getLine
 s<-map(map read.words).lines<$>getContents
 let c=f 2000 t s
 putStr$if c<2000 then show c else"TLE"
f c t[]=c
f c t([a,z]:x)=f(if t<z then c else min a c)t x


Measured memory_bytes: 892
while True:
    try: w = float(input())
    except: break

    if w <= 48.00:
        print('light fly')
    elif 48.00 < w <= 51.00:
        print('fly')
    elif 51.00 < w <= 54.00:
        print('bantam')
    elif 54.00 < w <= 57.00:
        print('feather')
    elif 57.00 < w <= 60.00:
        print('light')
    elif 60.00 < w <= 64.00:
        print('light welter')
    elif 64.00 < w <= 69.00:
        print('welter')
    elif 69.00 < w <= 75.00:
        print('light middle')
    elif 75.00 < w <= 81.00:
        print('middle')
    elif 81.00 < w <= 91.00:
        print('light heavy')
    else:
        print('heavy')


Measured memory_bytes: 5568
#include<iostream>

int main(){

  int n,k;

  while(std::cin >> n){
    k=0;
    for(int a=0;a<10;a++){
      for(int b=0;b<10;b++){
        for(int c=0;c<10;c++){
          for(int d=0;d<10;d++){
            if(a+b+c+d==n){
              ++k;
            }
          }
        }
      }
    }
    std::cout << k << std::endl;
  }
}

Measured memory_bytes: 3000
H, W = map(int, input().split())

if H > 1 and W > 1:
    if H % 2 == 0:
        result = W * (H // 2)
    else:
        if W % 2 == 0:
            result = W * (H // 2) + (W // 2)
        else:
            result = W * (H // 2) + (W // 2) + 1
else:
    result = 1

print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using ll = long long;
const ll INF = (ll)1e18 + 9;

template<typename Head> void print(Head head) { std::cout << head << std::endl; }
template<typename Head, typename... Tail> void print(Head head, Tail... tail)
{
  std::cout << head << " ";
  print(tail...);
}

struct UnionFind {
public:
  std::vector<ll> par;
  std::vector<ll> rank;
  std::vector<ll> size;
  std::vector<ll> diff_weight;

  UnionFind(ll N) {
    par  = std::vector<ll> (N+1, 0LL);
    size = std::vector<ll> (N+1, 1LL);
    rank = std::vector<ll> (N+1, 0LL);
    diff_weight = std::vector<ll> (N+1, 0LL);
    for (ll i = 0; i <= N; i++) par[i] = i;
  }

  ll find(ll x) {
    if (par[x] == x) return x;
    ll root = find(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    par[x] = root;
    return root;
  }

  void unite(ll x, ll y, ll w) {
    w += get_weight(x);
    w -= get_weight(y);

    x = find(x);
    y = find(y);
    if (x == y) return;

    size[x] += size[y];
    size[y] = size[x];

    if (rank[x] < rank[y]) std::swap(x, y), w = -w;
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    diff_weight[y] = w;

    return;
  }

  bool is_same(ll x, ll y) {
    return find(x) == find(y);
  }

  ll get_size(ll x){
    return size[find(x)];
  }

  ll get_weight(ll x){
    find(x);
    return diff_weight[x];
  }

  ll get_diff(ll x, ll y){
    return get_weight(y) - get_weight(x);
  }

};

int main()
{
  ll N, K, L;
  std::cin >> N >> K >> L;

  UnionFind douro_union(N);
  UnionFind senro_union(N);
  for (ll i = 0; i < K; i++) {
    ll p, q;
    std::cin >> p >> q;
    p--; q--;
    douro_union.unite(p, q, 0);
  }
  for (ll i = 0; i < L; i++) {
    ll r, s;
    std::cin >> r >> s;
    r--; s--;
    senro_union.unite(s, r, 0);
  }

  // 親が両方同じなら道路でも線路でもつながる
  std::map< std::pair< ll, ll >, ll > dic;
  for (ll i = 0; i < N; i++) {
    std::pair< ll, ll > tmp = std::make_pair(douro_union.find(i), senro_union.find(i));
    dic[tmp]++;
  }

  ll ans[N];
  for (ll i = 0; i < N; i++) {
    std::pair< ll, ll > tmp = std::make_pair(douro_union.find(i), senro_union.find(i));
    ans[i] = dic[tmp];
  }

  for (ll i = 0; i < N; i++) {
    std::cout << ans[i];
    if (i != N - 1) std::cout << " ";
  }
  std::cout << std::endl;

  return 0;
}


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

int main() {
  string S;
  long long K;
  cin >> S >> K;
  int last1 = -1;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] - '0' != 1) break;
    last1 = i;
  }
  if (K <= ++last1) {
    cout << '1';
  }
  else {
    cout << S[last1];
  }
  return 0;
}

Measured memory_bytes: 3556
using System;

class Program
{
  private static void Main()
  {
    string[] str = Console.ReadLine().Split(' ');
    
    int sum = 0;
    
    for(int i = 0; i < 3; i++)
    {
      sum += int.Parse(str[i]);
    }
    
    if(sum >= 22)
     Console.WriteLine("bust");
    else
      Console.WriteLine("win");
  }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int ans = 0;


signed main(){
    IOS;
    int n;
	cin >> n;
	vector <pii> dd;
	for (int i = 0; i < n; i++) {
		int a,b;
		cin >> a >> b;
		dd.pb({a,b});
	}
	sort(dd.begin(),dd.end());
	vector <int> ff, bb;
	vector <pii> ansff, ab;
	int z = 0;
	int y = inf;
	for (int i = 0; i < n-1; i++) {
		int b = dd[i].se;
		int a = dd[i].fi;
		z = max(a,z);
		y = min(b,y);
		ff.pb(max(y-z+1,0ll));
		ansff.pb({z,y});
	}
	for (int i = 0; i < N; i++);
	int q = 0;
	int x = inf;
	for (int i = 0; i < n-1; i++) {
		int a = dd[n-i-1].fi;
		int b = dd[n-i-1].se;
		q = max(a,q);
		x = min(b,x);
		bb.pb(max(x-q+1,0ll));
		ab.pb({q,x});
	}
	reverse(ab.begin(),ab.end());
	reverse(bb.begin(),bb.end());
	for (int i = 0; i < n-1; i++) {
		ans = max(ans,ff[i]+bb[i]);
	}
	for (int i = 0; i < n; i++) {
		pii c = dd[i];
		pii w;
		pii bk;
		if (i == 0)
		{
			w = {0,inf};
		}
		w = ansff[i-1];
		if (i == n-1)
		{
			bk = {0,inf};
		}
		bk = ab[i];
		pii rest = {max(w.fi,bk.fi),min(w.se,bk.se)};
		int cans = max(c.se-c.fi+1,0ll) + max(rest.se - rest.fi + 1, 0ll);
		ans = max(ans,cans);
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 8944
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


ll dp[210000][40];
vec solve(int a,int b,int t){
    if(t==1){
        return {a,b};
    }
    if(a){
        vec res=solve(0,b^a,t);
        for(auto &e:res)e^=a;
        return res;
    }
    int k;
    rep(i,t){
        if((1<<i)&b){
            k=(1<<i);break;
        }
    }
    int bb = b%k + b/k/2*k;
    vec res=solve(0,1,t-1);
    for(auto &e:res)e=(e%k + (e/k)*2*k );
    vec res2=solve(1,bb,t-1);
    for(auto e:res2){
        res.pb(e%k + (e/k)*2*k + k);
    }
    return res;
}

main(){
    ios
    int n=in();
    int a=in(),b=in();
    if((__builtin_popcount(a^b)&1) == 0){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
        print(solve(a,b,n));
    }
        
}


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

typedef long long int ll;

/*int main(void) {
    string S, T;
    
    cin >> S;
    cin >> T;

    if (!S.compare(0, S.length()-1, T, 0, S.length()-1)) {
        cout << "Yes";
    } else
    {
        cout << "No";
    }
    return 0;
}*/

int main(void) {
    int A, B, C, K;
    
    cin >> A >> B >> C >> K;

    int result;
    if(A > K) {
        result = K;
    } else if(A+B > K) {
        result = A;
    } else {
        result = A - (K-A-B);
    }

    cout << result;
    return 0;
}


Measured memory_bytes: 3620
#include<map>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL D[100111];

VI G[100111];

int par[100111];
int sz[100111];
LL C[100111];

bool check() {
    VI ord;
    ord.reserve(N);
    ord.push_back(0);
    REP (i, N) {
	int v = ord[i];
	EACH (e, G[v]) if (*e != par[v]) {
	    ord.push_back(*e);
	    par[*e] = v;
	}
    }
    REP (i, N) {
	int v = ord[N-1-i];
	sz[v] = 1;
	EACH (e, G[v]) if (*e != par[v]) {
	    sz[v] += sz[*e];
	    C[v] += C[*e] + sz[*e];
	}
    }
    REP (i, N) {
	int v = ord[i];
	if (C[v] != D[v]) return false;
	EACH (e, G[v]) if (*e != par[v]) {
	    C[*e] += C[v] - (C[*e] + sz[*e]) + (N - sz[*e]);
	}
    }

    return true;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", D+i);

    map<LL, pair<int, int> > mp;
    REP (i, N) mp[D[i]] = make_pair(i, 1);
    vector<pair<int, int> > E;
    E.reserve(N);
    bool yes = true;
    while (mp.size() > 1u) {
	auto z = prev(mp.end());
	int i = z->second.first;
	int sz = z->second.second;
	LL cst = D[i] + 2 * sz - N;
	if (cst == D[i]) {
	    yes = false;
	    break;
	}
	auto it = mp.find(cst);
	if (it == mp.end()) {
	    yes = false;
	    break;
	}

	G[i].push_back(it->second.first);
	G[it->second.first].push_back(i);
	E.emplace_back(i, it->second.first);
	it->second.second += sz;
	mp.erase(z);
    }

    if (yes && check()) {
	EACH (e, E) printf("%d %d\n", e->first+1, e->second+1);
    } else {
	puts("-1");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 13176
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string a, b;
  	int na, nb;
  	string u;
	cin >> a >> b;
  	cin >> na >> nb;
  	cin >> u;
  	if(a == u){
		cout << na-1 << ' ' << nb;
    }else {
		cout << na << ' ' << nb-1;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> p[i] >> p[i + 1];
  }
  vector<vector<int>> dp(n + 1, vector<int>(n + 1));
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l - 1;
      if (i == j)
        dp[i][j] = 0;
      else {
        int tmp = 1e9;
        for (int k = i; k < j; k++) {
          tmp = min(tmp, dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j]);
        }
        dp[i][j] = tmp;
      }
    }
  }
  debug(dp);
  cout << dp[1][n] << endl;
  return 0;
}


Measured memory_bytes: 3188
using System;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion
        var n = ReadLib.ReadAsInt();

        var arrs = ReadLib.ReadNTimesAsIntArray(n).Reverse().ToArray();
        long score = 0;
        foreach (var arr in arrs) {
            var a = arr[0] + score;
            var b = arr[1];
            if (a % b == 0) {
                continue;
            }

            var minMultiple = (a / b + 1) * b;
            score += minMultiple - a;
        }

        Console.WriteLine(score);

        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion
    }
}


static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

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

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double r = Double.parseDouble(br.readLine());

		double circle_area = r * r * Math.PI;
		double circle_len = r * 2 * Math.PI;

		System.out.printf("%.6f %.6f", circle_area, circle_len);

	}
}

Measured memory_bytes: 24688
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

int main() {
    string s;
    cin >> s;
    string ans = "Yes";
    rep(i, s.size()){
        if(i % 2 == 0){
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
                ans = "No";
            }
        }else{
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
                ans = "No";
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print(len(ans))
print(*ans)


Measured memory_bytes: 28040
PROGRAM abc088
    IMPLICIT NONE
    INTEGER I,N
    READ *,N
    READ *,I
    IF(i>=500) then
        WRITE (*,"(G3.0)") "Yes"
    else
        if (i>=mod(N,500)) then
            WRITE (*,"(G3.0)") "Yes"
        else
            WRITE (*,"(G2.0)") "No"
        END IF
    END IF
    
END 

            

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

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int dp[100000];
vector<int> e[100000];
int dfs(int v){
    if(dp[v] != -1) return dp[v];

    int res = 0;
    for(int nv : e[v]) chmax(res, dfs(nv)+1);
    return dp[v] = res;
}

int main(void){
    int N,M; cin >> N >> M;
    REP(i,M){
        int x,y; cin >> x >> y;
        x--; y--;
        e[x].push_back(y);
    }
    REP(i,N) dp[i] = -1;
    int ans = 0;
    REP(i,N) chmax(ans, dfs(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=1;i<=(n);++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
const int INF=1e9+7;
int dp[5005][5005];
vector<pii> v;
inline bool cmp(pii a,pii b){
	return a.F+a.S<b.F+b.S;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n){
		int x,y;cin>>x>>y;v.pb(mp(x,y));
	}
	sort(v.begin(),v.end(),cmp);
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for (int i=0;i<n;++i){
		for (int j=0;j<=i;++j){
			if (dp[i][j]!=-1){
				int cur=dp[i][j];
				if (dp[i+1][j]==-1||dp[i+1][j]>cur) dp[i+1][j]=cur;
				if (v[i].F>=cur&&(dp[i+1][j+1]==-1||dp[i+1][j+1]>cur+v[i].S)) dp[i+1][j+1]=cur+v[i].S;
			}
		}
	}
	for (int j=n;j>=0;--j){
		if (dp[n][j]!=-1){
			cout<<j<<endl;return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 98176
#include<stdio.h>

int main(){
	
    int n;
    for(int i=1 ; ; i++){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        else{
            printf("Case %d: %d\n",i,n);
        }
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


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

int a[1000000];

int main() {
    string s;
    long long a, b, n, ans;
    stack <long long > st;
    while (cin >> s) {
        if (s[0] == '+') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a + b);
        }
        else if (s[0] == '-') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b - a);
        }
        else if (s[0] == '*') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a * b);
        }
        else {
            n = s[0] - '0';
            for (int j = 1; j < s.size(); j++) n = n * 10 + (s[j] - '0');
            st.push(n);
        }
    }
    cout << st.top() << endl;
    return 0;
}


        



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    auto p = s.find('7');
    ATYN(p != string::npos)

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
using namespace std;
typedef unsigned long long  ull;

ull d[100];

int main() {
    d[0] = 2;
    d[1] = 1;
    int n;
    scanf("%d", &n);
    for (int i = 2; i <=n; i++)
        d[i] = d[i-1] + d[i-2];
    
    printf("%llu", d[n]);
    
    
    return 0;
}




Measured memory_bytes: 128
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

string s;
int n, a, b;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		if (s[i] == 'R')
			a++;
		else
			b++;
	cout << ((a > b) ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    int[] arr1 = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr);
    for(int i=0;i<n;i++){
      if(arr1[i]==arr[n-1]){
        System.out.println(arr[n-2]);
      }
      else{
        System.out.println(arr[n-1]);
      }
   }
  }
}

Measured memory_bytes: 89868
n = int(input())
a = list(map(int,input().split()))

if min(a)>=0:
    print(n-1)
    for i in range(1,n):
        print(i,i+1)
elif max(a)<=0:
    print(n-1)
    for i in range(n-1):
        print(n-i,n-i-1)
elif abs(max(a))>abs(min(a)):
    print(2*n-1)
    b = a.index(max(a))
    for i in range(n):
        print(b+1,i+1)
    for i in range(1,n):
        print(i,i+1)
else:
    print(2*n-1)
    b = a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for i in range(n-1):
        print(n-i,n-i-1)


Measured memory_bytes: 38384
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    int ans = min(a, k);
    k -= ans;
    k -= min(b, k);
    ans -= k;
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

int main() {
  std::vector<int> A(3);
  for (int i = 0; i < 3; ++i) {
    std::cin >> A[i];
  }

  std::sort(A.begin(), A.end(), std::greater<int>());
  int num = A[0] * 10 + A[1] + A[2];
  std::cout << num << std::endl;

  return 0;
}


Measured memory_bytes: 256
fun main() {
    val firstLine = readLine()!!.split(" ").map { it.toInt() }
    val (n, x) = firstLine[0] to firstLine[1]
    val t = firstLine[2]
    var result = 0
    var time = 0L
    while (result < n) {
        result += x
        time += t
    }
    println(time)
}

Measured memory_bytes: 36440
#include<cstdio>

const int MAX_S = 26;
char s[MAX_S];

bool isv = true;

int main(){
	scanf("%s",s);
	
	for(int i=0;s[i] != '\0';i++){
		for(int j=i+1;s[j] != '\0';j++){
			if(s[i] == s[j]){
				isv = false;
				break;
			}
		}
	}
	
	if(isv) printf("yes\n");
	else printf("no\n");
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, V):
    ans = 0
    for k in range(min(K, N)+1):
        for i in range(k+1):
            l = V[:i]
            r = V[N-(k-i):]
            # print(l, r)
            lr = l + r
            lr.sort(reverse=True)

            for _ in range(K-k):
                if lr and lr[-1] < 0:
                    lr.pop()
                else:
                    break
            ans = max(ans, sum(lr))

    return ans


def main():
    N, K = read_int_n()
    V = read_int_n()
    print(slv(N, K, V))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int no_of_input;
  vector<int> vect1;
  cin >> no_of_input;
  vect1.resize(no_of_input,INT_MAX);
  int input;
  for(int i=0;i<no_of_input-1;i++){
    cin >> input;
    vect1[i] = min(vect1[i],input);
    vect1[i+1] = min(vect1[i+1],input);
  }
  int ans = 0;
  for(auto k:vect1){
    ans += k;
  }
  cout << ans;


}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    map<int,int> A;
    REP(i,n){
        int tmp;
        cin >>tmp;
        A[tmp]++;
    }
    int ans=0;
    int i=0;
    vector<int> B(0);
    for(auto a:A){
        B.push_back(a.second);
    }
    sort(ALL(B));
    REP(i,A.size()-k)
        ans+=B[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10744
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
	int n;
	cin>>n;
	ll a[100000], b[100000];
	ll s1=0, s2=0;
	vector<P> v;
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
		s1+=a[i]; s2+=b[i];
		v.push_back(P(a[i], i));
		v.push_back(P(b[i], i));
	}
	sort(v.begin(), v.end());
	ll ans=min(s1, s2);
	set<int> st;
	ll s3=0;
	for(int i=0; i<n; i++){
		st.insert(v[i].second);
		s3+=v[i].first;
	}
	if(st.size()<n){
		cout<<min(s3, ans)<<endl;
		return 0;
	}
	if(v[n-1].second!=v[n].second){
		cout<<min(s3-v[n-1].first+v[n].first, ans)<<endl;
		return 0;
	}
	ll s4=s3-v[n-2].first+v[n].first;
	ll s5=s3-v[n-1].first+v[n+1].first;
	cout<<min(ans, min(s4, s5))<<endl;
	return 0;
}

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

int main(){
  int n, m, maxi = 0;
  std::cin >> n >> m;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    std::cin >> x[i];
    maxi = max(maxi, x[i]);
  }
  vector<int> mod(m, 0);
  for (int i = 0; i < n; i++) {
    mod[x[i]%m]++;
  }
  int ans = 0, tmp;

  for (int i = 1; 2*i <= m; i++) {
    if(2*i == m){
      tmp = mod[m/2]/2;
      ans += tmp;
      mod[m/2] -= tmp*2;
    }else{
      tmp = min(mod[i], mod[m - i]);
      ans += tmp;
      mod[i] -= tmp;
      mod[m - i] -= tmp;
    }
  }
  tmp = mod[0]/2;
  ans += tmp;
  mod[0] -= tmp*2;
  vector<int> s(maxi, 0);
  for (int i = 0; i < n; i++) {
    s[x[i]]++;
    if(s[x[i]] >= 2 and mod[x[i]%m] >= 2){
      s[x[i]] -= 2;
      mod[x[i]%m] -= 2;
      ans++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int d;
	cin >> d;
	cout << "Christmas";
	while ( d++ < 25 )
		cout << " Eve";
	cout << "\n";

	return 0;
}


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

int main(){
    string S;
    int K;
    cin>>K;
    cin>>S;
    if(S.length()<=K){
        cout<<S<<endl;
        return 0;
    }
    S=S.substr(0,K)+"...";
    cout<<S<<endl;
    return 0;
    
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    ll q;
    ll now=0;
    cin>>q;
    vector<char> a,b;
    rep(_,q){
        ll t;
        cin>>t;
        if(t==1){
            now=1-now;
        }
        else{
            ll f;char c;
            cin>>f>>c;
            if(now==0){
                if(f==1) a.push_back(c);
                else b.push_back(c);
            }
            else{
                if(f==1) b.pb(c);
                else a.pb(c);
            }
        }
    }
    if(now==0){
        repr(i,(ll)a.size()){
            cout<<a[i];
        }
        cout<<s;
        rep(i,(ll)b.size()){
            cout<<b[i];
        }
    }
    else{
        repr(i,(ll)b.size()){
            cout<<b[i];
        }
        reverse(all(s));
        cout<<s;
        rep(i,(ll)a.size()){
            cout<<a[i];
        }
    }
}

 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 976
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	rep(i, days.size()) if(days[i] == s){
		cout << 7 - i << endl;
		return 0;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 101;
const ll K = 100001;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int a[N];
int dp[N][K];

/*
//num = # of children, c = # of candies
int solve(int num, int c) {
	if (num == 0) {
		if (c > 0) return 0;
		return 1;
	}
	if (c < 0) return 0;
	if (c == 0) return 1;
	if (mem[num][c] != -1) return mem[num][c];
	ll res = 0;
	fori(a[num-1]+1) {
		res += solve(num-1, c-i);
		res %= MOD;
	}
	return mem[num][c] = res%MOD;
}
*/
int pre[N][K];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	 
	cin >> n >> k;
	fori(n) cin >> a[i];
	
	fori(N) 
		forj(K) {
			dp[i][j] = -1;
			dp[0][j] = 0;
			dp[i][0] = 1;
		}
	dp[0][0] = 1;

	for(int j = 1; j <= K; ++j)
		pre[0][j] = (pre[0][j-1] + dp[0][j-1])%MOD;
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 0; j <= k; ++j) {
			if (dp[i][j] == -1) {
				dp[i][j] = pre[i-1][j+1]-pre[i-1][max(0, j-a[i-1])];
				dp[i][j] %= MOD;
				if (dp[i][j] < 0) dp[i][j] += MOD;
			}
				
		//cerr << "dp[" << i << "][" << j << "] is " << dp[i][j] << nl;
			pre[i][j+1] = (pre[i][j] + dp[i][j])%MOD;
		//		cerr << "pre[" << i << "][" << j+1 << "] is " << pre[i][j+1] << nl;
		}
	}

	cout << dp[n][k]%MOD << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


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

int main()
{
    int a[3],b[2];
    for(int i=0;i<3;i++) cin >> a[i];
    for(int i=0;i<2;i++) cin >> b[i];
    a[1]=min(a[0],a[1]);
    cout << min(a[1],a[2])+min(b[0],b[1])-50 << endl;
    return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		boolean [][] cards = new boolean[4][13];
		String mark = new String();
		int n = sc.nextInt();
		
		for(int i=0; i<n; i++){
			mark = sc.next();
			if(mark.equals("S")){
				cards[0][sc.nextInt()-1] = true; 
			} else if(mark.equals("H")){
				cards[1][sc.nextInt()-1] = true;
			} else if(mark.equals("C")){
				cards[2][sc.nextInt()-1] = true;
			} else if(mark.equals("D")) {
				cards[3][sc.nextInt()-1] = true;
			}
		}
		
		for(int i=0; i<cards.length; i++){
			for(int j=0; j<cards[0].length; j++){
				if(!cards[i][j]){
					if(i==0){
						System.out.println("S "+(j+1));
					}
					else if(i==1){
						System.out.println("H "+(j+1));
					}
					else if(i==2){
						System.out.println("C "+(j+1));
					}
					else if(i==3){
						System.out.println("D "+(j+1));
					}
				}
			}
		}
	}
}

Measured memory_bytes: 18060
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K):
    if K > ((N-1)*(N-2))//2:
        print(-1)
        return
    
    m = []
    for i in range(2, N+1):
        m.append((1, i))
    
    k = ((N-1)*(N-2))//2 - K
    for i in range(2, N+1):
        if k == 0:
            break
        for j in range(i+1, N+1):
            k -= 1
            m.append((i, j))
            if k == 0:
                break
        

    print(len(m))
    for i, j in m:
        print(i, j)


def main():
    N, K = read_int_n()
    (slv(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6352
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	int n, t;
	cin >> n >> t;
	vector<int> c(n), d(n);
	for (int i = 0; i < n; i++) cin >> c[i] >> d[i];
	int min_cost = 10000;
	for (int i = 0; i < n; i++) {
		if (d[i] <= t) {
			if (min_cost > c[i]) {
				min_cost = c[i];
			}
		}
	}
	if (min_cost == 10000) cout << "TLE" << endl;
	else cout << min_cost << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
ll  power(ll  x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x ;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) ;
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) ;
    } 
    return res; 
}
 
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, k;
  cin >> n >> k;
  dll mul = (dll)((dll)1/ (dll)(n)) ;
  dll add = 0;
  for(ll i = 1; i <= n; i++) {
    if(i >= k) add = add + 1.00;
    else {
      ll poww = 0;
      ll tt = i;
      while(tt < k) {
        tt*=2;
        poww++ ;
      }
      ll div = power(2, poww) ;
      add = add + (dll) (dll)((dll)(1.000)/ (dll)(div)) ;
    }
  }
  add = (dll)((dll)(mul) * (dll)(add)) ;
  cout << fixed << setprecision(9) << add;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    char symbol[] = "SW";

    for (int v1 = 0; v1 < 2; ++v1) {
        for (int v2 = 0; v2 < 2; ++v2) {
            string ans(n, '.');
            ans[0] = symbol[v1];
            ans[1] = symbol[v2];
            vector<int> values(n, 0);
            values[0] = v1;
            values[1] = v2;
            for (int i = 1; i < n - 1; ++i) {
                int c = s[i] == 'o' ? 0: 1;
                c ^= ans[i] == 'W';
                values[i + 1] = values[i - 1] ^ c;
                ans[i + 1] = symbol[values[i + 1]];
            }
            int c = s[n - 1] == 'o' ? 0: 1;
            c ^= ans[n - 1] == 'W';
            if (values[0] != values[n - 2] ^ c) {
                continue;
            }
            c = s[0] == 'o' ? 0: 1;
            c ^= ans[0] == 'W';
            if (values[1] != values[n - 1] ^ c) {
                continue;
            }
            cout << ans << '\n';
            return 0;
        }
    }
    cout << "-1\n";
}


Measured memory_bytes: 968