akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if a == b && b == c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import itertools
n = int(input())
N = list(i for i in range(1,n+1))
L = itertools.permutations(N,n)
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
cnt, s, e = 0, 0, 0

for l in L:
  cnt += 1
  if a == l:
    s = cnt
  if b == l:
    e = cnt
print(abs(s-e))

  

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ta[26]={};
  for(int i=0;i<s.size();i++){
      ta[s[i]-'a']++;
  }
  for(int i=0;i<26;i++){
      if(ta[i]==0){
          char iwa=i+'a';
          cout<<iwa<<endl;
          return 0;
      }
  }
  cout<<"None"<<endl;
}


Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))
H.insert(0, 0)

ans = 0
while max(H) > 0:
    group = 0
    for i in range(1, N+1):
        if H[i-1] == 0 and H[i] > 0:
            group += 1
    ans += group
    for i in range(1, N+1):
        if H[i] > 0:
            H[i] -= 1

print(ans)



Measured memory_bytes: 39280
#include <stdio.h>

int partition(int *,int ,int );
void swap(int *, int *);

int main(){
  int i,j,n;
  int A[100000];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  j = partition(A,0,n-1);

  for(i = 0; i < n; i++){
    if(i == j) printf("[");
    printf("%d",A[i]);
    if(i == j) printf("]");
    if(i == n-1) break;
    printf(" ");
  }

  printf("\n");

  return 0;
}

int partition(int *A,int p,int r){
  int i,j,x;

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

void swap(int *A, int *B){
  int C;

  C = *A;
  *A = *B;
  *B = C;
}



Measured memory_bytes: 2156
def prime(n):
    is_prime=[True]*(n+1)
    is_prime[0],is_prime[1]=False,False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]


def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n //=f
        else:f +=2
    if n!=1:a.append(n)
    return a


P=prime(10**5)
A=[i for i in P if (i+1)//2 in P]
DP=[0]*(10**5+1)
for i in A:DP[i]=1
for i in range(1,10**5+1):
    DP[i]=DP[i-1]+DP[i]

for i in range(int(input())):
    l,r=map(int,input().split())
    print(DP[r]-DP[l-1])

Measured memory_bytes: 51416
#include<stdio.h>

int main(void){
	int kosu,a[5]={0},temp,right,temp2,left;

	scanf("%d",&kosu);

	for(temp=0;temp<kosu;temp++){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a[j]<a[j+1]){
					temp2=a[j];
					a[j]=a[j+1];
					a[j+1]=temp2;
				}
			}
		}
		right=(a[2])*(a[2])+(a[1])*(a[1]);
		
		left=(a[0])*(a[0]);
		
		if(left==right){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include<iomanip>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<vector<int>> vec(m);
	rep(i, 0, m - 1)
	{
		int k; cin >> k;
		rep(j, 0, k - 1)
		{
			int s; cin >> s;
			vec[i].push_back(s - 1);
		}
	}
	vector<int> p(m);
	rep(i, 0, m - 1)
	{
		cin >> p[i];
	}
	int res = 0;
	for (int i = 0; i < pow(2, n); ++i)
	{
		string x = "";
		for (int j = 0; j < n; ++j)
		{
			x += to_string((i >> j) & 1);
		}
		bool flag = true;
		for (int j = 0; j < m; ++j)
		{
			int cnt = 0;
			for (int y : vec[j])
			{
				if (x[y] == '1') cnt = 1 - cnt;
			}
			if (p[j] != cnt) flag = false;
		}
		if (flag) ++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <vector>

#include <iostream>
#include <vector>

using namespace std;

int main()
{
        int i;
        int n;

        vector<int> T;
        vector<int> X;
        vector<int> Y;

        int a, a1, a2, b, c;
        int s_x, s_y;
        int min;

        cin >> n;

        for (i=0; i<n; i++) {
                cin >> a;
                cin >> b;
                cin >> c;
                T.push_back(a);
                X.push_back(b);
                Y.push_back(c);

        }

        a1 = 0;
        s_x = 0;
        s_y = 0;

        for (i=0; i<T.size(); i++) {

                a2 = T[i];
                b = X[i];
                c = Y[i];

                min = (b - s_x) + (c - s_y);

                if ((a2 - a1) < min) {
                        break;
                }

                // (a2-a1) % 2 == 0 && min % 2 == 0
                // (a2-a1) % 2 == 1 && min % 2 == 1

                if (((a2-a1) % 2 == 0) && (min % 2 == 1)) {
                        break;
                }

                if (((a2-a1) % 2 == 1) && (min % 2 == 0)) {
                        break;
                }

                a1 = a2;
                s_x = b;
                s_y = c;
        }

        if (i==T.size()) {
                cout << "Yes" << endl;
        }else{
                cout << "No" << endl;
        };
}

Measured memory_bytes: 1644
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

double a[8];

void solve(){
	double dx1=a[2]-a[0];
	double dx2=a[6]-a[4];
	double dy1=a[3]-a[1];
	double dy2=a[7]-a[5];
	bool ans;
	
	if(dx1==0)ans=(dx2==0);
	else ans=(dx2!=0 && dy1/dx1==dy2/dx2);
	if(ans) puts("YES");
	else puts("NO");
}

int main(){
	li n;
	cin>>n;
	
	rin{
		rep(i,8)cin>>a[i];
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20005;
typedef long long ll;
ll a[maxn], b[maxn], n;
int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    ll sum = 0;
    ll op = 0;
    for(int i = 1; i <= n; i++){
        if(b[i] > a[i]){
            sum+=ceil((b[i] - a[i])/2.0);
        }
        op += b[i]-a[i];
    }
    if(sum <= op)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };

struct node {
	int state;
	vector<int> link;
};

vector<node> nod;

void paint(int ind, int val) {
	nod[ind].state = val;
	for (int c : nod[ind].link) {
		if (nod[c].state == -1) paint(c, val);
	}
}

int main() {
	ll N, M;
	cin >> N >> M;
	nod.resize(N);
	REP(i, 0, N)nod[i].state = -1;
	REP(i, 0, M) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		nod[a].link.push_back(b);
		nod[b].link.push_back(a);
	}
	int cur = -1;
	REP(i, 0, N) {
		if (nod[i].state == -1) {
			++cur;
			paint(i, cur);
		}
	}
	PRI(cur);
	return 0;
}

Measured memory_bytes: 10060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,m,ans,cnt[N],s[N],a[N],tot[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]++;
	for(int i=1;i<=n;i++)s[i+1]--,s[max(i-cnt[i]+1,1)]++;
	int fla=0;
	for(int i=1;i<=n;i++)
	{
		fla+=s[i];
		tot[i]=fla;
		if(!tot[i])ans++;
	}
	while(m--)
	{
		int l,r,bas;
		scanf("%d%d",&l,&r);
		bas=a[l];
		if(bas-cnt[bas]+1>0)
		{
			if(tot[bas-cnt[bas]+1]==1)ans++;
			tot[bas-cnt[bas]+1]--;
		}
		cnt[bas]--;
		if(r-cnt[r]>0)
		{
			if(tot[r-cnt[r]]==0)ans--;
			tot[r-cnt[r]]++;
		}
		cnt[r]++;
		a[l]=r;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4480
N = int(input())
B = list(map(int,input().split()))

A = [0] * N
A[0] = B[0]
for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])

A[N-1] = B[N-2]
ans = 0
for i in range(N):
    ans += A[i]
print(ans)

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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll INF = 1e14;
    vector<ll> dp(n,INF);
    for(i = 0;i < n;++i){
        auto itr = lower_bound(all(dp), a.at(i));
        *itr = a.at(i);
    }
    ll ans = lower_bound(all(dp), INF) - dp.begin();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main()
{
    int V,E;cin >> V>> E;
    vector<vector<int>> graph(V,vector<int> (V,-1));
    int u,v;
    for (int i=0;i<E;i++)
    {
        cin >> u >> v;
        cin >> graph[u][v];
    }
    vector<vector<int>> dp(1<<(V-1),vector<int> (V,INF)); //dp[s][v] sは今まで訪れた点集合、vは今いる点
    dp[0][0]=0;
    for (int i=0;i<1<<(V-1);i++) //iだけ1indexed
    {
        for (int u=0;u<V;u++)
        {
            for (int v=1;v<V;v++)
            {
                if (((i>>(v-1))&1)==0)
                {
                    if (graph[u][v]>=0)
                    {
                        //cout << (1<<(v-1)) << endl;
                        //cout << "i"<<i<< endl;
                        dp[i+(1<<(v-1))][v]=min(dp[i+(1<<(v-1))][v],dp[i][u]+graph[u][v]);
                    }
                }
            }
        }
    }
    int ans=INF;
    for (int i=1;i<V;i++)
    {
        if (graph[i][0]>=0) ans=min(ans,dp[(1<<(V-1))-1][i]+graph[i][0]);
    }
    if (ans==INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int X,Y; cin>>X>>Y;
  int ans=X%Y;
  ans=min(ans,Y-ans);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

vll calc(ll M) {
    vll res;
    for (ll x = 1; x * x <= M; x++) {
        if (M % x == 0) {
            res.push_back(x);
            res.push_back(M / x);
        }
    }

    return res;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, M;
    cin >> N >> M;
    auto div = calc(M);
    sort(div.begin(), div.end(), greater<ll>());
    ll ans = 1;
    for (auto& x : div) {
        if (M / x >= N) {
            ans = x;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        int res = 0;
        for(int i = 0; i < a.length; i++){
            if(a[i] != b[i])
                res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 41880
#include<bits/stdc++.h>
#define N 100010
#define ll long long
using namespace std;
int n;
ll a[N],b[N];
ll cnt=0;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++) {
		if(a[i]<b[i]) {
			cnt+=a[i];
			b[i]-=a[i];
			if(a[i+1]<b[i]) {
				cnt+=a[i+1];
				a[i+1]=0;
			}
			else {
				cnt+=b[i];
				a[i+1]-=b[i];
			}
		}
		else {
			cnt+=b[i];
		}
	}
	printf("%lld",cnt); 
	return 0;
}

Measured memory_bytes: 1792
import numpy as np

(N,M) = map(int,input().split())
B = np.ones(M,dtype=np.int)

for _ in range(N):
    A = np.array(list(map(int,input().split())))[1:]
    for i in range(M):
        if not i+1 in A:
            B[i] = 0
print(B.sum())

Measured memory_bytes: 12396
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S[10];
  for (auto i = 0; i < 3; ++i) {
    cin >> S[i];
  }
  int now = 0;
  while (S[now].size() > 0) {
    int nnow = S[now][0] - 'a';
    S[now].erase(0, 1);
    now = nnow;
    // cerr << "now = " << (char)('A' + now) << endl;
  }
  cout << (char)('A' + now) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()
{
    
    int result=0;
    int i,N;
    char* string;
    
    scanf("%d",&N);
    string = (char*)malloc(N*sizeof(char));
    scanf("%s",string);
    for(i=0;i<N-2;i++)
    {
        if(string[i]=='A' && string[i+1]=='B' && string[i+2]=='C')
        {
            result++;
        }
    }
    printf("%d",result);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
const int inf = 1e9;

const int MAX = 1 << 26;
int dp[MAX];

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> a(n);
    a[0] = (1 << (s[0] - 'a'));
    rep(i, n - 1) {
        a[i + 1] += a[i] ^ (1 << (s[i + 1] - 'a'));
    }

    rep(i, MAX) dp[i] = inf;
    dp[0] = 0;

    rep(i, n) {
        int t = inf;
        t = min(t, dp[a[i]] + 1);
        rep(j, 26) {
            t = min(t, dp[a[i] ^ (1 << j)] + 1);
        }
        if (i == n - 1) {
            cout << t << endl;
            return 0;
        }
        dp[a[i]] = min(dp[a[i]], t);
    }
}


Measured memory_bytes: 263556
#include<bits/stdc++.h>
#include<queue>
using namespace std;
vector<queue<int>>tree;
vector<queue<int>>wi;
vector<int>cl;
vector<int>si;
void dfs(int x, int c) {
  cl[x] = c;
  for (int i = 0; i < si[x]; i ++) {
    int u = tree[x].front();
    tree[x].pop();
    tree[x].push(u);
    int w = wi[x].front();
    wi[x].pop();
    wi[x].push(w);
    if (cl[u] != -1) continue;
    int d = (c + w) % 2;
    dfs(u, d);
  }
}
int main () {
  int N;
  cin >> N;
  tree.resize(N);
  wi.resize(N);
  cl.assign(N, -1);
  si.assign(N, 0);
  for (int i = 0; i < N - 1; i ++) {
    int a, b, w;
    cin >> a >> b >> w;
    a --;
    b --;
    tree[a].push(b);
    tree[b].push(a);
    w %= 2;
    wi[a].push(w);
    wi[b].push(w);
    si[a] ++;
    si[b] ++;
  }
  dfs(0, 0);
  for (int i = 0; i < N; i ++) cout << cl[i] << endl;
}


Measured memory_bytes: 135680
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define print(var) cout << var
int main() {
  int N;
  cin >> N;
  vector<char> S(N, '0');
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  int count = 0;
  bool p, w, g, y;
  p = w = g = y = false;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'P' && !p) {
      count++;
      p = true;
    }
    if (S[i] == 'W' && !w) {
      count++;
      w = true;
    }
    if (S[i] == 'G' && !g) {
      count++;
      g = true;
    }
    if (S[i] == 'Y' && !y) {
      count++;
      y = true;
    }
  }
  string res;
  if (count == 3)
    res = "Three";
  if (count == 4)
    res = "Four";
  print(res);
  return 0;
}

Measured memory_bytes: 888
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int A, B, C;
	int ans = 0;

	cin >> A >> B >> C;

	for (int i = 1; i <= 100; i++) {
		if ((A * i) % B == C) {
			ans = 1;
		}
	}

	if(ans){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li unsigned long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s second
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const char &i, char &j)
{
    
    return i > j;
    
}
void solve()
{
   li n,k;
   cin>>n;
   li a[n],su=0;
   map<li,li>mp;
   rep(i,n)
   cin>>a[i],su+=a[i],mp[a[i]]++;
   cin>>k;
   li u,v;
   rep(i,k)
   {
       cin>>u>>v;
       if(mp.find(v)==mp.end())
       mp[v]=mp[u];
       else
       mp[v]+=mp[u];
       su=su+mp[u]*v-mp[u]*u;
       mp[u]=0;
       cout<<su<<endl;
       
   }
}
int main()
{
    li t;
    t=1;
    while(t--)
    solve(),cout<<endl;
    
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   string s;
   int K;
   cin>>s>>K;

   string a = "abcdefghijklmnopqrstuvwxyz";

   for(int i=0;i<s.size();i++){
      //cout<<a.size()-(s[i]-'a')<<" "<<K<<endl;
      if(i==s.size()-1)s[i]=(char)(((s[i]-'a')+K)%a.size()+'a');
      else if(s[i]=='a')continue;
      else if(a.size()-(s[i]-'a')<=K){
         K-=a.size()-(s[i]-'a');
         s[i] = 'a';
      }
   }

   cout<<s<<endl;
   return 0;

}


Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int x, p;
    cin >> x >> p;
    ld ans;
    int tmp = (x + 1) / 2;
    ans = (ld(100) / ld(p)) * ld(tmp);
    cout << fixed << setprecision(20) << ans << "\n";

    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int ans = 1, cnt = 0;
	while (ans < B) {
		ans += A - 1;
		++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

unsigned int K, i;
string S;
cin >> K >> S;

if(S.size() <= K){
  cout << S << endl;
}
else{
  for (i = 0; i < K; i++){
  cout << S.at(i);
  }
  cout << "..." << endl;
}

}

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


int main() {
    int num[3];
    cin>>num[0]>>num[1]>>num[2];
    sort(num,num+3);
    int count=0;
    count+=num[2]-num[1];
    num[0]+=count;
    if((num[2]-num[0])%2==0)count+=(num[2]-num[0])/2;
    else count+=(num[2]-num[0])/2+2;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back



int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n;
		cin>>n;
		double a[n];
		for(auto &x:a)
		{
			cin>>x;
		}
		double dp[n][3000];
		//dp[i][j] pob of getting j number of head at pos i
		memset(dp,0,sizeof(dp));
		dp[0][1]=a[0];
		dp[0][0]=(1-a[0]);
		for(int i=1;i<n;i++)
		{
			for(int j=0;j<3000;j++)
			{
				dp[i][j]+=dp[i-1][j]*(1-a[i]);
				if(j-1>=0)
					dp[i][j]+=dp[i-1][j-1]*a[i];
					
					
			}
		}
		double ans=0;
		for(int i=n/2+1;i<3000;i++)
		{
			ans+=dp[n-1][i];
		}
		cout<<setprecision(9)<<ans<<'\n';
	}
		
}


Measured memory_bytes: 74044
$>.sync=S='? '+?0*N=gets.to_i;
*A=?!;
N.times{|i|S[i+2]=?1;i.times{|j|
S[j+2]=?1;
puts S;
S[j+2]=?0;
gets=="1
"&&A<<"(#{i},#{j})"
};S[i+2]=?0};
puts A*?\s

Measured memory_bytes: 3148
num = list(map(int,input().split()))
if num[1] ==0:
  print(num[0])
else:  
  num_list = list(map(int,input().split()))
  flg = True
  ans = num[0]
  distance = 0

  while flg:
    ch_1 = ans-distance
    ch_2 = ans+distance
    if ch_1 not in num_list:
      print(ch_1)
      flg = False
    elif ch_2 not in num_list:
      print(ch_2)
      flg = False
    else:
      distance +=1

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
	is_prime[0]=is_prime[1]=true;
	for(int i=4;i<MAX;i+=2){
		is_prime[i]=true;
	}
	for(int i=3;i*i<MAX;i+=2){
		if(!is_prime[i]){
			for(int j=i*i;j<MAX;j+=i){
				is_prime[j]=true;
			}
		}
	}
	for(int i=0;i<MAX;i++){
		if(!is_prime[i]){
			sumprime[i]=sumprime[i-1]+i;
		}else{
			sumprime[i]=sumprime[i-1];
		}
	}
}
*/


int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//double	pi=3.14159265358979323846;
	//sieve();
	
	
	int x,y;
	cin>>x>>y;
	int f=0;
	for(int i=(x*2);i<=(x*4);i+=2){
		if(i==y){
			f=1;
			break;
		}
	}
	if(f==0){
		cout<<"No\n";
	}else{
		cout<<"Yes\n";
	}

		
	
	return 0;
	
	
	
	
}

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

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);

    int l=max(a,c);
    int r=min(b,d);

    printf("%d\n",max(0,r-l));
    return 0;
}


Measured memory_bytes: 256
n = input()
m = tuple(n)
n = int(n)
ans = 0
keta = len(m)
if keta%2 == 1:
    for i in range(keta-1):
        if (i+1)%2 == 0:
            ans += (10**(keta-(i+1)))*9
    print(n-ans)
else:
    for i in range(keta):
        if (i+1)%2 == 0:
            ans += (10**(keta-(i+1)))*9
    print(ans)


Measured memory_bytes: 3060
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数
#define D_VAL_MAX		1000000000								// 最大値

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Out[D_ARRAY_MAX * 20];							// 出力内容
static char *scpOut;											// 出力位置

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 出力内容 - 追加
int
fOutAdd(
	int piVal					// <I> 値
)
{
	char lc1Buf[1024];
	sprintf(lc1Buf, "%d ", piVal);
	int liLen = strlen(lc1Buf);
	memcpy(scpOut, lc1Buf, liLen);
	scpOut += liLen;

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 条件 - 取得
	int liN, liK, liS;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d", &liN, &liK, &liS);

	// S を K 個追加
	for (i = 0; i < liK; i++) {
		fOutAdd(liS);
	}

	// !S を (N-K) 個追加
	int liVal;
	if (liS < D_VAL_MAX) {
		liVal = D_VAL_MAX;
	}
	else {
		liVal = 1;
	}
	for (i = 0; i < liN - liK; i++) {
		fOutAdd(liVal);
	}

	// 出力
	*scpOut = '\0';
	scpOut--;
	*scpOut = '\n';
	fOutLine(sc1Out);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	scpOut = sc1Out;											// 出力位置

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2304
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B.insert(0,0)
C = list(map(int,input().split()))
C.insert(0,0)
cnt = B[A[0]]
for i in range(1,N):
    if A[i]-A[i-1]==1:
        cnt += C[A[i-1]]
    cnt += B[A[i]]
print(cnt)

Measured memory_bytes: 61856
#include <stdio.h>

long long N, X;
long long layer[51], patty[51];

long long get_layer (int level)
{
    if (level == 0) return 1;
    return get_layer(level - 1) * 2 + 3;
}

long long get_patty (int level)
{
    if (level == 0) return 1;
    return get_patty(level - 1) * 2 + 1;
}

long long eat_runrun (int level, long long x)
{
    if (level == 1) {
        if (x == 5)  return 3;
        if (x == 4) return 3;
        if (x == 3) return 2;
        if (x == 2) return 1;
        return 0;
    }
    if (x > layer[level] - 1) return patty[level];
    if (x == (layer[level] + 1) / 2) return patty[level - 1] + 1;
    else if (x < (layer[level] + 1) / 2) return eat_runrun(level - 1, x - 1);
    else return patty[level - 1] + 1 + eat_runrun(level - 1, x - (layer[level] + 1) / 2);
}

int main (void)
{
    int i;

    scanf("%lld %lld", &N, &X);

    for (i = 0; i < 51; i++) {
        layer[i] = get_layer(i);
        patty[i] = get_patty(i);
    }

    printf("%lld\n", eat_runrun(N, X));

    return 0;

}

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

#define INFTY 2147483647

int count;

void merge( int *a, int left, int mid, int right) {

  int *l, *r;
  int n1, n2;

  int i, j, k;

  n1 = mid - left;
  n2 = right - mid;
  
  l = (int *)malloc(sizeof(int) *(n1+1));
  r = (int *)malloc(sizeof(int) *(n2+1));

  for( i=0; i<n1; i++) {
    l[i] = a[left+i];
  }
  for( i=0; i<n2; i++) {
    r[i] = a[mid+i];
  }

  l[n1] = INFTY;
  r[n2] = INFTY;

  i=0;
  j=0;

  for( k=left; k<right; k++) {

    if( l[i] <= r[j]) {
      a[k] = l[i];
      i++;
    }
    else {
      a[k] = r[j];
      j++;
    }

    count++;

  }

}


void mergeSort( int *a, int left, int right) {

  int mid;

  if( left+1 < right) {
    mid = ( left + right)/2;
    mergeSort( a, left, mid);
    mergeSort( a, mid, right);
    merge( a, left, mid, right);
  }

}


int *makeIntArray( int n) { 

  int *a;
  int i;

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

  for( i=0; i<n; i++) {
    scanf("%d", &a[i]);
  }

  return a; //配列ポインタ

}


int main() {

  int n;
  int *a;

  int i;


  scanf("%d", &n);
  a = makeIntArray( n );

  mergeSort( a, 0, n);

  for( i=0; i<n-1; i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n%d\n", a[i], count);

  return 0;

}

Measured memory_bytes: 63344
#include<bits/stdc++.h>
using namespace std;
 
#define int            long long int 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define bs             binary_search    // binary_search(a,a+n,x);
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define lower(x)         transform(x.begin(), x.end(), x.begin(), ::tolower);           
#define upper(x)          transform(x.begin(), x.end(), x.begin(), ::toupper);
#define lb             lower_bound      // lower_bound(a,a+n,x) - a; => For Index
#define up             upper_bound      // upper_bound(a,a+n,x) - a; => For Index       
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
 
}
 
void solution()
{
    int n;
    cin>>n;

    int arr[n];

    floop(0,n)
    cin>>arr[i];

    int ans = 0;
    int Max = INT_MIN;

    for(int i=0;i<n;i++)
    {
        Max = max(Max,arr[i]);

        ans+=Max-arr[i];
    }

    cout<<ans<<endl;
}
 
int32_t main()
{
    c_p_c();
 
    // int t;
    // cin>>t;
 
    // while(t--)
    // {
        solution();
    //}
 
    return 0;
}

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

int main(){
    int64_t N,K;
    cin >> N >> K;
    vector<int64_t> H(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> H.at(i);
    }
    sort(H.begin(),H.end());
    int64_t sum = 0;
    if ( N > K ){
        for ( int i = 0; i < N - K; ++i){
            sum += H.at(i);
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int h, w;
string s;
signed main() {
	cin >> h >> w;
	for1(i, h) {
		cin >> s; cout << s << ' ' << s << endl;
	}
}

Measured memory_bytes: 256
N,x=map(int,input().split())
A=list(map(int,input().split()))
import copy
C=copy.copy(A)
B=[0 for k in range(N-1)]
for k in range(N-1):
    B[k]=A[k]+A[k+1]
#print(B)
for k in range(N-1):
    if B[k]-x>0:
        if B[k]-x>A[k+1]:
            A[k]=x
            A[k+1]=0
        else:
            A[k+1]=A[k+1]-B[k]+x
        if k!=N-2:
            B[k+1]=A[k+1]+A[k+2]
#print(A)
ans=0
for k in range(N):
    ans+=C[k]-A[k]
print(ans)


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

using namespace std;
#define WHITE 0 //未到達
#define GLAY 1 //訪問中
#define BLACK 2 //訪問完了
#define INF 1000000001

int num_node;

int dfs(const vector<vector<int> > &adj_list, vector<int> &d, vector<int> &f,const int id, int counter){
    counter++;
    d[id] = counter;
    if(id!=0){
        for(int i = 0; i < adj_list[id].size(); i++){
            if(d[adj_list[id][i]] == INF){
                counter = dfs(adj_list,d,f,adj_list[id][i],counter);
        }
        }   
    }
    else{
        for(int i = 1; i < num_node + 1;i++){
            if(d[i]==INF){
                counter = dfs(adj_list,d,f,i,counter);
            }
        }
    }
    
    counter++;
    f[id] = counter;
    return counter;
}



int main(){
    int id, k, to;
    cin >> num_node;
    vector<vector<int> > adj_list(num_node+1);
    vector<int> color[num_node+1];
    vector<int> d(num_node+1,INF), f(num_node+1,INF);

    adj_list[0].push_back(1);
    for(int j = 0 ;j < num_node;j++){
        cin >> id >> k;
        for(int i =0;i < k; i++){
            cin >> to;
            adj_list[id].push_back(to);
        }    
    }
    
    dfs(adj_list, d, f, 0, -1);
    for(int i=1;i <= num_node; i++){
        printf("%d %d %d\n",i,d[i],f[i]);
    }

    return 0;
}



Measured memory_bytes: 3272
#include <stdio.h>
int main(){
	int n,a;
	scanf("%d",&n);
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)printf("hon\n");
	else if(a==0||a==1||a==6||a==8)printf("pon\n");
	else if(a==3)printf("bon\n");
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool ans = true;
  rep(i,n){
    int a;
    cin >> a;
    if(a % 2 == 0){
      if(a % 3 != 0 && a % 5 != 0) ans = false;
    }
  }
  if(ans){
    puts("APPROVED");
  }else{
    puts("DENIED");
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){
  int a,b;
  int money;
  int o100,o500,o1000;
  while(cin>>a>>b){
    if(a==0&&b==0) break;
    money = b - a;
    o1000 = money / 1000;
    money %= 1000;
    o500 = money / 500;
    money %= 500;
    o100 = money / 100;
    printf("%d %d %d\n",o100,o500,o1000);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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;}

int main(){
	double a,b,c;
	cin >> a >> b >> c;
	c = c * 3.14159265 / 180;
	cout << fixed << setprecision(8);
	cout << (double)(a*b*sin(c)/2) << endl;
	cout << (double)(a + b + sqrt(pow(a,2.0)+pow(b,2.0)-2*a*b*cos(c))) << endl;
	cout << (double)(b * sin(c)) << endl;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k-i;j++){
      if(i+j>n) continue;
      int d=k-i-j;
      vector<int> s(0);
      int now=0;
      for(int a=0;a<i;a++){
        now+=v[a];
        s.push_back(v[a]);
      }
      for(int b=n-j;b<n;b++){
        now+=v[b];
        s.push_back(v[b]);
      }
      sort(s.begin(),s.end());
      for(int r=0;r<d;r++){
        if(r>=s.size()) break;
        if(s[r]>0) break;
        now-=s[r];
      }
      ans=max(now,ans);
    }
  }
  cout<<ans<<endl;
}
      


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();
		String T = scan.next();

		if(S.equals( T.substring(0, T.length()-1))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void solve() {
	ll t;
	rep(i,1,6) {
		cin >> t;
		if (t==0) {cout << i; return;}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <set>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc126_a(vector<vector<string>> v) {

    int n = atoi(v[0][0].c_str());
    int k = atoi(v[0][1].c_str());

    string s = v[1][0];

    string s1 = s.substr(0, k - 1);

    string s2 = s.substr(k - 1, 1);
    transform(s2.begin(), s2.end(), s2.begin(), ::tolower);
    string s3 = s.substr(k);

    cout << s1 << s2 << s3;


}

int main() {

    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    abc126_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    string s;

    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == ',') s[i] = ' ';
    }

    cout << s << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool f = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'C') {
      for(int j = i+1; j < s.size(); j++) {
        if(s[j] == 'F') f = 1;
      }
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

const int IMAX = pow(2.0,31.0)-1;

#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n;
    scanf("%d ",&n);
    int *data = inputArray(n);
    int h[100010];
    for(int i=0;i<n;i++)h[i]=data[i];
    int dp[100010];
    for(int i=0;i<100010;i++){
        dp[i]=IMAX;
    }
    dp[0] = 0;
    for(int i = 0;i<100010;i++){
        dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    printf("%d",dp[n-1]);
    free(data);
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	vector<ll> a;
	ll n,cnt=0;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll x; cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			for(ll k=j+1;k<n;k++)
			{
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i]+a[j]>a[k])
				{
					cnt++;

				}
			}
		}
	}
	cout<<cnt;

	return 0;
}

Measured memory_bytes: 3636