akhauriyash/Code-Regression huggingface dataset:
(h=Hash[q=[[$_.chop,0]]]
puts (while q[0]
s,c=q.shift
break c if s=~/^(r+|g+|b+)$/
(0..s.size-2).map{|i|s[i]!=s[i+1]&&(t=s.dup;t[i,2]="rgb".delete(t[i,2])*2;h[t]||=(q<<[t,c+1];0))}end)||:NA)while gets>?a

Measured memory_bytes: 7524
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  s[3]='8';
  std::cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1e9+7
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  INT_MAX
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)

using namespace std;
const int MX = 2e5 + 7;
const db pi=3.1415926535898;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll power(ll b, ll e, ll MOD = mod) { ll ans = 1; while (e) { if (e&1) ans = (ans*b) % MOD; b = (b*b) % MOD; e /= 2; } return ans; }
ll inv(ll num, ll MOD = mod) { return power(modulo(num), MOD - 2, MOD); }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
int main()
{
	//ios::sync_with_stdio(0);cin.tie(0);
	int t,n,m;
	db x,h,s;
	cin>>s>>h>>x;
	db res;
  if(s*s*h>2*x)
	res=90.0-(atan (2*x/(s*h*h))/pi)*180;
	else {
      //cout<<"s"<<endl;
    res=90.0-atan((0.5*s*s*s)/(s*s*h-x))/pi*180;
	}
	printf("%.15f\n",res);
	//cout<<90.0-(x/(s*s*h))*90<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
	string s1,s2,s3;
	cin>>s1>>s2;
	ll f1,f2;
	cin>>f1>>f2;
	cin>>s3;
	if (s3==s1)
	f1--;
	else
	f2--;
	cout<<f1<<" "<<f2<<endl;
	
	

		

}


	
  
  

		
		
		
		
		
		
	
	
	 
		
		
	
	
	

	


	
	
	
   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
 
int main() {
  LL n;
  cin >> n;
  LL dist = n - 1;
  for (LL i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      LL j = n / i;
      LL cur = (i - 1) + (j - 1);
      dist = min(cur, dist);
    }
  }
  cout << dist << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;


class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> arr = new ArrayList<Integer>();
		
		int x = scan.nextInt();
		while(x != 0){
			arr.add(x);
			x = scan.nextInt();
		}
		
		int size = arr.size();
		for(int i = 0; i < size; i++){
			System.out.println("Case " + (i + 1) + ": " + arr.get(i));
		}
	}
}


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

void cal_fibonacci(long *a,int n) {
   a[0] =  1;
   if(n > 0) a[1] =  1;
   int i;
   for (i = 2; i <= n; i++) {
     a[i] = a[i-1] + a[i-2];
   }
}

int main()
{
  int n;
  long *a;
  scanf("%d",&n);
  a = malloc(sizeof(long) * (n+1));
  cal_fibonacci(a,n);
  printf("%ld\n",a[n]);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef P Vector;

typedef pair<P,Vector> Line;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int dot(Vector a,Vector b){
	return a.first*a.second+b.first*b.second;
}

int cross(Vector a,Vector b){
	return a.first*b.second-b.first*a.second;
}

int n;
int x[9],y[9];
int ans;
vector<Line> li;
bool po=false;

bool same(Line a,Line b){
	if(a.second.first==0){
		if(a.first.first==b.first.first && b.second.first==0)return true;
	}else if(a.second.second==0){
		if(a.first.second==b.first.second && b.second.second==0)return true;
	}else{
		int diff=b.first.first-a.first.first;
		if(diff%a.second.first!=0)return false;
		int bi=diff/a.second.first;
		if(cross(a.second,b.second)==0 && a.first.second+bi*a.second.second==b.first.second)return true;
	}
	return false;
}

void dfs(int bit){
	//printf("%d\n",bit);
	if(bit==(1<<n)-1){
		ans=min(ans,(int)li.size());
		return;
	}
	if(ans<=li.size())return;
	for(int i=0;i<n;i++){
		if(bit>>i & 1){
			for(int j=0;j<n;j++){
				if(!(bit>>j & 1)){
					P mid=P((x[i]+x[j])/2,(y[i]+y[j])/2);
					Vector vec=Vector(y[j]-y[i],x[i]-x[j]);
					int g=gcd(abs(y[j]-y[i]),abs(x[i]-x[j]));
					//printf("%d %d %d\n",abs(y[j]-y[i]),abs(x[i]-y[j]),g);
					vec.first/=g;
					vec.second/=g;
					bool flag=false;
					for(int k=0;k<li.size();k++){
						if(same(li[k],Line(mid,vec))){
							flag=true;
							break;
						}
					}
					if(!flag){
						li.push_back(Line(mid,vec));
					}
					dfs(bit+(1<<j));
					if(!flag){
						li.pop_back();
					}
				}
			}
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x[i],&y[i]);
		x[i]*=2;
		y[i]*=2;
	}
	vector<Line> li;
	bool po=false;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			P mid=P((x[i]+x[j])/2,(y[i]+y[j])/2);
			Vector vec=Vector(y[j]-y[i],x[i]-x[j]);
			int g=gcd(abs(y[j]-y[i]),abs(x[i]-x[j]));
			vec.first/=g;
			vec.second/=g;
			for(int k=0;k<n;k++){
				if(k==i)continue;
				for(int l=k+1;l<n;l++){
					if(l==j)continue;
					P mid2=P((x[k]+x[l])/2,(y[k]+y[l])/2);
					Vector vec2=Vector(y[l]-y[k],x[k]-x[l]);
					g=gcd(abs(y[l]-y[k]),abs(x[l]-x[k]));
					vec2.first/=g;
					vec2.second/=g;
					if(same(Line(mid,vec),Line(mid2,vec2)))po=true;
				}
			}
		}
	}
	if(!po){
		printf("%d\n",n-1);
		return 0;
	}
	ans=n-2;
	dfs(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
const int N=25;
const long long INF=4557430888798830399;
int n;
int a[N];
map<pair<int,int>,long long>f[N][N];
long long dfs(int l,int r,int p,int q)
{
	if(l>r) return 0;
	if(f[l][r].count({p,q})) return f[l][r][{p,q}];
	long long res=INF;
	for(int i=l;i<=r;i++)
		res=min(res,dfs(l,i-1,p,p+q)+dfs(i+1,r,p+q,q)+1LL*(p+q)*a[i]);
	return f[l][r][{p,q}]=res;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	printf("%lld",dfs(2,n-1,1,1)+a[1]+a[n]);
	return 0;
}


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

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

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < n;++i){
        cin >> f.at(i);
    }
    sort(all(a));
    sort(all(f),greater<ll>());
    ll tmpmax = 0;
    ll tmpsuma = 0;
    for(i = 0;i < n;++i){
        tmpmax = max(tmpmax, a.at(i)*f.at(i));
        tmpsuma += a.at(i);
    }
    if(tmpsuma <= k){
        cout << 0 << endl;
        return 0;
    }
    if(k == 0){
        cout << tmpmax << endl;
        return 0;
    }
    ll sup = tmpmax;
    ll inf = 1;
    while(true){
        if(sup == inf){
            break;
        }
        ll tmp = (sup + inf)/2;
        ll tmpk = 0;
        for(i = 0;i < n;++i){
            tmpk += max(a.at(i) - tmp/f.at(i),0LL);
        }
        if(tmpk <= k){
            sup = tmp;
        }else{
            inf = tmp+1;
        }
    }
    cout << inf << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb=new StringBuilder();
		int i,j,k;
		int[][][] list=new int[4][3][10];
		for(i=0;i<4;i++){
			for(j=0;j<3;j++){
				for(k=0;k<10;k++){
					list[i][j][k]=0;
				}
			}
		}
		String str=br.readLine();
		int n=Integer.parseInt(str);
		for(i=0;i<n;i++){
			String[] house=br.readLine().split(" ");
			int b=Integer.parseInt(house[0])-1;
			int f=Integer.parseInt(house[1])-1;
			int r=Integer.parseInt(house[2])-1;
			int v=Integer.parseInt(house[3]);
			
			list[b][f][r]+=v;
		}
		for(i=0;i<4;i++){
			for(j=0;j<3;j++){
				for(k=0;k<10;k++){
					System.out.print(" "+ list[i][j][k]);
				}
				System.out.println();
			}
			if(i==3)break;
			System.out.println("####################");
		}
	}
}

Measured memory_bytes: 24612
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i=i*2){
       ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

N = int(input())
a = int(list(str(N))[-1])

if N % 2 == 1:
	print(0)
else:
	par = 5
	ctr = 0
	while par <= N:
		ctr += ((N - a) // par) // 2
		par *= 5
	print(ctr)

Measured memory_bytes: 38256
N, M = map(int, input().split())

ab_list = [list(map(int, input().split())) for i in range(N)]

ab_list_sorted = sorted(ab_list, reverse=False, key=lambda x:x[0])

nokori_honsu = M
cost = 0

for ab in ab_list_sorted:
    if ab[1] >= nokori_honsu:
        cost += nokori_honsu * ab[0]
        break
    else:
        cost += ab[1] * ab[0]
        nokori_honsu -= ab[1]
        
print(cost)

Measured memory_bytes: 29800
/* ex5_3
    fmuacshai */

#include<stdio.h>
int main(void){
    //縦の行数をheight、横の列数をwideとする
    int height,wide;
    //heightの入力
    scanf("%d",&height);
    //wideの入力
    scanf("%d",&wide);
    //マス目の配列をsqueres[height][wide]とする
    char squeres[height][wide];
    //縦の列を残すか判別する配列をsensorh[]、
    //横の列を残すか判別する配列をsensorw[]とする
    int sensorh[height],sensorw[wide];
    //squeres[height][wide]を入力
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            scanf(" %c",&squeres[i][j]);
        }
    }
    //sensorh[]の中身を全て0にする
    for(int i=0;i<height;i++){
        sensorh[i]=0;
    }
    //sensorw[]の中身を全て0にする
    for(int j=0;j<wide;j++){
        sensorw[j]=0;
    }
    //'#'が入力されているところに対応する行と列を把握する
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            //'#'だったら
            if(squeres[i][j]=='#'){
                //対応する部分の配列に1を入力
                sensorh[i]=1;
                sensorw[j]=1;
            }
        }
    }
    //対応する行列がどちらも1が入力されていたらを出力
    for(int i=0;i<height;i++){
        for(int j=0;j<wide;j++){
            //対応する行列がどちらも1が入力されていたら
            if(sensorh[i]==1 && sensorw[j]==1){
                //squeres[i][j]を出力
                printf("%c",squeres[i][j]);
            }
        }
        //消されなかったものがあった列は最後に改行
        if(sensorh[i]==1){
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
<?php
// Your code here!
// $n,$= explode(" ",trim(fgets(STDIN)));
fscanf(STDIN,"%d",$k);
fscanf(STDIN,"%s",$s);

if(strlen($s) <= $k){
    echo $s;
}else{
    echo substr($s, 0, $k),"...";
}

?>

Measured memory_bytes: 16116
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

int main(){
	lint n;cin>>n;
	string s;cin>>s;
	lint a[26]={};
	rep(i,n)a[s[i]-'a']++;
	lint ans=1;
	rep(i,26)if(a[i]){
		ans*=a[i]+1;
		ans%=md;
	}cout<<ans-1<<endl;
}

//sub-EOF


Measured memory_bytes: 1024
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

type StringStack struct {
	container []string
}

func NewStringStack() *StringStack {
	return &StringStack{
		container: make([]string, 0),
	}
}

func (s *StringStack) Push(value string) {
	s.container = append(s.container, value)
}

func (s *StringStack) Pop() string {
	if s.Size() == 0 {
		panic("StringStack is empty")
	}
	x := s.container[len(s.container) - 1]
	s.container = s.container[:len(s.container) - 1]
	return x
}

func (s *StringStack) Size() int {
	return len(s.container)
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	e := 0
	o := 0
	for i := 0; i < N; i++ {
		a := io.NextInt()
		if a % 2 == 0 {
			e++
		} else {
			o++
		}
	}
	e += o / 2;
	o = o % 2;
	if o == 1 {
		if e == 0 {
			io.PrintLn("YES")
		} else {
			io.PrintLn("NO")
		}
	} else {
		io.PrintLn("YES")
	}
}

Measured memory_bytes: 7040
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
const int Maxn=100005;
char c[Maxn];
bool dp[Maxn];
int main(){
	scanf("%s",c+1);
	dp[0]=true;
	int n=strlen(c+1);
	for (int i=1;i<=n;i++){
		if (i>=5 && c[i-4]=='e' && c[i-3]=='r' && c[i-2]=='a' && c[i-1]=='s' && c[i]=='e'){
			dp[i]|=dp[i-5];
		}
		if (i>=5 && c[i-4]=='d' && c[i-3]=='r' && c[i-2]=='e' && c[i-1]=='a' && c[i]=='m'){
			dp[i]|=dp[i-5];
		}
		if (i>=6 && c[i-5]=='e' && c[i-4]=='r' && c[i-3]=='a' && c[i-2]=='s' && c[i-1]=='e' && c[i]=='r'){
			dp[i]|=dp[i-6];
		}
		if (i>=7 && c[i-6]=='d' && c[i-5]=='r' && c[i-4]=='e' && c[i-3]=='a' && c[i-2]=='m' && c[i-1]=='e' && c[i]=='r'){
			dp[i]|=dp[i-7];
		}
	}
	if (dp[n]) printf("YES\n");
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,d=0,n,m,k,ans=0;
    string s,s2;
    cin >> n;
    cin >> s;
    //VI p(n);
    if(n>=3200) { cout << s <<endl;}
    else { cout << "red" <<endl;}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define pi acos(-1.0)


int  main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
    vector<data_type> store;
    double n;
    cin>>n;
    cout<<fixed<<setprecision(5)<<2.0*pi*n<<endl;



    return 0;
}




Measured memory_bytes: 3804
from itertools import chain


def solve():
    N, M, K = map(int, input().split())

    A = map(int, input().split())
    *B, = map(int, input().split())

    answer = 0

    sum_b = sum(B)
    idx_b = M
    remain = K

    for i, a in enumerate(chain([0], A)):
        remain -= a
        if remain < 0:
            break

        while sum_b > remain:
            if idx_b < 0:
                break
            idx_b -= 1
            b = B[idx_b]
            sum_b -= b

        answer = max(answer, i + idx_b)

    return answer


def main():
    print(solve())


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef unsigned long long ull;


int main(void){
    int n, k;
    cin >> n >> k;
    vector<pair<ll,ll>> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec.at(i).first >> vec.at(i).second;
    }

    ull ans = 1e19;

    for(int i1=0; i1<n; i1++){
        for(int i2=0; i2<n; i2++){
            for(int i3=0; i3<n; i3++){
                for(int i4=0; i4<n; i4++){
                    ll x1 = vec.at(i1).first;
                    ll x2 = vec.at(i2).first;
                    ll y1 = vec.at(i3).second;
                    ll y2 = vec.at(i4).second;
                    if(x1 > x2){
                        swap(x1, x2);
                    }
                    if(y1 > y2){
                        swap(y1, y2);
                    }
                    int cnt = 0;
                    for(int i5=0; i5<n; i5++){
                        if(vec.at(i5).first >= x1 && vec.at(i5).first <= x2 && vec.at(i5).second >= y1 && vec.at(i5).second <= y2){
                            cnt++;
                        }
                    }
                    if(cnt >= k){
                        ull rect = (x2 - x1) * (y2 - y1);
                        ans = min(ans, rect);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = ll(1e9) + ll(7); //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result) * (x));
    
    x=((x)*(x));
    
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}

int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
  ll n;
  cin >> n ;
  if(n&1)cout << 0;
  else {
    ll res = 0 , s = 10;
    while(s<=1e18){
      res += (n/s);
      s *= 5;
    }
    cout << res;
  }
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int r[9] = {};

    for (int i = 0; i < n; i++)
    {
        r[min(a[i] / 400, 8LL)]++;
    }

    int cnt = 0;
    for (int i = 0; i < 8; i++)
    {
        if (r[i] > 0)
            cnt++;
    }

    int mx = 0;
    int mn = 0;
    if (cnt == 0)
    {
        mn = 1;
        mx = min(r[8], INF);
    }
    else
    {
        mn = cnt;
        mx = min(cnt + r[8], INF);
    }

    cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  int sum = 0;
  int sqsum = 0;
  for (int i = 0; i < N; i++){
    cin >> X.at(i);
    sum += X.at(i);
    sqsum += X.at(i) * X.at(i);
  }
  
  int cost = 0;
  int min = sqsum;
  for (int j = 1; j <= 100; j++){
    cost = N * j * j - 2 * j * sum + sqsum;
    if (cost < min){
      min = cost;
    }
  }
  
  cout << min;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

namespace {

int InsertionSort(int* a, int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; ++i) {
    const int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}

int ShellSort(int* a, int n) {
  int cnt = 0;
  int m = 0;
  int G[100];
  G[0] = 1;
  for (int i = 0; i < 100; ++i) {
    G[i + 1] = 3 * G[i] + 1;
    ++m;
    if (G[i + 1] >= n) {
      break;
    }
  }
  sort(G, G + m, greater<int>());

  cout << m << endl;
  for (int i = 0; i < m; ++i) {
    if (i > 0) printf(" ");
    printf("%d", G[i]);
  }
  printf("\n");

  for (int i = 0; i < m; ++i) {
    cnt += InsertionSort(a, n, G[i]);
  }

  return cnt;
}

}  // namespace

int main() {
  int n;
  int a[1000000];

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  const int cnt = ShellSort(a, n);

  cout << cnt << endl;
  for (int i = 0; i < n; ++i) {
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
//B Ordinary Number
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n,ans;
  cin>>n;
  ans=0;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
  {
    cin>>vec.at(i);
  }
  for(int i=1;i<n-1;i++)
  {
    if(((vec.at(i-1)<vec.at(i))&&(vec.at(i)<vec.at(i+1)))||(vec.at(i-1)>vec.at(i))&&(vec.at(i)>vec.at(i+1)))
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> vs(n);
    for (int i = 0; i < n; ++i) cin >> vs[i];
    map<int, int> count;
    for (auto v: vs) count[v] += 1;
    int res = 0;
    for (int val = 1 << 30; val > 1; val /= 2) {
        vector<pair<int, int>> ps(count.begin(), count.end());
        for (auto p: ps) {
            if (count.find(val - p.first) != count.end()) {
                int pairs = min(count[p.first], count[val - p.first]);
                if (p.first == val - p.first) {
                    pairs = count[p.first] / 2;
                }
                res += pairs;
                count[p.first] -= pairs;
                count[val - p.first] -= pairs;
            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 12004
#include<bits/stdc++.h>
#define Mo 1000000007
#define N 200000
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long LL;
typedef long double LD;
using namespace std;
int a[N], h[N], n;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int m = 0, ans1 = n, ans2 = n, now = 0;
	memset(h, 0, sizeof h);
	for(int i = 1; i <= n; i += 2) {
		h[a[i]]++;
		if (m < h[a[i]]) m = h[a[i]], now = a[i];
	}
	ans1 -= m;
	m = 0, memset(h, 0, sizeof h);
	for(int i = 2; i <= n; i += 2) {
		h[a[i]]++;
		if (a[i] != now) m = max(m, h[a[i]]);
	}
	ans1 -= m;
	m = 0, now = 0, memset(h, 0, sizeof h);
	for(int i = 2; i <= n; i += 2) {
		h[a[i]]++;
		if (m < h[a[i]]) m = h[a[i]], now = a[i];
	}
	ans2 -= m;
	m = 0, memset(h, 0, sizeof h);
	for(int i = 1; i <= n; i += 2) {
		h[a[i]]++;
		if (a[i] != now) m = max(m, h[a[i]]);
	}
	ans2 -= m;
	cout << min(ans1, ans2) << endl;
} 


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{  int a,h = 0,m = 0,s = 0,tmp = 0;
	scanf("%d",&a);
	h = a / 3600;
	tmp = a % 3600;
	m = tmp  / 60;
	s = tmp % 60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
n,*z=`dd`.split.map &:to_i
t=(e=[*0...n]).dup
f=->q{t[q]}
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(k%2>0&&e.map!(&f);t=t.map &f;k/=2)while k>0
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 55540
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : July 06, 2020 9:53 AM
 *    Problem Name  : B - Judge Status Summary
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc173/tasks/abc173_b
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    
    int n,cnt_ac=0, cnt_tle=0, cnt_wa=0, cnt_re=0;
    cin >> n;

    for(int i=1; i<=n; i++){
	    string s;
	    cin >> s;

	    if (s == "AC") cnt_ac ++;
	    else if ( s == "TLE") cnt_tle++;
	    else if (s == "WA") cnt_wa++;
            else if ( s == "RE") cnt_re ++;
    }

    cout << "AC x " << cnt_ac << endl;
    cout << "WA x " << cnt_wa << endl;
    cout << "TLE x " << cnt_tle << endl;
    cout << "RE x " << cnt_re << endl;

    return 0 ;
}


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

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


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

  ll n;
  cin >> n;

  auto res = prime_factor(n);
  ll ans = 0;
  for(auto j:res){
    int num = j.second;
    int ko = 1;
    while(num-ko>=0){
      ans++;
      num-=ko;
      ko++;
    }  
  }
  cout << ans << endl;
  
  return 0;
    

}


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

int main() {
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int>> alphabets(26);
  for(int i = 0; i < n; i++) alphabets[s[i]-'a'].push_back(i);
  for(int i = 0; i < n; i++) alphabets[s[i]-'a'].push_back(i+n);
  long long ans = 0LL;
  int p = 0;
  for(int i = 0; i < m; i++) {
    int c = t[i] - 'a';
    if(alphabets[c].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    p = *lower_bound(alphabets[c].begin(), alphabets[c].end(), p) + 1;
    if(p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 15;
const int inf = 1e9 + 10;
int c[N], a[N][N];
int b[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = inf;
    for (int mask = 1; mask < (1 << n); mask++) {
        for (int j = 1; j <= m; j++) {
            b[j] = 0;
        }
        int cur = 0;
        for (int i = 1; i <= n; i++) {
            if (mask & (1 << (i - 1))) {
                cur += c[i];
                for (int j = 1; j <= m; j++) {
                    b[j] += a[i][j];
                }
            }
        }
        bool ok = 1;
        for (int j = 1; j <= m; j++) {
            if (b[j] < x) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            ans = min(ans, cur);
        }
    }
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,a[200001],b[2000001],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		int f=0;
		if(b[a[i]]>1)continue;
		if(a[i]==1)
		{
			ans++;
			continue;
		}
		for(int j=1;j<=sqrt(a[i]);j++)
		{
			if(j==1)
			{
				if(b[j])
				{
					f=1;
					break;
				}
				continue;
			}
			if(a[i]%j==0||a[i]%(a[i]/j)==0)
			{
				if(b[j]||b[a[i]/j])
				{
					f=1;
					break;
				}
			}
		}
		if(f==0)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 8280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c;
	else if (b == c)cout << a;
	else if (a == c)cout << b;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long ll;

/////////////////////////////////DEBUG/////////////////////////////////
void printd(const char* format)
{
  #ifdef DEBUG
    std::cout << format;
  #endif
}
template<typename T, typename... Targs>
void printd(const char* format, T value, Targs... Fargs)
{
  #ifdef DEBUG
    for ( ; *format != '\0'; format++ ) {
        if ( *format == '%' ) {
           std::cout << value;
           printd(format+1, Fargs...);
           return;
        }
        std::cout << *format;

    }
  #endif
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////// YAY /////////////////////////////////
void solve()
{
  int n; cin>>n;
  int ans = n + n*n + (n*n*n);
  std::cout << ans << '\n';
}

int main(int argc, char const *argv[]) {
  int t;
  t=1;

  #ifdef DEBUG
    freopen("input.txt","r", stdin);
    clock_t start, end;
    start = clock();
    cin>>t;
  #endif


  for(int i = 1; i<=t; i++)
  {
    // std::cout << "Case "<<i<<": " << '\n';
    solve();
  }

  #ifdef DEBUG
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    time_taken *= 1000;
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " ms " << endl;
  #endif
}


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

using namespace std;


/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	assert(a > 0 && a < 10);
	assert(b > 0 && b < 10);
	assert(c > 0 && c < 10);

	// a, b, c のうち2個の一致を a, b の比較だけでチェックできるようにしたい 
	if (b == c) {
		// a == cなら、入れ替えても結果は同じ
		int tmp = a;
		a = c;
		c = tmp;
	}
	else if (a == c) {
		// b == cなら、入れ替えても結果は同じ
		int tmp = b;
		b = c;
		c = tmp;
	}
	string isPoor = "No";
	if (a == b && b != c) {
		isPoor = "Yes";
	}

	cout << isPoor << endl;

	return 0;
}


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


int main(void)
{
    int n;
    scanf("%d", &n);
    int l;
    scanf("%d", &l);

    int a[n];
    for (int i=0; i < n; i++){
        a[i] = l + i;
    }

    int sum = 0;
    for (int i=0; i < n; i++)
        sum += a[i];

    if(0 < a[0])
        sum -= a[0];
    else if(a[n-1] < 0)
        sum -= a[n-1];
    
    printf("%d\n", sum);

    return 0;
} 



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

bool ok(vi& p)
{
    int n = len(p);
    rep(i,n-1){
        if(p[i] > p[i+1]){
            return false;
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi p(n);
    rep(i,n){
        cin >> p[i];
    }
    vi vec;
    while(!ok(p)){
        if(p[0] < p[n-1] && (p[n-1] != n-1 || p[0] != 0)){
            vec.pb(n-1);
            swap(p[0],p[n-1]);
        }else{
            vec.pb(1);
            vi tmp(n);
            rep(i,n){
                tmp[i] = p[(i+1)%n];
            }
            p = tmp;
        }
    }
    cout << len(vec) << "\n";
    rep(i,len(vec)){
        cout << vec[i] << "\n";
    }
    return 0;
}


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

#define ll long long
#define endl "\n"
#define FILEIN freopen("input.txt", "r", stdin)

ll binPow(ll a, ll n){
    ll ans = 1;
    while(n){
        if(n & 1){
            ans *= a;
        }
        a = a * a;
        n >>= 1;
    }
    return ans;
}

int main(){
    // FILEIN;
    int n; cin>>n;
    int A[n+1], B[n+1], C[n+1], dp[n+1][3] = {{}};
    for(int i = 1; i<=n; i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    for(int i = 1; i<=n; i++){
        dp[i][0] = A[i] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = B[i] + max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2] = C[i] + max(dp[i-1][1] , dp[i-1][0]);
    }
    int ans = max(dp[n][0], dp[n][1]);
    ans = max(dp[n][2], ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = 0
    y = 0
    sort_a = sorted(a, reverse=True)
    for i in range(n):
        if i % 2 == 0:
            m += sort_a[i]
        else:
            y += sort_a[i]
    print(m - y)
main()


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

int main()
{
    int K, N, lastto = 0, distance=0, where = -1, dochu = 0;
    cin >> K >> N;
    vector<int> A(N);
    vector<int> vec(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);

        if (i >= 1 && distance <= A.at(i) - A.at(i - 1))
        {
            distance = A.at(i) - A.at(i - 1);
            where = i;
        }
    }
    if(distance<K-A.at(N-1)+A.at(0))
    {
        where = -1;
    }

    lastto = K - A.at(N - 1) + A.at(0);

    for (int i = 1; i < N; i++)
    {
        if (i != where)
        {
            dochu = dochu+ A.at(i) - A.at(i - 1);
            //cout << dochu << endl;
            //cout << lastto << endl;
        }
    }

    if (where == -1)
    {
        cout << A.at(N-1)-A.at(0)<< endl;
    }
    else
    {
        cout  << dochu+lastto << endl;
    }
}


Measured memory_bytes: 4752
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
using namespace std;

const int inf=1e9+7;

#define int long long int

signed main()
{
#ifdef LOCAL
	assert(freopen("in.in","r",stdin));
#endif
	int n,w;cin>>n>>w;
	vector<pair<int,int>> arr(n,{0,0});
	for(auto& i:arr) cin>>i.first>>i.second;
	vector<vector<int>> dp(n+1,vector<int>(w+1));
	for(auto i=0;i<=n;i++){
		for(auto j=0;j<=w;j++){
			if(i && arr[i-1].first<=j) dp[i][j]=max(arr[i-1].second+dp[i-1][j-arr[i-1].first] , dp[i-1][j]);
			else if(i) dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Nikkei2019_2_qual
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] ds = ReadInts();
            if (ds[0] != 0)
            {
                WriteLine(0);
                return;
            }
            Array.Sort(ds);
            long[] cnts = new long[n];
            cnts[0] = 1;
            long mask = 998244353;
            long res = 1;
            for(int i = 1; i < n; i++)
            {
                if (ds[i] == 0 || cnts[ds[i] - 1] == 0)
                {
                    WriteLine(0);
                    return;
                }
                res *= cnts[ds[i] - 1];
                res %= mask;
                cnts[ds[i]]++;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define REP(var, start, count) for(int var=start; var<count; var++)

int main(void) {
	int N;
	cin >> N;
	
	REP(h, 1, 3501) {
		REP(n, 1, 3501) {
			double wd = 1.0/(4.0/N - 1.0/h - 1.0/n);
			
			int wi[2];
			wi[0] = ceil(wd);
			wi[1] = floor(wd);
			
			REP(i, 0, 2) {
				int w = wi[i];
				if (w < 1) { continue; }
				if ( 4*h*n*w == (h*n + n*w + w*h)*N ) {
					cout << h << " " << n << " " << w << endl;
					return 0;
				}
			}
		}
	}
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;
#define call(a) for(auto i:(a))cout<<i<<" ";cout<<endl;
#define ENDL printf("\n");
signed main(){
  int n;
  cin>>n;
  vint a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  map<signed,signed> m{};
  rep(i,n){
    m[a[i]]++;
  }
  a.erase(unique(all(a)),a.end());
  int res=0;
  for(auto itr=m.begin();itr!=m.end();++itr){
    res+=(itr->first<=itr->second?itr->second-itr->first:itr->second);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 5120
"use strict";

const main = (arg) => {
  const input = arg.trim().split("\n")[0];
  const numbers = input.split(" ");
  for (let i = 0; i < numbers.length; i++) {
    if (parseInt(numbers[i]) === 0) return console.log(i + 1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


Measured memory_bytes: 29636
#include<cstdio>
int num[2][102];
int main()
{
	int n, t;
	while (scanf("%d%d", &n, &t) != EOF)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", &num[0][i], &num[1][i]);
		int minn = 0x3f3f3f;
		for (int i = 0; i < n; ++i)
			if (num[1][i] <= t)minn = minn < num[0][i] ? minn : num[0][i];
			if (minn == 0x3f3f3f)printf("TLE\n");
			else printf("%d\n", minn);
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<vector<int>> g(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u][v] = 1;
    }
    vector<vector<int>> id(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++)
        id[i][i] = 1;
    vector<vector<vector<int>>> reach;
    reach.emplace_back(id);
    reach.emplace_back(g);
    for (int t = 2; t <= 100; t++)
    {
        vector<vector<int>> nxt(n, vector<int>(n, 0));
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int k = 0; k < n; k++)
                {
                    nxt[i][j] |= reach[t - 1][i][k] * g[k][j];
                }
            }
        }
        reach.emplace_back(nxt);
    }
    int ret = 0;
    bool update = true;
    vector<int> st(n, 0);
    st[n - 1] = 1;
    while (update)
    {
        // printv(st);
        update = false;
        ret++;
        set<int> cand;
        for (int i = 0; i < n; i++)
        {
            if (st[i])
                continue;
            bool fa = false, fb = false, fc = false;
            for (int j = 0; j < n; j++)
            {
                if (!st[j])
                    continue;
                if (reach[a][i][j])
                    fa = true;
                if (reach[b][i][j])
                    fb = true;
                if (reach[c][i][j])
                    fc = true;
            }
            if (fa && fb && fc)
                cand.emplace(i);
        }
        if (cand.size() != 0)
            update = true;
        for (auto v : cand)
        {
            st[v] = 1;
        }
        if (st[0])
        {
            cout << ret << endl;
            return 0;
        }
        if (!update)
        {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 4212
#include<stdio.h>

int main(void){
  int x=100000;
  int i,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    x=x*1.05; 
    if(x%1000!=0){
      x=x+1000;
    }
    x=x/1000;
    x=x*1000;
  }
  printf("%d\n",x);
  return(0);
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
    long a, b;
    readf("%d %d", &a, &b);

    if (a <= 5) {
        writeln(0);
    } else if (a <= 12) {
        writeln(b / 2);
    } else {
        writeln(b);
    }

}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }
  
  vector<bool> C(N, true);
  for (int i = 0; i < M; i++) {
    //cerr << H[A[i]-1] << ' ' << H[B[i]-1] << endl;
    if(H[A[i]-1] <= H[B[i]-1]) {
      C[A[i]-1] = false;
    }
    if(H[B[i]-1] <= H[A[i]-1]) {
      C[B[i]-1] = false;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    //cerr << C[i] << endl;
    if (C[i] == true) {
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4556
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a){
		cout<<k<<endl;
	}
	else if(k<=a+b){
		cout<<a<<endl;
	}
	else{
		cout<<a-(k-(a+b))<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3652