akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
bool desc(pii a,pii b)
{
    if(a.F==b.F)
    {
        return a.S>b.S;
    }
    else
    {
        return a.F>b.F;
    }
}
void oblivious()
{
    int n,w1;
    cin>>n>>w1;
    int w[n+1],v[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    int dp[n+1][w1+1];
    mem0(dp);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w1;j++)
        {
            if(j>=w[i])
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w1]<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}
//Md Zuhair

Measured memory_bytes: 82400
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

class WeightedUnionFind():

    def __init__(self,N):
        self.N = N
        self.parents = [-1] * self.N
        self.diff_weight = [0] * self.N
    
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            p = self.find(self.parents[x])
            self.diff_weight[x] += self.diff_weight[self.parents[x]]
            self.parents[x] = p
            return p
    
    def weight(self,x):#xの親からの重みを返す
        self.find(x)
        return self.diff_weight[x]
    
    def diff(self,x,y):#同じグループにいたらxとyの重みの差を返す
        if self.find(x) == self.find(y):
            return self.weight(y) - self.weight(x)
        else:
            return 10000000000

    def unite(self,x,y,w):#wieght(y) = weight(x) + dとなるように合体
        w += self.weight(x)
        w -= self.weight(y)

        x = self.find(x)
        y = self.find(y)
        if x == y:
            if self.diff(x,y) == w:
                return True
            else:
                return False

        if self.parents[x] > self.parents[y]:
            x,y = y,x
            w *= -1
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        self.diff_weight[y] = w
        return True
    
    def same(self,x,y):
        return self.find(x) == self.find(y)
        
    def size(self,x):
        return -self.parents[self.find(x)]

def solve(N,M):
    uf = WeightedUnionFind(N)
    for _ in range(M):
        q = input().split()
        if q[0] == '!':
            a,b,w = map(int,q[1:])
            a -= 1
            b -= 1
            uf.unite(a,b,w)
        else:
            a,b = map(int,q[1:])
            a -= 1
            b -= 1
            ans = uf.diff(a,b)
            if ans == 10000000000:
                print('UNKNOWN')
            else:
                print(ans)

def main():
    while True:
        N,M = map(int,input().split())
        if N == 0 and M == 0:
            break
        solve(N,M)
if __name__ == '__main__':
    main()


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

int main(void){
    ll N, M;
    cin >> N >> M;
    ll B[N], R[N];
    REP(i,N){B[i] = 1; R[i] = 0;}
    R[0] = 1;
    ll x, y;
    REP(i,M){
        cin >> x >> y;
        B[x-1] -= 1;
        B[y-1] += 1;
        if(R[x-1]==1){
            R[y-1] = 1;
            if(B[x-1]==0){
                R[x-1] = 0;
            }
        }
    }
    ll res = 0;
    REP(i,N){
        if(B[i]>0 && R[i]==1){
            res += 1;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n, k;
    cin >> n >> k;
    ll m = n / k;
    ll d = n - m * k;
    cout << min(d, k -d) << '\n';

    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) else 1000000000

    path_null = dfs(cur+1, a, b, c)
    path_a = dfs(cur+1, a+L[cur], b, c) + 10
    path_b = dfs(cur+1, a, b+L[cur], c) + 10
    path_c = dfs(cur+1, a, b, c+L[cur]) + 10

    return min(path_null, path_a, path_b, path_c)

print(dfs(0,0,0,0))


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

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))
#define sz(x) (ll)x.size()

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

const ll inf = (ll)1e18 + 5;
const ll mod = 1e9+7;

#define lsb(i) ((i)&-(i))

ll nax = 2e5 + 5;
VLL arr(nax);

void add(ll i, ll k) {
    while (i < nax) {
        arr[i] += k;
        i += lsb(i);
    }
}

ll sum(ll i) {
    ll total = 0;
    while (i > 0) {
        total += arr[i];
        i -= lsb(i);
    }
    return total;
}

void init(VVLL & E, ll s, VLL & timein, VLL & timeout, ll & time) {
    time++;
    timein[s] = time;

    for (ll to : E[s]) init(E, to, timein, timeout, time);

    time++;
    timeout[s] = time;
}

void solve() {
	ll n;
    cin >> n;
    VVLL E(n);

    REP(i,0,n) {
        ll k;
        cin >> k;
        E[i].resize(k);
        REP(j,0,k) {
            cin >> E[i][j];
        }
    }

    // do a preorder traversal
    VLL timein(n), timeout(n);
    ll time = 1;
    init(E, 0, timein, timeout, time);

    ll q;
    in(q);
    REP(i,0,q) {
        ll t;
        cin >> t;
        if (t == 0) {
            ll a, b;
            cin >> a >> b;
            add(timein[a], b);
            add(timeout[a], -b);
        } else {
            ll a;
            cin >> a;
            cout << sum(timein[a]) << endl;
        }
    }


}

signed main() {
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}


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

using namespace std;

int dp[200001];
long long int memo[2];
long long int mypow(long long int x,long long int n,long long int mod)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((x%mod)*(res%mod)%mod)%mod;
			res%=mod;
		}
		x = ((x%mod)*(x%mod)%mod);
		x%=mod;
		n/=2;
	}
	return res;
}

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

	int n,cnt = 0;
	string s;

	cin >> n;
	cin >> s;

	if(n==1)
	{
		if(s[0]=='0')
		{
			cout << 1 << '\n';
			return 0;
		}
		else
		{
			cout << 0 << '\n';
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			cnt++;
		}
	}

	dp[0] = 0;
	for(int i=1;i<=200000;i++)
	{
		int bitcnt = 0;
		int val = i;
		while(val > 0)
		{
			if(val%2==1)
			{
				bitcnt++;
			}
			val/=2;
		}
		dp[i] = dp[i%bitcnt] + 1;
	}

	if(cnt>1)
	{
		long long int temp = 0;
		for(int i=n-1;i>=0;i--)
		{
			int mod = cnt - 1;
			if(s[i]=='1')
			{
				temp = ((temp%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
				temp%=mod;
			}
		}
		memo[0] = temp;
	}
	long long int temp = 0;
	for(int i=n-1;i>=0;i--)
	{
		int mod = cnt + 1;
		if(s[i]=='1')
		{
			temp = ((temp%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
			temp%=mod;
		}
	}	
	memo[1] = temp;

	for(int i=0;i<n;i++) {
		if(s[i]=='0') {
			long long int value = memo[1];
			int mod = cnt+1;
			value = ((value%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
			value%=mod;
			cout << dp[value] + 1 << '\n';
		}
		else {
			if(cnt==1) {
				cout << 0 << '\n';
			}
			else {
				long long int value = memo[0];
				int mod = cnt-1;
				value = ((value%mod) - (mypow(2,n-1-i,mod)%mod)%mod);
				value%=mod;
				if(value < 0)
				{
					value+=mod;
				}
				cout << dp[value] + 1 << '\n';
			}
		}
	}
	return 0;
}	


Measured memory_bytes: 4536
#include <stdio.h>

//
// void swap(int *a, int *b){
//   int x;
//   x = *a;
//   *a = *b;
//   *b = x;
// }

int partition(int A[], int p, int r){
  int sw;
  int x = A[r];
  int i = p - 1, j;
  for(j = p; j < r; j++){
      if(A[j] <= x){
          i++;
          sw = A[i]; A[i] = A[j]; A[j] = sw;
      }
  }
    sw = A[i+1]; A[i+1] = A[r]; A[r] = sw;
  return i+1;
}

int main(){
  int i, n, A[100001];
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  int p = partition(A, 0, n - 1);
  printf("%d", A[0]);
  for(i = 1; i < n; i++) {
    if (p == i) printf(" [%d]", A[i]);
    else printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
def male_or_female(seat,m_max,m_min,seat_0):
    global seat_check, n_max, n_min
    print(seat)
    s=input()

    if seat%2==0:
        if s==seat_0:
            n_min=seat
            seat=int(0.5*(m_max+seat))
            seat_check=seat
            
        else :
            n_max=seat
            seat=int(0.5*(m_min+seat))
            seat_check=seat
            
    else:
        if s!=seat_0:
            n_min=seat
            seat=int(0.5*(m_max+seat))
            seat_check=seat
        else :
            n_max=seat
            seat=int(0.5*(m_min+seat))
            seat_check=seat


n_max=int(input())
n_min=0

print(0)
seat_zero=input()
seat_check=int(0.5*n_max)

for i in range(19):
    male_or_female(seat_check, n_max, n_min, seat_zero)


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    //cin>>t;
    t=1;
    while(t--){
        ll n; cin>>n;
        ll h[n];
        rep(i,0,n-1){cin>>h[i];}
        ll dp[n]={0};
        dp[0]=0; dp[1] = abs(h[0]-h[1]) + dp[0];
        rep(i,2,n-1){
            dp[i] = min(abs(h[i-1]-h[i]) + dp[i-1] , abs(h[i-2]-h[i]) + dp[i-2]);
        }
        cout<<dp[n-1];
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int a,b,c;
  cin >> a >> b >> c;
  REP(i,200){
    int t=i*60+c;
    if(t%(a+b)<=a){
      cout << t << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int x,y;

int main () {
while(1){
	cin>>x>>y;
if(x==0 && y==0){
break;

}
if(x>y){
cout<<y<<" "<<x<<endl;

}
if(x<y){
cout<<x<<" "<<y<<endl;

}
if(x==y){
cout<<x<<" "<<y<<endl;
}

}




return 0;

}

Measured memory_bytes: 1160
def is_palindrome(s):
    n = len(s)
    for i in range(n // 2):
        if s[i] != s[-(i + 1)]:
            return False
    return True

s = input()
n = len(s)
if is_palindrome(s) and is_palindrome(s[:n // 2]) and is_palindrome(s[-(n // 2):]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int tmp = sc.nextInt();
    for(int i = 1; i < n; i++){
      tmp = f(tmp, sc.nextInt());
    }
    System.out.println(tmp);
  }
  
  public static int f(int a, int b){
    int big = Math.max(a,b);
    int small = Math.min(a,b);
    while(big % small != 0){
      big = big % small;
      int tmp = small;
      small = big;
      big = tmp;
    }
    return small;
  }
}


Measured memory_bytes: 48212
n,s = map(int, input().split())
for x in range(0,n+1):
    for y in range(0, n-x+1):
        z = n-x-y
        if 10000*x + 5000*y + 1000*z == s:
            print('{} {} {}'.format(x, y, z))
            break
    else:
        continue
    break
else:
    print('-1 -1 -1')

Measured memory_bytes: 3060
using System;
using System.Reflection;
using System.Linq.Expressions;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(' ');
            int[] Ns = new int[Keys.Length];
            for (int i = 0; i < Keys.Length; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }

        static void Main() {
            var Key = getKeys(' ');
            int[,] Map = new int[Key[0], Key[1]];
            bool[,] isBomb = new bool[Key[0], Key[1]];
            string S;
            for (int i = 0; i < Key[0]; i++) {
                S = Console.ReadLine();
                for (int j = 0; j < Key[1]; j++) {
                    if (S[j] == '#') {
                        isBomb[i, j] = true;
                        Increment(Map, i, j);
                    }
                }
            }
            for (int i = 0; i < Key[0]; i++) {
                S = "";
                for (int j = 0; j < Key[1]; j++) {
                    S += (isBomb[i, j]) ? "#" : Map[i, j].ToString();
                }
                Console.WriteLine(S);
            }
        }
    
        static void Increment(int[,] MAP, int h, int w) {
            if (w > 0) {
                MAP[h, w - 1]++;
            }
            if (w < MAP.GetLength(1) - 1) {
                MAP[h, w + 1]++;
            }
            if (h > 0) {
                if (w > 0) {
                    MAP[h - 1, w - 1]++;
                }
                MAP[h - 1, w]++;
                if (w < MAP.GetLength(1) - 1) {
                    MAP[h - 1, w + 1]++;
                }
            }
            if (h < MAP.GetLength(0) - 1) {
                if (w > 0) {
                    MAP[h + 1, w - 1]++;
                }
                MAP[h + 1, w]++;
                if (w < MAP.GetLength(1) - 1) {
                    MAP[h + 1, w + 1]++;
                }
            }
        }
    }
}


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

int main() {
  int k,a,b;
  
  bool flag = false;
  
  cin >> k >> a >> b;
  
  for(int i = a ; i <= b ; i++){
    if(i%k == 0)
      flag = true;
  }
  
  if(flag)
    cout << "OK";
  
  else
    cout << "NG";
}

Measured memory_bytes: 3600
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string[] i2 = Console.ReadLine().Split(' ');
            int n = int.Parse(i2[0]);
            int m = int.Parse(i2[1]);

            int i = k;
            while (i <= m)
            {
                if(i >= n){
                    Console.WriteLine("OK");
                    return;
                }
                i += k;
            }
            Console.WriteLine("NG");
            return;
        }
    }
}


Measured memory_bytes: 27540
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = read() 
    val reversedN = n.reversed()
    println(if(n == reversedN) "Yes" else "No")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

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

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 31856
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t a, b;
    std::cin >> a >> b;

    auto d = b - a;

    auto s = (d-1)*d/2;

    std::cout << s - a << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
X = input()

def goes_to_zero(n):
  cnt = 0
  while(n > 0):
    n %= bin(n).count('1')
    cnt += 1
  return cnt
  
c1 = X.count('1')
xint = int(X,2)
xtp = xint % (c1 + 1)
if (c1 - 1) == 0:  
  xtm = 0
else:
  xtm = xint % (c1 - 1)
  
for i in range(n)  :
  if X[i] == '0':
    print(goes_to_zero( (xtp + pow(2,n-1-i,(c1+1))) % (c1+1) ) + 1)
  else:
    if (c1-1) == 0:
      print(0)
    else:
      print(goes_to_zero( (xtm - pow(2,n-1-i,(c1-1)) ) % (c1-1) ) +1)

Measured memory_bytes: 83476
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, d;
  cin >> n >> d;
  ll res = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    ll dist = x * x + y * y;
    res += dist <= d*d;
  }
  cout << res << endl;

  ret;
}


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

#define FASTIO ios::sync_with_stdio(NULL); cin.tie(NULL);
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define compination(x) ((x*(x-1))/2)
#define all(x) x.begin() , x.end()
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vch vector  <char>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define vss vector  <string>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define PI  3.141592654
#define OO (ll)1e18
using namespace std;
void ONLINE__JUDGE();

pii swapii( pii pr ){ return { pr.S , pr.F }; }
int dx[] = { 0  , 0  , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 , 0  , 0  , -1 , +1 , +1 , -1 };

const int mod = 7901;
const int MAX = 1e3 + 9;

ll x, y , z;
int main()
{

    cin >> x >> y >> z; ll cnt = 0 , scaler = x;
    while ( scaler <= z )
    {
        cnt += y; scaler += x;
    }
    cout << cnt;
    return 0;
}




Measured memory_bytes: 256
x, y = gets.split.map(&:to_i)[0..1]
pvalues = gets.split.map(&:to_i).sort.reverse[0...x]
qvalues = gets.split.map(&:to_i).sort.reverse[0...y]
rvalues = gets.split.map(&:to_i).sort.reverse

plast = x - 1
qlast = y - 1
rvalues.each do |r|
  p = (plast >= 0) ? pvalues[plast] : nil
  q = (qlast >= 0) ? qvalues[qlast] : nil
  if p.nil? && q.nil?
    break
  elsif p.nil?
    which = :q
  elsif q.nil?
    which = :p
  else
    which = (p < q) ? :p : :q
  end

  if which == :p
    if p < r
      pvalues[plast] = r
      plast -= 1
    else
      break
    end
  else # which == :q
    if q < r
      qvalues[qlast] = r
      qlast -= 1
    else
      break
    end
  end
end

total = pvalues.inject(&:+) + qvalues.inject(&:+)
puts total


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

int main(){
    int n;
    cin >> n;
    
    long L[100];
    L[0] = 2;
    L[1] = 1;

    for(int i = 2; i < n+1; i++){
        L[i] = L[i-1] + L[i-2];
    }

    cout << L[n] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        StringBuilder sb = new StringBuilder();
        int p = 5;
        while (N > 0) {
            boolean prime = true;
            if (p % 5 == 1) {
                for (int i = 2; i * i <= p; i++) {
                    if (p % i == 0) {
                        prime = false;
                        break;
                    }
                }
                if (prime) {
                    sb.append(p);
                    sb.append(' ');
                    N--;
                }
            }
            p++;
        }
        System.out.println(sb.toString().trim());
    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e5;
const int size=1e5;
const int inf=1e9;
int N,M;
vector<int> g[size];
int dist[size]={};
bool visit[size]={};
void dfs(int v){
	for(int u:g[v]){
		if(!visit[u]){ dfs(u); visit[u]^=1; }
        dist[v]=max(dist[v],dist[u]+1);
	}return;
}
int main(){
	cin>>N>>M;
	int x,y;
	rep(i,0,M){
		cin>>x>>y; x--; y--;
		g[x].push_back(y);
	}
	rep(i,0,N) dfs(i);
	cout<<*max_element(dist,dist+N)<<endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  map<string,int> mp;
  int q;
  cin >> q;
  REP(i,q){
    int t;
    string key;
    cin >> t >> key;
    if(t==0){
      int x;
      cin >> x;
      mp[key] = x;
    }else if(t==1){
      cout << mp[key] << endl;
      if(mp[key]==0) mp.erase(key);
    }else if(t==2){
      mp.erase(key);
    }else{
      auto itr = mp.lower_bound(key);
      string r;
      cin >> r;
      auto itr2 = mp.upper_bound(r);
      for(auto i = itr;i!=itr2;++i){
        cout << i->first << " " << i->second << endl;
      }
    }
  }
}




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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    const int MX = 1e6;
    bitset<MX+1> ng;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(!ng[A[i]]){
            if(i==N-1 || A[i] != A[i+1]) ans++;
            for(int j=A[i]; j<=MX; j+=A[i]) ng[j] = 1;
        }
    }

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


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int A[K];
  priority_queue<int> dis;
  
  for(int i = 0; i < K; i++){
    cin >> A[i];
  }
  
  for(int i = 0; i < K-1; i++){
    dis.push(A[i+1] - A[i]);
  }
  
  dis.push(N-A[K-1]+A[0]);
   int max;
  max = dis.top();
      
  cout << N - max << endl;
}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int sum = 0;
            a %= b;
            while (c-- > 0 && a > 0) {
                sum += a * 10 / b;
                a = a * 10 % b;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26040
# abc112_b
init = input().split(" ")

# 初期情報
N = int(init[0])
T = int(init[1])

c = []
t = []


try:
	while True:
		temp = input().split(" ")
		c.append(int(temp[0]))
		t.append(int(temp[1]))
		
except:
	pass

mincost = max(c)
mincost_id = 0

if min(t) > T:
	print("TLE")
else:
	for j in range(N):
		if t[j] <= T:
			
			if c[j] < mincost:
				mincost = c[j]
				mincost_id = j
	print(mincost)

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn calc(depth: usize, g: i64, used: usize, cnts: &Vec<i64>, cs: &Vec<i64>) -> usize {
    let n = cnts.len();
    if depth == n {
        let mut ans = 0;
        let mut sum = 0;
        for i in 0..n {
            if ((used >> i) & 1) == 1 {
                let p = (i + 1) as i64 * 100;
                sum += p * cnts[i] + cs[i];
                ans += cnts[i];
            }
        }
        for i in (0..n).rev() {
            if ((used >> i) & 1) == 1 {
                continue;
            }
            let p = (i + 1) as i64 * 100;
            let c = std::cmp::max(0, std::cmp::min((g - sum + p - 1) / p, cnts[i]));
            sum += p * c;
            ans += c;
        }
        return ans as usize;
    }
    let ans = std::cmp::min(
        calc(depth + 1, g, used, cnts, cs),
        calc(depth + 1, g, used | (1 << depth), cnts, cs),
    );
    return ans;
}

fn main() {
    let n = read::<usize>();
    let g = read::<i64>();
    let mut cnts = vec![0; n];
    let mut cs = vec![0; n];
    for i in 0..n {
        cnts[i] = read::<i64>();
        cs[i] = read::<i64>();
    }
    let ans = calc(0, g, 0, &cnts, &cs);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int x[5];

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

  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 3588
use std::cmp;
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだStringを空白で分解する
    // println!("buf: {:?}", buf);
    buf = buf.replace("\n", " ");
    buf = buf.replace("\r", " ");
    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let max_w: i32 = iter.next().unwrap().parse().unwrap();

    let mut w: Vec<i32> = vec![];
    let mut v: Vec<i32> = vec![];
    for i in 0..n {
        v.push(iter.next().unwrap().parse().unwrap());
        w.push(iter.next().unwrap().parse().unwrap());
    }
    // println!("{:?}", w);
    // println!("{:?}", v);
    println!("{}", solve(&w, &v, max_w));
}

fn solve(w: &Vec<i32>, v: &Vec<i32>, max_w: i32) -> i32 {
    let mut dp: Vec<Vec<i32>> = vec![];
    for i in 0..w.len() + 1 {
        dp.push(vec![0; (max_w + 1) as usize]);
    }
    for i in 0..w.len() {
        for j in 0..max_w + 1 {
            if j < w[i] {
                dp[(i + 1) as usize][j as usize] = dp[i as usize][j as usize];
            } else {
                dp[(i + 1) as usize][j as usize] = cmp::max(
                    dp[i as usize][j as usize],
                    dp[(i + 1) as usize][(j - w[i]) as usize] + v[i],
                );
            }
        }
    }
    // println!("{:?}", dp);
    dp[w.len()][max_w as usize]
}


Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};
#define Graph(type) vector< vector< Edge<type> > >

int main() {
    int V, E, start;
    cin >> V >> E >> start;

    Graph(int) G(V);
    for(int i=0; i<E; i++) {
        int s, t, d; cin >> s >> t >> d;
        G[s].push_back(Edge<int>(t, d));
    }

    vector<bool> inq(V, false);
    queue<int> que;
    vector<int> rec(V, 1 << 30);
    que.push(start);
    inq[start] = true;
    rec[start] = 0;

    while(!que.empty()) {
        int point = que.front(); que.pop();
        inq[point] = false;
        for(size_t i=0; i<G[point].size(); i++) {
            Edge<int> next = G[point][i];
            int to = next.to, cost = next.cost;
            if(rec[to] > rec[point] + cost) {
                rec[to] = rec[point] + cost;
                if(!inq[to]) {
                    inq[to] = true;
                    que.push(to);
                }
            }
        }
    }
    for(int i=0; i<V; i++) {
        if(rec[i] != 1<<30) cout << rec[i] << endl;
        else cout << "INF" << endl;
    }
    return 0;
}

Measured memory_bytes: 14748
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    int n;
    cin >> n;
    vector<int> A(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }
    A.push_back(0);

    vector<long long> acc(n + 2, 0);

    for (int i = 1; i <= n + 1; ++i) {
        acc[i] = acc[i - 1] + abs(A[i] - A[i - 1]);
    }

    for (int i = 1; i <= n; ++i) {
        long long ans = acc[i - 1] + acc[n + 1] - acc[i + 1] + abs(A[i + 1] - A[i - 1]);
        cout << ans << '\n';
    }



    return 0;
}

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

using ll = long long;
#define print(x) cout << #x << '=' << x << endl

int main()
{
    long long a,b,c,d;
	long long ans1,ans2,ans3,ans4;
    cin >> a >> b >> c >> d;

    ans1 = a*c;
    ans2 = a*d;
    ans3 = b*c;
    ans4 = b*d;

    cout << max(ans1 , max(ans2 , max(ans3,ans4))) << endl;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())

if n <=9:
  res = n
elif n <= 99:
  res = 9
elif n <= 999:
  res = 9 + (n - 100 + 1)
elif n <= 9999:
  res = 909
elif n <= 99999:
  res = 909 + (n - 10000 + 1)
else:
  res = 90909

print(res)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(b - a) <= d && abs(c - b) <= d) || (abs(c - a) <= d)) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N+1];
		long[] B = new long[N];
		for(int i = 0; i < N+1; i++) A[i]=sc.nextLong();
		for(int i = 0; i < N; i++) B[i]=sc.nextLong();
		sc.close();
      
		long ans = 0;
      	for(int i = 0; i < N; i++){
			long d1 = Math.min(A[i], B[i]);
			ans += d1;
			A[i] -= d1;
			B[i] -= d1;
			long d2 = Math.min(A[i+1], B[i]);
			ans += d2;
			A[i+1] -= d2;
			B[i] -= d2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 89804
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n, m;
    cin >> n >> m;
    ll k;
    VE cnt(m+1);
    REP(i, n){
        cin >> k;
        REP(j, k){
            ll num;
            cin >> num;
            cnt[num]++;
        }
    }
    ll ans = 0;
    REP(i, m+1)if(cnt[i] == n)ans++;
    print(ans);
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> v;
deque<int> d;
int main()
{
	lint n;
	cin>>n;
	while(n>0){
		if(n%2>0){
			v.pb(1);
			n--;n/=2;
		}
		else{
			v.pb(0);n--;
		}
	}
	reverse(All(v));
	int m=v.size();
	rep(i,m){
		if(v[i]==0) d.push_front(i+1);
		else d.pb(i+1);
	}
	cout<<m*2<<endl;
	rep(i,m) cout<<d[i]<<' ';
	rep(i,m){
		if(i<m-1) cout<<i+1<<' ';
		else cout<<i+1<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    vector<int> A(5);
    for (int i=0; i<5; i++) {
        cin >> A[i];
    }
    
    int min=10,index_last=0;
    for (int i=0; i<5; i++) {
        if (A[i]%10!=0) {
            if (A[i]%10<min) {
                min=A[i]%10;
                index_last=i;
            }
        }
    }
    
    int ans=0;
    for (int i=0; i<5; i++) {
        if (i!=index_last&&A[i]%10!=0) {
            A[i]=((A[i]+10)/10) * 10;
        }
        //cout << A[i] << endl;
        ans+=A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def int_raw():
    return int(raw_input())
 
def ss_raw():
    return raw_input().split()
 
def ints_raw():
    return map(int,ss_raw())
 
INF = 1<<29
 
def make1d_arr(n,val=INF):
    return [val for i in xrange(n)]

def make2d_arr(w,h,val =INF):
    return [[val for i in xrange(w)]for i in xrange(h)]
 
def floyd_warshall(costs):
    N = len(costs)
    for k in xrange(N):
        for i in xrange(N):
            for j in xrange(N):
                costs[i][j]  = min(costs[i][j],costs[i][k]+costs[k][j])
    return costs
 
N,M = ints_raw()
costs = make2d_arr(N+1,N+1,INF)
E = []
for i in xrange(M):
    a,b,c = ints_raw()
    E.append((a,b,c))
    costs[a][b]=c
    costs[b][a]=c
 
costs = floyd_warshall(costs)
 
ans  = 0
for e in E:
    if costs[e[0]][e[1]] < e[2]:
        ans+=1
print ans

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e5;
int n, m, h[N];
bool z[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> h[i];
  FOR(_, 0, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(h[a]<=h[b]) z[a]=true;
    if(h[b]<=h[a]) z[b]=true;
  }
  int ans=0;
  FOR(i, 0, n) ans += !z[i];
  cout << ans << endl;
}

Measured memory_bytes: 4072
def solve():
  ans = 0
  R, G, B, N = map(int, input().split())
  for r in range(N//R+1):
    for g in range(N//G+1):
      bb = N-r*R-g*G
      if bb>=0 and bb%B==0:
        ans += 1
  return ans
print(solve())

Measured memory_bytes: 73472