akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

string ans[1<<20];
char s[32];
char t[32];

int main(){
#ifdef LOCAL
    freopen("in","r",stdin);
#endif
    while(cin >> s && s[0]!='#'){
        int sz = 0;
        int n = strlen(s);
        rep(i,n) t[i] = s[i];
        t[n] = 0;
        char change[26];
        rep(mask,1<<n){
            bool ok = true;
            rep(i,n){
                ok &= s[i]!='z' || ~mask>>i&1;
            }
            if(!ok) continue;
            rep(i,n){
                t[i] = s[i] + (mask>>i & 1);
            }
            memset(change,30,sizeof(change));
            rep(i,n){
                change[t[n-i-1]-'a'] = n-i-1;
            }
            loop(i,1,26) t[change[i]]--;
            if(strcmp(t,s)==0){
                rep(i,n){
                    t[i] = s[i] + (mask>>i&1);
                }
                ans[sz++] = t;
            }
        }
        sort(ans, ans + sz);
        printf("%d\n",sz);
        if(sz > 10){
            rep(i,5) printf("%s\n", ans[i].c_str());
            rep(i,5) printf("%s\n", ans[sz-5+i].c_str());
        } else {
            rep(i,sz){
                printf("%s\n",ans[i].c_str());
            }
        }
    }
}

Measured memory_bytes: 10492
#include <cstdio>

using namespace std;

int main(void){
    int n,m,c,a[20][20],b[20],i,j,res=0,sum;
    scanf("%d %d %d",&n,&m,&c);
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        sum = 0;
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
            sum += b[j]*a[i][j];
        }
        if(sum+c > 0)res++;
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
main(){
  int a[5],b[5],i,j,hit=0,blow=0;
  while(scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(a[i]==b[j] && i==j){
	  hit++;
	}
	else if(a[i]==b[j]){
	  blow++;
	}
      }
    }
	printf("%d %d\n",hit,blow);
	hit=0;
	blow=0;
  }
  return 0;
}   

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long a){
 cout << a + a*a + a*a*a << endl; 
}

int main(){
    long long a;
				scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define adrep(i,s,n) for (int i=(s);i<(n);i++)
using namespace std;
typedef long long ll;


int main(){

  ll a,b;
  cin>>a>>b;
	
  cout<<a*b<<endl;

}


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

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int64_t r=0,g=0,b=0;
  for(int i=0;i<n;i++)
  {
    if(s.at(i)=='R')
      r++;
    else if(s.at(i)=='G')
      g++;
    else
      b++;
  }
  int64_t sum=r*g*b;
  
  for(int j=1;j<n;j++)
  {
    int i=j-1,k=j+1;
    while(i>=0&&k<=n-1)
    {
      if(s.at(i)!=s.at(j)&&s.at(i)!=s.at(k)&&s.at(j)!=s.at(k))
        sum--;
      i--;
      k++;
    }
  }
    
  cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

#define PI 3.1415926535897932384626433832795028841971

signed main(void)
{
	int a, b, h, m; cin >> a >> b >> h >> m;
	h %= 12;
	double t;
	t = ((60*h+m)/2.0 - m*6) * PI/180;
	double c;
	c = a*a + b*b - 2*a*b*cosf64(t);
	c = sqrt(c);
	cout << std::fixed << std::setprecision(30) << c << endl;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    ll r;
    cin >> r;
    db val = (M_PI)*2*db(r);
    cout << fixed << setprecision(3) << val << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    vi p(n+1);
    rp(i,n) cin >> p.at(i+1);
    int ctr=0;
    repi(i,1,n+1){
        if(p[i]!=i) ctr++;
    }
    YES(ctr==0||ctr==2);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int a,b,c,d;
    double e;
    cin >> a >> b;
    
    c=a/b;
    d=a%b;
    e=(double)a/b;
    
    cout<< c << endl << d << endl;
    
    std::cout.precision(5);
    std::cout << std::fixed << e << endl;;
}


Measured memory_bytes: 3268
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = -float('inf')
    for n in range(N):
        m = n
        ans_tmp = 0
        cnt = 0
        repeat_flag = False
        for k in range(K):
            nxt = P[m]
            score = C[nxt-1]
            ans_tmp += score
            ans = max(ans, ans_tmp)
            m = nxt-1
            cnt += 1
            if m == n:
                repeat_flag = True
                break
        if not repeat_flag:
            continue
        if K%cnt == 0:
            divK = K//cnt - 1
            r = cnt
        else:
            divK = K//cnt
            r = K%cnt
        if ans_tmp <= 0:
            continue
        repeat_ans_tmp = ans_tmp * divK
        for k in range(r):
            nxt = P[m]
            score = C[nxt-1]
            repeat_ans_tmp += score
            ans = max(ans, repeat_ans_tmp)
            m = nxt-1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68716
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }
int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long lcm = C / gcd(C, D) * D;
    cout << B - A + 1 - (B / C - (A - 1) / C) - (B / D - (A - 1) / D) +
                (B / lcm - (A - 1) / lcm)
         << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int x;

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

	cin >> x;
	cout << (x>=30 ? "Yes" : "No") << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
int main(){
	int n;
	cin >> n;
	vector<int> a(n,0);
	rep(i,n) cin >> a[i];
	int ans = 0;
	int min = 1000,max = 0;
	rep(i,n){
		if(max < a[i]) max = a[i];
		if(min > a[i]) min = a[i];
	}
	//cout << max << "|"<< min << endl;
	cout << max - min << endl;
     
	return 0;
}


Measured memory_bytes: 256
num = gets.to_i
array = []
(1..num).each do |n|
  if n % 3 == 0 && n % 5 == 0
    array << "FizzBuzz"
  elsif n % 5 == 0
    array << "Buzz"
  elsif n % 3 == 0
    array << "Fizz"
  else
    array << n
  end
end
p array.select {|a| a.to_i.positive?}.sum

Measured memory_bytes: 45800
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    class SegmentTree:#非再帰(こちらの方が速い) #1-indexed
        # 初期化処理
        # f : SegmentTreeにのせるモノイド
        # default : fに対する単位元
        def __init__(self, size, f=lambda x,y : max(x,y), default=0):
            self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
            self.default = default
            self.dat = [default]*(self.size*2) # 要素を単位元で初期化
            self.f = f
    
        def update(self, i, x):
            i += self.size
            self.dat[i] = x
            while i > 0:
                i >>= 1
                self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])
    
        def query(self, l, r):
            l += self.size
            r += self.size
            lres, rres = self.default, self.default
            while l < r:
                if l & 1:
                    lres = self.f(lres, self.dat[l])
                    l += 1
    
                if r & 1:
                    r -= 1
                    rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
                l >>= 1
                r >>= 1
            res = self.f(lres, rres)
            return res
    n,k=MI()
    seg=SegmentTree(size=2*300000+1)
    for i in range(n):
        x=I()
        mx=seg.query(300000+x-k,300000+x+k+1)
        #print(mx,x)
        seg.update(300000+x,mx+1)
    print(seg.query(0,2*300000+2))
        
    
    
    
    








if __name__=="__main__":
    main()



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

int main(){
	int n;
	while(1){
		cin>>n;
		if(!n)break;
		int rest=1000-n;
		int fihu=rest/500;
		int hun=(rest-fihu*500)/100;
		int fif=(rest-fihu*500-hun*100)/50;
		int ten=(rest-fihu*500-hun*100-fif*50)/10;
		int five=(rest-fihu*500-hun*100-fif*50-ten*10)/5;
		int one=rest%5;
		cout<<fihu+hun+fif+ten+five+one<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
fn a_753() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input);

    input = input.trim_right().to_string();
    if input == "7".to_string() ||
        input == "5".to_string() ||
        input == "3".to_string() {
        println!("YES");
    }
    else {
        println!("NO");
    }
}

fn main() {
    a_753();
}

Measured memory_bytes: 4352
#include <cstdio>
const int maxn = 1e5+5;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int n,m,l[maxn],r[maxn];
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i)scanf("%d %d",&l[i],&r[i]);
	int L = 1,R = n;
	for(int i=1;i<=m;++i)
		L = max(l[i],L),R = min(r[i],R);
	printf("%d",max(0,R-L+1));
	return 0;
} 

Measured memory_bytes: 2512
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 3005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,m,mod;
int fac[maxn],inv[maxn],pp[maxn],p2[maxn];
int S[maxn][maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int power(int a,int k){
	int ret=1;
	for (;k;k>>=1,a=1ll*a*a%mod) if (k&1) ret=1ll*ret*a%mod;
	return ret;
}

int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}

int main(){
	n=read(),mod=read();
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=1; inv[n]=power(fac[n],mod-2); for (int i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	pp[0]=2; for (int i=1;i<=n;i++) pp[i]=1ll*pp[i-1]*pp[i-1]%mod;
	p2[0]=1; for (int i=1;i<=n;i++) p2[i]=(p2[i-1]<<1)%mod;
	for (int i=0;i<=n;i++){
		S[i][0]=1;
		for (int j=1;j<=i;j++) S[i][j]=(1ll*(j+1)*S[i-1][j]+S[i-1][j-1])%mod;
	}
	int ans=0;
	for (int i=0;i<=n;i++){
		int res=0,pps=1;
		for (int j=0;j<=i;j++){
			res=(res+1ll*S[i][j]*pps)%mod;
			pps=1ll*pps*p2[n-i]%mod;
		}
		res=1ll*res*pp[n-i]%mod;
		res=1ll*res*C(n,i)%mod;
		ans=(ans+res*((i&1)?-1:1))%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 34304
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define LL long long

LL read() {
    LL x = 0, f = 1; char c = getchar();
    while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
    while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
    return x * f;
}

int main() {
    LL l = read(), orgl = l, r = read(), orgr = r, tr = r, ans;
    
    for(int i = 59; i >= 0; i--)
        if((l ^ r) >> i & 1) {
            l |= 1ll << i;
            int tmp = i;
            for(tmp--; tmp >= 0; tmp--) tr |= 1ll << tmp;
            for(i--; i >= 0 && !(r >> i & 1); i--) ;
            for(i; i >= 0; i--) r |= 1ll << i;
            break;
        }
    if(r >= l) return printf("%lld\n", tr - orgl + 1), 0;
    ans = r - orgl + 1 + tr - l + 1;
    
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <cstdlib>
#include <stack>
#include <stdio.h>
#include <vector>
#include <sstream>

using namespace std;
typedef long long int ll;

vector<string> split(const string &s){

  vector<string> elms;
  stringstream ss(s);
  string item;
  while(getline(ss, item,' ')){
    if(!item.empty()){
      elms.push_back(item);
    }
  }
  return elms; 
}


int main(){

  string line;
  //fill(line,line+1000,'\0');
  
  stack<ll> st;
  getline(cin,line);
  vector<string> elms = split(line);
  
  int i=0;
  //cout<<line<<endl<<line.size()<<endl;
  while(i<elms.size()){
    
    //if(cin.eof()) break;
    //if(elm=='\n') break;
    if(elms[i]=="+" || elms[i]=="-" || elms[i]=="*"){
      ll x = st.top();
      st.pop();
      ll y = st.top();
      st.pop();
      ll z = 0;
      if(elms[i]=="+") z = y+x;
      if(elms[i]=="-") z = y-x;
      if(elms[i]=="*") z = y*x;
      st.push(z);
    }
    else{
      stringstream ss;
      int ret;
      ss<<elms[i];
      ss>>ret;
      //cout<<ret<<endl;
      st.push(ret);
    }
    i++;
  }
  cout<<st.top()<<endl;
 
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        bool e = false, w = false, n = false, s = false;
        string str;
        in >> str;
        for (int i = 0; i < str.size(); i++) {
            if ('E' == str[i]) {
                e = true;
            }
            if ('W' == str[i]) {
                w = true;
            }
            if ('N' == str[i]) {
                n = true;
            }
            if ('S' == str[i]) {
                s = true;
            }
        }
        out << (e == w &&n == s ? "Yes" : "No") << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

using namespace std;

int main() {

	int n;
	scanf("%d", &n);

	vector<int> p(n), q(n);
	for(int &x : p) scanf("%d", &x);
	for(int &x : q) scanf("%d", &x);

	vector<int> id(n);
	iota(id.begin(), id.end(), 1);

	int a = -1, b = -1;
	int tmp = 0;
	do {
		if(a != -1 and b != -1) break;
		tmp++;
		if(id == p) a = tmp;
		if(id == q) b = tmp;

	} while(next_permutation(id.begin(), id.end()));

	printf("%d\n", abs(a - b));

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int T,X;
    cin>>T>>X;

    cout << (double)T/X << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll dfs(ll i,ll ap,ll bp,ll cp,ll n,ll a,ll b,ll c,vector<ll> l){
    if(i==n){
        if(min({ap,bp,cp})>0) return fabs(a-ap)+fabs(b-bp)+fabs(c-cp)-30;
        else return 1e9;
    }
    ll usea=dfs(i+1,ap+l[i],bp,cp,n,a,b,c,l)+10;
    ll useb=dfs(i+1,ap,bp+l[i],cp,n,a,b,c,l)+10;
    ll usec=dfs(i+1,ap,bp,cp+l[i],n,a,b,c,l)+10;
    ll use_=dfs(i+1,ap,bp,cp,n,a,b,c,l);
    return min({usea,useb,usec,use_});
}

int main(){
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    vector<ll> l(n);
    for(ll i=0;i<n;i++) cin>>l[i];
    cout<<dfs(0,0,0,0,n,a,b,c,l)<<endl;
    return 0;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
#define Graph vector<vector<int> >
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言

int N=0,t=1;
vector<int> d(101,-1);//vを最初に発見した発見時刻を記録 時刻−１で初期化
vector<int> f(101,-1);//vのリストを調べ終えた時刻を記録 時刻−１で初期化

void dfs(Graph &G , int u){

	if(d[u]==-1){d[u]=t++;}

	for(auto next_u: G[u]){
		
		if(d[next_u]!=-1) {continue;}//G[u]の中身のそれがすでに探索済みならば continue	

		if(G[u].empty()){ f[next_u]=t++;}  //G[u]が空であったとき、そこにラストタイムスタンプを押す。
		dfs(G,next_u);
	}

	if(f[u]==-1)f[u]=t++;//G[u]のリストを全て調べ終わって、G[u]にラストスタンプが押されてないときラストスタンプを押す。		

	}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


cin>> N;

Graph G(N+1);


for (int i = 1; i <=N; ++i){

	int n; cin>>n;//使わないやつ
	int k; cin>>k;
	REP(j,k){int a; cin >>a; G[i].push_back(a);}

}

for (int i = 1; i <=N; ++i)
{
	dfs(G,i);
}





for (int i = 1; i <=N; ++i)
{
	cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
}




return 0;

}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  long long s[n];
  REP(i,n){
    if(i==0){
      s[i]=a[i];
    }else{
      s[i]=s[i-1]+a[i];
    }
  }
  map<long long,long long> mp;
  REP(i,n){
    mp[s[i]]++;
  }
  long long ans=0;
  REP(i,n){
    if(s[i]==0){
      ans++;
    }
  }
  for(auto p:mp){
    ans += p.second*(p.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <map>
#include <set>
#define pi 3.1415926

using namespace std;

int main()
{
	int ht, wd;
	while (cin >> ht >> wd)
	{
		vector<string> v;
		for (int i = 0; i < ht; i++)
		{
			string t;
			cin >> t;
			v.push_back(t);
		}
		string s = "", ans = "";
		s += "#";
		s += string(wd, '#');
		s += "#";
		s += "\n";
		ans += s;
		for (int i = 0; i < ht; i++)
		{
			s = "";
			s += "#";
			s += v[i];
			s += "#";
			s += "\n";
			ans += s;
		}
		s = "";
		s += "#";
		s += string(wd, '#');
		s += "#";
		s += "\n";
		ans += s;
		cout << ans << flush;
	}
	return 0;
}

Measured memory_bytes: 888
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };


int main () {
	int n;
	while (true) {
		cin >> n;
		if (n == 0) break;
		int a;
		int ans = 0;

		rep (i, n / 4) {
			cin >> a;
			ans += a;
		}
		cout << ans << endl;
	}

}

 


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

bool is_valid(int m, vector<int> &d) {
    string s = to_string(m);
    rep(i, d.size()) {
        int pos = s.find(to_string(d[i]));
        if (pos != -1) return false;
    }
    return true;
}

int main() {
    int n,k; cin >> n >> k;
    vector<int> d(k);
    rep(i,k) cin >> d.at(i);

    int ans = n;
    for (;;ans++) {
        if(is_valid(ans,d)) break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;
int main()
{
    stack<int> S;
    int a,b,x;
    string s;
    while(cin>>s)
    {
        if(s[0]=='+')
        {
            b=S.top();S.pop();
            a=S.top();S.pop();
            S.push(a+b);
        }
        else if(s[0]=='-')
        {
            b=S.top();S.pop();
            a=S.top();S.pop();
            S.push(a-b);
        }
        else if(s[0]=='*')
        {
            b=S.top();S.pop();
            a=S.top();S.pop();
            S.push(a*b);
        }
        else S.push(atoi(s.c_str()));
    }
    cout<<S.top()<<endl;
    return 0;
}


Measured memory_bytes: 3168
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

public class Main {
  private static String solve(String text) {
    boolean hasN = text.contains("N");
    boolean hasW = text.contains("W");
    boolean hasS = text.contains("S");
    boolean hasE = text.contains("E");
    if (hasN == hasS && hasW == hasE) {
      return "Yes";
    } else {
      return "No";
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String text = reader.next();
    out.println(solve(text));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 22356
#include <iostream>
using namespace std;
int main(){
  char c;
  cin >> c;
  char ans;
  if(c == 'A') ans = 'T';
  else if(c == 'C') ans = 'G';
  else if(c == 'G') ans = 'C';
  else if(c == 'T') ans = 'A';

  cout << ans << endl;
}


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

int main(){
    int n,k; cin >> n >> k;
    cout << (int)(log(n) / log(k) + 1) << endl;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


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

    if (n & 1) {
        cout << 2*n << endl;
    }else{
        cout << n << endl;
    }


    return 0;
}


Measured memory_bytes: 256
def solve():
    N, x, *a = map(int, open(0).read().split())
    
    p_sum_a = sum(a)
    
    if x < a[0]:
        a[0] = x
    
    for i in range(1, N):
        if x < a[i-1] + a[i]:
            a[i] = x - a[i-1]
    
    sum_a = sum(a)
    print(p_sum_a - sum_a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14092
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        int count = int.Parse(ReadLine());
        List<Rest> rests = new List<Rest>();

        for (int i = 0; i < count; i++)
        {
            var data = ReadLine().Split(' ');
            var rs = new Rest(data[0], int.Parse(data[1]), i + 1);
            rests.Add(rs);
        }

        rests.Sort();

        rests.Select(rs=>rs.num).WriteToConsole();

        ReadKey();
    }
}

internal struct Rest : IComparable
{
    public string name;
    public int hyoka;
    public int num;

    public Rest(string name, int hyoka, int num)
    {
        this.name = name;
        this.hyoka = hyoka;
        this.num = num;
    }

    public int CompareTo(object obj)
    {
        var rs = (Rest)obj;

        if (rs.name == this.name)
        {
            return rs.hyoka.CompareTo(hyoka);
        }
        else
        {
            return name.CompareTo(rs.name);
        }
    }
}


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

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


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

int main(){
	int N;
	int a[102];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&a[i]);
	}
	
	int ret = 0;
	int cnt = 0;
	int pre = 0;
	for(int i = 1 ; i <= N ; i ++){
		if(a[i] != pre){
			ret += cnt/2;
			cnt = 1;
			pre = a[i];
		}
		else {
			cnt ++;
		}
	}
	ret += cnt/2;
	
	cout << ret << endl;
}



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

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

typedef long long ll;

class Edge;
class Node {
 public:
  list<Edge *> con_edges;
};

class Edge {
 public:
  Node *a;
  Node *b;
  int color;

  Node *GetOther(Node *n) {
    if (n != a) return a;
    return b;
  }
};

Edge *EDGE_NIL;

void Paint(Node *node, Edge *parent_edge = EDGE_NIL) {
  int color = 1;
  for (auto itr = node->con_edges.begin(); itr != node->con_edges.end();
       itr++) {
    if (*itr == parent_edge) {
      continue;
    }

    // color
    if (parent_edge != EDGE_NIL) {
      if (parent_edge->color == color) color += 1;
    }
    (*itr)->color = color;
    color++;

    Node *child = (*itr)->GetOther(node);
    Paint(child, *itr);
  }
}

int main() {
  int n;
  cin >> n;
  vector<Node> nodes(n);
  vector<Edge> edges(n - 1);
  FOR(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    edges[i].a = &nodes[a - 1];
    edges[i].b = &nodes[b - 1];
    nodes[a - 1].con_edges.push_back(&edges[i]);
    nodes[b - 1].con_edges.push_back(&edges[i]);
  }
  int k = 0;
  FOR(i, 0, n) { k = max(k, (int)nodes[i].con_edges.size()); }

  Node *root = &nodes[0];
  Paint(root);
  cout << k << endl;
  FOR(i, 0, n - 1) { cout << edges[i].color << endl; }
  return 0;
}

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

int main(){
    string s, oddstr;
    cin >> s;
    
    for(int i=0; i<s.length(); i++){
        if(i%2==0){
            oddstr.push_back(s[i]);
        }
    }
    cout << oddstr << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[200010],b[200010];
ll cap[200010],cup[400010],capcnt,cupcnt;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	for(int i=0;i<m;i++)scanf("%lld",b+i);
	sortup(a,n);
	sortup(b,m);
	int j=0;
	for(int i=0;i<n;i++){
		while(j<m&&b[j]<a[i]){
			cup[cupcnt++]=b[j++];
		}
		if(j==m||a[i]<b[j]){
			cup[cupcnt++]=a[i];
		}else if(j<m&&a[i]==b[j]){
			cup[cupcnt++]=a[i];
			cap[capcnt++]=a[i];
			j++;
		}
	}
	while(j<m)cup[cupcnt++]=b[j++];
	printf("%d %d\n",capcnt,cupcnt);
	for(int i=0;i<capcnt;i++)printf("%lld\n",cap[i]);
	for(int i=0;i<cupcnt;i++)printf("%lld\n",cup[i]);
}


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if (a > b)
            {
                int t = a;
                a = b;
                b = t;
            }

            Console.WriteLine(a < c && c < b ? "Yes" : "No");
        }
    }
}


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

int main(){
  int n; cin >>n;
  vector<long long> a(n+1);
  vector<long long> b(n);
  for(int i = 0; i < n+1; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) cin >> b[i];
  long long ans = 0;
  for(int i = n-1; i >= 0; i--){
    int ki=min(a[i+1], b[i]);
    ans+=ki;
    b[i] -=ki;
    if(a[i]>b[i]){
      ans+=b[i];
      a[i]-=b[i];
    } 
    else{
      ans+=a[i];
      a[i]= 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void)
{
    int i,n;
        double x,mean,poi[1010]={0};
    
    while(scanf("%d",&n)==1 && n!=0){
        x=0;
        for(i=0;i<n;i++){
            scanf("%lf",&poi[i]);
            x+=poi[i];
        }
        mean=x/n;
        x=0;
        
        for(i=0;i<n;i++){
            x+=pow(poi[i]-mean,2);
        }
        
        mean=sqrt(x/n);
        printf("%f\n",mean);
    }
    return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int math[100000];

bool cmp(int a,int b){
    return a>b;
}

int main(){
    int i,sum=0,flag;
    cin>>i;
    for(int t=0;t<i;t++)
        cin>>math[t];
    sort(math,math+i,cmp);
    flag=1;
    for(int t=1;t<=i;t++)
        if(math[t]!=math[t-1]){
            sum+=flag%2;
            flag=1;

        }
        else{
            flag++;
        }
    cout<<sum<<endl;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    long long N,K;
    cin>>N>>K;
    long long z=N%K;
    long long ans=min(z,K-z);
    cout<<ans<<endl;   
    return 0;
}


Measured memory_bytes: 3168
#include<stdio.h>

int main(void)
{
	int a[2];
	int b;
	char dmmy;
	int index[101][101];
	int Yokototal[101];
	int tatetotal[101];
	int YokoCount = 0;
	scanf("%d %d", &a[0], &a[1]);

	//初期化
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			index[i][j] = 0;
		}
	}
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			tatetotal[i]= 0;
		}
	}
	for (int i = 0; i < 100; i++)
	{
		Yokototal[i] = 0;
	}

	//読み込み
	for (int i = 0; i < a[0]; i++)
	{
		for (int j = 0; j < a[1]; j++)
		{
			scanf("%c", &dmmy);
			scanf("%d", &b);
			index[i][j] = b;
			Yokototal[i] = Yokototal[i] + index[i][j];
			tatetotal[j] = tatetotal[j] + index[i][j];
		}
		YokoCount++;
		tatetotal[a[1]] = tatetotal[a[1]] + Yokototal[i];
	}

	//出力
	for (int i = 0; i < a[0]; i++)
	{
		if (i != 0)
		{
			printf("\n");
		}
		for (int j = 0; j < a[1]; j++)
		{
			if (j != 0)
			{
				printf(" %d", index[i][j]);
			}
			else
			{
				printf("%d", index[i][j]);
			}
		}
		printf(" %d", Yokototal[i]);
	}
	printf("\n");
	for (int i = 0; i < a[1] + 1; i++)
	{
		if (i != 0)
		{
			printf(" %d", tatetotal[i]);
		}
		else
		{
			printf("%d", tatetotal[i]);
		}
	}
	printf("\n");
	return 0;
}



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

#define E 1000000

int main()
{
	int e;

	while (cin >> e && e > 0) {
		int Min = E + 1;
		

		for (int i = 0; i <= 1000; i++) {
			for (int j = 0; j <= 100; j++) {
				if (i*i + j*j*j > e)
					break;
				int s;
				s = (e - i*i - j*j*j) + i + j;
				
				Min = min(Min, s);
			}
		}
		cout << Min << endl;

	}

    return 0;
}

Measured memory_bytes: 3060
{-# LANGUAGE OverloadedStrings #-}
import           Data.Attoparsec.ByteString.Char8
import qualified Data.ByteString.Char8            as B

main :: IO ()
main = do
  Right (k, x) <- parseOnly ((,) <$> decimal <* space <*> decimal) <$> B.getLine
  B.putStrLn $ if solve k x then "Yes" else "No"

solve :: Int -> Int -> Bool
solve k x = 500 * k >= x

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;



int main(){
   int n;cin>>n;
    vector<string> s(n);
   
    vector<ll> name(5,0);
    rep(i,n){
        cin>>s[i];
        if(s[i][0]=='M') name[0]++;
        if(s[i][0]=='A') name[1]++;
        if(s[i][0]=='R') name[2]++;
        if(s[i][0]=='C') name[3]++;
        if(s[i][0]=='H') name[4]++;
    }
    ll res=0,ans;
    for (int bit = 0; bit < (1<<5); bit++)
    {
        if(__builtin_popcount(bit)!=3)continue;
        //cout<<"bit"<<bit;
        ans = 1;
        for (int i = 0; i < 5; i++)
        {
           
            if(bit&(1<<i)){
                ans = ans * name[i];
            }
        }
        //cout<<ans<<endl;
        res += ans;
    }
    
    cout<<res<<endl;
return 0;
}

Measured memory_bytes: 6144
D=dict()
for i in "abcdefghijklmnopqrstuvwxyz":
  D[i]=100
n=int(input())
for _ in range(n):
  s=input()
  for j in D:
    D[j]=min(D[j],s.count(j))
ans=""
for k in "abcdefghijklmnopqrstuvwxyz":
  ans+=k*D[k]
print(ans)

Measured memory_bytes: 3064
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

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

	if (b%a == 0) {
		cout << a + b << endl;
	} else {
		cout << b - a << endl;
	}
}


 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
	bool flag = false;
	if(a > 9)
	{
		flag = true;
	}
	if(b > 9)
	{
		flag = true;
	}
	
	if(flag)
	{
		cout << -1;
	}
	else
	{
		cout << a * b;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    d = set()
    N = int(input())
    for i in range(N):
        S = input().split()
        if S[0] == 'insert':
            d.add(S[1])
        elif S[0] == 'find':
            if S[1] in d:
                print("yes")
            else:
                print("no")

if __name__ == '__main__':
    main()


Measured memory_bytes: 30992
public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new java.util.Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		while(true) {
			c = c - b;
			if (c<=0) {
				System.out.println("Yes");
				break;
			}
			a = a - d;
			if(a<=0) {
				System.out.println("No");
				break;
			}
		}
		
	
	}
}


Measured memory_bytes: 35816
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

  sort(A.begin(), A.end(), greater<int>());

  ll ans = 0;
  priority_queue<ll> que;
  que.push(A[0]);
  rep(i,N-1){
    ans += que.top();
    que.pop();

    que.push(A[i+1]);
    que.push(A[i+1]);
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 6940