akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    ll n,ans[40],d=0;
    scanf("%lld",&n);
    // ll [n];
    if(n==0){
        printf("0\n");
        return 0;
    }
    while(n!=0){
        if(ABS(n)%POW(2,d+1)==POW(2,d)){
            ans[d]=1;
            n-=POW(-2,d);
        }else{
            ans[d]=0;
        }
        d++;
    }
    rrep(i,d-1,0){
        printf("%lld",ans[i]);
    }
    printf("\n");
    return 0;
}


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

int main(){
	int N;
	unsigned long a=2, b=1, c;
	cin >> N;
	if(N==0){
		cout << 2 << endl;
		return 0;
	} else if(N==1){
		cout << 1 << endl;
		return 0;
	} else if(N>1){
		for(int i=0; i<N-1; i++){
			c=a+b;
			a=b;
			b=c;
		}
	}
	cout << c << endl;
}

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

using ll = long long;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if (x >= a * a * b / 2) ans = atan(2.0 * (a * a * b - x) / a / a / a) * 180 / M_PI;
    else ans = 90.0 - atan(2.0 * x / a / b / b) * 180 / M_PI;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>
#include <cassert>
#pragma region ACL
#include <atcoder/fenwicktree>
//#include <atcoder/math>
#include <atcoder/string>
#include <atcoder/scc>
#include <atcoder/segtree>
#pragma endregion

using namespace std;
using namespace atcoder;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int k; cin >> k;
	string res = "ACL";
	rep(i, k)cout << res;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    int a,b[10000],c=0,i,j=0;
    double d,e;
    cin>>a;
    e=6.28318530717958623200*a;

    printf("%lf",e);

}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    ll mx = std::max({A, B, C});
    ll ans = 0;
    while (A + 2 <= mx) {
        ans++;
        A += 2;
    }
    while (B + 2 <= mx) {
        ans++;
        B += 2;
    }
    while (C + 2 <= mx) {
        ans++;
        C += 2;
    }

    ll n = 0;
    if (A != mx)
        n++;
    if (B != mx)
        n++;
    if (C != mx)
        n++;

    if (n == 1)
        ans += 2;
    if (n == 2)
        ans++;
    cout << ans << endl;
    return 0;
}

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

int Sort(int A[],int N){
	int min,t,s=0;
	for(int i=0; i<N-1; i++){
		min = i;
		for(int j=i; j<N; j++){
			if( A[j]<A[min] ) min = j;
		}

		t = A[i];
		A[i] = A[min];
		A[min] = t;

		if( i != min ) s++;
	}
	return s;
}


int main(){
	int A[100],N,i,s;

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

	s = Sort(A,N);

	for(int i=0; i<N; i++){
		if( i>0 ) cout << " ";
		cout << A[i];
	}
	cout << "\n";
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 1164
package main

import (
	"fmt"
)

func main() {
	var S string
	week := map[string]int{"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
	fmt.Scan(&S)
	for name, days := range week {
		if S == name {
			fmt.Println(days)
			break
		}
	}
	return
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

ll gcd (ll a ,ll b){
    ll c;
    while (a>0) {
        c=a;
        a=b%a;
        b=c;
    }
    return c;
}
int main(){
    ll b,c,d,e,k,n,o=1,p,q,x,y,z,max1=0,ans=1;
    string s,t,u;
    cin>>n;
    ll a[n],r[n],l[n];
    for (ll i=0; i<n; i++) {
        cin>>a[i];
    }
    l[0]=a[0];
    r[n-1]=a[n-1];
    for (ll i=1; i<n; i++) {
        l[i]=gcd(l[i-1],a[i]);
    }
    for (ll i=n-2; i>=0; i--) {
        r[i]=gcd(r[i+1],a[i]);
    }
    max1=r[1];
    for (ll i=1; i<n-1; i++) {
        max1=max(gcd(l[i-1],r[i+1]),max1);
    }
    max1=max(max1,l[n-2]);
    cout<<max1<<endl;
}






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

#define lint long long
#define ll long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

vector<bool> done;

void dfs(int v, const vector< vector<int> > &g, LLP &p){
    done[v] = true;

    if(v < 100000){
        ++p.first;
    }else{
        ++p.second;
    }

    for(auto to : g[v]){
        if(!done[to]){
            dfs(to, g, p);
        }
    }

    return;
}

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

    lint n;
    cin >> n;

    vector< vector<int> > g(200000);
    rep(i, n){
        int x, y;
        cin >> x >> y;
        g[--x].emplace_back((--y) += 100000);
        g[y].emplace_back(x);
    }

    lint ans = 0;
    done.resize(200000);
    rep(i, 200000){
        if(!done[i]){
            LLP p;
            dfs(i, g, p);
            ans += p.first * p.second;
        }
    }
    ans -= n;

    cout << ans << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
	string n;
	cin>>n;
	if (n[0]=='7'||n[1]=='7'||n[2]=='7')
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3624
count = 0
ok = true
gets.to_i.times do
  p, x = gets.chomp.split
  case p
    when "("
      count += x.to_i
    else
      count -= x.to_i
  end
  ok = false if count < 0
end
ok = false if count != 0
puts ok ? "YES" : "NO"

Measured memory_bytes: 6100
from collections import defaultdict
from heapq import heappush, heappop
INF = 9999999999999999999999999999

def spanning_tree(G):
  n = len(G)
  T = {}
  added = set([0])
  heap = []
  for v in G[0]:
    heappush(heap, (G[0][v], (0, v)))
  while len(added) < n:
    while True:
      c, e = heappop(heap)
      if e[1] not in added:
        break
    T[e] = c
    added.add(e[1])
    for v in G[e[1]]:
      heappush(heap, (G[e[1]][v], (e[1], v)))

  return T


G = {}

n, m = [int(v) for v in input().strip().split(' ')]
for i in range(n):
  G[i] = {}
for _ in range(m):
  s, t, c = [int(v) for v in input().strip().split(' ')]
  G[s][t] = c
  G[t][s] = c

if m == 0:
  print(0)
  exit()

T = spanning_tree(G)

s = 0
for e in T:
  s += T[e]

print(s)

Measured memory_bytes: 54184
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int>A(N + 1);
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		A[a]++;
	}
	int ans = 0;
	int n = 0;
	for (int i = X; i >= 0; i--) {
		ans += A[i];
	}
	for (int i = X; i <= N; i++) {
		n += A[i];
	}
	chmin(ans, n);
	cout << ans << endl;
}


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

int main(){
	int k,t;	cin>>k>>t;
	priority_queue< pair<int,int> >PQ;

	for(int i=1;i<=t;i++){
		int a;	cin>>a;
		PQ.push( {a,i} );
		// {個数、種類}
	}

	int a=0,i;
	while(PQ.empty()==false){
		pair<int,int> p=PQ.top();	PQ.pop();
		a=p.first;	i=p.second;
		if(PQ.empty())break;
		

		pair<int,int> q=PQ.top();		PQ.pop();
		int b=q.first, j=q.second;

		PQ.push( {a-b,i} );

	}


	cout<<max(a-1,0)<<endl;
	return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    auto P = aryread!double();
    auto dp = new double[][](N + 1, N + 1);

    foreach (ref row; dp)
        row[] = 0.0;

    dp[0][0] = 1.0;

    foreach (n; 0 .. N)
        foreach (x; 0 .. N)
        {
            dp[n + 1][x] += dp[n][x] * (1 - P[n]);
            dp[n + 1][x + 1] += dp[n][x] * P[n];
        }
    // foreach (row; dp)
    //     writeln(row);
    writefln("%.10f", dp[N][(N + 1) / 2 .. $].sum());
}


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

int main() {
  int n,m,tc;
  cin >> n >> m >> tc;

  vector<vector<int>> a(n + 2);
  vector<pair<int,int>> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i].first >> t[i].second;
  }
  sort(t.begin(),t.end());
  for (int i = 0; i < m; i++) {
    a[t[i].first].push_back(t[i].second);
  }
  while(tc--) {
    int p,q;
    cin >> p >> q;

    int res = 0;
    for (int i = p; i <= q; i++) {
      int cnt = (int)a[i].size() - (a[i].end() - upper_bound(a[i].begin(), a[i].end(), q));
      res += cnt;
    }
    cout << res << '\n';
  }
  return 0;
}

Measured memory_bytes: 3712
N, A, B, C = map(int, input().split())
v = [A, B, C]
s = [-1 for i in range(N)]
for i in range(N):
    t = input()
    if t == "AB":
        s[i] = 0
    if t == "BC":
        s[i] = 1
    if t == "AC":
        s[i] = 2
ans = [-1 for i in range(N)]
OK = True

for i in range(N):
    p = s[i]
    q = (s[i]+1)%3
    if v[p] < v[q]:
        ans[i] = p
        v[p] += 1
        v[q] -= 1
    elif v[p] > v[q]:
        ans[i] = q
        v[p] -= 1
        v[q] += 1
    elif v[p] > 0:
        if i == N-1:
            ans[i] = p
            v[p] += 1
            v[q] -= 1
        elif s[i+1] == q:
            ans[i] = q
            v[p] -= 1
            v[q] += 1
        else:
            ans[i] = p
            v[p] += 1
            v[q] -= 1
    else:
        OK = False
        break

ch = ["A", "B" ,"C"]
if OK:
    print("Yes")
    for i in range(N):
        print(ch[ans[i]])
else:
    print("No")

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

int main(){
	int h, w;
	cin >> h >> w;
	string l(w+2, '#');
	cout << l << endl;
	for(int i=0; i<h; i++){
		string tmp;
		cin >> tmp;
		cout << '#' << tmp << "#\n";
	}
	cout << l << endl;
	return 0;
}



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

int main(){
	
	string s;
	cin >> s;
	int c=0,max_c = 0;
	for (char x: s){
		//cout << x;
		if (x == 'A' || x == 'C' || x == 'G' || x == 'T'){
			c++;
		}
		else {
			if (c > max_c) max_c = c;
				c = 0;
			}
	}
	if (c > max_c) max_c = c;
	cout << max_c;
}


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



Measured memory_bytes: 82020
from copy import copy
n = int(input())
a = [int(x) for x in input().split()]
ans1=[(-1)**i for i in range(n)]

b=copy(a)
res_b=0
sb=0
c=copy(a)
res_c=0
sc=0
for i in range(n):
  sb+=a[i]
  if ans1[i]*sb>0:
    pass
  else:
    b[i]=ans1[i]-(sb-b[i])
    sb=sb-a[i]+b[i]
    res_b+=abs(b[i]-a[i])

  sc+=a[i]
  if -1*ans1[i]*sc>0:
    pass
  else:
    c[i]=-1*ans1[i]-(sc-c[i])
    sc=sc-a[i]+c[i]
    res_c+=abs(c[i]-a[i])
  
print(min(res_b,res_c))

Measured memory_bytes: 70692
#include <bits/stdc++.h>
#define p INT_MAX
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]= p;
        for(int j=i-1;j>=i-k && j>=1;j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

#define SIZE 110

int H, W;
char a[SIZE][SIZE];

void initialize() {
    for (int h=0; h<SIZE; ++h) {
        for (int w=0; w<SIZE; ++w) {
            a[h][w] = '#';
        }
    }
}

int main() {
    std::cin >> H >> W;
    initialize();
    for (int h=1; h<=H; ++h) {
        for (int w=1; w<=W; ++w) {
            std::cin >> a[h][w];
        }
    }
    for (int h=0; h<H+2; ++h) {
        for (int w=0; w<W+2; ++w) {
            std::cout << a[h][w];
        }
        std::cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))

a = sorted(a, reverse = True)
final = 0

if n % 2 == 0:
    ak = a[0:int(n/2)]
    for i in ak[1::]:
        final += i
    final *= 2
    final += ak[0]
else:
    ak = a[0:(int(n/2) + 1)]
    for i in ak[1::]:
        final += i
    final *= 2 
    final += ak[0]
    final -= ak[len(ak) - 1]


print(final)


Measured memory_bytes: 31808
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010


int main(){
  if(df)printf("*** debug mode ***\n");
  int n;
  scanf("%d",&n);
  long int a[MAX],b[MAX],i;
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%ld",&b[i]);
  }
  long int count=0,need=0;
  for(i=0;i<n;i++){
    count+=(b[i]-a[i]);
    need+=((a[i]<b[i])?(b[i]-a[i]+1)/2:0);
    if(df)printf("count:%ld need:%ld\n",count,need);
  }

  printf("%s",(count>=need)?"Yes":"No");
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 512
A, B, C = map(int, input().split())

if not all([A % 2 == 0, B % 2 == 0, C % 2 == 0]):
    print(0)

elif A == B == C:
    print(-1)
else:
    cnt = 0
    while all([A % 2 == 0, B % 2 == 0, C % 2 == 0]):
        cnt += 1
        A, B, C = ((B+C)//2, (A+C)//2, (A+B)//2)
    print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  int sum = A[0] + A[1] + A[2];
  if (sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, T;
	cin >> N >> T;
	vector<int>t(N);
	rep(i, N) {
		cin >> t[i];
	}
	int ans = T;
	rep(i, N - 1) {
		ans += min(t[i + 1] - t[i], T);
	}
	cout << ans << endl;
}




Measured memory_bytes: 1024
n = int(input())
nums=list(input().split())

def bubbleSort(nums,n):
    flag=True
    count=0
    while flag:
        flag=False
        for j in range(n-1,0,-1):
            if int(nums[j])<int(nums[j-1]):
                tmp=nums[j]
                nums[j]=nums[j-1]
                nums[j-1]=tmp
                flag=True
                count+=1

    print(' '.join(nums))
    print(count)

bubbleSort(nums,n)


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main(){
    while(1){
        int h, w, k = 1;
        char mark[] = {'#', '.'};
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            k = 1 - k;
            int l = k;
            for(int j = 0; j < w; j++){
                cout << mark[l];
                l = 1 - l;
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
//
//  main.cpp
//  G- Longest Path
//
//  Created by dz2701 on 8/26/20.
//  Copyright © 2020 dz2701. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+1;
int N, M, dp[MAX]; //max route to get to i
int k[MAX];

vector<int>adj[MAX];


int main(){
    cin >> N >> M;
    for(int i=1;i<=M;++i){
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b); //only go from a to b
        k[b]++;
    }
    
    queue<int>q;
    for(int i=1;i<=N;i++){
        if(!k[i]){
            q.push(i);
        }
    }
    
    while(!q.empty()){
        auto f = q.front();
        q.pop();
        for(auto i : adj[f]){
            k[i]--;
            dp[i] = max(dp[i], dp[f]+1);
            if(k[i]==0)q.push(i);
        }
    }
    
    int ans = -1e9;
    for(int i=1;i<=N;i++){
        ans = max(ans, dp[i]);
    }
    
    cout << ans;
    return 0;
    
}


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

using namespace std;

int n,k,m;

int s1(int n,int k)
{
	static int f[155];
	f[0] = 1;
	for(int i = 1;i <= n + 1; ++ i)
	{
		f[i] = 0;
		for(int j = 0;j <= k; ++ j)
			if(i - j - 1 >= 0)
				f[i] = (f[i] + f[i - j - 1]) % m;
	}
	return f[n + 1];
}

int s2(int n,int k)
{
	static int f[155][155][155];
	static int typ[155];
	int tot = 0;
	for(int i = 1;i * 2 - k <= n; ++ i)
	{
		tot ++;
		if(i * 2 <= n) typ[tot] |= 2;
		if(i * 2 - k > 0) typ[tot] |= 1;
	}
	f[0][0][0] = 1;
	for(int i = 1;i <= tot; ++ i)
		for(int j = 0;j <= k + 1; ++ j)
			for(int l = 0;l <= i; ++ l)
				if(f[i - 1][j][l])
				{
					//×óÓÒ¾ù²»Ñ¡
					f[i][0][0] = (f[i][0][0] + f[i - 1][j][l]) % m;
					//Ñ¡×ó²»Ñ¡ÓÒ
					if(typ[i] & 1)
						f[i][j ? j + 1 : 0][0] = (f[i][j ? j + 1 : 0][0] + f[i - 1][j][l]) % m;
					//Ñ¡ÓÒ²»Ñ¡×ó
					if(typ[i] & 2)
						f[i][0][l + 1] = (f[i][0][l + 1] + f[i - 1][j][l]) % m;
					if(typ[i] == 3)
						f[i][j ? j + 1 : l + 2][l + 1] = (f[i][j ? j + 1 : l + 2][l + 1] + f[i - 1][j][l]) % m;
				}
	int as = 0;
	for(int i = 0;i <= k + 1; ++ i)
		for(int j = 0;j <= tot; ++ j)
			as = (as + f[tot][i][j]) % m;
	return as;
}

int main()
{
	scanf("%d%d%d",&n,&k,&m);
	if(k % 2 == 0)
	{
		printf("%lld\n",(s1(n / 2,k / 2) * 1ll * s1((n + 1) / 2,k / 2)) % m);
	}
	else printf("%d\n",s2(n,k));
}

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

int main(){
    long long int K,A,B;
    cin >> K >> A >> B;
    if(K<=A){cout << 1 << endl;return 0;}
    if(A<=B){cout << -1 << endl;return 0;}
    K-=A;
    cout << 3+((long long int)(K-1)/(A-B))*2  << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    int N=Integer.parseInt(scanner.next());
	    int Q=Integer.parseInt(scanner.next());
	    String S =scanner.next();
	    S=S.replaceAll("AC", "aC");
	    int[] L=new int[Q];
	    int[] R=new int[Q];
	    int[] t = new int[N+1];

	    for(int i=0; i<Q;i++) {
	    	L[i]=Integer.parseInt(scanner.next());
	    	R[i]=Integer.parseInt(scanner.next());
	    }

	    int c= 0;
	    t[0]=0;
	    for (int i=0; i<N;i++) {
	    	if (S.charAt(i) == 'a') {
	    	    c++;
	    	}
	    	t[i+1]=c;
	    }

	    for (int i=0; i<Q; i++) {
	    	int ca=t[R[i]-1] - t[L[i]-1];


	    	System.out.println(ca);
	    }

	}
}

Measured memory_bytes: 64716
#include<stdio.h>
#include<stdlib.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

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

	unsigned short A[n+1];
	unsigned short B[n+1];

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}
	int C[max+1] = {0};

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 10540
n = int(input())
lst = list(map(int,input().split()))
lst2 = [0]*n
all_sum = 0
for e in lst:
    all_sum += e

for i in range(n):
    for j in range(i+1):
        lst2[i] += lst[j]


for before,now in zip(lst2,lst2[1:]):
    if abs(abs(now-all_sum)-abs(now))<abs(abs(before-all_sum)-abs(before)):
        ans = abs(abs(now-all_sum)-abs(now))
    else:break

print(ans)




Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main(){
    long long a, b, x;
    cin >> a >> b >> x;
    if(a != 0)
    cout << b / x - (a - 1) / x << endl;
    else 
    cout << (b / x) + 1 << endl;
    return 0; 
}

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

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

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(2 * n);
    REP(i, 0, n) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    vector<ll> sum(2 * n + 1, 0);
    REP(i, 0, 2 * n) {
        sum[i + 1] += a[i % n] + sum[i];
    }

    auto check = [&](ll mid) -> bool {
        REP(i, 0, n) {
            auto it1 = lower_bound(sum.begin() + i, sum.end(), mid + sum[i]) - sum.begin();
            auto it2 = lower_bound(sum.begin() + it1, sum.end(), mid + sum[it1]) - sum.begin();
            auto it3 = lower_bound(sum.begin() + it2, sum.end(), mid + sum[it2]) - sum.begin();
            if (it3 - i <= n) return true;
        }
        return false;
    };

    ll l = 0, r = 1LL << 60;
    ll ans = 0;
    while (l <= r) {
        ll mid = (l + r) / 2;
        if (check(mid)) {
            l = mid + 1;
            ans = mid;
        } else {
            r = mid - 1;
        }
    }
    cout << ans << endl;

    return 0;
}



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

public class Main {
	public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int n = in.nextInt();
        Set<String> set = new HashSet<>();
      	for (int i = 0; i < n; ++i) {
        	String s = in.next();
          	if (!set.contains(s)) set.add(s);
        }
      	System.out.println(set.size());
    }
}


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

int main(){
    string S;
    cin >> S;
    bool f = false;
    for(int i = 0;i < 3;i++){
        if(S[i] == S[i+1]){
            f = true;
            break;
        }
    }
    if(f){
        cout << "Bad" << endl; 
    }else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim().split('\n').shift().split(' ')
  let M = input[1] - 0
  let N = input[0] - M
  let count = 1
  count += Math.ceil(N / (M - 1))
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8012
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int X,Y;

int main(){
  cin>>X>>Y;
  out(X+Y/2);  
}


Measured memory_bytes: 256
from queue import Queue

K = int(input())

q = Queue()

for i in range(1,10):
    q.put(i)

for _ in range(K):
    ans = q.get()
    if ans % 10 == 0:
        q.put(ans*10)
        q.put(ans*10+1)
    elif ans % 10 == 9:
        q.put(ans*10+8)
        q.put(ans*10+9)
    else:
        d = ans % 10
        q.put(ans*10+d-1)
        q.put(ans*10+d)
        q.put(ans*10+d+1)

print(ans)

Measured memory_bytes: 12460
using System.Linq;
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = Volume0.QQ();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class Volume0
    {
        public static string QQ()
        {
            return string.Join("\n",
                Enumerable.Range(1, 9)
                    .Select(x => string.Join("\n", Enumerable.Range(1, 9)
                        .Select(y => string.Format("{0}x{1}={2}", x, y, x * y)).ToArray()
                        )).ToArray());
        }
    }
}

Measured memory_bytes: 5892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long k = sc.nextLong();

		long gcd = 0;

		long sum = 0;

		for (int ai = 1; ai <= k; ai++) {
			for (int bi = 1; bi <= k; bi++) {
				for (int ci = 1; ci <= k; ci++) {
					gcd = getGcd(getGcd(ai, bi), ci);
					sum += gcd;
				}
			}
		}

		System.out.println(sum);
	}

	private static long getGcd(long x, long y) {

		long bigger = Math.max(x, y);
		long smaller = Math.min(x, y);

		long mod = bigger % smaller;

		while (mod != 0) {
			bigger = smaller;
			smaller = mod;
			mod = bigger % smaller;
		}

		return smaller;
	}

}


Measured memory_bytes: 35788
function Main(input) {
  input = input.split("\n");
  var H = parseInt(input[0].split(" ")[0]);
  var W = parseInt(input[0].split(" ")[1]);
  var K = parseInt(input[0].split(" ")[2]);
  input.shift();
  var c = input.map(i => i.split(""));
  var ans =0;
  c.splice(H,c.length);
  var maph = new Array([0],[1]);
  for(var i=0;i<H-1;i++){
    var mapsub = new Array(0);
    for(var j=0;j<maph.length;j++){
      var zero =[...maph[j]];
      var one =[...maph[j]];
      zero.push(0);
      one.push(1);
      mapsub.push(zero);
      mapsub.push(one);
    }
    maph=mapsub;
  }
  var mapw = new Array([0],[1]);
  for(var i=0;i<W-1;i++){
    var mapsub = new Array(0);
    for(var j=0;j<mapw.length;j++){
      var zero =[...mapw[j]];
      var one =[...mapw[j]];
      zero.push(0);
      one.push(1);
      mapsub.push(zero);
      mapsub.push(one);
    }
    mapw=mapsub;
  }
  var blacks=0;
  for(var i=0;i<maph.length;i++){
    for(var j=0;j<mapw.length;j++){
      for(var k=0;k<H;k++){
        for(var l=0;l<W;l++){
          if(maph[i][k]==0&&mapw[j][l]==0&&c[k][l]=="#"){
            blacks++;
          }
        }
      }
      if(blacks==K){
        ans++;
      }
      blacks=0;
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32504
#include <iostream>
#include <string>

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '2') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if(a<=x && a+b>=x) cout << "YES" << endl;
  else cout << "NO" << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main()
{
    ll N, K;
    cin >> N >> K;
    VLL x(N);
    rep(i,N){
        cin >> x[i];
    }
    ll min_right=INF;
    ll min_left=INF;
    ll all_min=INF;
    ll l=0;
    ll r=0;
    rep(i,N-K+1){
        l=x[i];
        r=x[i+K-1];
        min_right=min(min_right,abs(r)+abs(r-l));
        min_left=min(min_left, abs(l)+abs(r-l));
        all_min=min(all_min,min_right);
        all_min=min(all_min, min_left);
    }
    cout << all_min << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long n;
    cin >> n;
    for (long i = sqrt(n); i >= 1; i--)
    {
        if (n % i == 0)
        {
            cout << n / i + i - 2 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int n;
int ac,wa,tle,re;
string s;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n){
        cin >> s;
        if(s == "AC") ac++;
        else if(s == "TLE") tle++;
        else if(s == "WA") wa++;
        else re++;
    }

    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}


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


static inline int find(int n, int target[], int len) {
    int i;
    
    for ( i = 0; i < len; i++ ) {
        if ( target[i] == n ) {
            return 1;
        }
    }

    return 0;
}

static void read_numbers(int array[], int num) {
    int i, d;

    for ( i = 0; i < num; i++ ) {
        scanf("%d", &d);
        array[i] = d;
        (void)fgetc(stdin);
    }

    return;
}

int main(int argc, char* argv[]) {
    int n, q, i;
    int* S;
    int* T;
    int C = 0;
    
    scanf("%d\n", &n);
    S = malloc( sizeof(int) * n );
    read_numbers(S, n);

    scanf("%d\n", &q);
    T = malloc( sizeof(int) * q );
    read_numbers(T, q);

    for ( i = 0; i < q; i++ ) {
        C += find(T[i], S, n);
    }

    printf("%d\n", C);

    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int main(void)
{
  long int a, b, c, k, result = 0;
  
  scanf("%ld %ld %ld %ld", &a, &b, &c, &k);
  
  if( k > a ){
    result += a;
  } else {
      result += k;
  }
  
  k -= (a+b);
  
  if( k <= 0 ){
      printf("%ld\n", result);
      return 0;
  }
  
  result -= k;
  
  printf("%ld\n", result);
  return 0;
  
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#define maxn 200009
using namespace std;
char s[maxn];
int cntw[maxn], cntb[maxn];
int main(){
	int n;
	cin >> n;
	scanf("%s", s + 1);
	int last = 0;
	
	for(int i = 1; i <= n; i++)
		if(s[i] == '.')
			last = i;
	
	if(last == 0){
		puts("0");
		return 0;
	}
	
	
	for(int i = 1; i <= n; i++){
		cntw[i] = cntw[i - 1];
		cntb[i] = cntb[i - 1];
		if(s[i] == '.')
			cntw[i]++;
		else
			cntb[i]++;
			
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		
		if(s[i] == '.'){
			int cur = min(cntw[i], cntb[i]);	
			ans = min(ans + 1, cur);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
#define f(x) (x)*(x)

using namespace std;

int n;
int a[1001];
int cnt;
int ans;
int tt=0x7fffffff;

int main()
{
	cin>>n;
	int mi=tt,ma=-tt;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		cnt+=a[i];
		if(a[i]<mi) mi=a[i];
		if(a[i]>ma) ma=a[i];
	}
	int t=cnt/n;
	for(int k=mi;k<=ma;k++)
	{
		ans=0;
		for(int i=1;i<=n;i++)
		{
			ans+=f(a[i]-k);
		}
		if(ans<tt) tt=ans;
	}
	cout<<tt;
	return 0;
}

Measured memory_bytes: 256
def sieve(n):
    isPrime = [True]*(n+1)
    isPrime[0] = isPrime[1] = False
    for i in range(3,n+1,2):
        if isPrime[i]:
            for j in range(2*i,n+1,i): isPrime[j] = False
    for i in range(4,n+1,2): isPrime[i] = False
    return isPrime

n = int(input())
ans = []
for i,p in enumerate(sieve(55555)):
    if p and i%5 == 1:
        ans.append(i)
        if len(ans) == n: break
print(*ans)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    char c; cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

int main() {
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  cout << 15 - x1 - x2 - x3 - x4 - x5 << endl;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


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

int main() {
	string S;
  	int K;
  cin >> K >> S;
  int sizes=0;
   sizes =S.size();
  string T;
  if(sizes <= K){
  cout << S << endl;
  }
  else{
    for (int i = 0; i < K; i++) {
    cout << S.at(i) ;
}
    cout << "..." << endl;

  
  }
  
  
  
}


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

int a[6];

class Dice{
  public:
   
    Dice(int aa, int bb, int cc, int dd, int ee, int ff){
        a[0] = aa;
        a[1] = bb;
        a[2] = cc;
        a[3] = dd;
        a[4]= ee;
        a[5] = ff;
        
    }
    
    void roll_N(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = bbb;
        a[1] = fff;
        a[2] = ccc;
        a[3] = ddd;
        a[4] = aaa;
        a[5] = eee;
    }
    
    void roll_S(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = eee;
        a[1] = aaa;
        a[2] = ccc;
        a[3] = ddd;
        a[4] = fff;
        a[5] = bbb;
    }
    
    void roll_E(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = ddd;
        a[1] = bbb;
        a[2] = aaa;
        a[3] = fff;
        a[4] = eee;
        a[5] = ccc;
    }
    
    void roll_W(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = ccc;
        a[1] = bbb;
        a[2] = fff;
        a[3] = aaa;
        a[4] = eee;
        a[5] = ddd;
    }
};

int main(){
    int A, B, C, D, E, F;
    string direction;
    
    cin >> A >> B >> C >> D >> E >> F;
    
    Dice sai(A, B, C, D, E, F);
    
    cin >> direction;
    
    for(int i = 0; direction[i] != '\0'; i++){
        if(direction[i] == 'N'){
            sai.roll_N(A, B, C, D, E, F);
        }
        
        else if(direction[i] == 'S'){
            sai.roll_S(A, B, C, D, E, F);
        }
        
        else if(direction[i] == 'E'){
            sai.roll_E(A, B, C, D, E, F);
        }
        
        else if(direction[i] == 'W'){
            sai.roll_W(A, B, C, D, E, F);
        }
        
        A = a[0];
        B = a[1];
        C = a[2];
        D = a[3];
        E = a[4];
        F = a[5];
    }
    
    cout << a[0] << endl;
}



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

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, x, l;
	cin >> n >> x;
	int cnt = 1,d=0;
	for(int i=0;i<n;++i)
	{
		cin >> l;
		d += l;
		if(d<=x) cnt++;
	}
	cout << cnt ;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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

Measured memory_bytes: 26140
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let v: Vec<char> = buf.trim().chars().collect();

    let mut cnt = 0;
    let mut del = 0;
    for &x in v.iter() {
        if x == 'S' {
            cnt += 1;
        } else if cnt > 0 {
            cnt -= 1;
            del += 2;
        }
    }
    println!("{}", v.len() - del);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
S = input()
counter = collections.Counter(S)
count = 1
mod = 10 ** 9 + 7
for _, v in counter.items():
    # その文字数の数 + 1ケース（選ばないケース)
    count = count * (v + 1) % mod

# 空文字列も含まれるので1引く
ans = (count - 1) % mod
print(ans)


Measured memory_bytes: 3444