akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(2);
    vector<uint64_t> num_vec(0), red_vec(0), green_vec(0), white_vec(0);
    // string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, white;
    uint64_t num, result2;
    // uint64_t result;
    double length, mass, result;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    int64_t temp, temp2, temp3;
    int64_t i, j, k, l, count, n, x, y, o, size, a, b, c;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
    
    cin >> mass;

    result = 2 * mass * M_PI;

    cout << result << endl;

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 3732
n = int(input())
a = list(map(int, input().split()))
new_list = []
count = 0

for i in a:
    if i % 2 == 0:
        new_list.append(i)
    else:
        continue
for i in new_list:
    if i % 3 == 0 or i % 5 == 0:
        count += 1
if count == len(new_list):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <stdio.h>
#define INF 110001000
#define min(a, b) a<b?a:b
  
int n, m, s, g1, g2;
int gp[100][100];
  
int main(void)
{
    int i, j, k, f, t, d;
    scanf("%d %d %d %d %d", &n, &m, &s, &g1, &g2);
    while (n) {
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                gp[i][j] = INF;
            }
            gp[i][i] = 0;
        }
        for (i = 0; i < m; i++) {
            scanf("%d %d %d", &f, &t, &d);
            gp[f-1][t-1] = d;
        }
        for (k = 0; k < n; k++) {
            for (i = 0; i < n; i++) {
                for (j = 0; j < n; j++) {
                    gp[i][j] = min(gp[i][j], gp[i][k] + gp[k][j]);
                }
            }
        }
        int ans = INF;
        for (k = 0; k < n; k++) {
            ans = min(ans, gp[s-1][k] + gp[k][g1-1] + gp[k][g2-1]);
        }
        printf("%d\n", ans);
        scanf("%d %d %d %d %d", &n, &m, &s, &g1, &g2);
    }
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))

using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int n, m, a, b;
vector<int> adj[51];
vector<pi> edge;
vector<int> v(51);

int dfs(pair<int, int> p, int i)
{
    v[i]=1;
    int ret=1;
    for(auto j : adj[i])
    {
        if(p == mp(i, j)||(p.F==j&p.S==i)) continue;
        if(!v[j])
        {
            ret += dfs(p, j);
        }
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
        edge.pb({a, b});
    }
    int ans=0;
    for(auto p : edge)
    {
        v.clear(); v.resize(51);
        int x = dfs(p, 1);
        if(x!=n) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	
	cin>>N>>K;
	
	if(K != 1)cout<<N-K<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const int N=500005,M=998244353;
int n,m,i,j,ans,vis[305];
bitset<305> p[305],a[305];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
		{
			int t;
			scanf("%d",&t);
			a[i][j-1]=t;
		}
	for(i=1;i<=n;i++)
	{
		for(j=m-1;j>=0;--j)
			if(a[i][j])
				if(vis[j]==0)
				{
					p[j]=a[i];
					vis[j]=1;
					break;
				}
				else
					a[i]^=p[j];
		if(j<0)
			ans++;
	}
	cout<<((qpow(2,n)-qpow(2,ans))*qpow(2,m-1)%M+M)%M;
}


Measured memory_bytes: 256
from collections import Counter

S = input()
T = input()

S_cnt = Counter(S).most_common()
T_cnt = Counter(T).most_common()

if len(S_cnt) != len(T_cnt):
    print('No')
else:
    for i in range(len(S_cnt)):
        if S_cnt[i][1] != T_cnt[i][1]:
            print('No')
            exit()
    print('Yes')

Measured memory_bytes: 4016
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

template<class T>
class lazySegmentTree{
private:
    vector<T> dat;
    vector<T> lazy;
    int _size;  //the number of leaves
    T _init;
    
public:
//    lazySegmentTree( vector<T> vec, T init = numeric_limits<T>::max() ): _init(init){
//        int size = vec.size();
//        if(size==0)return ;
//        
//        _size = 1;
//        while(_size<size)_size*=2;
//        dat.resize(_size*2);
//        rep(i,vec.size())dat[i+_size] = vec[i];
//        lazy.resize(_size*2,_init);
//    }
    
    lazySegmentTree( int size, T init = numeric_limits<T>::max() ): _init(init){
        if(size==0)return ;
        
        _size = 1;
        while(_size<size)_size*=2;
        
        dat.resize(_size*2,_init);
        lazy.resize(_size*2,_init);
    }
    
    
    void eval(int num, int l, int r){
        if(lazy[num]==0) return ;
        dat[num] += lazy[num];
        
        if(r-l>1){  //?????§?????????
            lazy[num*2] += lazy[num]/2;
            lazy[num*2+1] += lazy[num]/2;
        }
        lazy[num] = 0;
    }
    
    
    
    T update(int s, int t, T x, int num=1, int l=0, int r=-1){
        if(r==-1)r =_size;
        
        eval(num,l,r);
        
        if(r<=s || t<=l) return _init ;   //????±??????????
        //        if(s<=l && r<=t) lazy[num] += x * (r-l);
        if(s<=l && r<=t){
            lazy[num] += x * (r-l);
            eval(num,l,r);
        }
        else{
            update(s, t, x, num*2, l, (l+r)/2);
            update(s, t, x, num*2+1, (l+r)/2, r);
            dat[num] = dat[num*2] + dat[num*2+1];
        }
        return dat[num];
    }
    
    
    T find(int s, int t, int num=1, int l=0, int r=-1){
        if(r==-1)r = _size;
        
        eval(num,l,r);
        
        
        if(r<=s || t<=l) return _init;  //????±??????????
        if(s<=l && r<=t) return dat[num];
        else{
            return find(s, t, num*2, l, (l+r)/2) + find(s, t, num*2+1, (l+r)/2, r);
        }
    }
    
    int size(){ return _size; }
};



signed main(){
    int n,q;
    cin>>n>>q;
    
    lazySegmentTree<int> seg(n, 0);
    
    rep(i,q){
        int type,s,t,x;
        cin>>type;
        if(type==0){
            cin>>s>>t>>x;
            s--;
            seg.update(s,t,x);
        }else{
            cin>>s>>t;
            s--;
            cout<<seg.find(s,t)<<endl;
        }
    }
}

Measured memory_bytes: 7024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
typedef long long ll;
using namespace std;
const int maxn = 200009;
int n,a[maxn];
ll f[maxn][2][3];
int main(){
    scanf("%d",&n);
    for(int i = 0; i <= n; i++){
        f[i][0][0] = f[i][0][1] = f[i][0][2] = f[i][1][0] = f[i][1][1] = f[i][1][2] = -1e17;
    }
    f[0][0][0] = 0;
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    for(int i = 1; i <= n; i++){
        f[i][0][0] = f[i-1][1][0];
        f[i][0][1] = max(f[i-1][0][0],f[i-1][1][1]);
        f[i][0][2] = max(f[i-1][0][1],f[i-1][1][2]);
        f[i][1][0] = f[i-1][0][0] + a[i];
        f[i][1][1] = f[i-1][0][1] + a[i];
        f[i][1][2] = f[i-1][0][2] + a[i];
    }
    if(n % 2 == 0) printf("%lld",max(f[n-1][1][0],f[n][1][1]));
    else printf("%lld",max(max(f[n-2][1][0],f[n-1][1][1]),f[n][1][2]));
    return 0;
}

Measured memory_bytes: 13984
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long double a[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort (a + 1, a + n + 1);
	long double sum = (a[1] + a[2]) / 2.0;
	for (int i = 3; i <= n; i++) {
		sum = (a[i] + sum) / 2;
	}
	printf("%.10Lf\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
//Can you get AC?
using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    bool flag = false;
    REP(i,s.length()-1){
        if(s.substr(i,2)=="AC") flag = true;
    }
    if(flag) print("Yes");
    else print("No");
    return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};


int main(){
    fIO


    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1) return cout << 1, 0;
    ll uper = (w + 1LL) / 2LL;
    cout << ((h + 1LL) / 2LL) * uper + (h - (h + 1LL) / 2LL) * (w - uper);
}









Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=[0]*(n+1)

for i in a:
    x[i]+=1
s=sum([x[i]*(x[i]-1)//2 for i in range(1,n+1)])


for i in range(n):
    k=a[i]
    p=x[k]*(x[k]-1)//2
    q=(x[k]-1)*(x[k]-2)//2
    print(s-p+q)

Measured memory_bytes: 24996
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;

  for(int i=a; i< a+k; i++){
    if( i > b ) break;
    printf("%d\n", i);
  }
  for(int i=b-k+1; i<= b; i++){
    if(i<a+k) continue;
    printf("%d\n", i);
  }
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    ll res = 1;

    while (res * res <= n)
        res++;

    res--;

    cout << res * res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,flg,i,max;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)  scanf("%d",&a[i]);
	flg=0; max=1;
	for(i=0;i<n;i++){
		max--; a[i]=a[i]/10;
		if(max<=a[i]) max=a[i];
		if(max==0){
			flg=1; break;
		}
	}
	max=0;
	if(flg==0){
		for(i=n-1;i>=0;i--){
			if(max<=a[i]) max=a[i];
			if(max==0){
				flg=1; break;
			}
			max--;
		}
	}
	if(flg==0) printf("yes\n");
	else printf("no\n");
	return 0;
	}


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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
long long p = 200003;
long long r[200002];
long long m[200003];
int n;
long long x, ans;
long long a[200002];
double pi = 3.14159265358979323846;
void fft(double* XR, double* XI, double* SP, int FFN) {
	if (FFN == 0) {}
	else {
		long long L = 1;
		L <<= FFN;
		for (long long I = 0; I < L; I++) {
			if (I % 2) SP[I / 2 + L / 2] = XR[I];
			else SP[I / 2] = XR[I];
		}
		for (long long I = 0; I < L; I++) {
			XR[I] = SP[I];
		}
		for (long long I = 0; I < L; I++) {
			if (I % 2) SP[I / 2 + L / 2] = XI[I];
			else SP[I / 2] = XI[I];
		}
		for (long long I = 0; I < L; I++) {
			XI[I] = SP[I];
		}
		fft(XR, XI, SP, FFN - 1);
		fft(&XR[L / 2], &XI[L / 2], SP, FFN - 1);
		double T[6];
		for (long long I = 0; I < L / 2; I++) {
			T[0] = XR[I]; T[1] = XI[I];
			T[2] = XR[I + L / 2]; T[3] = XI[I + L / 2];
			T[4] = T[2] * cos((2 * I * pi) / L) - T[3] * sin((2 * I * pi) / L);
			T[5] = T[2] * sin((2 * I * pi) / L) + T[3] * cos((2 * I * pi) / L);
			XR[I] = T[0] + T[4];
			XI[I] = T[1] + T[5];
			XR[I + L / 2] = T[0] - T[4];
			XI[I + L / 2] = T[1] - T[5];
		}
	}
}
double b[1024 * 512];
double c[1024 * 512];
double d[1024 * 512];
int main() {
	r[0] = 1;
	for (int i = 1; i < 200002; i++) {
		r[i] = r[i - 1] * 2 % p;
	}
	for (int i = 0; i < 200002; i++) {
		m[r[i]] = i;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &x);
		if (x != 0) {
			a[m[x]]++;
		}
	}
	for (int i = 0; i < 200002; i++) {
		b[i] = a[i];
		ans -= a[i] * (r[i] * r[i] % p);
	}
	fft(b, c, d, 19);
	for (int i = 0; i < 1024 * 512; i++) {
		d[i] = -2 * b[i] * c[i];
		b[i] = b[i] * b[i] - c[i] * c[i];
		c[i] = d[i];
		d[i] = 0;
		b[i] /= 1024 * 512;
		c[i] /= 1024 * 512;
	}
	fft(b, c, d, 19);
	for (int i = 0; i < 400003; i++) {
		x = b[i] + 0.5;
		ans += r[i % 200002] * x;
	}
	printf("%lld\n", ans / 2);
}

Measured memory_bytes: 19488
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

string ground[12];
int dx[4] = {0, 1, -1, 0};
int dy[4] = {-1, 0, 0, 1};

void dfs(int i, int j) {
	if (ground[i][j] == '0')
		return;
	ground[i][j] = '0';
	for (int k = 0; k < 4; k++) {
		int ni = i + dx[k];
		int nj = j + dy[k];
		if (0<=ni && ni<12 && 0<=nj && nj<12)
			if (ground[ni][nj] == '1')
				dfs(ni, nj);
	}
}

int main() {
	string s;
	while (cin >> ground[0]) {
		int ans = 0;
		for (int i = 1; i < 12; i++)
			cin >> ground[i];
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				if (ground[i][j] == '1') {
					dfs(i, j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int N;cin>>N;
    int info[N][N];
    rep(i,N){
        string S;cin>>S;
        rep(j,N){
            info[i][j]=S[j]-48;
        }
    }
    vector<int> a[N];
    rep(i,N){
        rep(j,N){
            if(info[i][j])a[i].push_back(j);
        }
    }

    //二部グラフ判定
    int color[N];
    bool ok=true;
    rep(i,N)color[i]=-1;
    queue<int> que;
    que.push(0);color[0]=0;
    while(que.size()){
        int u=que.front();que.pop();
        rep(j,N){
            if(info[u][j]){
                if(color[j]==color[u])ok=false;
                else if(color[j]==-1){
                    color[j]=!color[u];
                    que.push(j);
                }
            }
        }
    }


    if(ok==false)cout<<-1<<endl;
    else{ //warshall_floyd
        rep(i,N){
            rep(j,N){
                if(i!=j and info[i][j]==0)info[i][j]=INF;
            }
        }
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(info[i][k]==INF or info[k][j]==INF)continue;
                    info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
                }
            }
        }
        int ans=0;
        rep(i,N){
            rep(j,N){
                ans=max(ans,info[i][j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#define pi 3.14159265359
int main()
{
          double r,A,C;
          scanf("%lf",&r);
          A=pi*r*r;
          C=2*pi*r;
          printf("%lf %lf",A,C);
          return 0;

}



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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    int K;
    string S;
    cin >> K >> S;

    if(S.length() <=K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }
}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 3628
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;

int main(void) {
	int N, Y;
	cin >> N >> Y;

	for (int x = 0; x <= N; ++x) {
		int _Y = Y - x * 10000;
		int _N = N - x;
		for (int y = 0; y <= _N; ++y) {
			int z = _N - y;
			if (x + y + z != N) {
				continue;
			}

			int res = _Y - y * 5000 - z * 1000;
			if (res == 0) {
				cout << x << " " << y << " " << z << "\n";
				return 0;
			}
		}
	}

	OUT("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.next().split("");
        
        int result = 0;
        for (String s : str) {
            if (s.equals("+")) {
                result++;
            } else {
                result--;
            }
        }
      
        System.out.println(result);
    }
}


Measured memory_bytes: 35760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j,ss=0;
    cin>>a>>b;
    int s[b];
    for(i=0;i<b;i++)
    {
        cin>>s[i];
        ss+=s[i];
    }
    if(ss>a)
        cout<<"-1"<<endl;
    else
        cout<<a-ss<<endl;
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define DEBUG false
#pragma GCC optimize "trapv"

using namespace std;

int32_t main()
{
 nitro;
 int n;
 cin>>n;
 int dp[3005][3005];
 std::vector<int> v(n);
 for(int& x:v)
 cin>>x;
 for(int l=n-1;l>=0;--l)
 {
     for(int r=l;r<n;++r)
     {
         if(l==r)
         dp[l][r]=v[l];
         else
         dp[l][r]=max(v[l]-dp[l+1][r],v[r]-dp[l][r-1]);
 }
 }
 cout<<dp[0][n-1]<<'\n';
return 0;
}

Measured memory_bytes: 70784
N, D = [int(x) for x in input().split()]
grid = []
for _ in range(N):
    grid.append([int(x) for x in input().split()])
count = 0    
for i in range(N - 1):
    for j in range(i+1, N):
        curr_dist = 0
        for k in range(D):
            curr_dist += (grid[i][k] - grid[j][k]) * (grid[i][k] - grid[j][k])
        for k in range(128):
            if curr_dist == (k * k):
                count += 1
                break
print(count)            
            
            


Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main(A, N):
    d1 = defaultdict(int)
    d2 = defaultdict(int)

    for i, a in enumerate(A):
        d1[i+a] += 1
    
    for i, a in enumerate(A):
        d2[i-a] += 1

    cnt = 0
    for x in list(d1.keys())+list(d2.keys()):
        cnt += d1[x]* d2[x]

    print(cnt//2)
    pass

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    main(A, N)


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    int n;
    cin>>n;

    vector<ll> A(n,0);

    for(int i=0;i<n;++i)    cin>>A[i];

    ll ans = A[0];

    for(int i=1;i<n;++i)    ans = gcd(ans, A[i]);

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 3988
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
K=[0 for i in range(N)]
for i in range(N):
    for p in G[i]:
        K[p]+=1
q=deque(i for i in range(N) if K[i]==0)
res=[]
while q:
    v1=q.popleft()
    res.append(v1)
    for v2 in G[v1]:
        K[v2]-=1
        if K[v2]==0:
            q.append(v2)
if len(res)==N:
    print(-1)
else:
    print(0)



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
        cout << 0 << endl;
        return 0; 
    }
    if (A == B && B == C && C == A) {
        cout << -1 << endl;
        return 0;
    }
    int div_count = 0;
    while (true) {
        if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) break;
        int half_A = A / 2, half_B = B / 2, half_C = C / 2;
        A = half_B + half_C;
        B = half_C + half_A;
        C = half_A + half_B;
        div_count++;
    }
    cout << div_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int N, R;
    cin >> N >> R;
    if(N >= 10) {
        cout << R << endl;
    } else {
        cout << (R + 100*(10-N)) << endl;
    }
}

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

int insertion_sort(int A[], int N) {
    int v, j;
    for (int i = 0; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A [j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        cout << A[0];
        for (int i = 1; i < N; i++) {
            cout << ' ' << A[i];
        }
        cout << endl;
    }
    return 0;
}

int main() {
    int N;
    int A[100];

    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    insertion_sort(A, N);

    return 0;

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N), D(N + 1);
    rep(i, N)
    {
        cin >> L[i];
    }
    D[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        D[i] = D[i - 1] + L[i - 1];
    }
    int count = 0;
    rep(i, N + 1)
    {
        if (X >= D[i])
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int64_t n;
    cin>>n;
    string s="";
    while(n!=0){
        int k = n%26;
        //cout<<char('a'+k-1);
        if(k==0){
            s += 'z';
            n -= 26;
            n /= 26;
        }
        else{
            s += char('a'+k-1);
            n /= 26;
        }
        
    }
    Re(s);
    cout<<s<<endl;
}

Measured memory_bytes: 3640
import numpy as np
from numba import njit


n = int(input())
arr = np.array(list(map(int, input().split())))


@njit
def solve(arr):
    cnt = np.bincount(arr)
    for i in range(2, 10**6 + 1):
        if (cnt[i::i]).sum() > 1:
            return False
    else:
        return True


if np.gcd.reduce(arr) != 1:
    print("not coprime")
elif solve(arr):
    print("pairwise coprime")
else:
    print("setwise coprime")

Measured memory_bytes: 208192
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll n,num;
	cin >> n;
	ll MAX,MIN;
	cin >> num;
	MIN = num;
	MAX = -1145141919;
	//cout << num<<MIN << MAX << endl;
	REP(i,n-1){
		cin >> num;
		
		MAX = (ll)max(MAX,num-MIN);
		MIN = (ll)min(MIN,num);
		//cout << num<<MIN << MAX << endl;
	}
	cout << MAX << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  ll ac = 0, wa = 0, tle = 0, re = 0;
  for (ll i = 0; i < N; ++i) {
    string temp;
    cin >> temp;
    if (temp == "AC") {
      ac += 1;
    }
    else if (temp == "WA") {
      wa += 1;
    }
    else if (temp == "TLE") {
      tle += 1;
    }
    else {
      re += 1;
    }
  }
  cout << "AC x " << ac << "\n";
  cout << "WA x " << wa << "\n";
  cout << "TLE x " << tle << "\n";
  cout << "RE x " << re << "\n";
}


Measured memory_bytes: 3680
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

			final int n = sc.nextInt();

			List<String> list = new ArrayList<>();
			for(int i=0;i<n;i++) {
				list.add(sc.next());
			}

			int ac=0;
			int wa=0;
			int tle=0;
			int re=0;
			for(String s: list) {
				if(s.equals("AC")) {
					ac++;
				}else if(s.equals("WA")) {
					wa++;
				}else if(s.equals("TLE")) {
					tle++;
				}else if(s.equals("RE")) {
					re++;
				}else {
					continue;
				}
			}

			System.out.println("AC x " + ac);
			System.out.println("WA x " + wa);
			System.out.println("TLE x " + tle);
			System.out.println("RE x " + re);

		}
	}
}

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

using namespace std;

int main()
{
    int t,i,z,x;
    string s,l,r;
    multimap<string,int>m;
    multimap<string,int>::iterator it,ut;
    cin>>t;
    for (i=1;i<=t;++i){

        cin>>x;
        if (x==0){

            cin>>s>>z;
            m.insert(make_pair(s,z));

        }
        else if (x==1){

            cin>>s;
            it=m.lower_bound(s);
            for (;it!=m.end() && (it->first)==s;++it){



                    cout<<(it->second)<<endl;


            }

        }
        else if (x==2){

            cin>>s;
            m.erase(s);

        }
        else if (x==3){

            cin>>l>>r;
            it=m.lower_bound(l);
            ut=m.upper_bound(r);
            //ass
            for (;it!=ut;++it){

                cout<<(it->first)<<' '<<(it->second)<<endl;

            }
        }
    }

    return 0;
}



Measured memory_bytes: 24840
#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
struct data {
  string lx;
  int len;
  bool operator < (const data &C) const {
    for(int i = 0; i < min(len, C.len); ++i) {
      if(lx[i] > C.lx[i]) return false;
      if(lx[i] < C.lx[i]) return true;
    }
    return len < C.len;
  }
  bool operator == (const data &C) const {
    if(len != C.len) return false;
    for(int i = 0; i < len; ++i)
      if(lx[i] != C.lx[i]) return false;
    return true;
  }
} a[10];
priority_queue<data> q;

char s[N];

bool check(data A) {
  int res = 0, flg = 1;
  while(!q.empty()) a[++res] = q.top(), q.pop();
  for(int i = 1; i <= res; ++i)
    if(A == a[i]) flg = 0;
  for(int i = 1; i <= res; ++i) q.push(a[i]);
  return flg;
}

int main() {
  int k;
  scanf("%s%d", s + 1, &k);
  int n = strlen(s + 1);
  for(int i = 1; i <= n; ++i) {
    string ll = "";
    for(int j = i; j <= min(n, i + k - 1); ++j) {
      ll += s[j];
      if(q.size() < k) q.push((data){ll, j - i + 1});
      else {
        if(!check((data){ll, j - i + 1})) continue;
        data h = q.top(); q.pop();
        data w = (data){ll, j - i + 1};
        if(h < w) q.push(h);
        else q.push(w);
      }
    }
  }
  data w = q.top();
  cout << w.lx << endl;
  q.pop();
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as ddict

ii=jj=0
ia,ja=[],[]
rows=ddict(int)
cols=ddict(int)
H,W,M=map(int,input().split())
tgts=set()
for _ in range(M):
    i,j=map(int,input().split())
    tgts.add((i,j))

    rows[i]+=1
    cols[j]+=1
    x=rows[i]
    if x>ii:
        ii=x
        ia=[i]
    elif x==ii:
        ia.append(i)
    y=cols[j]
    if y>jj:
        jj=y
        ja=[j]
    elif y==jj:
        ja.append(j)



ans=0
for i in ia:
    for j in ja:
        k=rows[i]+cols[j]
        if (i,j) in tgts:
            k-=1
        else:
            ans=k
            break
        ans=max(ans,k)

print(ans)


Measured memory_bytes: 180456
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll a[10], i, ans, count = 0;
	for (i = 0; i < 7; i++)
		cin >> a[i];
	if (a[0] % 2 == 1)
		count++;
	if (a[3] % 2 == 1)
		count++;
	if (a[4] % 2 == 1)
		count++;
	if (a[0]>0&&a[3]>0&&a[4]>0&&count>=2) {
		ans = 3;
      a[0]--;
		a[3]--;
		a[4]--;
	}
	else
		ans = 0;
	ans += a[0]/2*2 + a[1] +a[3]/2*2+a[4]/2*2;
	cout << ans << endl;
}

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

int n;

void solve(string s, char c) {
  if (s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char i = 'a'; i <= c; i++) solve(s + i, (i == c ? c + 1 : c));
}

int main() {
  cin >> n;
  solve("", 'a');
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    vector<ll> a(100000), b(100000);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    ll cum = 0;
    for(int i=n-1; i>=0; i--){
        a[i] += cum;
        int tmp = a[i]%b[i];
        if(tmp==0) continue;
        else cum += b[i] - tmp;
    }
    cout << cum << endl;
    return 0;
}

Measured memory_bytes: 4812
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N);
    VI A(N);
    LL sum = 0;
    REP(i, N) {
        RI(A[i]);
    }
    REP(i, N) {
        DRI(b);
        A[i] -= b;
        sum += A[i];
    }
    if (sum < 0) {
        PI(-1);
        return 0;
    }
    sort(ALL(A));
    int j = lower_bound(ALL(A), 0) - A.begin();
    int ans = N;
    while (j < N && sum >= A[j]) {
        sum -= A[j];
        ans--;
        j++;
    }
    PI(ans);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

#define INF 2001
#define NIL -2


struct node{
    int key=INF, pi=NIL, flag=0;
};

node grf[101];
int hv[101][101], n;

void search(){
    int min = INF, mini = NIL;
    for(int i=0;i<n;++i){
        if(grf[i].flag != 1 && grf[i].key < min){
            min = grf[i].key;
            mini= i;
        }
    }
    
    if(min == INF){
        return;
    }
    
    grf[mini].flag = 1;
    for(int j=0;j<n;++j){
        if((grf[j].flag != 1 && hv[mini][j] != -1) && hv[mini][j] < grf[j].key){
            grf[j].key = hv[mini][j];
            grf[j].pi = mini;
        }
    }
    
    return;
    
}

int main(){
    int total=0;
    cin >> n;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin >> hv[i][j];
        }
    }
    
    grf[0].key = 0;
    grf[0].flag = 1;
    for(int j=0;j<n;++j){
        if(hv[0][j] != -1 && hv[0][j] < grf[j].key){
            grf[j].key = hv[0][j];
            grf[j].pi = 0;
        }
    }
    
    for(int i=1;i<n;++i){
        search();
    }
    
    for(int i=0;i<n;++i){
        total+=grf[i].key;
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/04  Problem: Nagoya_univ_contest_17_e  / Link: https://agc019.contest.atcoder.jp/tasks/agc019_a  ----- */
/* ------問題------

あなたは行きつけの店、インフバリューにアイスティーを買いに来ています。
この店では、様々なサイズのボトル入りアイスティーが様々な価格で売られています。
具体的な価格は、0.25 リットルサイズが一つ Q 円、0.5 リットルサイズが一つ H 円、1 リットルサイズが一つ S 円、2 リットルサイズが一つ D 円です。各サイズの在庫は無限にあります。
あなたはちょうど N リットルのアイスティーを買いたいです。これに必要な金額は何円でしょうか？

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	VL a(4);
	FOR(i, 0, 4) {
		cin >> a[i];
	}
	cin >> N;
	LL one = LINF;
	LL two = LINF;
	one = min({ one,a[0] * 4LL,a[1] * 2LL,a[2] });
	two = min(one * 2, a[3]);
	if (N % 2 == 1)ans = N / 2 * two + one;
	else ans = N / 2 * two;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map(String::toInt)
    println(op139c(h))
}

fun op139c(h: List<Int>): Int {
    var max = 0
    var tmp = 0
    var lastNumber = 0

    for (i in h) {
        if (i <= lastNumber) tmp++ else tmp = 0
        lastNumber = i
        max = Math.max(max, tmp)
    }

    return max
}


Measured memory_bytes: 57920
n=int(input())
L=[]
a=True
for i in range(n):
  L.append(input())
if len(L)!=len(set(L)):
  print('No')
else:
  for i in range(1,len(L)):
    if L[i][0]==L[i-1][-1]:
      continue
    else:
      a=False
  if a is True:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
#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 REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                     
#define pb push_back 
#define PII pair<int,int>     
                     
#define VS vector<string>     
#define VI vector<int>        
#define ll long long int      
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {     
    int h,w;cin >> h >> w;    
    vector<char> c(w);        
    REP(i,h) {       
        REP(j,w) cin >> c[j]; 
        REP(j,w) cout << c[j];
        cout << endl;
        REP(j,w) cout << c[j];
        cout << endl;                                                                                                                    
    }                
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
vector<int>edge[N];
int n,k,u[N],v[N],d[N],sz[N],f[N],leng[N];
int lef[N],cnt_l;
bool del[N];
queue<int>lf;
int len[N];
void dfs(int x,int fa,int dep){
	d[x]=dep;
	for(int i=0;i<edge[x].size();i++){
		int vv=edge[x][i];
		if(vv==fa)continue;
		dfs(vv,x,dep+1);
	}
}
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d %d",&u[i],&v[i]);
		edge[u[i]].push_back(v[i]);
		edge[v[i]].push_back(u[i]);
	}
	if(!(k&1)){
		int ans=99999999;
		for(int i=1;i<=n;i++)d[i]=0;
		for(int i=1;i<=n;i++){
			int cnt=0;
			dfs(i,0,0);
			for(int j=1;j<=n;j++)if(d[j]>k/2)cnt++;
			ans=min(ans,cnt);
		}
		printf("%d\n",ans);
	}
	if(k&1){
		int ans=99999999;
		for(int i=1;i<n;i++){
			int cnt=0;
			dfs(u[i],v[i],0);
			dfs(v[i],u[i],0);
			for(int j=1;j<=n;j++)if(d[j]>k/2)cnt++;
			ans=min(ans,cnt);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin >> s;
	int sum = 0;
	rep(i,s.size())sum += (s[i] - '0');
	cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int L,L_MAX;
    L = L_MAX = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'T' ||  S[i] == 'G' || S[i] == 'C'){
            L++;
            L_MAX = max(L_MAX,L);
            //cout << S[i] << endl;
        }
        else{
            L = 0;
        }
    }
    cout << L_MAX << endl;
}


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

int main ()
{
    int N;
    string S;
    cin >> N >> S;
    int flag[125] = {0};
    int ans = 0;
    for(int i=1; i<N; i++)
    {
        int cnt = 0;
        for(int j=0; j<i; j++)
        {
            flag[int(S[j])] = 1;
        }

        for(int k=i; k<N; k++)
        {
            if (flag[(int)S[k]] == 1 )
            {
                cnt++;
                flag[(int)S[k]] = 0;
            }
        }

        ans = max(cnt,ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int findsum(int m){
	int sum = 0;
	while(m>0){
		sum += m%10;
		m /= 10;
	}
	return sum;
}
 
int main(){
	int n,a,b,l;
	cin >> n >> a >> b;
	int count = 0;
 
	for(int i=1;i<=n;i++){
		l = findsum(i);
		if(l>=a && l<=b) count += i;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int p[99]={};
    int q[99]={};
    int k[99]={};
    int f[99]={};
    int g[99]={};
    int a=0;
    int b=0;
    int tmp=0;
    int ans=0;
    
    k[1] = 1;
    
    cin >> n;
    
    for(int i=2; i<=n; i++){
        
        k[i] = k[i-1] * i;
        
    }
    
    for(int i=1; i<=n; i++){
        
        cin >> p[i];
        
    }
    
    for(int i=1; i<=n; i++){
        
        cin >> q[i];
        
    }
    
    for(int i=1; i<=n-1; i++){
        
        tmp = 0;
        
        for(int j=1; j<=n; j++){
            
            if(f[j]==1){
                
                continue;
                
            }
            
            if(p[i]==j){
                
                f[j] = 1;
                a += tmp * k[n-i];
                break;
                
            } else {
                
                tmp += 1;
                
            }
            
        }
        
    }
    
    for(int i=1; i<=n-1; i++){
        
        tmp = 0;
        
        for(int j=1; j<=n; j++){
            
            if(g[j]==1){
                
                continue;
                
            }
            
            if(q[i]==j){
                
                g[j] = 1;
                b += tmp * k[n-i];
                break;
                
            } else {
                
                tmp += 1;
                
            }
            
        }
        
    }
    
    ans = abs(a-b);
    
    // cout << a << endl;
    // cout << b << endl;
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256