akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int n,A,B,C,ans;
int L[10],visited[10];
int dfs(int k, int a, int b, int c){
    if(k == n){
        if(a == 0 || b == 0 || c == 0) return MAX;
        return abs(a - A)+abs(b-B)+abs(c-C);
    }
    int ans = MAX;
    ans = min(ans, dfs(k+1, a+L[k], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b+L[k], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c+L[k]) + (c>0 ? 10:0));
    ans = min(ans, dfs(k+1,a,b,c));
    return ans;
}
int main(){
    cin >> n >> A >> B >> C;
    for(int i = 0; i < n; i++){
        cin >> L[i];
    }
    cout << dfs(0,0,0,0) << endl;
    return 0;
}




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

int main() {
    string s; cin >> s;
    int N = s.size();
    vector<int> nxt(N);
    for(int i=0; i<N; i++) {
        if(s[i] == 'L') nxt[i] = i-1;
        if(s[i] == 'R') nxt[i] = i+1;
    }

    for(int t=0; t<60; t++) {
        vector<int> to(N);
        for(int i=0; i<N; i++) {
            to[i] = nxt[ nxt[i] ];
        }
        swap(nxt, to);
    }

    vector<int> ans(N);
    for(int i=0; i<N; i++) ans[ nxt[i] ]++;
    
    for(int i=0; i<N; i++) {
        cout << ans[i] << " \n"[i+1 == N];
    }
}


Measured memory_bytes: 1392
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

bool comp(const pair<int,int> a,const pair<int,int> b){
  if(a.first > b.first) return true;
  else if(a.first < b.first) return false;
  else{
    if(a.second>b.second) return false;
    else return true;
  }
};


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans[n]={};
  vector<pair<int,int>> x;
  rep(i,n){
    x.push_back({a[i],i});
  }
  sort(x.begin(),x.end(),comp);
  int prevheight,nownum;
  prevheight=x[0].first;
  nownum=x[0].second;
  rep(i,x.size() ){
    if(prevheight!=x[i].first){
      ans[nownum]+=(prevheight-x[i].first)*i;
      prevheight=x[i].first;
      if(x[i].second < nownum) nownum=x[i].second;
    }
  }
  ans[nownum]+=prevheight*n;
  rep(i,n){
    cout<<ans[i]<<endl;
  }
      
  
  
  
    
  
    

  return 0;
}


Measured memory_bytes: 6896
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    use std::collections::VecDeque;
    let mut vecdeque: VecDeque<usize> = VecDeque::new();
    let n: usize = read();
    for i in 0..n {
        if i % 2 == 0 {
            vecdeque.push_back(read());
        } else {
            vecdeque.push_front(read());
        }
    }
    let vec: Vec<usize> = if n % 2 == 1 {
        vecdeque.into_iter().rev().collect()
    } else {
        vecdeque.into_iter().collect()
    };
    println!(
        "{}",
        vec.into_iter()
            .map(|i| i.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 1e9+7;
const int maxn = 3000+1;
ll dp[maxn][maxn];
string str;
int N;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> str;
	dp[0][1] = 1;
	forn(i,2,N+1){
		dp[0][i] += dp[0][i-1];
		dp[0][i] %= mod;
	}
	forn(i,1,N){
		for(int j = 1; j <= i+1; j++){
			if(str[i-1] == '<'){
				dp[i][j] = dp[i-1][j-1];
				//forn(k,1,j){
					//dp[i][j] += dp[i-1][k];
					//dp[i][j] %= mod;
				//}
			}else{
				dp[i][j] = ((dp[i-1][i+1]%mod)-(dp[i-1][j-1]%mod))%mod;
				
				//forn(k,j,i+2){
					//dp[i][j] += dp[i-1][k];
					//dp[i][j] %= mod;
				//}
			}
			//cout << i << ' ' << j << ' ' << dp[i][j] << ":D\n";
		}
		for(int j = 1; j <= N; j++){
			dp[i][j] = ((dp[i][j])+(dp[i][j-1]))%mod;
			dp[i][j] %= mod;
		}
	}
	ll res = dp[N-1][N];
	if(res < 0)res += mod;
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define forn(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;

void solve(int _t){
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	forn(i, 0, n){
		cin >> a[i]>>b[i]>>c[i];
	}
	ll dp[n][3];
	forn(i,0,n)forn(j, 0, n) dp[i][j]=0;
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	forn(i, 1, n){
		dp[i][0] = max({dp[i-1][1],dp[i-1][2]})+a[i];
		dp[i][1] = max({dp[i-1][0],dp[i-1][2]})+b[i];
		dp[i][2] = max({dp[i-1][0],dp[i-1][1]})+c[i];
	}

	cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]})<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	forn(test, 1, t+1){
		solve(test);
	}
	return 0;
}

Measured memory_bytes: 7128
N = int(input())
if N <=104:
    print(0)
    
elif N <= 106:
    print(1)

else:
    if N%2 != 0:
        num = list(range(105, N+1))
        kotae = list(range(1, N+2, 2))
    else:
        num = list(range(105, N))
        kotae = list(range(1, N, 2))
        
    num = num[::2]
    ans = [0] * len(num)
    
    for index, i in enumerate(num):
        for t in kotae:
            if i%t ==0:
                ans[index] += 1
    print(len([1 for x in ans if x>=8]))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int W=0,H=0;
    int ans[100000]={0};
    char board[21][21];
    int quex[100000]={0};
    int quey[100000]={0};
    int count=0;
    int queC=0;
    while(1){
        scanf("%d %d",&W,&H);
        if(W==0&&H==0){
            break;
        }
        for(int i=0;i<H;i++){
            scanf("%s",board[i]);
            for(int j=0;j<W;j++){
                if(board[i][j]=='@'){
                    quex[0]=j;
                    quey[0]=i;
                }
            }
        }
        queC=0;
        while(1){
          
            int sw=0;
            if(quex[queC]!=0){
                if(board[quey[queC]][quex[queC]-1]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1]-1;
                    quey[queC]=quey[queC-1];
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quex[queC]!=W-1){
                if(board[quey[queC]][quex[queC]+1]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1]+1;
                    quey[queC]=quey[queC-1];
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quey[queC]!=0){
                if(board[quey[queC]-1][quex[queC]]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1];
                    quey[queC]=quey[queC-1]-1;
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quey[queC]!=H-1){
                if(board[quey[queC]+1][quex[queC]]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1];
                    quey[queC]=quey[queC-1]+1;
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(sw==0){
                queC-=1;
            }
           
            if(queC<0){
                ans[count]+=1;
                break;
            }
        }
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2868
N=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
    c=input()
    if(c=='AC'):
        AC+=1
    elif(c=='WA'):
        WA+=1
    elif(c=='TLE'):
        TLE+=1
    else:
        RE+=1

print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << x << '\n';

#define INF (1 << 29)

#define FAST cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//________

main(){
  FAST;
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = min(b,d) - max(a,c);
  chmax(ans, 0);
  outl(ans);
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

flag = False

for i in range(N+1):
  for j in range(N+1-i):
    k = N - i - j
    if 10000 * i + 5000 * j + 1000 * k == Y:
      flag = True
      x = i
      y = j
      z = k

if flag:
  print(x, y, z)
else:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
//#include<cstdlib>
//#include<cmath>
#include<cstring>
//#include<algorithm>
//#include<climits>
using namespace std;

char s[105];
bool c=false,f=false;

int main() {
    scanf("%s", s); 
    for(int i=0; i<strlen(s); i++) {
        if(s[i]=='C') c=true;
        if(s[i]=='F'&&c==true) f=true;
    }
    if(f==true) printf("Yes\n");
    else printf("No\n"); 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 1000000
bool isP[MAX];
int n,sumP[MAX];
int main(){
  for(int i=2;i<MAX;i++)isP[i]=true;
  for(int i=2;i*i<=MAX;i++)
    if(isP[i])for(int j=i*i;j<MAX;j+=i)isP[j]=false;
  for(int i=2;i<MAX;i++)sumP[i]=isP[i]+sumP[i-1];
  while(1){
    cin>>n;
    if(n==0)break;
    cout<<sumP[n+n]-sumP[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 6044
n=int(input())
s=[input()]
f=True
for i in range(1,n):
    d=input()
    if d in s or s[i-1][len(s[i-1])-1]!=d[0]: 
        f= False
    s.append (d)


if f :
    print ("Yes")

else:
    print ("No")
    


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))

count,m = 0,0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    m = max(m,count)
    count = 0
m = max(m,count)
print(m)

Measured memory_bytes: 14252
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

#define X first
#define Y second

int n;
vector<pii> p;

int memo[1001][1001];

int solve(int l, int r){
	if(l == r) return 0;
	if(memo[l][r]) return memo[l][r];
	int res = INF;
	for(int i=l;i<r;i++){
		int sum = 0;
		sum += solve(l, i) + solve(i+1, r);
		sum += p[i].Y - p[r].Y + p[i+1].X - p[l].X;
		res = min(res, sum);
	}
	return memo[l][r] = res;
}

main(){
	ios::sync_with_stdio(false);
	while(cin >> n){
		p.resize(n);
		REP(i, n) cin >> p[i].X >> p[i].Y;
		cout << solve(0, n-1) << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;
int lists[1000][1000];

struct cake {
    ll cost;
    int i;
    int j;
    bool operator<(const cake& key) const {
        return this->cost < key.cost;
    }
};
cake make_cake(ll c, int ii, int jj) {
    cake a;
    a.cost = c; a.i = ii, a.j = jj;
    return a;
}

int main() {
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    REP(i, x) scanf("%lld", &a[i]);
    REP(i, y) scanf("%lld", &b[i]);
    REP(i, z) scanf("%lld", &c[i]);
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c), greater<ll>());

    priority_queue<cake> q;
    REP(i, x) REP(j, y) {
        lists[i][j] = 1;
        q.push(make_cake(a[i]+b[j]+c[0], i, j));
    }
    REP(p, k) {
        cake tmp = q.top();
        q.pop();
        int i = tmp.i;
        int j = tmp.j;
        printf("%lld\n", tmp.cost);
        
        if (lists[i][j] < z) {
            q.push(make_cake(a[i]+b[j]+c[lists[i][j]], i, j));
            lists[i][j]++;
        }
    }
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n,d,x;cin>>n>>d>>x;
	vector<int> a(n);
	int i,j;
	rep(i,n)cin>>a[i];
	int ans=0;
	rep(i,n)
	{
		rep(j,d)
		{
			if(j%a[i]==0)ans++;
		}
	}
	cout<<ans+x<<endl;
}


Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            long A = long.Parse(S[0]);
            long V = long.Parse(S[1]);

            S = Console.ReadLine().Split(' ');
            long B = long.Parse(S[0]);
            long W = long.Parse(S[1]);

            S = Console.ReadLine().Split(' ');
            long T = long.Parse(S[0]);


            //long dist = Math.Abs(A - B);
            //long catch_speed = V - W;

            //if (T * catch_speed >= dist) Console.WriteLine("YES");
            //else Console.WriteLine("NO");
            //return;


            for (int i = 0; i < T; i++)
            {
                if (A < B)
                {
                    B += W;
                    if (A + V >= B)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    else
                    {
                        A += V;
                    }
                }
                else if (A > B)
                {
                    B -= W;
                    if (A - V <= B)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    else
                    {
                        A -= V;
                    }
                }
            }

            Console.WriteLine("NO");
            return;

        }
    }
}


Measured memory_bytes: 27492
//10^5 = 100000
//10^9 = 1000000000
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr ll INF = 1ll << 60;

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

    std::vector<ll> x(N);

    ll num_plus = 0;
    bool has_zero = false;
    for (ll i = 0; i < N; ++i) {
        cin >> x[i];
        if (x[i] > 0) { ++num_plus; }
        if (x[i] == 0) { has_zero = true; }
    }
    
    const ll num_minus = N - num_plus - (has_zero ? 1 : 0);
    const ll border = N - num_plus;

    ll ans = INF;

    ll left = 0;
    while (1) {
        const ll right = K - left - (has_zero ? 1 : 0);

        if (left > K) { break; }
        if (left > num_plus || right > num_minus) {
            ++left;
            continue;
        }

        ll cost;
        if (left == 0) {
            cost = -x[border - right - (has_zero ? 1 : 0)];
        } else if (right == 0) {
            cost = x[border + left - 1];
        } else {
            cost = x[border + left - 1] - x[border - right - (has_zero ? 1 : 0)];
            cost += std::min(x[border + left - 1], -x[border - right - (has_zero ? 1 : 0)]);
        }

        ans = std::min(ans, cost);

        ++left;
    }

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


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

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

  int N;
  cin >> N;

  vector<int> A(N + 1);
  F0R(i, N + 1) cin >> A[i];

  vector<int> B(N);
  F0R(i, N) { cin >> B.at(i); }

  ll ans = 0;

  F0R(i, N) {
    ll V = min(A[i], B[i]);
    A[i] -= V;
    B[i] -= V;
    ans += V;
    V = min(A[i + 1], B[i]);
    A[i + 1] -= V;
    B[i] -= V;
    ans += V;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
	ll n; cin >> n;
	ll k = floor(1 + log2(1 + (n - 1) * (ld(25) / ld(26))) / log2(26));
	string ans = "";
	n -= 1 + ((pow(26, k - 1) - 1) * 26) / 25.0;
	while(k)
	{
		ans += char(97 + n % 26);
		n /= 26;
		k--;
	}	
	reverse(all(ans));
	cout << ans;
	return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int MOD = 1e9 + 7;
const int N = 22;
int a[N][N];
int dp[N][1<<N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);

	for (int i = 0; i < n; i++)
		if (a[0][i]) dp[0][1<<i] = 1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < (1<<n); j++) {
			if (!dp[i][j]) continue;
			for (int k = 0; k < n; k++) {
				int x = 1 << k;
				if (a[i+1][k] && (j & x) == 0)
					dp[i+1][j|x] = (dp[i+1][j|x] + dp[i][j]) % MOD;
			}
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1<<n); j++) printf("%d ", dp[i][j]);
		puts("");
	}
	*/

	int ans = 0;
	for (int i = 0; i < (1<<n); i++)
		ans = (ans + dp[n-1][i]) % MOD;
	printf("%d\n", ans);
}


Measured memory_bytes: 176384
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <unordered_map>

using namespace std;
#define ll long long int
#define endl "\n"

int main() {
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> v(m);
    unordered_map<ll,list<ll>> mp;
    for(ll i=0;i<m;i++)
    {
        cin>>v[i].first>>v[i].second;
        mp[v[i].first].push_back(v[i].second);
        mp[v[i].second].push_back(v[i].first);
    }
    bool visited[n]={false};
    ll cycles=0;
    for(ll i=0;i<n;i++)
    {
        if(visited[i]==false)
        {
            visited[i]=true;
            queue<ll> q;
            q.push(i+1);
            while(!q.empty())
            {
                ll node=q.front();
                q.pop();
                for(auto itr:mp[node])
                {
                    if(visited[itr-1]==false)
                    {
                        q.push(itr);
                    }
                    visited[itr-1]=true;
                }
            }
            cycles++;
        }
        //cout<<cycles<<endl;
    }
    cout<<cycles-1<<endl;
}


Measured memory_bytes: 16876
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector <ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

typedef ll Flow;
typedef ll Weight;
const ll INF = 1e15;

struct Edge {
	int src, dest, rev;
	Flow cap;
	Weight cost;
	bool operator < (const Edge &rhs) const
	{
		return cost > rhs.cost;
	}
	Edge(int s, int d) : src(s), dest(d) { ; }
	Edge(int s, int d, int c) : src(s), dest(d), cost(c) { ; }
	Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int src, int dest, Flow cap)
{
	g[src].push_back(Edge{ src, dest, (int)g[dest].size(), cap, 0 });
	g[dest].push_back(Edge{ dest, src, (int)g[src].size() - 1, 0, 0 });
}

void add_edge(Graph &g, int from, int to, Flow cap, Weight cost)
{
	g[from].push_back(Edge(from, to, (int)g[to].size(), cap, cost));
	g[to].push_back(Edge(to, from, (int)g[from].size() - 1, 0, -cost));
}

Flow dfs(Graph &g, vector<bool> &used, int v, int t, Flow f)
{
	if (v == t) return f;
	used[v] = true;
	for (Edge& e : g[v])
	{
		if (!used[e.dest] && e.cap > 0)
		{
			Flow d = dfs(g, used, e.dest, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				g[e.dest][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

Flow ford_fulkerson(Graph &g, int s, int t)
{
	Flow flow = 0;
	for (;;)
	{
		vector<bool> used(g.size(), false);
		Flow f = dfs(g, used, s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	Graph g(n + 2);
	int src = n, snk = n + 1;
	ll geta = 1e10;
	REP(i, n)
	{
		add_edge(g, src, i, -a[i] + geta);
		add_edge(g, i, snk, geta);
	}
	REP(i, n)
	{
		REP(j, n)
		{
			int k = (i + 1) * (j + 2);
			if (k <= n) add_edge(g, i, k - 1, INF);
			else break;
		}
	}
	ll f = ford_fulkerson(g, src, snk);
	cout << -(f - geta * n) << endl;
	return 0;
}

Measured memory_bytes: 384
import Foundation

func main() {
    guard let line = readLine() else { return }
    let inputs = line.components(separatedBy: " ").compactMap() { Int($0) }
    let x = inputs[0]
    let k = inputs[1]
    let d = inputs[2]
    var tmp = 0
    
    if abs(x) / d < k {
        for i in 1...k {
            if abs(x) < i * d {
                tmp = i
                break
            }
        }
        if (k - tmp) % 2 == 0 {
            print(tmp * d - abs(x))
        } else {
            print(d - ((tmp * d) - abs(x)))
       }
    } else  {
        print(abs(x) - k * d)
    }
}


main()

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

int main(int argc, char const *argv[]) {
  string S;
  cin >> S;

  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else if (S == "Rainy") {
    cout << "Sunny" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
g1,s1,b1 = map(int,input().split())
g2,s2,b2 = map(int,input().split())
def trade(n,g1,s1,b1,g2,s2,b2):
  tradelist = []
  for x,y in (g1,g2),(s1,s2),(b1,b2):
    if x < y:
      tradelist.append((x,y))
  if not tradelist:
    return n
  dp = [0]*(n+1)
  for w,v in tradelist:
    for i in range(n+1-w):
      dp[i+w] = max(dp[i+w],dp[i]+v)
  ptr = n
  ret = dp[n]
  while ptr and dp[ptr-1] == dp[n]:
    ret += 1
    ptr -= 1
  return ret

ans1 = trade(n,g1,s1,b1,g2,s2,b2)
ans2 = trade(ans1,g2,s2,b2,g1,s1,b1)
print(ans2)

Measured memory_bytes: 228380
#include <stdio.h>
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
typedef long long ll;

using namespace std;

const int N = 3e5 + 111, inf = 1e9, mod = 1e9 + 7, C = 2000;
const double pi = acos(-1.0), eps = 1e-9;
const ll INF = 1e18;

int n, a[N], b[N], ans, cnt[4011][4011], f[N], rv[N];

int bp(int x, int y){
	int z = 1;
	while(y){
		if(y & 1)
			z = 1LL * z * x % mod;
		x = 1LL * x * x % mod;
		y >>= 1;
	}
	return z;
}

int cnk(int x, int y){
	return 1LL * f[x] * rv[y] % mod * rv[x - y] % mod;
}

int add(int x, int y){
	x += y;
	if(x >= mod)
		return x - mod;
	return x;
}

int sub(int x, int y){
	x -= y;
	if(x < 0)
		return x + mod;
	return x;
}

int main(){
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cout << setprecision(10) << fixed;

	f[0] = rv[0] = 1;
	for(int i = 1; i <= 10000; ++i)
		f[i] = 1LL * f[i - 1] * i % mod, rv[i] = bp(f[i], mod - 2);

	cin >> n;
	
	for(int i = 1; i <= n; ++i)
		cin >> a[i] >> b[i], cnt[a[i] + C][b[i] + C]++;

	for(int i = 4000; i >= 0; --i)
	for(int j = 4000; j >= 0; --j){
		if(i - 1 >= 0)
			cnt[i - 1][j] = add(cnt[i - 1][j], cnt[i][j]);
		if(j - 1 >= 0)
			cnt[i][j - 1] = add(cnt[i][j - 1], cnt[i][j]);	
	}

	for(int i = 1; i <= n; ++i)
		ans = add(ans, cnt[-a[i] + C][-b[i] + C]), ans = sub(ans, cnk(a[i] + a[i] + b[i] + b[i], a[i] + a[i])); 

	cout << 1LL * ans * rv[2] % mod;
	
	//cout << (clock() + 0.0) / CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 65024
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    int maxH = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < maxH) {
            cout << "No" << endl;
            return 0;
        }
        maxH = max(maxH, x - 1);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se)),
               min(getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se)))
n = int(readline())
for _ in [0] * n:
    li = tuple(map(int, readline().split()))
    p0, p1, p2, p3 = (x + y * 1j for x, y in zip(li[::2], li[1::2]))
    s1 = Segment(p0, p1)
    s2 = Segment(p2, p3)
    print("{0:.10f}".format(getDistances(s1, s2)))

Measured memory_bytes: 8048
N = int(input())
*A, = map(int, input().split())
setA = set(A)
if len(setA) == 3:
    a, b, c = list(setA)
    print('Yes' if a ^ b ^ c == 0 and A.count(a) == A.count(b) == A.count(c) else 'No')
elif len(setA) == 2: print('Yes' if 2*A.count(0) == A.count(max(setA)) else 'No')
elif len(setA) == 1: print('Yes' if max(setA) == 0 else 'No')
else: print('No')

Measured memory_bytes: 14212
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var h = NextInt;
        var w = NextInt;
        var n = NextInt;
        HashSet<Tuple> candidateCenter = new HashSet<Tuple>();
        HashSet<Tuple> black = new HashSet<Tuple>();
        for (int iterate = 0; iterate < n; iterate++)
        {
            var a = NextInt;
            var b = NextInt;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    Tuple point = new Tuple(a + i, b + j);
                    if (point.Item1 <= 1 || h - 1 < point.Item1 || point.Item2 <= 1 || w - 1 < point.Item2)
                        continue;
                    candidateCenter.Add(point);
                }
            }
            black.Add(new Tuple(a, b));
        }
        var res = new long[10];
        res[0] = (long)(h - 2) * (w - 2);
        foreach (var cand in candidateCenter.ToArray())
        {
            res[0]--;
            int count = 0;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if (black.Contains(new Tuple(cand.Item1 + i, cand.Item2 + j)))
                        count++;
                }
            }
            res[count]++;
        }
        Console.WriteLine(string.Join("\n", res));
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}

struct Tuple
{
    public int Item1;
    public int Item2;
    public Tuple(int item1, int item2)
    {
        Item1 = item1;
        Item2 = item2;
    }
    public override int GetHashCode() => (Item1 << 2) + (Item2 << 5) + (Item1 ^ Item2);
}


Measured memory_bytes: 62784
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
#include<numeric>
#define LONG long long int
using namespace std;
int main() {
	int r;
	cin >> r;
	cout << r * r << endl;
	
	return 0;
}

Measured memory_bytes: 256
// AOJ DSL_4_A Union of Rectangles
// 2018.5.14 bal4u

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 2005
#define MAX   4005

int x1[MAX_N], y1[MAX_N], x2[MAX_N], y2[MAX_N];
int x[MAX], xs;
int y[MAX], ys;
short s[MAX][MAX];

int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int xbsch(int a)
{
	int m, l = 0, r = xs;

    while (l < r) {
        m = (l + r) >> 1;
        if (x[m] < a) l = m + 1; else r = m;
    }
	return l;
}
int ybsch(int a)
{
	int m, l = 0, r = ys;

    while (l < r) {
        m = (l + r) >> 1;
        if (y[m] < a) l = m + 1; else r = m;
    }
	return l;
}

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int main()
{
	int N, i, r, c, r1, c1, r2, c2;
	long long ans;

	N = in(); xs = ys = 0;
	for (i = 0; i < N; i++) {
		x1[i] = c = in(), y1[i] = r = in();
		x[xs++] = c, y[ys++] = r;
		x2[i] = c = in(), y2[i] = r = in();
		x[xs++] = c, y[ys++] = r;
	}
	qsort(x, xs, sizeof(int), cmp); xs = uniq(x, xs);
	qsort(y, ys, sizeof(int), cmp); ys = uniq(y, ys);

	for (i = 0; i < N; i++) {
		c1 = xbsch(x1[i]), c2 = xbsch(x2[i]);
		r1 = ybsch(y1[i]), r2 = ybsch(y2[i]);

		s[r1][c1]++, s[r1][c2]--;
		s[r2][c1]--, s[r2][c2]++;
	}

	for (r = 0; r < ys; r++) for (c = 1; c < xs; c++) s[r][c] += s[r][c-1];
	for (r = 1; r < ys; r++) for (c = 0; c < xs; c++) s[r][c] += s[r-1][c];

	ans = 0;
	for (r = 0; r < ys; r++) for (c = 0; c < xs; c++) {
		if (s[r][c]) {
			c1 = c;
			while (s[r][c]) c++;
			ans += (long long)(x[c]-x[c1])*(y[r+1]-y[r]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 33152
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N, K;

int main()
{
    cin >> N >> K;
    if (K % 2 == 1)
    {
        ll v = N / K;
        cout << v * v * v << endl;
    }
    else
    {
        ll v = N / K;
        ll v2 = N / (K / 2);
        ll v3 = v2 - v;
        cout << v * v * v + v3 * v3 * v3 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  string a, b;
  cin >> a >> b >> a;
  cout << "A" << char(b[0]) <<"C" << endl;
  getchar();
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
 
int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=100005;
ll k;
int n,m,ans[N],q[N],a[N],que[N];
ll dq[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)q[i]=i;
	m=read(); cin>>k;
	for(int i=1;i<=m;i++){
		int pos=read();
		swap(q[pos],q[pos+1]);
	}
	for(int i=1;i<=n;i++)if(!ans[i]){
		que[0]=i; int jb=1;
		for(int j=q[i];j!=i;j=q[j])que[jb++]=j;
		for(int j=0;j<jb;j++)ans[que[j]]=que[(j+k%jb)%jb];
	}
	for(int i=1;i<=n;i++)dq[i]=a[ans[i]]-a[ans[i]-1];
	for(int i=1;i<=n;i++)dq[i]+=dq[i-1];
	for(int i=1;i<=n;i++)writeln(dq[i]);
}
/*
1 2 3 4 5
1 3 2 4 5
1 3 4 2 5
1 3 4 5 2
*/

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int graph[110][110]={0};
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int v,k,tm;
        cin>>v>>k;
        while(k--)
        {
            cin>>tm;
            graph[v][tm]=1;
        }
    }
    for(int i=1;i<=n;++i)
    {
    for(int j=1;j<=n;++j)
    {
        if(j>1){cout<<" ";}
        cout<<graph[i][j];
    }
    cout<<endl;
    }
    return 0;
}



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

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

    vector<int> can(n, 0);
    vector<int> q(n, 1);
    can[0] = 1;

    for (int i = 0; i < m; i += 1) {
        int x, y; cin >> x >> y;
        x -= 1, y -= 1;
        if (can[x]) {
            can[y] = 1;
        }

        q[x] -= 1;
        q[y] += 1;

        if (q[x] == 0) {
            can[x] = 0;
        }
    }

    int ans = accumulate(can.begin(), can.end(), 0);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long

signed main() {
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int>> t(m);
	vector<int> p(m);
	vector<int> y(m);
	for (size_t i = 0; i < m; i++)
	{
		cin >> p[i];
		cin >> y[i];	
	}
	for (size_t i = 0; i < m; i++)
	{
		t[i] = make_tuple(p[i], y[i], i);
	}

	sort(t.begin(), t.end());
	vector<pair<int, string>> pr(m);
	int pNum = 1;
	int oldPId = get<0>(t[0]);
	for (size_t i = 0; i < m; i++)
	{
		stringstream ssp;
		stringstream ssy;
		int pId = get<0>(t[i]);
		if (oldPId != pId) {
			pNum = 1;
			oldPId = pId;
		}
		ssp << setw(6) << setfill('0') << pId;
		ssy << setw(6) << setfill('0') << pNum;
		pr[i] = make_pair(get<2>(t[i]), ssp.str() + ssy.str());
		pNum++;
	}
	sort(pr.begin(), pr.end());
	for (size_t i = 0; i < m; i++)
	{
		cout << pr[i].second << endl;
	}

}




Measured memory_bytes: 11648
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readStrings2() = readLn().split("").filter { it.isNotEmpty() }
private fun readInts2() = readStrings2().map(String::toInt)
private fun initArray(n:Int, v:String) = Array(n) { v }
private fun initIntArray(n:Int, v:Int) = IntArray(n) { v }

fun main(args: Array<String>) {
    val ( H1, M1, H2, M2, K) =  readInts()

    val hDiff = H2 - H1
    val mDiff = M2 - M1
    val diff = hDiff * 60 + mDiff

    println("${diff - K}")
}

Measured memory_bytes: 36352
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  //int ans = 0;
  //string ans = "No";

  string ans = "";
  string s; cin >> s;
  rep(i, s.size()){
    if (s[i] == '0') ans += "0";
    if (s[i] == '1') ans += "1";
    if (s[i] == 'B') if (ans != "") ans.pop_back();
  }

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

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans_ind = 0
ans_d = 1e9

for i, h in enumerate(H):
    d = abs(T - h * 0.006 - A)
    if d < ans_d:
        ans_d = d
        ans_ind = i + 1
print(ans_ind)

Measured memory_bytes: 3188
#include<stdio.h>

int n,A[50];

int solve (int i,int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res=solve(i+1,m)||solve(i+1,m-A[i]);
}

int main(){
    int q,M,i;
    
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
 }
 return 0;
}


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

int main(){
  int k;
  cin>>k;
  if(k%2==0){
    cout<<k*k/4<<endl;
  }
  if(k%2==1){
    cout<<((k-1)/2)*((k+1)/2)<<endl;
  }
}

Measured memory_bytes: 256
n=int(input())
num_list=list(map(int,input().split()))

ans=str(num_list[0])
for k in range(1,len(num_list)):
    ans+=" "+str(num_list[k])
print(ans)

for i in range(1,n):
    v=num_list[i]
    j=i-1
    while j>=0 and num_list[j]>v:
        num_list[j+1]=num_list[j]
        j-=1
    num_list[j+1]=v

    ans=str(num_list[0])
    for k in range(1,len(num_list)):
        ans+=" "+str(num_list[k])
    print(ans)


Measured memory_bytes: 5600