akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0

typedef struct tag_card {
    char suit_;
    int num_;
} card_t;

void DisplayArray(card_t C[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%c%d", C[i].suit_, C[i].num_);
    }
    printf("\n");
}

void BubbleSort(card_t C[], int N)
{
    int i, j;
    card_t tmp;

    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j >= i; j--) {
            if (C[j].num_ < C[j - 1].num_) {
                tmp = C[j];
                C[j] = C[j - 1];
                C[j - 1] = tmp;
            }
        }
    }
}

void SelectionSort(card_t C[], int N)
{
    int i, j, minj;
    card_t tmp;

    for (i = 0; i < N; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (C[j].num_ < C[minj].num_) {
                minj = j;
            }
        }
        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }
}

int IsStable(card_t cBubble[], card_t cSelection[], int N)
{
    int i;

    for (i = 0; i < N; i++) {
        if (cBubble[i].suit_ != cSelection[i].suit_) return FALSE;
    }

    return TRUE;
}

int main(void)
{
    int N, i;
    scanf("%d%*c", &N);
    card_t* C1 = (card_t*)malloc(sizeof(card_t) * N);
    card_t* C2 = (card_t*)malloc(sizeof(card_t) * N);

    for (i = 0; i < N; i++) {
        scanf("%c%d%*c", &C1[i].suit_, &C1[i].num_);
        C2[i].suit_ = C1[i].suit_;
        C2[i].num_ = C1[i].num_;
    }

    BubbleSort(C1, N);
    SelectionSort(C2, N);

    DisplayArray(C1, N);
    printf("Stable\n");
    DisplayArray(C2, N);
    if (IsStable(C1, C2, N)) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }

    return 0;
}

Measured memory_bytes: 612
package main

import (
  "fmt"
)

func main() {
  var k int
  fmt.Scan(&k)
  fmt.Println(task(k))
}

func task(k int) int {
  var p int
  slice := []int{1,2,3,4,5,6,7,8,9}
  for i:=0; i < k; i++ {
    p = slice[i]
    if p%10 != 0 {
      slice = append(slice, 10*p + p%10 -1)
    }
    slice = append(slice, 10*p + p%10)
    if p%10 != 9 {
      slice = append(slice, 10*p + p%10 +1)
    }
  }
  return p
}


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

int main(){
	int D, E, min, temp, t;
	double ans;
	
	while(1){
		
		cin>>D>>E;
		
		if(D == 0 && E == 0) break;
		
		min = fabs(D * D - E * E);
		t = 0;
		
		for(int i = 1; i <= D/2 + 1; i++){
			temp = fabs(i * i + (D - i) * (D - i) - E * E);
			if(min > temp){
				min = temp;
				t = i;
			}
		}
		
		ans = fabs(pow(t * t + (D - t) *(D - t), 1.0/2.0)  - E);
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3252
S = input()
if len(S) == 7:
  if S == "keyence":
    print("YES")
  else:
    print("NO")
  exit()
T = len(S) - 7
for i in range(1,T+1):
  tmp = ""
  l = 0
  while l + i < len(S):
    tmp = S[:l] + S[l+i:]
    if tmp == "keyence":
      print("YES")
      exit()
    l += 1
print("NO")

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

Measured memory_bytes: 21712
n = int(input())
a = list(map(int,input().split()))
mina = max(a)
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
a.sort()
for i in range(n-1):
    mina = min(mina,gcd(a[i],a[i+1]))
print(mina)

Measured memory_bytes: 14224
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  std::vector<int> t(D), bestT(D);
  int ans = 0;
  //std::set<int> last[26];
  //for(auto& li: last) li.insert(-1); // sentinel
  int ansk[27], dif[26];
  for(int k = 0; k <= 26; ++k) {
    ansk[k] = 0;
    int las[26];
    std::fill_n(las, 26, -1);
    for(int d = 0; d < D; ++d) {
      for(int T = 0; T < 26; ++T) {
        dif[T] = s[d][T];
        int sv = las[T];
        las[T] = d;
        for(int i = 0; i < 26; ++i) {
          dif[T] -= c[i]*(d+k - las[i]);
        }
        las[T] = sv;
      }
      t[d] = std::max_element(dif, dif+26) - dif;
      las[t[d]] = d;
      ansk[k] += dif[t[d]];
    }
    if(ansk[k] > ans) {
      ans = ansk[k];
      std::copy(t.begin(), t.end(), bestT.begin());
    }
  }
  std::copy(bestT.begin(), bestT.end(), t.begin());
  //for(auto& li: last) li.insert(D); // sentinel
#if 0  
  // additional score when t[d] = i compare to t[d] = -1
  auto sum_up = [](int d) { return d*(d-1)/2; };
  auto score = [&](int d, int i)->int {
    int res = s[d][i];
    auto it = last[i].lower_bound(d);
    int nd = *it;
    int pd = *--it;
    int diff = sum_up(d-pd) + sum_up(nd-d) - sum_up(nd-pd);
    res -= c[i]*diff;
    return res;
  };
  int lm = 0, renew = 0;
  int sc[26];
  auto one_day = [&](int d) {
    int pi = t[d];
    last[pi].erase(d);
    for(int i = 0; i < 26; ++i) sc[i] = score(d, i);
    int mi = std::max_element(sc, sc+26) - sc;
    if(mi != pi) {
      ans += sc[mi] - sc[pi];
      ++renew;
    }
    last[mi].insert(d);
  };
  
  // hill climbing
  int range = 50;
  for(int rep = 0;; ++rep) {
    if((xor64()>>25)%2) {
      one_day(xor64()%365);
    } else {
      // swap
      int d1 = xor64()%D, d2 = xor64()%D;
      while(d1 < d2-range || d2 < d1-range || t[d1] == t[d2]) {
          d1 = xor64()%D; d2 = xor64()%D;
      }
      int pi1 = t[d1], pi2 = t[d2];
      last[pi1].erase(d1);
      int diff = score(d1, pi2) - score(d1, pi1);
      last[pi2].insert(d1);
      last[pi2].erase(d2);
      diff += score(d2, pi1) - score(d2, pi2);
      if(diff > 0) {
        last[pi1].insert(d2);
        t[d1] = pi2;
        t[d2] = pi1;
        lm = 0;
      } else {
        last[pi2].insert(d2);
        last[pi2].erase(d1);
        last[pi1].insert(d1);
      }
    }
    if(rep%100 == 0) {
      int x = get_time();
      if(x > 1950) break;
    }
  }
#endif
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 3696
N, M = map(int, input().split())
s = [int(c) for c in input().split()]
t = [int(c) for c in input().split()]
MOD = 10**9+7

dp = [[0]*(M+1) for i in range(N+1)]
dp_cum = [[0]*(M+1) for i in range(N+1)]

dp[0][0] = 1
for i in range(N+1):
  dp_cum[i][0] = 1
for j in range(M+1):
  dp_cum[0][j] = 1
  
for i in range(N):
  for j in range(M):
    if s[i]!=t[j]:
      dp[i+1][j+1] = 0
    else:
      dp[i+1][j+1] = dp_cum[i][j]
    dp_cum[i+1][j+1] = dp_cum[i][j+1] + dp_cum[i+1][j] - dp_cum[i][j] + dp[i+1][j+1]
    dp_cum[i+1][j+1] %= MOD

print(dp_cum[-1][-1])

Measured memory_bytes: 104924
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=1e5+5;
ll a[N];
int main()
{
 priority_queue<double,vector<double>,greater<double>>q;
 ll n;
 scanf("%lld",&n);
 rep(i,0,n)
 {
 	double t;
 	scanf("%lf",&t);
 	q.push(t);
 }
 double ans=0;
 while(q.size()>1)
 {
 	double sum=q.top();
 	q.pop();
 	sum+=q.top();
 	q.pop();
 	sum/=2.0;
 	q.push(sum);
 }
 printf("%lf\n",q.top());
}




Measured memory_bytes: 256
icase=0
if icase==0:
    n=int(input())
    t=list(map(int,input().split()))
    sumt=sum(t)
    m=int(input())
    for i in range(m):
        pi,xi=map(int,input().split())
        sumtp=sumt-t[pi-1]+xi
        print(sumtp)
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

int MOD = 1e9 + 7;
void add(int &a, int b) {
  a += b;
  if(a >= MOD) a -= MOD;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  REP(h, H) {
    REP(x, W) {
      for(int bit = 0; bit < (1 << W - 1); bit++) {
        bool ok = true;
        for(int i = 0; i < W - 2; i++) {
          if((bit & (1 << i)) && (bit & (1 << i + 1))) { ok = false; }
        }
        if(!ok) continue;
        if(bit & (1 << x - 1)) {
          add(dp[h + 1][x - 1], dp[h][x]);
          continue;
        }
        if(bit & (1 << x)) {
          add(dp[h + 1][x + 1], dp[h][x]);
          continue;
        }
        add(dp[h + 1][x], dp[h][x]);
      }
    }
  }
  cout << dp[H][K - 1] << endl;
  return 0;
}

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

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

    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#強い人のコード
N=int(input())
ans='Yes'
odd=0
four=0
for x in map(int,input().split()):
    if x%2==1:
        odd+=1
    elif x%4==0:
        four+=1
#4の倍数+1が奇数の数より少ないとダメ
if four+1<odd:
    ans='No'
#4の倍数+1が奇数と同じかつその合計が全体より少ないとダメ（ひとつ奇数が余ることになる）
elif four+1==odd and odd+four<N:
    ans='No'
print(ans)


Measured memory_bytes: 11480
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int p[200001] = {0};
double kaku[200001] = {0.0};

int main()
{
	int N = 0, K = 0, i = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &p[i]);
	}

	for (i = 0; i < N; i++) {
		int val = 0;
		if (p[i] == 1) {
			val = 1;
		} else {
			if (p[i]%2 == 0) {
				val = (p[i]+1)*(p[i]/2);
				//printf("i=%d val=%d\n", i , val);
			} else {
				val = ((p[i]+1)*(p[i]/2)) + ((p[i]+1)/2) ;
				//printf("i=%d val=%d\n", i , val);
			}
		}
		if (i > 0) {
			kaku[i] = ((double)val/(double)p[i]) + kaku[i-1];
			//printf("i=%d kaku[i]=%f\n", i , kaku[i]);
		} else {
			kaku[i] = ((double)val/(double)p[i]);
		}
		//printf("i=%d kaku[i]=%f\n", i , kaku[i]);
	}

	double max = 0.0;
	for (i = N-1; K-1 < i; i--) {
		max = MAX(kaku[i]-kaku[i-K], max);
		//printf("i=%d max=%f %f %f\n", i , max, kaku[i], kaku[i-(K)]);
	}

	max = MAX(kaku[i], max);
	printf("%.9f", max);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ll long long
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
struct D{int a,b; D(){} D(int _a, int _b){a=_a,b=_b;} inline D operator + (D x){return D(a+x.a,b+x.b);}}w[MAXN+5];
int a[MAXN+5], q[MAXN+5], in[MAXN+5], n, m, k, h, t, S, T; ll Ans; bool book[MAXN+5]; vector<int> e[MAXN+5];
void DFS(int p, int c, int fa){k += c, w[p] = D(0,1-(c<<1)); for(auto v:e[p]) if(v^fa&&(p^S||v^T)&&(p^T||v^S)) DFS(v,c^1,p);}
void DFS_s(int p, int fa){for(auto v:e[p]) if(v^fa&&(p^S||v^T)&&(p^T||v^S)) DFS_s(v,p), w[p] = w[p]+w[v];}
int main()
{
	n = read(); if(n&1) return puts("-1"),0; m = read(); for(rint i = 1, a, b; i <= m; a = read(), b = read(), e[a].push_back(b), e[b].push_back(a), ++in[a], ++in[b], i++);
	if(m==n){for(rint i = 1; i <= n; in[i]<=1?book[q[++t]=i]=true:0, i++); h = 1; for(; h<=t; ) for(auto v:e[q[h++]]) --in[v]==1?book[q[++t]=v]=true:0;} else t = n;
	if(t<n){for(rint i = 1; i <= n; i++) if(!book[i]) for(auto v:e[S=i]) if(!book[v]){T = v; goto out;}} else S = 1; ;out:; DFS(S,0,0); if(m<n&&k^(n-k)) return puts("-1"),0;
	if((n-t)&1) w[S].b -= (n>>1)-k, w[T].b -= (n>>1)-k, Ans += abs((n>>1)-k); if(t<n&&~(n-t)&1){if(k^(n-k)) return puts("-1"),0; --w[S].a, ++w[T].a;}
	DFS_s(S,0); if(m<n||(n-t)&1){for(rint i = 1; i <= n; Ans += abs(w[i].b), i++); return printf("%lld\n",Ans),0;}
	a[k=1] = 0; for(rint i = 1; i <= n; w[i].a ? a[++k] = w[i].a>0?w[i].b:-w[i].b : Ans += abs(w[i].b), i++);
	sort(a+1,a+k+1); for(rint i = 1; i <= k; Ans += abs(a[i]-a[-~k>>1]), i++); return printf("%lld\n",Ans),0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    double a[n],b[n],A=0,B=0,C=0,D=0;
    r(i,n) cin>>a[i];
    r(i,n) cin>>b[i];
    r(i,n)
    {
        A+=abs(a[i]-b[i]);
        B+=abs(a[i]-b[i])*abs(a[i]-b[i]);
        D+=abs(a[i]-b[i])*abs(a[i]-b[i])*abs(a[i]-b[i]);
        C=max(C,abs(a[i]-b[i]));
    }
    B=sqrt(B);
    D=pow(D,1.0/3);
    printf("%.6f\n",A);
    printf("%.6f\n",B);
    printf("%.6f\n",D);
    printf("%.6f\n",C);
}


Measured memory_bytes: 3412
N = int(input())
MOD = 10 ** 9 + 7
D = [0] * 4
D[0] = 1

for i in range(N):
	ND = list(D)
	ND[0] = (D[0] * 8) % MOD
	ND[1] = (D[0] + D[1] * 9) % MOD
	ND[2] = (D[0] + D[2] * 9) % MOD
	ND[3] = (D[3] * 10 + D[1] + D[2]) % MOD
	D = ND

print(D[-1])


Measured memory_bytes: 91212
#include <iostream>
using namespace std;
typedef long long ll;
string str;
ll al[26];
int main(void){
    // Your code here!
    cin >> str;
    if (str == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    if (str.length() < 26) {
        for (ll i = 0; i < str.length(); i++) {
            al[str[i] - 'a']++;
        }
        for (ll i = 0;i < 26; i++) {
            if (al[i] == 0) {
                str.push_back(i + 'a');
                break;
            }
        }
        cout << str << endl;
    } else {
        for (ll i = 25; ; i--) {
            if (str[i - 1] < str[i]) {
                cout << str.substr(0, i - 1);
                for (ll j = 25; ; j--) {
                    if (str[i - 1] < str[j]) {
                        cout << str[j] << endl;
                        break;
                    }
                }
                break;
            }
        }
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
m //= 2
if n > m:
    print(m)
else:
    print((n+m)//2)

Measured memory_bytes: 5076
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new Main().solve(in, out);
		in.close();
		out.close();
	}
	
	public void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int c = in.nextInt();
		int k = in.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; ++i) {
			t[i] = in.nextInt();
		}
		Arrays.sort(t);
		int p = 1, ind = 0, ans = 1;
		for (int i = 1; i < n; ++i) {
			if (p == c || t[i] - t[ind] > k) {
				p = 1;
				ind = i;
				++ans;
			} else {
				++p;
			}
		}
		out.println(ans);
	}
}

Measured memory_bytes: 50156
x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2 - x1, y2 - y1
x3, y3 = x2 -dy, y2 + dx
x4, y4 = x1 -dy, y1 + dx
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class WUFTree {
    vector<int> parent;
    vector<int> height;
    vector<int> diff_weight;

public:
    WUFTree(int size)
    {
        for (int i = 0; i < size; i++) {
            parent.push_back(i);
            height.push_back(0);
            diff_weight.push_back(0);
        }
    }
    int root(int node)
    {
        return shrink(node).first;
    }
    void merge(int n0, int n1, int w)
    {
        int r0 = root(n0), r1 = root(n1);
        int z = w + weight(n0) - weight(n1);
        if (r0 == r1) {
            return;
        }
        if (height[r0] < height[r1]) {
            swap(r0, r1);
            z *= -1;
        }
        if (height[r0] == height[r1])
            height[r0]++;
        parent[r1] = r0;
        diff_weight[r1] = z;
    }
    int diff(int n0, int n1)
    {
        return weight(n1) - weight(n0);
    }

protected:
    pair<int, int> shrink(int node)
    {
        if (parent[node] == node) {
            return make_pair(node, 0);
        }
        pair<int, int> p = shrink(parent[node]);
        parent[node] = p.first;
        diff_weight[node] += p.second;
        return make_pair(parent[node], diff_weight[node]);
    }
    int weight(int node)
    {
        return shrink(node).second;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    WUFTree uf(n);
    rep(i, m)
    {
        int l, r;
        int d;
        cin >> l >> r >> d;
        l--;
        r--;

        if (uf.root(l) == uf.root(r) && uf.diff(l, r) != d) {
            cout << "No" << endl;
            return 0;
        } else {
            uf.merge(l, r, d);
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1772
(let* ((n (read))
       (lst (loop :repeat 2 :collect (loop :repeat n :collect (read)))))
  (princ (loop :for k :from 0 :upto (1- n) :maximize (+ (reduce #'+ (subseq (first lst) 0 (1+ k)))
                                                        (reduce #'+ (subseq (second lst) k n))))))

Measured memory_bytes: 15588
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}

//小文字=大文字+32

int main() {
	int n;
	cin >> n;
	vector<ll>a(n+1);
	vector<ll>b(n);
	rep(i, n+1) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	ll ans=0;
	rep(i, n) {
		ans += min(b[i], a[i]);
		b[i] -= min(b[i], a[i]);
		ans += min(b[i], a[i+1]);
		a[i + 1] -= min(b[i], a[i + 1]);
	}
	

	cout << ans;


}
	



Measured memory_bytes: 4788
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ten[] = new int[n];
		for(int i=0;i<n;i++)ten[i]=0;
		for(int s=0;s<n*(n-1)/2;s++){
			int teki=in.nextInt();
			int mika=in.nextInt();
			teki=teki-1;
			mika=mika-1;
			int t=in.nextInt();
			int m=in.nextInt();
			if(t>m)ten[teki]+=3;
			else if(t<m)ten[mika]+=3;
			else if(t==m){
				ten[teki]++;
				ten[mika]++;
			}
		}
		int rnk[] = new int[n];
		for(int s=0;s<n;s++){
			int cnt=1;
			for(int i=0;i<n;i++){
				if(ten[s]<ten[i])cnt++;
			}
			rnk[s]=cnt;
		}
		for(int i=0;i<n;i++)System.out.println(rnk[i]);
	}
}

Measured memory_bytes: 42188
#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

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

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<int> dp(3, 0);
	vector<int> newdp(3, 0);
	int a,b,c;
	cin>>dp[0]>>dp[1]>>dp[2];
	// cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<"\n";
	for(int i=0;i<n-1;++i){
		cin>>a>>b>>c;
		newdp[0] = max(dp[1], dp[2]) + a;
		newdp[1] = max(dp[0], dp[2]) + b;
		newdp[2] = max(dp[0], dp[1]) + c;
		dp = newdp;
		// cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<"\n";
	}

	cout<<max(max(dp[0], dp[1]), dp[2])<<"\n";
	
	return 0;
}

Measured memory_bytes: 3620
local n=io.read("n")

local dp={{0,-10^12}}
for i=1,n do
    a=io.read("n")
    dp[i+1]={}
    dp[i+1][1]=math.max(dp[i][1]+a,dp[i][2]-a)
    dp[i+1][2]=math.max(dp[i][1]-a,dp[i][2]+a)
end
print(dp[n+1][1])

Measured memory_bytes: 13304
from sys import stdin,stdout
x,n=map(int,stdin.readline().split())
if n==0:print(x);exit(0)
s=set(map(int,stdin.readline().split()))
m1=m2=x
while 1:
    if m1 not in s:
        print(m1);exit(0)
    if m2 not in s:
        print(m2);exit(0)
    m1-=1
    m2+=1

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

int main() {
  int X;
  cin >> X;
  
  int fhund = 0, five = 0;
  fhund = X / 500;
  X -= fhund * 500;
  five = X / 5;
  
  cout << fhund * 1000 + five * 5 << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int ans;
	if(a >= b+c){
		ans = 0;
	}
	else{
		ans = c-(a-b);
	}
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const int inf = 1e9;
const ll linf = 1e18;

int fact(int n)
{
    if (n == 1) return 1;
    else return n * fact(n - 1);
}

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

    int n; cin >> n;
    double x[n], y[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    int a[n];
    iota(a, a + n, 0);

    double dist = 0.0;
    do {
        for (int i = 0; i < n - 1; i++) {
            dist += sqrt((x[a[i + 1]] - x[a[i]]) * (x[a[i + 1]] - x[a[i]]) + (y[a[i + 1]] - y[a[i]]) * (y[a[i + 1]] - y[a[i]]));
        }
    } while (next_permutation(a, a + n));

    dist /= fact(n);

    cout << setprecision(15) << dist << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    set<int>s;
    cin>>n;
    while(n--){
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, l);
    vector<int> bits;
    while(l){
        bits.push_back(l & 1);
        l >>= 1;
    }
    int n = (int)bits.size();
    int m = 2*(n-1) + accumulate(Range(bits), -1);
    printf("%d %d\n", n, m);
    
    for(int i = 1; i < n; i ++){
        printf("%d %d 0\n", i, i+1);
        printf("%d %d %d\n", i, i+1, 1 << (i-1));
    }
    int need = 1 << (n-1);
    for(int i = n-1; i > 0; i --){
        if(bits[i-1] == 0) continue;
        printf("%d %d %d\n", i, n, need);
        need += 1 << (i-1);
    }
}



Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0, ans = 0;
    rep(i, n){
        if(s[i] == 'I'){
            x++;
        }
        if(s[i] == 'D'){
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* while(!cin.eof()) */

#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e18+100)
#define N 1000200 

int fre[N];

// Driver code to test above functions
int32_t main()
{
    
 
    

    int n;
    cin >> n;
    n--;
    cout << ((n)*(n+1))/2;


    return 0;  
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  int i,j;
  double x,h,temp;
  while(1){
    scanf("%lf %lf",&x,&h);
    if(x==0 && h==0){
      break;
    }
    temp=x*x/4+h*h;
    temp=sqrt(temp);
    temp=temp*x*2+x*x;
    printf("%f\n",temp);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int n,f=0;
    cin>>n;
    for(int i=1; i<=9; i++)
    {
        int y= n/i;
        if(y>=1&&y<=9&&(n%i)==0)
        {
            cout<<"Yes"<<endl;
            f=0;
            break;
        }
        else
            f=f+1;

    }
    if(f!=0)
        cout<<"No"<<endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int n, m, arr[100010], state[100010], y, x;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)arr[i]=1;
	state[0]=1;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		x--;y--;
		if(arr[x]==0)continue;
		if(arr[x]==1&&state[x]==1){
			state[x]=0;
			state[y]=1;
		}
		if(state[x]==1)state[y]=1;
		arr[x]-=1;
		arr[y]+=1;
	}
	int sayac=0;
	for(int i=0;i<n;i++)if(state[i])sayac++;
	cout<<sayac;
	return 0;
}

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

int A[100010];

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) cin >> A[i];
    sort(A, A+N);
    int ans=A[N-1]-A[0];
    for(int i=1; i<N-1; ++i) ans += abs(A[i]);
    cout << ans << endl;
    for(int i=N-2; i>=0; --i){
        if(A[i]>0){
            cout << A[0] << ' ' << A[i] << endl;
            A[0] -= A[i];
        }
        else{
            cout << A[N-1] << ' ' << A[i] << endl;
            A[N-1] -= A[i];
        }
    }
    return 0;
}



Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

int sticks[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool valid[10] = {false,false,false,false,false,false,false,false,false,false};
string dp[10001][10];

string dfs(int n, int curr);
string compare(string a, string b);

int main(int argc, char*argv[]) {
  int n, m;
  cin >> n >> m;
  for(int i=0; i<=n; i++) {
    for(int j=0; j<10; j++) {
      dp[i][j] = "+";
    }
  }
  for(int i=0; i<m; i++) {
    int k;
    cin >> k;
    valid[k] = true;
  }
  string s = dfs(n, 9);
  s.erase(0, 1);
  cout << s << endl;
  return 0;
}

string dfs(int n, int curr) {
  if(dp[n][curr] != "+") {
    return dp[n][curr];
  }
  if(n==0) {
    stringstream ss;
    ss << curr;
    return ss.str();
  }
  string best = "-";
  for(int i=curr; i>=1; i--) {
    if(valid[i] && n >= sticks[i]) {
      string u = dfs(n-sticks[i], i);
      if(u != "-") {
        if(best == "-") best = u;
        else best = compare(best, u);
      }
    }
  }
  if(best == "-") {
    dp[n][curr] = "-";
    return best;
  } else {
    stringstream ss2;
    ss2 << curr;
    dp[n][curr] = ss2.str() + best;
    return dp[n][curr];
  }
}
string compare(string a, string b) {
  if(a.length() > b.length()) return a;
  if(a.length() < b.length()) return b;
  for(int i=0; i<a.size(); i++) {
    if(a[i] > b[i]) return a;
    else if(b[i] > a[i]) return b;
  }
  return a;
}

Measured memory_bytes: 249344
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b && b<c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26196
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int a[510],b[510],s[510];
int n;
int check(int x){
	FOR(i,1,n)b[i]=a[i]%x;
	sort(b+1,b+n+1);
	if(b[n]==0)return 0;
	FORD(i,n,1)s[i]=s[i+1]+x-b[i];
	int sum=0;
	FOR(i,1,n-1){
		sum+=b[i];
		if(sum==s[i+1])return sum;
	}
}
int main(){
	int k;
	in(n);in(k);
	int s=0;
	FOR(i,1,n)in(a[i]),s+=a[i];
	int ans=0;
	for(int i=1;i*i<=s;i++){
		if(s%i)continue;
		if(check(i)<=k)ans=max(ans,i);
		if(check(s/i)<=k)ans=max(ans,s/i);
	}
	out(ans);
}
//4 1 2 1


Measured memory_bytes: 256
function main(input) {
  var str = input.split("\n");
  str = str[0];
  var rep = str.replace(/[^ATGC]/g, "*");
  var sp = rep.split("*");

  var max = 0;
  for(i=0; i<sp.length; i++){
    var leg = sp[i].length;
    if(leg > max){
      max = leg;
    }
  }

  console.log(max);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

signed main(){
  int n;cin>>n;
  if(n==1){
    cout<<1<<endl<<0<<endl;return 0;
  }
  if(n==2){
    cout<<2<<endl<<0<<endl<<11<<endl;return 0;
  }
  cout<<n-1<<endl;
  for(int i=1;i<n;i++){
    cout<<1;for(int j=1;j<i;j++)cout<<0;cout<<1<<endl;
  }

}



Measured memory_bytes: 3112
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n + 1];

		for (int i = 0; i < n + 1; i++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);

		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = x[i + 1] - x[i];
		}

		int ans = d[0];
		for (int i = 0; i < n; i++) {
			ans = gcd(d[i], ans);
		}

		System.out.println(ans);
		sc.close();
	}

	public static int gcd(int m, int n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 47804
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    //int n,vol,s[100];
    double a,n,vol,s[1000], avg;
    while(true){

        cin >>n;
        if(n==0) break;
        vol = 0;
        a = 0;
        for(int i = 0; i < n; i++){
            cin >>s[i];
            vol += s[i];
        }
        avg = vol / n;
        for(int i =0; i < n; i++){
            a += pow(s[i]-avg, 2.0);
        }
        a /= n;
        printf("%lf\n", sqrt(a));
    }
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, a0, b;
    cin >> n >> a0 >> b;
    ll a = a0 - b;
    vector<ll> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());

    vector<ll> cs(n + 1);
    cs.at(n) = 0;
    for(int i = n - 1; i >= 0; --i){
        cs.at(i) = cs.at(i + 1) + h.at(i);
    }

    ll lo = 0, hi = (h.back() + b - 1) / b;
    while(lo < hi){
        const ll mid = (lo + hi) / 2;
        ll i = upper_bound(h.begin(), h.end(), mid * b) - h.begin();
        ll rest = 0;
        for(int j = i; j < n; ++j){
            rest += (h.at(j) - mid * b + a - 1) / a;
        }
        if(rest <= mid){
            hi = mid;
        }else{
            lo = mid + 1;
        }
    }
    cout << lo << endl;
    return 0;
}


Measured memory_bytes: 1792
n,m = map(int, input().split())
dic_s = {}
for i  in range(n):
    dic_s[i] = []
for i in range(m):
    a = list(map(int, input().split()[1:]))
    for num in a:
        dic_s[num-1].append(i)
p = list(map(int, input().split()))
total = 0

def judge_bright(judge):
    for i,num in enumerate(judge):
        if num%2 != p[i]:
            return False
    return True

for i in range(2 ** n): # n個のスイッチの組み合わせ
    judge = [0 for i in range(m)]
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 1だったら(オンだったら)
            for d in dic_s[j]: #jのスイッチにつながる電球がカウントされる
                judge[d] += 1
    
    if judge_bright(judge):      # ぜんぶついた！
        total+=1
print(total)

Measured memory_bytes: 43500
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q){
		if(n==0&&q==0) break;
		string g[n];
		int a[n][2],b;
		for(int i=0;i<n;i++){
			cin>>g[i]>>a[i][0]>>a[i][1];
			a[i][0]=a[i][1]-a[i][0]+1;
		}
		for(int i=0;i<q;i++){
			cin>>b;
			for(int t=0;t<n;t++){
				if(b>=a[t][0]&&b<=a[t][1]){
					cout<<g[t]<<" "<<b-a[t][0]+1<<endl;
					goto end;
				}
			}
			cout<<"Unknown"<<endl;
			end:;
		}
	}
    return 0;
}

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


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

 if(op == "+"){
   cout << a + b << endl;
 }else{
   cout << a - b << endl;
 }


}





Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int count=2;

    cin >> a >> b >> c;

    if(a==b&&b==c&&c==a)count=1;
    else if(a!=b&&b!=c&&c!=a)count=3;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define Max 4
using namespace std;
int main(void){
  char s[4];
  for(int i(0);i<Max;i++)cin>>s[i];
  int f(0);
  for(int i(0);i<2;i++){
    if(s[i+1]==s[i]){
      if(s[i+2]==s[i+1])f=1;
    }
  }
  if(f==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main() {
  int N,tmp,ans;
  cin>>N;
  vector <int> A(N);
  tmp=0;
  ans=0;
  while(tmp==0){
  for (int i=0;i<N;i++)
    cin >> A.at(i);
  for(int i=0;i<N;i++){
    if (A.at(i)%2!=0){
      tmp++;
      ans--;
      break;
    }
    A.at(i)/=2;
  }
  ans++;
}
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int sum = 0;

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                    int s = input[0] + input[1] + input[2];
                    int w = input[3];

                    sum += GetPrice(s, w);
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }

        static int GetPrice(int s, int w)
        {
            if (s <= 60 && w <= 2) return 600;
            if (s <= 80 && w <= 5) return 800;
            if (s <= 100 && w <= 10) return 1000;
            if (s <= 120 && w <= 15) return 1200;
            if (s <= 140 && w <= 20) return 1400;
            if (s <= 160 && w <= 25) return 1600;
            return 0;
        }
    }
}

Measured memory_bytes: 9428
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> C(N-1), S(N-1), F(N-1);
  rep(i, N-1) {
    cin >> C[i] >> S[i] >> F[i];
  }

  rep(i, N-1) {
    long long now = S[i];

    for (int j = i; j < N-1; j++) {
      now = std::max(now, (long long)S[j]);
      for(long long k = now; k <= now * F[j]; k++) {
        if (k % F[j] == 0) {
          now = k;
          break;
        }
      }
      
      now += C[j];
    }

    cout << now << endl;
  }

  cout << 0 << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



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

    int N;
    cin >> N;
    vector<int> v;
    while(N--){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    cout << unique(v.begin(), v.end()) - v.begin();
}


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

#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
int const mod = 1e9+7;
#define END {cout<<(ans)<<'\n'; return 0;}
#define ALL(vec) vec.begin(),vec.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,s,n) for(int i=s; i<n; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define fi first
#define se second
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,(n)-1)cout<<a[i]<<' '; cout<<a[(n)-1]<<'\n';
#define prip(p) cout<<(p).first<<' '<<(p).second<<'\n'
template<class T> inline bool cmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool cmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int n,m,q,_,x,y;
string s,sb;
bool ok;
char ch;

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

  cin>>n; int a[n]; rep(i,n)cin>>a[i];
  unordered_map<int,bool>o;
  for(int i=0; i<(1<<n); i++){
    x=0;
    rep(j,n)if((i>>j)&1)x+=a[j];
    o[x]=1;
  }
  cin>>q;
  rep(i,q){
    cin>>x;
    pri1(o[x]?"yes":"no");
  }
}


Measured memory_bytes: 3232
#include <iostream>
#include <iomanip>
#include <valarray>
using namespace std;

int main()
{
    int n;
    cin >> n;
    valarray<double> x(n), y(n), d(4);

    for (auto &xi: x) cin >> xi;
    for (auto &yi: y) cin >> yi;

    for (int i = 0; i < 3; i++)
        d[i] = pow(pow(abs(x - y), i + 1).sum(), 1.0 / (i + 1));
    d[3] = abs(x - y).max();

    cout << fixed << setprecision(8);
    for (auto &di: d)
        cout << di << endl;

    return 0;
}


Measured memory_bytes: 3444
package main

import "fmt"

func main() {
	var n, m int
	var sum int
	fmt.Scan(&n, &m)
	a := make([]int, m)

	for i := range a {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	if n < sum {
		fmt.Println(-1)
	} else {
		fmt.Println(n - sum)
	}
}


Measured memory_bytes: 2400
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <fstream> 
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
   char s[100];
   int i =0;
   int c[26];
   for(int l=0;l<26;l++){
   c[l] = 0;	
   }
   int wrong = 0;
   while(cin >> s[i]){
   i++;	
   }
   for(int j=0;j<i;j++){
   if(s[j] == 'a' ){
   c[0]++;
   }else if(s[j] == 'b'){
   c[1]++;	
   }else if(s[j] == 'b'){
   c[1]++;	
   }else if(s[j] == 'c'){
   c[2]++;	
   }else if(s[j] == 'd'){
   c[3]++;	
   }else if(s[j] == 'e'){
   c[4]++;	
   }else if(s[j] == 'f'){
   c[5]++;	
   }else if(s[j] == 'g'){
   c[6]++;	
   }else if(s[j] == 'h'){
   c[7]++;	
   }else if(s[j] == 'i'){
   c[8]++;	
   }else if(s[j] == 'j'){
   c[9]++;	
   }else if(s[j] == 'k'){
   c[10]++;	
   }else if(s[j] == 'l'){
   c[11]++;	
   }else if(s[j] == 'm'){
   c[12]++;	
   }else if(s[j] == 'n'){
   c[13]++;	
   }else if(s[j] == 'o'){
   c[14]++;	
   }else if(s[j] == 'p'){
   c[15]++;	
   }else if(s[j] == 'q'){
   c[16]++;	
   }else if(s[j] == 'r'){
   c[17]++;	
   }else if(s[j] == 's'){
   c[18]++;	
   }else if(s[j] == 't'){
   c[19]++;	
   }else if(s[j] == 'u'){
   c[20]++;	
   }else if(s[j] == 'v'){
   c[21]++;	
   }else if(s[j] == 'w'){
   c[22]++;	
   }else if(s[j] == 'x'){
   c[23]++;	
   }else if(s[j] == 'y'){
   c[24]++;	
   }else if(s[j] == 'z'){
   c[25]++;	
   }
   }
   for(int k=0;k<26;k++){
   if(c[k] % 2 == 1){
   wrong++;	
   }
   }
   if(wrong == 0){
   cout << "Yes" << endl;
   }else{
   cout << "No" << endl;	
   }    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    for (int i = 1; i <= 3500; i++) {
        for (int j = 1; j <= 3500; j++) {
            double t = 4.0 / n - 1.0 / i - 1.0 / j;
            if (t <= 0) continue;
            t = 1.0 / t;
            int64_t k = (int64_t)floor(t + 0.5);
            if (abs(t - k) < 1e-9 && k <= 3500) {
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

int main(){
    string s;
    cin >> s;

    if(s=="Sunny")  puts("Cloudy");
    if(s=="Cloudy") puts("Rainy");
    if(s=="Rainy")  puts("Sunny");
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, SUML[101], SUMR[101];
string S;

int main() {
  INCANT;
  cin >> N >> S;

  if (S[0]=='(') SUML[0]=1;
  else SUMR[0]=1;
  rep(i, N) {
    if (!i) continue;
    char c = S[i];
    if (c=='(') {
      SUML[i] +=SUML[i-1]+1;
      SUMR[i] = SUMR[i-1];
    } else {
      SUMR[i] += SUMR[i-1]+1;
      SUML[i] = SUML[i-1];     
    }
  }
  int left=0;
  rep(i, N) left=max(left, SUMR[i]-SUML[i]);
  rep(i, N) SUML[i]+=left;
  int right = SUML[N-1] - SUMR[N-1];
  rep(i,left) cout << '(';
  cout << S;
  rep(i, right) cout << ')';
  cout << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr1[100003];
int arr2[100003];
int arr3[100003];
int dpa[100003];
int dpb[100003];
int dpc[100003];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr1[i]>>arr2[i]>>arr3[i];
    }
    dpa[1]=arr1[1];
    dpb[1]=arr2[1];
    dpc[1]=arr3[1];
    for(int i=2;i<=n;i++){
        dpa[i]=max(dpb[i-1]+arr1[i],dpc[i-1]+arr1[i]);
        dpb[i]=max(dpc[i-1]+arr2[i],dpa[i-1]+arr2[i]);
        dpc[i]=max(dpa[i-1]+arr3[i],dpb[i-1]+arr3[i]);
    }
    cout<<max(dpa[n],max(dpb[n],dpc[n]));
    return 0;
}


Measured memory_bytes: 2560
cnt = [0,0]
while gets
    a, b, c = $_.chomp.split(',').map(&:to_i)
    if (a**2 + b**2) == c**2
        cnt[0] += 1
    end
    if a == b
        cnt[1] += 1
    end
end
puts cnt[0],cnt[1]

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int a,b; cin >> a >> b;
    int ans;
    if (a <= b) ans = a;
    else ans = a - 1;
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int  ans;
string s,t;
signed main() {
    cin >> s >> t;
    for (int i=0;i<3;i++) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    T, A = map(int, input().split(" "))
    H = list(map(int, input().split(" ")))
    target = (T - A) / 0.006
    difference = 10 ** 6
    answer = 60
    for i in range(N):
        if abs(H[i] - target) < difference:
            difference = abs(H[i] - target)
            answer = i
    print(answer + 1)


if __name__ == '__main__':
    main()

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

int main()
{
  int H, W;
  string top = "";
  string naka = "";
  cin >> H >> W;
  while (H != 0 && W != 0)
  {
    for (int j = 0; j < W; j++)
    {
      top += "#";
      if (j == 0 || j == (W - 1))
      {
        naka += "#";
      }
      else
      {
        naka += ".";
      }
    }

    for (int i = 0; i < H; i++)
    {
      if (i == 0 || i == (H - 1))
      {
        cout << top << endl;
      }
      else
      {
        cout << naka << endl;
      }
    }
    printf("\n");
    top = "";
    naka = "";
    cin >> H >> W;
  }
}


Measured memory_bytes: 3224
#include<cstdio>
#include<algorithm>

using namespace std;
int main(void){
   int field[3][51],n,r;
   while(scanf("%d%d",&n,&r),n+r){
      for(int i = 0;i < n;i++){field[0][i] = n-i-1;}
      for(int i = 0;i < r;i++){
         int p,c;scanf("%d%d",&p,&c);
         for(int j = 0;j < p-1;j++){
            field[2][j] = field[0][j];
         }
         for(int j = 0;j < c;j++){
            field[1][j] = field[0][p-1+j];
         }
         for(int j = 0;j < c;j++){
            field[0][j] = field[1][j];
         }
         for(int j = 0;j < p-1;j++){
            field[0][c+j] = field[2][j];
         }
      }
      printf("%d\n",field[0][0]+1);
   }
   return 0;
}

Measured memory_bytes: 1028