akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[3];
int dp2[3];
int main(){
    int n;
    cin >> n;
    while(n--){
        int a,b,c;
        cin >> a >> b >> c;
        dp[0] = a+max(dp2[1],dp2[2]);
        dp[1] = b+max(dp2[0],dp2[2]);
        dp[2] = c+max(dp2[1],dp2[0]);
        swap(dp,dp2);
    }
    cout << *max_element(dp2,dp2+3) << endl;
}

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

int main() {
    int n;
    cin >> n;
    double x[n];
    string u[n];
    for (int i = 0; i < n; i++)
        cin >> x[i] >> u[i];
    double ans = 0;
    for (int i = 0; i < n; i++) {
        if (u[i] == "JPY")
            ans += x[i];
        else
            ans += 380000.0 * x[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		if(a+b>c+d) {
			System.out.println("Left");
		}
		else if(a+b<c+d){
		System.out.println("Right");
	}
		else {
			System.out.println("Balanced");
		}
		}
}

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

int main() {
    int n;
    cin>>n;
    int x=0;
    int yy=0;
    while(n--)
    {
    	int a,b;
    	cin>>a>>b;
    	if(a==b)
    	 x++;
    	else x=0;
    	if(x>=3) 
    		yy=1;
    }
    if(yy==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 5e5+5;
// check for forloop
// take input
// overflow
// intialize variable
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    vector<int> vec;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        vec.push_back(arr[i]);
    }
    sort(vec.begin(),vec.end());
    int p1=vec[n/2-1], p2=vec[n/2];
    for(int i=0;i<n;i++){
        if(arr[i]<=p1){
            cout<<p2<<endl;
        }
        else cout<<p1<<endl;
    }
}

Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
int cnt[10];
int main(){
  
    int tc=3;
    while(tc--){
        int ola;cin>>ola;
        cnt[ola]++;
    }
    if(cnt[5]==2 && cnt[7]==1)puts("YES");
    else puts("NO");
    return 0;
}


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

class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x, int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x),findSet(y));
  }

  void link(int x, int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n,a,b,q;
  int t;
  cin>>n>>q;
  DisjointSet ds=DisjointSet(n);

  for(int i=0;i<q;i++){
    cin>>t>>a>>b;
    if(t==0) ds.unite(a,b);
    else{
      if(ds.same(a,b)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
}



Measured memory_bytes: 3216
#!/usr/bin/env python3
c = 0
m = int(input())
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf:
    for j in range(pf[i]):
        pf[i] -= j + 1
        c += 1
        if pf[i] < 0:
            c -= 1
            break
        elif pf[i] == 0:
            break
print(c)

Measured memory_bytes: 9456
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;


int main(void){
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int c1, c2, c3;
    c1 = b/c - (a-1)/c;
    c2 = b/d - (a-1)/d;
    c3 = b/(c*d/__gcd(c,d)) - (a-1)/(c*d/__gcd(c,d));
    long long int ans;
    ans = c1+c2-c3;
    cout << b-a+1-ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_digital_gifts(void) {
	int n;
	double total = 0;
	double btc = 380000;

	double x;
	string u;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;

		double x_num =x;
		
		if (u == "JPY") total += x_num;
		else            total += (x_num * btc);
	}

	cout << total << endl;
}

int main()
{
    b_digital_gifts();

    return 0;
}

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

using namespace std;
using ll = long long;

int n, ma, mb;
vector<int> a, b, c;
int memo[50][410][410];

int rec(int i, int ra, int rb) {
  if (memo[i][ra][rb] != -1) {
    return memo[i][ra][rb];
  }
  if (ra != 0 && rb != 0 && ra * mb == rb * ma) {
    return 0;
  }
  if (i == n) {
    return 10000;
  }
  return memo[i][ra][rb] = min(
    rec(i + 1, ra, rb),
    rec(i + 1, ra + a[i], rb + b[i]) + c[i]
  );
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> ma >> mb;
  a = vector<int>(n);
  b = vector<int>(n);
  c = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 410; j++) {
      for (int k = 0; k < 410; k++) {
        memo[i][j][k] = -1;
      }
    }
  }
  int price = rec(0, 0, 0);
  if (price >= 10000) {
    cout << -1 << endl;
  } else {
    cout << price << endl;
  }
  return 0;
}


Measured memory_bytes: 33152
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    


    return 0;
}



Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
def num2list(x):
    ret = [0]*40
    for i in range(40):
        ret[i] = x % 2
        x = x // 2
    return ret
def list2num(l):
    ret = 0
    for i,x in enumerate(l):
        ret += x * (2**i)
    return ret
def num2sum(x):
    ret = [0] * 40
    for i in range(40):
        if(i==0):
            amari = x % 4
            if(amari == 1 or amari == 2):
                ret[i] = 1
            else:
                ret[i] = 0
        else:
            pow2 = 2**i
            amari = x % (pow2*2)
            if(amari < (pow2)):
                ret[i] = 0
            else:
                if(amari % 2 == 0):
                    ret[i] = 1
                else:
                    ret[i] = 0
    return ret
def sublist(xl,yl):
    ret = [0]*40
    for i in range(40):
        x = xl[i]
        y = yl[i]
        if((x==0 and y==0) or (x==1 and y==1)):
            ret[i] = 0
        else:
            ret[i] = 1
        
    return ret

# スペース区切りの整数の入力
A, B = map(int, input().split())
Al = num2sum(A-1)
Bl = num2sum(B) 
#print(num2list(B))
#print(Al)
#print(Bl)
ret = list2num(sublist(Al,Bl))
# 出力
print(ret)

Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,cnt=0,mod=0;
  cin >> N;
  vector<int> A(N,0),cou(100001,0);
  REP(i,N)cin >> A[i];
  REP(i,N){
    cou[A[i]]++;
  }
  REP(i,100001){
    if((cou[i] % 2 == 1)){
      mod++;
    }
    if(cou[i] != 0 && cou[i] % 2 == 0)
      cnt++;
  }
  
  cout << mod + (cnt%2==1 ? cnt-1 : cnt) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double tmp = 100.0;
    ll X; cin >> X;
    ll cnt = 0;
    while (true){
        if ((ll)(tmp) >= X){break;}
        tmp = floor(tmp * 1.01);
        cnt++;
    }
    cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(u==s){
        printf("%d %d\n",a-1,b);
        return 0;
    }
    else{
        printf("%d %d\n",a,b-1);
        return 0;
    }
}

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

int main(){
  long long int n,a,b;
  cin >> n >> a >> b;
  if(a>b) cout << 0 << endl;
  else if(a<b&&n==1) cout << 0 << endl;
  else if(a==b&&n==1) cout << 1 << endl;
  else cout << (b-a)*(n-2) + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long x = in.nextLong();
        long start = 100;
        int days = 0;
        while (start + start / 100l <= x) {
            start += start / 100l;
            days++;
        }
        if (start < x) {
            days++;
        }
        out.println(days);
        out.close();
    }
}


Measured memory_bytes: 27080
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

#define UF_ROOT ((size_t)1000000)

size_t uf[100000];

static size_t uf_GetRootIdx(const size_t a) {
    if (uf[a] == UF_ROOT) {
        return a;
    }
    else {
        const size_t rt = uf_GetRootIdx(uf[a]);
        uf[a] = rt;
        return rt;
    }
}

static void uf_Append(const size_t a, const size_t b) {
    const size_t aRoot = uf_GetRootIdx(a);
    const size_t bRoot = uf_GetRootIdx(b);

    if (aRoot != bRoot) {
        uf[aRoot] = bRoot;
    }
}

int main(void) {
    size_t N, M;

    scanf("%zu %zu\n", &N, &M);

    for (size_t i = 0; i < N; i++) {
        uf[i] = UF_ROOT;
    }

    for (size_t i = 0; i < M; i++) {
        size_t x, y, z;
        scanf("%zu %zu %zu", &x, &y, &z);
        x--;
        y--;
        if (i < M - 1) {
            scanf("\n");
        }

        uf_Append(x, y);
    }

    size_t cnt = 0;

    for (size_t i = 0; i < N; i++) {
        if (uf[i] == UF_ROOT) {
            cnt++;
        }
    }

    printf("%zu", cnt);

    return 0;
}


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

using namespace std;

class info {
public:
  int val, weight;
  char type;
  long date;
  string name;

  info(){};
  info(int v, int w, char t, long d, string s) {
    val = v;
    weight = w;
    type = t;
    date = d;
    name = s;
  }

  friend ostream& operator<<(ostream& os, const info& d);

  bool operator<(const info& right) const {
    if (val != right.val) {
      return val < right.val;
    }
    if (weight != right.weight) {
      return weight < right.weight;
    }
    if (type != right.type) {
      return type < right.type;
    }
    if (date != right.date) {
      return date < right.date;
    }
    if (name != right.name) {
      return name < right.name;
    }
    return 1;
  }
};

ostream& operator<<(ostream& os, const info& d) {
  os << d.val << " " << d.weight << " " << d.type << " " << d.date << " " << d.name;
  return os;
}

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<info> vec(n);

  int v, w;
  char t;
  long d;
  string s;

  for (int i = 0; i < n; i++) {
    cin >> v >> w >> t >> d >> s;
    // cout << v << " " << w << " " << t << " " << d << " " << s << endl;
    vec[i] = info(v, w, t, d, s);
  }

  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    cout << vec[i] << endl;
  }
}




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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = int(2e5) + 5;
const int inf = (int)1e9 + 7;


string s;
int cnt[27];

int main(){
  cin >> s;
  for(char i : s){
    cnt[i - 'a']++;
  }
  int n = (int)s.size();
  ll ans = n * (n + 1ll) / 2;
  for(int i = 0; i < 26; ++i){
    ans -= cnt[i] * (cnt[i] + 1ll) / 2;
  }
  cout << ans + 1;
  return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}



void solve(){

    ll n,mm;
    cin>>n>>mm;

    vec v;
    v.pb(-1);
    loop(i,0,n)
    {
        ll x; cin>>x; v.pb(x);
    }
    ll cnt[n+1]{0};

    loop(i,0,mm){
        ll a,b;
        cin>>a>>b;
        if(v[a]>=v[b]){
            cnt[b]=-1;
        }
        if(v[a]<=v[b]){
            cnt[a]=-1;
        }
    }

    ll ans=0;
    loop(i,1,n+1){
        if(cnt[i]==0)
            ans++;
    }

    cout<<ans;


    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 5128
import math
A,B = map(int,input().split())
minA=math.ceil(float(A  )*100/8) 
minB=math.ceil(float(B  )*100/10)
maxA=float(A+1)*100/8
maxB=float(B+1)*100/10

print(max(minA,minB)) if max(minA,minB)<min(maxA,maxB) else print(-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int m = p[0];
  int count = 1;
  for (int i = 1; i < n; i++) {
    if (m >= p[i]) {
      count++;
      m = p[i];
    }
  }
  cout << count <<endl;
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int X;
  cin >> X;
  ll sum = 0;
  for (ll i = 1; i < 1000000; i++) {
    sum += i;
    if (sum >= X) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int a[1000000];

int  binary_search(int target, int right){
    int mid, left;
    left = 0;
    while(left < right){
    mid = (right + left) / 2;
    if (target == a[mid]) {
        return 1;
    } else if (target < a[mid]) {
        right = mid;
    } else {
        left = mid + 1;
    }
    }
    return 0;
    }

int main(){
   int b, c, d, i, j, count;
   count = 0;
   
   scanf("%d", &c);
   for (i = 0; i < c; i++){
      scanf("%d", &a[i]);
   }
   scanf("%d", &d);
   for(i = 0; i < d; i++){
      scanf("%d", &b);
      if (binary_search(b, c) == 1){
        count++;
      }
   }
   printf("%d\n", count);
   
        
    
    return 0;
}



Measured memory_bytes: 2108
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
// sort(ALL(v), [](auto const& lhs, auto const& rhs) { return lhs > rhs; /* 左の方が大きい...というイメージ。*/ });
// --------------------------------------------------------------------------------------------- //

static const int MAX = 100001;
static const ll MOD = 1000000007;


int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int M, K; cin >> M >> K;
	if(M == 0 && K == 0){
		cout << 0 << " " << 0 << endl;
		return 0;
	}
	if(M == 1 && K == 1){
		cout << -1 << endl;
		return 0;
	}
	int lim = 2 << (M-1);
	vector<int> v;
	if(K == 0){
		rep(i, lim){
			if(i) cout << " ";
			rep(_, 2){
				if(_) cout << " ";
				cout << i;
			}
		}
		cout << endl;
		return 0;
	}
	if(K >= lim){
		cout << -1 << endl;
		return 0;
	}
	else{
		rep(i, lim){
			if(i == K) continue;
			v.push_back(i);
		}
		v.push_back(K);
		rrep(i, lim){
			if(i == K) continue;
			v.push_back(i);
		}
		v.push_back(K);
	}
	rep(i, v.size()){
		if(i) cout << " ";
		cout << v[i];
	}
	cout << endl;

	return 0;
}


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

if n == 2:
    print(abs(a[1] - a[0]))
    exit()

s = [0]

for i in range(n):
    s.append(s[-1]+a[i])

s = s[1:]

ma = s[-1]

ans = 10 ** 18


for i in s[:-1]:
    ans = min(ans, abs(ma-2*i))

print(ans)

Measured memory_bytes: 24820
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	int a[n+2];
	a[0]=0;
	a[n+1]=0;
	int b[n+1],sumb=0;
	for(int i=1; i<n+1; i++){
		cin >> a[i];
	}
	for(int i=0; i<n+1; i++){
		b[i] = abs(a[i]-a[i+1]);
		sumb+=b[i];
	}
	for(int i=0; i<n; i++){
		cout << sumb-(b[i]+b[i+1])+abs(a[i]-a[i+2])<<"\n";
	}
	return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
#define intscan(x) {scanf("%d", &x);}
#define Ntimes(N) for(int i=0; i<N; i++)
#define min(x,y) (((x)<(y)) ? (x) : (y))
#define max(x,y) (((x)>(y)) ? (x) : (y))
typedef int* intarray;
typedef char* string;

int main(){
    int N, ans = 0;
    intscan(N);
    int* V = new int[N];
    int* C = new int[N];
    Ntimes(N) intscan(V[i]);
    Ntimes(N) intscan(C[i]);
    Ntimes(N) ans += (V[i]>C[i]) ? V[i]-C[i] : 0;
    printans(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int dp[1048580];
int need1[21],need2[21];
int put[1048580],go[1048580][21];
int n,m,k;
int main()
{     int i,j,p,q,a,b,c;
      scanf("%d%d%d",&n,&m,&k);
      for(i=1;i<=k;i++){
      	scanf("%d%d%d",&a,&b,&c);
      	a--,b--;
      	need1[a]|=(1<<b);
      	need2[a]|=(1<<b)*c;
      }
      n--;
      memset(go,-1,sizeof(go));
      memset(put,-1,sizeof(put));
      for(i=0;i<(1<<n);i++){
      	 int num=0;
         for(j=0;j<n;j++)
            if(i&(1<<j)){
              if(j>0&&!(i&(1<<(j-1)))){
                go[i][num]=i^(1<<j)^(1<<(j-1));
              }
              num++;
            }
      }
      for(i=0;i<(1<<n);i++)
         for(j=n-1;j>=0;j--){
            if((i&(1<<j)))continue;
            put[i]=i^(1<<j);
            break;
		 }
      dp[0]=1;
      for(i=0;i<m;i++){
         for(j=0;j<(1<<n);j++)
		    if(put[j]){
              dp[put[j]]+=dp[j];
              dp[put[j]]%=1000000007;
         }
         for(p=0;p<n;p++)
            for(j=(1<<n)-1;j>=0;j--)
			   if(go[j][p]!=-1){
                 dp[go[j][p]]+=dp[j],
                 dp[go[j][p]]%=1000000007;
               }
         for(j=0;j<(1<<n);j++)
            if((j&need1[i])!=need2[i])
              dp[j]=0;
      }
      int ans=0;
      for(i=0;i<(1<<n);i++)
         ans+=dp[i],
         ans%=1000000007;
      printf("%d\n",ans%1000000007);
	  return 0;
}


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

int main() {
  int X, A, B, C, D;
  cin >> X;
  A=X/1000;
  B=(X-A*1000)/100;
  C=(X-A*1000-B*100)/10;
  D=X%10;
  
  if(A+B+C+D==7)cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  else if(A-B+C+D==7)cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  else if(A+B-C+D==7)cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  else if(A+B+C-D==7)cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  else if(A-B-C-D==7)cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  else if(A+B-C-D==7)cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  else if(A-B+C-D==7)cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  else if(A-B-C+D==7)cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;

}

Measured memory_bytes: 3552
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

ll n, m, ans;

int main()
{
    sf("%lld%lld", &n, &m);
    if (n >= m / 2) {
        pf("%lld\n", m/2);
    }
    else {
        ans = n;
        m -= (n * 2);
        ans += (m/4);
        pf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.chomp.split().map(&:to_i)

answer = 0
count = 0

(n-1).times do |i|
  if h[i] >= h[i+1]
    count += 1
  else
   count = 0
  end
 answer = count if count > answer
end

puts answer

Measured memory_bytes: 9604
#include <iostream>

using namespace std;
int main()
{

    int r,m;
    cin>>r>>m;
    if(r>=1 && r<=m && m<=20){
    if(m%r==0)
    {
        cout<<m+r;
    }
    else{
        cout<<m-r;
    }}
    else{
        cout<<"wrong";
    }
    return 0;
}

Measured memory_bytes: 256
def N(Dice):
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E(Dice):
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W(Dice):
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S(Dice):
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
def DICE(Dice,Dice2):
    if (Dice[0] in Dice2)==False:
        """print('No')"""
        return 0
    else:
        for j in range(6):
            if j%2==0:
                N(Dice2)
            else:
                W(Dice2)
            for i in range(4):
                N(Dice2)
                W(Dice2)
                S(Dice2)
                if Dice==Dice2:
                    break
            if Dice==Dice2:
                break
    if Dice==Dice2:
        """print('Yes')"""
        return 1
    else:
        """print('No')"""
        return 0
cnt=0             
a=int(input())
Dice=[i for i in range(a)]
for i in range(a):
     Dice[i]=[int(i) for i in input().split()]
for i in range(a-1):
    for j in range(i+1,a):
        cnt+=DICE(Dice[i],Dice[j])
if cnt==0:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 7836
#include <stdio.h>
#include <stdlib.h>

int main() {
  int i;
  int j;
  int n;
  int key;
  int *a;

  /* input the array length */
  scanf("%d", &n);

  a = (int *)malloc(n * sizeof(int));

  /* make an array */
  for(i = 0; i < n; i++) {
    scanf("%d" ,&a[i]);
    printf("%d", a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");

  /* sorting */
  for(i = 1; i < n; i++) {
    key = a[i];
    /* insert a[i] into the sorted sequence a[0,....,j-1] */
    j = i - 1;
    while((j >= 0) && (a[j] > key)) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;

    /* print the array*/
    for(j = 0; j < n; j++) {
      printf("%d", a[j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
    
  }
  
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> a(N + 1, vector<int>(3 + 1));
  for (int i = 1; i <= N; i++) cin >> a[i][1] >> a[i][2] >> a[i][3];
  vector<vector<int>> dp(N + 1, vector<int>(3 + 1));
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= 3; j++)
      for (int k = 1; k <= 3; k++)
        if (j != k) dp[i][k] = max(dp[i - 1][j] + a[i][k], dp[i][k]);
  cout << max(max(dp[N][1], dp[N][2]), dp[N][3]) << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;
    while(1) {
        scanf("%d %c %d\n", &a, &op, &b);
        switch(op) {
        case '+':
            printf("%d\n", a+b);
            break;
        case '-':
            printf("%d\n", a-b);
            break;
        case '*':
            printf("%d\n", a*b);
            break;
        case '/':
            printf("%d\n", a/b);
            break;
        case '?':
            goto end;
        default:
            goto end;
        }
    };
end:
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

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

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int K, T, ans=0;
	int a[1005];
	int mx = 0, sum=0;

	cin >> K >> T;
	rep(i,T){
		cin >> a[i];
		chmax( mx, a[i] );
		sum += a[i];
	}
	
	ans = mx - (sum - mx) - 1;
	chmax(ans, 0);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD = 1e9+7;
int N, M;

ll fact(ll a) {
  if (a == 0) return 1;
  return a * fact(a-1) % MOD;
}

int main() {
  cin >> N >> M;

  if (abs(N-M) > 1) {
    cout << 0 << endl;
  } else {
    if (N != M) cout << fact(N) * fact(M) % MOD << endl;
    else cout << fact(N) * fact(M) % MOD * 2 % MOD << endl;
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

int main(){
  int N, T;
  std::cin >> N >> T;
  std::vector<int> A_arr(N);
  for(int i = 0; i < N; i++) std::cin >> A_arr[i];

  int max_diff = 0, n_diff = 0;
  int p_min = A_arr[0];
  for(int i = 1; i < N; i++){
    int diff = A_arr[i]-p_min;
    if(diff > max_diff){
      max_diff = diff;
      n_diff = 1;
    }else if(diff == max_diff){
      n_diff++;
    }
    p_min = std::min(p_min, A_arr[i]);
  }

  std::cout << n_diff << std::endl;

  return 0;
}



Measured memory_bytes: 640
A, B, C, X, Y = [int(x) for x in raw_input().split()]
s = 0
p = min(X, Y)
X -= p
Y -= p
s += p * min(A+B, 2*C)
s += X * min(A, 2*C)
s += Y * min(B, 2*C)
print s

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

int output(int t,int a[10]);

int main()
{
	int n,t;
	while(scanf("%d",&n)!=EOF)
	{
		if(n>=1024||n<0)
		{
		}
		else
		{
			int a[10]={0};
			double x=0;
			t=0;

			for(x;x<10;x++)
			{
				int y;
				y=pow(2,x);

				if(n%(2*y)==y)
				{
					a[t]=y;
					t++;
					n-=y;
				}
				if(n==0)
				{
					for(int z=0;z<t;z++)
					{
						if(z==(t-1))
						{
							printf("%d\n",a[z]);
						}
						else
						{
							printf("%d ",a[z]);
						}
					}
					break;
				}
			}
		}
	}
}

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

int main(){
    int n,m; cin >> n >> m;
    vector<int> AC(n,0);
    vector<int> WA(n,0);
    for(int i=0;i<m;i++){
        int p; cin >> p;
        string s; cin >> s;
        if(s=="AC"){
            if(AC[p-1]==0){
                AC[p-1]=1;
            }
        }else{
            if(AC[p-1]==0){
                WA[p-1]++;
            }
        }
    }
    int ac = 0, wa = 0;
    for(int i=0;i<n;i++){
        ac+=AC[i];
        if(AC[i]==1){
            wa+=WA[i];
        }
    }
    cout << ac << " " << wa << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e3+5;
const int MOD=1e9+7;

int n, a, b, c, d;
int cache[N][N], cache2[N][N];
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int num(int r, int take)
{
	int &ans=cache2[r][take];
	if(ans!=-1)
		return ans;
	return modinv(pow(fact[r], take, MOD));
}

int dp2(int n, int r, int take)
{
	int ans=fact[n] * invfact[n-r*take];
	ans%=MOD;
	int den=num(r, take);
	ans*=den;
	ans%=MOD;
	return ans;
}

int dp(int remaining, int freq)
{
	if(remaining==0)
		return 1;
	if(freq==b+1)
		return 0;
	int &ans=cache[remaining][freq];
	if(ans!=-1)
		return ans;
	ans=dp(remaining, freq+1);
	for(int i=c;i<=d;i++)
	{
		int take=i*freq;
		if(take>remaining)
			continue;
		int ways=dp2(remaining, freq, i);
		ways*=dp(remaining-take, freq+1);
		ways%=MOD;
		ways*=invfact[i];
		ways%=MOD;
		ans+=ways;
	}
	ans%=MOD;
	return ans;
}

int32_t main()
{
	IOS;
	precompute();
	memset(cache, -1, sizeof(cache));
	memset(cache2, -1, sizeof(cache2));
	cin>>n>>a>>b>>c>>d;
	int ans=dp(n, a);
	cout<<ans;
	cerr<<(double)clock()/CLOCKS_PER_SEC;
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int d[10][10]; //d[u][v]は辺e=(u,v)のコスト,存在しないならINF(d[i][i]=0)
int n = 10; //頂点数

void warshall_floyd() {
    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int h,w; cin >> h >> w;
    rep(i,10)rep(j,10) cin >> d[i][j];
    int a[h][w];
    rep(i,h)rep(j,w) cin >> a[i][j];
    warshall_floyd();
    int ans = 0;
    rep(i,h)rep(j,w) {
        if (a[i][j]==-1) continue;
        ans += d[a[i][j]][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
import Foundation
import CoreFoundation

#if swift(>=4.0)
#else
extension String {
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map{String($0)}
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func joined(separator separator: String = " ") -> String {
        return self.map{String($0)}.joinWithSeparator(separator)
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func reverse() {
        self = self.reversed()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: Character = " ") -> [String] {
    return readLine()!.split(separator: separator)
}
func readIntSplit(by separator: Character = " ") -> [Int] {
    return readLine()!.split(separator: separator).map{Int($0)!}
}
infix operator ** { associativity right precedence 155 }    // 右結合，乗除算より強くビットシフトより弱い
func **(lhs: Int, rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
func **(lhs: Int, rhs: Double) -> Double {
    return pow(Double(lhs), rhs)
}
//func gcd(_ x: Int, _ y: Int) -> Int {
//    return y>0 ? gcd(y, x%y) : x
//}
//func lcm(_ x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // タプル配列のソート
//print("Ready")

/*************** メインプログラム ***************/

let N = readInt()!
var A = readIntSplit()
let sum = A.reduce(0){$0+$1}
let B = readIntSplit()
for i in 0..<N {
    if A[i] < B[i] {
        A[i+1] = max(A[i+1]-(B[i]-A[i]), 0)
        A[i] = 0
    } else {
        A[i] -= B[i]
    }
}
print(sum - A.reduce(0){$0+$1})


Measured memory_bytes: 11504
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	REP(i,m){
		int a;
		cin>>a;
		n-=a;
	}
	
	if(n<0) cout<<-1<<endl;
	else cout<<n<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] =x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x= Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b){return a<b ? a:b;}

int main(){
    int elaps = 0,c;
    int i,q;
    P u;
    scanf("%d %d", &n,&q);
    
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1;tail=n+1;
    
    while(head != tail){
        u = dequeue();
        c=min(q,u.t);
        u.t -=c;
        elaps += c;
        if(u.t > 0)enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    deque<char> c;
    string s;
    int q; cin >> s >> q;
    rep(i,s.size())c.push_back(s[i]);
    int t;
    bool rev = false;
    rep(i,q){
        cin >> t;
        if(t==1){
            rev = !rev;
        }
        else{ //追加
            int f; char c1;
            cin >> f >> c1;
            if(f==1){
                if(rev == false) c.push_front(c1); //先頭に追加
                else c.push_back(c1);
            }
            else {
                if(rev == false) c.push_back(c1);
                else c.push_front(c1);
            }
        }
    }
    if(rev == false){
        for(auto res = c.begin();res!=c.end();res++){
            cout << *res;
        }
    }
    else{
        for(auto res = c.rbegin();res!=c.rend();res++){
            cout << *res;
        }
    }
    cout << endl;
}


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

int main(){
  string n;
  cin >> n;
  
  if(n.at(0) == n.at(1) && n.at(1) == n.at(2)){
    cout << "Yes" <<endl;
  }
  else if(n.at(1) == n.at(2) && n.at(2) == n.at(3)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  char a,b,c;
  cin >> a >> b;
  if(a == 'H'){
    cout << b << endl;
  }else{
    if(b == 'H'){
      cout << 'D' << endl;
    }else{
      cout << 'H' << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/* Counting Characters */
#include <stdio.h>

int main()
{
    char w;
    int i, a[26] = {};
    while( scanf("%c", &w) != EOF ){
        //if(w == '\n'){ break; }
        if('a' <= w && w <= 'z'){
            a[w - 'a']++;
        }
        else if('A' <= w && w <= 'Z'){
            a[w - 'A']++;
        }
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n", i+'a', a[i]);
    }
    return 0;
}


Measured memory_bytes: 2032
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);

		int nx = stdIn.nextInt();
        int [] x = new int[nx];
        int j = 0;

            for(int i = 0; i < nx; i++){
                switch(Integer.valueOf(stdIn.nextInt())) {
                case 0:
        	    	   x[j] = stdIn.nextInt();
        		   j++;
        		   break;
                case 1:
        		System.out.println(x[stdIn.nextInt()]);
        		break;
                case 2:
        		j--;
        		x[j] = 0;
        		break;
                             }
            }

	}
}



Measured memory_bytes: 109628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,L;
    cin >>N>>L;
    vector<string>S(N);
    rep(i,N){
        cin>>S[i];
    }

    sort(all(S));

    rep(i,N){
        cout<<S[i];
    }
    cout<<endl;
    



    return 0;
    

}

Measured memory_bytes: 3576
#include <stdio.h>

int main(){
	int i, j, S;
	int X[3][3];
	for(i = 0; i < 3; i++){
		for(j = 0; j < 3; j++){
			X[i][j] = -1;
		}
	}
	scanf("%d%d%d", &X[0][0], &X[0][1], &X[1][1]);
	for(S = -100000; S <= 100000; S++){
		X[0][2] = S - X[0][0] - X[0][1];
		X[2][0] = S - X[0][2] - X[1][1];
		X[2][2] = S - X[0][0] - X[1][1];
		X[1][0] = S - X[0][0] - X[2][0];
		X[1][2] = S - X[0][2] - X[2][2];
		X[2][1] = S - X[0][1] - X[1][1];
		if(X[1][0] + X[1][1] + X[1][2] == S && X[2][0] + X[2][1] + X[2][2] == S){
			for(i = 0; i < 3; i++){
				for(j = 0; j < 3; j++){
					printf("%d ", X[i][j]);
				}
				printf("\n");
			}
			return 0;
		}
	}
}

Measured memory_bytes: 128