akhauriyash/Code-Regression huggingface dataset:
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    let s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    input! {
        k: usize1,
    }
    println!("{}", s[k]);
}

fn main() {
    run();
}


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

int main (){
    ios_base::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        ll a,b,ans=0;cin>>a>>b;
        if(a==b) ans=2*a-2;
        else {
            ll tmp=sqrt(a*b);
            if(tmp*tmp==a*b) tmp--;
            if(tmp*(tmp+1)>=a*b) ans=2*tmp-2;
            else ans=2*tmp-1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n, m, l;
    int a[100][100], b[100][100];
    long c[100][100];
    int i, j, k;
    
    scanf("%d%d%d", &n, &m, &l);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for(j=0;j<m;j++)
    {
        for(k=0;k<l;k++)
        {
            scanf("%d", &b[j][k]);
        }
    }
    
    for(i=0;i<n;i++)
    {
        for(k=0;k<l;k++)
        {
            c[i][k] = 0;
            for(j=0;j<m;j++)
            {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    
    for(i=0;i<n;i++)
    {
        for(k=0;k<l-1;k++)
        {
            printf("%ld ", c[i][k]);
        }
        printf("%ld\n", c[i][k]);
    }
    
    return(0);
}


Measured memory_bytes: 2120
#include<iostream>
#define F(A, B) for(int A=0; A<B; A++)
using namespace std;

int main(){
	int n, all=0;

	for(int i=1; i<1000; i++){
		if(i%3 == 0){
			all += 200;
		}else{
			all += 195;
		}
	}
	cin >> n;
	F(i, n){
		int y, m, d;
		cin >> y >> m >> d;
		int pls=0;
		for(int i=1; i<y; i++){
			if(i%3 == 0){
				pls += 200;
			}else{
				pls += 195;
			}
		}
		for(int i=1; i<m; i++){
			if(y%3 == 0){
				pls += 20;
			}else if(i%2 == 0){
				pls += 19;
			}else{
				pls += 20;
			}
		}
		pls += d;
		cout << all-pls+1 << endl;
	}
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
total = sum(S)

ans = 0 if total % 10 == 0 else total
for s in S:
    if (total - s) % 10 != 0:
        ans = max(ans, total - s)
    
print (ans)

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

public class Main
{
	public static void main(String[] args) throws Exception
	{
		Reader reader = new Reader();
		OutputStream out = new BufferedOutputStream(System.out);
      	int n = reader.nextInt();
      	int r = reader.nextInt();
      	if(n < 10)
          r += 100 * (10-n);
		out.write(("" + r).getBytes());
		out.flush();
	}
	static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            return ret;
        }
        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            return ret;
        }
 
        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }
 
        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxt=(1<<20)+10;
const int maxn=2e5+10;
int dfn[maxn],rht[maxn],DFN,n,faiter[maxn],sz[maxn];
vector<int> g[maxn];

int ans[maxn],rec[maxn];
void dfs(int x,int fa)
{
	dfn[x]=++DFN;
	faiter[x]=-1;
	sz[x]=1;
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i];
		if(to==fa)
		{
			faiter[x]=i;
			continue;
		}
		dfs(to,x);
		sz[x]+=sz[to];
	}
	rht[x]=DFN;
}
int val[maxn];
int bit[maxn];
void add(int p,int v)
{
//	cout<<" add "<<p<<" "<<v<<endl;
	p=n+1-p;
	while(p<maxn)
	{
		bit[p]+=v;
		p+=p&-p;
	}
}
int sum(int p)
{
	if(!p)return 0;
//	cout<<"sum "<<p<<endl;
	p=n+1-p;
	int ret=0;
	while(p>0)
	{
		ret+=bit[p];
		p-=p&-p;
	}
	return ret;
}
set<int> active[maxn];
void merge(set<int> &a,set<int> &b)
{
	if(a.size()<b.size())swap(a,b);
	if(b.empty())return;
	for(set<int>::iterator it=b.begin();it!=b.end();it++)
		a.insert(*it);
}
void remove(set<int> &a,int v)
{
	if(a.empty())return;
	set<int>::iterator pos=a.lower_bound(v);
	set<int>::iterator nxt;
	for(set<int>::iterator it=a.begin();it!=pos;it=nxt)
	{
	//	cout<<(*it)<<endl;
		add(*it,-val[*it]);
		val[v]+=val[*it];
	//	cout<<"???\n";
		nxt=it;
		++nxt;
		a.erase(it);
	}
}
void DP(int x,int fa,int inhebound,int cur)
{
//	cout<<"t "<<x<<" "<<fa<<" "<<inhebound<<" "<<cur<<endl;
//	system("pause");
	val[x]=1;
	cur=max(cur,fa);
//	inhebound=max(inhebound,cur);
	//	ans[x]=sz[x]-getans(1,1,n,dfn[x]+1,rht[x],fa);
	//	cout<<x<<" "<<ans[x]<<endl;
	//	ans[x]+=ans[fa];
		for(int i=0;i<g[x].size();i++)
		{
			int to=g[x][i];
			if(to==fa)continue;
				ans[to]+=sum(max(x,cur));
				if(to==1)
				{
		//			cout<<"A "<<sum(max(x,cur))<<endl;
				}
			if(to<max(inhebound,cur))
			{
				ans[to]-=sum(max(inhebound,cur));
				if(to==1)
				{
		//			cout<<"A "<<-sum(max(inhebound,cur))<<endl;
				}
				DP(to,x,max(inhebound,cur),cur);
			}
			else
			{
				DP(to,x,0,cur);
			}
			merge(active[x],active[to]);
	//		cout<<"mer "<<x<<" "<<to<<endl;
			active[to].clear();
		}
		
		
		
	//	if(x==1)
		{
	//		cout<<"A "<<-sum(cur)<<endl;
		}
		ans[x]-=sum(cur);
	if(inhebound)
	{
	//	if(x==1)cout<<"A "<<sum(inhebound)<<endl;
		ans[x]+=sum(inhebound);
	}
	else{
	//	if(x==1)cout<<"A "<<sz[x]<<endl;
	ans[x]+=sz[x];
	}
		
		
	//	cout<<x<<" "<<ans[x]<<" "<<sz[x]<<" "<<fa<<endl;
	//	system("pause");
		remove(active[x],x);
		add(x,val[x]);
		active[x].insert(x);
		
}
void calc(int x,int fa)
{
	ans[x]+=ans[fa];
	for(int i=0;i<g[x].size();i++)
	{
		if(g[x][i]!=fa)
		{
			calc(g[x][i],x);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
		sort(g[i].begin(),g[i].end());
	dfs(1,0);
//	cout<<"here\n";
	ans[0]=-n;
	DP(1,0,0,0);
	calc(1,0);
	for(int i=2;i<=n;i++)
		printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 43776
import java.util.*;
public class Main {
    static public void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w==0) break;
            for(int i = 0;i<h;i++){
                for(int j = 0;j<w;j++){
                    if(i==0 || i==h-1 || j==0 || j==w-1) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.printf("\n");
            }
                System.out.printf("\n");
        }
        sc.close();
    }
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if (a[0] == a[1])
        cout << a[2];
    else
        cout << a[0];
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<pair<int, int>> A;
  for(int i=0; i<N; i++){
    int tmpA;
    cin >> tmpA;
    A.push_back(make_pair(tmpA, i));
  }
  sort(A.begin(), A.end(), greater<pair<int, int>>());
  for(int i=0; i<N; i++){
    int ans;
    if(A[0].second == i) ans = A[1].first;
    else ans = A[0].first;
    cout << ans << endl;
  }
  return 0; 
}

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

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<int> a(m);
        int odd = 0;
        vector<bool> f(m, false);
        int p[2];
        p[0] = -1, p[1] = -1;
        int k = 0;
        for (int i = 0; i < m; i ++) {
                scanf("%d", &a[i]);
                if (a[i] & 1) {
                        if (odd > 1) return !puts("Impossible");
                        p[k ++] = i;
                        odd ++;
                }
        }
        if (odd > 0) if (p[0] != 0) swap(a[p[0]], a[0]);
        if (odd > 1) if (p[1] != m - 1) swap(a[p[1]], a[m - 1]);
        for (int i = 0; i < m; i ++) cout << a[i] << (i == m - 1 ? '\n' : ' ');
        vector<int> ans;
        if (m == 1) {
                if (a[0] > 1) ans.push_back(a[0] - 1);
                ans.push_back(1);
        } else {
                if (a[0] != 1) ans.push_back(a[0] - 1);
                for (int i = 1; i < m - 1; i ++) {
                        ans.push_back(a[i]);
                }
                ans.push_back(a[m - 1] + 1);
        }
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); i ++) cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
        return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n,m,j=0;
    cin>>n;
    int a[n];
    int x[2];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            x[j]=i;
            j++;
            if(j==2)
            {
                break;
            }
        }
    }
    if(j==0)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    swap(a[x[0]],a[x[1]+1]);
    int jj=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            jj++;
        }
    }
    if(jj>0)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> data(M, vector<int>(2));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int nummin = 1;
    int nummax = 100000;
    for (int i = 0; i < M; i++) {
        nummin = max(nummin, data.at(i).at(0));
        nummax = min(nummax, data.at(i).at(1));
    }
    int ans = max(nummax - nummin + 1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




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

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

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

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

vector<string> lt;
map<string, int> mp;

void dfs(int sy, int sx, int y, int x, int dir, string s) {
    int ny = (y + dy[dir] + h) % h;
    int nx = (x + dx[dir] + w) % w;
    if (sy != ny || sx != nx) {
        string ns = s + lt[ny][nx];
        mp[ns] ++;
        dfs(sy, sx, ny, nx, dir, ns);
    }
}

int main() {
    while (cin >> h >> w) {
        if (!h) break;
        lt.resize(h);
        for (int i=0; i<h; ++i) {
            cin >> lt[i];
        }
        mp.clear();
        for (int i=0; i<h; ++i) {
            for (int j=0; j<w; ++j) {
                for (int k=0; k<8; ++k) {
                    string s(1, lt[i][j]);
                    dfs(i, j, i, j, k, s);
                }
            }
        }
        string magic = "";
        int len = -1;
        for (auto it=mp.begin(); it!=mp.end(); ++it) {
            if (it->second < 2) continue;
            if (len < (int)(it->first).size() || (len == (int)(it->first).size() && it->first < magic)) {
                len = (it->first).size();
                magic = it->first;
            }
        }
        if (magic == "") {
            cout << 0 << endl;
        } else {
            cout << magic << endl;
        }
    }
    return 0;
}


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

int main(){
  int N,M;
  long sum=0,Asum=0,Bsum=0;
  vector<int> A,B;
  cin>>N>>M;
  A.resize(N);
  B.resize(M);

  for(int i=0;i<N;i++){
    cin>>A[i];
    Asum+=A[i];
  }
  for(int i=0;i<M;i++){
    cin>>B[i];
    Bsum+=B[i];
  }
  
  sum=Asum*Bsum;

  cout<<sum<<endl;
  return 0;
}



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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int pref[11];
	pref[0]=(a*c)-b;
	for(int i=1;i<=10;i++)
	{
		pref[i]=(a*pref[i-1])-b;
		
	}
	cout<<pref[0]<<endl;
	for(int i=1;i<10;i++)
	{
		cout<<pref[i]<<endl;
	}


}



Measured memory_bytes: 256
<?php
//ワーシャルフロイド（全点対最短路問題）
$file_handle = fopen('php://stdin', "r");
//$file_handle = fopen('aoj0189_in.txt', "r");


function warshall_floyd($d) {
	global $m;

	for ($i = 0; $i <= $m; ++$i) {
	    for ($j = 0; $j <= $m; ++$j) {
	        for ($k = 0; $k <= $m; ++$k) {
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $d[$j][$i] + $d[$i][$k];
	            if ($via < $d[$j][$k]) {
	                $d[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $d;
}

while(1){
	//ファイル読み込み
	$n = trim(fgets($file_handle));     //道の数(町の数では無い)
	
	//終了条件
	if ($n == 0) break;
	
	//変数初期化
	$d = array();
	$num_city = 0;
	
	for ($i=1; $i<=$n; ++$i){
		$info = trim(fgets($file_handle));
		$explode = explode(' ', $info);
		$a = $explode[0]; $b = $explode[1]; $c = $explode[2];
		$d[$a][$b] = $d[$b][$a] = $c;
		//最大値をとって町の数を取る。
		$num_city = max($num_city, $a, $b);
	}
	$m = $num_city;

	//町の数で
	//ワーシャルフロイド準備。
	for ($i=0; $i<=$m; ++$i){
		for ($j=0; $j<=$m; ++$j){
			//定義済みならばcontinue
			if ( isset($d[$i][$j]) ) continue;
			if ($i === $j){
				$d[$i][$i] = 0;
			} else {
				$d[$i][$j] = INF;
			}
		}
	}

	//探索
	$res = warshall_floyd($d);

	//最小値の通勤時間総和計算
	$sum_dist = array();	//各町からの距離総和
	$min_dist = INF;		//最小距離総和
	$min_city = '';			//距離総和が最小の町番号

	for ($i=0; $i<=$m; ++$i){
		$sum_dist[$i] = 0;	//距離初期化
	}
	for ($i=$m; $i>=0; --$i){	//同値の場合はより町番号が小さい方を採用するので逆順
		for ($j=$m; $j>=0; --$j){
			$sum_dist[$i] += $res[$i][$j];
		}
		//最小値比較・更新
		if ($min_dist >= $sum_dist[$i]){
			$min_dist = $sum_dist[$i];
			$min_city = $i;
		}
	}

	//出力
	echo $min_city.' '.$min_dist;
	echo PHP_EOL;

}

fclose($file_handle);

Measured memory_bytes: 6744
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var output = 0;
  var count = 0;
  while(N > 0){
    N = Math.floor(N / 2);
    output += Math.pow(2, count);
    count++;
  }
  myout(output);

}


Measured memory_bytes: 30364
import queue

def main():
    K = int(input())

    numq = queue.Queue()
    for n in range(1, 9+1):
        numq.put(n)

    ans = None
    for _ in range(K):
        n = numq.get()
        #print('[DEBUG] n: ', n)
        #print('[DEBUG] type(n): ', type(n))
        base = n*10
        if base//10%10 >= 1:
            numq.put(base + (base//10%10-1))
        numq.put(base + (base//10%10))
        if base//10%10 <= 8:
            numq.put(base + (base//10%10+1))
        ans = n

    print(ans)
        

if __name__=='__main__':
    main()


Measured memory_bytes: 12996
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

template<typename T>
struct Fenwick{
    vector<T> bit;
    T mod;
    Fenwick(int n){
        bit = vector<T>(n + 1);
        mod = 0;
    }
    void add(int i, T v){
        int n = bit.size();
        ++i;
        while(i < n){
            bit[i] += v;
            i += i & -i;
        }
    }
    T get(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += bit[i];
            i -= i & -i;
        }
        return res;
    }
};

int func(const string &S, const string &T) {
    int N = S.size();
    Fenwick<int> bit(N + 10);
    vector<queue<int>> v(0x100);
    for(int i = 0; i < N; ++i) {
        v[S[i]].push(i);
    }
    int res = 0;
    for(int i = 0; i < N; ++i) {
        char c = T[i];
        int p = v[c].front();
        v[c].pop();
        int q = p + i - bit.get(p);
//        cerr << c << "," << p << "," << q << ","<< q - i << endl;
        res += q - i;
        bit.add(p, 1);
    }
    return res;
}

void solve(std::string S){
    int N = S.size();
    vector<int> d(0x100);
    for(int i = 0; i < N; ++i) {
        d[S[i]]++;
    }
    int c = 0;
    char ex = 'A';
    for(int i = 0; i < 0x100; ++i) {
        if (d[i] % 2 != 0){
            ++c;
            ex = i;
        }
    }
    if ((N % 2 == 0 && c > 0) || (N % 2 == 1 && c != 1)) {
        cout << -1 << endl;
        return;
    }
    vector<int> e(0x100);
    string T = "", U = "";
    int init = 0;
    for(int i = 0; i < N; ++i) {
        char c = S[i];
        if (e[c] < d[c] / 2) {
            init += i - T.size();
            T += c;
        } else {
            U += c;
        }
        ++e[c];
    }
    if (N % 2 != 0) {
        for(int i = 0; i < U.size(); ++i) {
            if (U[i] == ex) {
                init += i;
                if (i == 0) {
                    U = U.substr(1);
                } else if(i + 1 == U.size()) {
                    U.pop_back();
                } else {
                    U = U.substr(0, i) + U.substr(i + 1);
                }
                break;
            }
        }
    }
//    cerr << T << init << U << endl;
    reverse(ALL(U));

    cout << init + func(T, U) << endl;
}

signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 2692
A, B, C = list(map(int, input().split()))
K = int(input())

c = 0
while A >= B:
    B *= 2
    c += 1
while B >= C:
    C *= 2
    c += 1

if c > K:
    ans = "No"
else:
    ans = "Yes"
print(ans)


Measured memory_bytes: 9096
s = str(input())
n = len(s)
rc = 0
lc = 0
p = 0
state = 1 #1がR、0がL
ans = [0] * n
for i in range(n):
  #print(ans, rc, lc, p)
  if state:
    if s[i] == "R":
      rc += 1
      if s[i+1] == "L":
        ans[i] += (rc+1)//2
        ans[i+1] += rc//2
        state = 0
        p = i
        rc = 0
  else:
    if s[i] == "L":
      lc += 1
      if i == n-1 or s[i+1] == "R":
        ans[p+1] += (lc+1)//2
        ans[p] += lc//2
        state = 1
        lc = 0
print(" ".join(map(str,ans)))

Measured memory_bytes: 50544
#include<cstdio>

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a == b) {
    if (b == c) printf("1\n");
    else printf("2\n");
  }else if (a == c) {
    printf("2\n");
  }else if (b == c) {
    printf("2\n");
  }else {
    printf("3\n");
  }
  return 0;
}


Measured memory_bytes: 128
s = input()

x = s[:2]
y = s[2:]

mmyy = 1 <= int(x) <= 12 and 0 <= int(y) <= 99
yymm = 0 <= int(x) <= 99 and 1 <= int(y) <= 12
if mmyy:
    if yymm:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if yymm:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 3060
import java.io.*;
class Main{
	public static void main(String[] args){
		try{
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String c = in.readLine();
			int time = Integer.parseInt(c);
			
			int h = time/3600;
			int m = (time%3600)/60;
			int s = time % 60;
			
			System.out.println(h+":"+m+":"+s);

		}catch(IOException e){
			e.printStackTrace();
		}

	}
}

Measured memory_bytes: 24452
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

// [c, d)
string calc_naive(int a, int b, int c, int d) {
  int mi = min(a, b);
  int ma = max(a, b);
  int len = (ma + mi) / (mi + 1);
  //DEBUGP(len);
  // TODO it is O(a + b)
  assert (a + b <= 10000);
  int na = a;
  int nb = b;
  string s;
  char cur = '*';
  int cnt = 0;
  REP(i, 0, a + b) {
    if (cnt >= len) {
      cur = 'A' + 'B' - cur;
      s += cur;
      cnt = 1;
      if (cur == 'A') {
	na -= 1;
      } else {
	nb -= 1;
      }
      continue;
    }
    if (na >= 1 && nb <= na * len) {
      if (cur != 'A') {
	cur = 'A';
	cnt = 0;
      }
      s += cur;
      cnt += 1;
      na -= 1;
      continue;
    }
    if (cur != 'B') {
      cur = 'B';
      cnt = 0;
    }
    s += 'B';
    nb -= 1;
    cnt += 1;
  }
  assert (na == 0);
  assert (nb == 0);
  //DEBUGP(s);
  return s.substr(c, d - c);
}

// [c, d)
string calc(int a, int b, int c, int d) {
  int mi = min(a, b);
  int ma = max(a, b);
  int len = (ma + mi) / (mi + 1);
  //DEBUGP(calc_naive(a, b, 0, a + b));
  // DEBUGP(len);
  int zpw = (a + b) % (len + 1);
  // x s.t. z >= 1?
  ll pass = -1;
  ll fail = a + b;
  while (fail - pass > 1) {
    ll mid = (fail + pass) / 2;
    ll na = a - mid * len;
    ll nb = b - mid;
    if (na >= 1 && nb >= 0 && nb <= na * len) {
      pass = mid;
    } else {
      fail = mid;
    }
  }
  if (pass == -1) {
    string ret;
    REP(i, c, d) {
      int j = a + b - 1 - i;
      ret += j % (len + 1) == len ? "A" : "B";
    }
    return ret;
  }
  ll na = a - pass * len;
  ll nb = b - pass;
  string deb;
  REP(i, c, min((ll)d, (len + 1) * pass)) {
    deb += i % (len + 1) == len ? "B" : "A";
  }
  ll y = nb / len;
  ll w = nb - y * len;
  ll z = na - y;
  REP(i, max((ll)c, (len + 1) * pass), min((ll)d, (len + 1) * pass + z)) {
    deb += "A";
  }
  REP(i, max((ll)c, (len + 1) * pass + z), min((ll)d, (len + 1) * pass + z + w)) {
    deb += "B";
  }
  REP(i, max((ll)c, (len + 1) * pass + z + w), d) {
    int j = (a + b - 1 - i) % (len + 1);
    deb += j == len ? "A" : "B";
  }
  return deb;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  if (1) {
    REP(a, 1, 10) {
      REP(b, 1, 10) {
	string naive = calc_naive(a, b, 0, a + b);
	string smart = calc(a, b, 0, a + b);
	if (naive != smart) {
	  DEBUGP(a);
	  DEBUGP(b);
	  DEBUGP(naive);
	  DEBUGP(smart);
	}
      }
    }
  }
  int q;
  cin >> q;
  REP(mulieribus, 0, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << calc(a, b, c - 1, d) << "\n";
  }
}


Measured memory_bytes: 384
fn main() {
    proconio::input! {
        s: String,
        t: String,
    }

    let ss = s.as_bytes();
    let tt = t.as_bytes();

    let calc = |offset| {
         return (0..tt.len()).filter(|&i| tt[i] != ss[i + offset] ).count();
    };

    let ans = (0..(ss.len() - tt.len() + 1))
        .map(|x| calc(x))
        .min()
        .unwrap();

    println!("{}", ans);
}


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

int main(){
    int n;
    cin >> n;
    string x;
    cin >> x;
    vector<int> ans(n+1, 0);

    vector<int> fn(n+1, 0);
    fn[1] = 1;
    for(int i = 2; i <= n; i++){
        int popcount = 0;
        int tmp = i;
        while(tmp){
            if(tmp & 1) popcount++;
            tmp >>= 1;
        }
        fn[i] = fn[i % popcount]+1;
        //cout << fn[i] << " " << i % popcount<< endl;
    }

    int popcount_x = 0;
    for(int i = 0; i < x.length(); i++){
        if(x[i] == '1') popcount_x++;
    }

    int base0 = 1, base2 = 1;
    vector<int> memo0(n, 0), memo2(n, 0);
    long long int memosum0 = 0, memosum2 = 0;
    for(int i = n-1; i >= 0; i--){
        memo0[i] = base0;
        memo2[i] = base2;
        if(x[i] == '1'){
            memosum0 += base0;
            memosum2 += base2;
        }

        base0 *= 2;
        base2 *= 2;
        if(popcount_x <= 1) base0 = 0;
        else base0 %= popcount_x-1;
        base2 %= popcount_x+1;
    }

    for(int i = 0; i < n; i++){
        if(x[i] == '0'){
            long long int x1 = memosum2+memo2[i];
            cout << fn[x1%(popcount_x+1)]+1 << endl;
        }else{
            if(popcount_x == 0){
                if(i == n-1) cout << 1 << endl;
                else cout << 2 << endl;
            }else if(popcount_x == 1){
                cout << 0 << endl;
            }else{
                long long int x1 = memosum0-memo0[i];
                cout << fn[x1%(popcount_x-1)]+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 6820
Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine())

        Dim A As Integer = CInt(tmp(0))
        Dim B As Integer = CInt(tmp(1))

        Dim w = A - B * 2

        Console.WriteLine(If(w > 0, w, 0))
        'Console.Read()

    End Sub

End Module


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll cnt2(ll a) {
    ll cnt = 0;
    while (a % 2 == 0) {
        cnt++;
        a /= 2;
    }
    return cnt;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);

    rep(i, N) {
        cin >> a[i];
    }
    ll L = 1;
    ll ct = cnt2(a[0]);
    rep(i, N) {
        if (ct != cnt2(a[i])) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= ct;
    }
    M >>= (ct - 1);

    rep(i, N) {
        L = lcm(L, a[i]);
        if (L > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    M /= L;
    ll ans = (M + 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define ll long long
using namespace std;

int main()
{
  int N, X;
  cin>>N>>X;
  ll a[N];
  ll mn[N];
  for(int i=0; i<N; i++)
  {
    cin>>a[i];
    mn[i] = -1;
  }

  ll answ = -1;
  for(int k=0; k<N; k++)
  {
    ll tot = (ll)X * k; //provo a prendere tutti i possibili k

    for(int i=0; i<N; i++)
    {
      if(mn[i] == -1 || a[(i-k+N)%N] < mn[i])
       mn[i] = a[(i-k+N)%N];
      tot += mn[i];
    }

    if(answ == -1 || tot < answ) answ = tot;
  }

  cout<<answ;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

void counting_sort(const int arr_in[], int arr_out[], const int n, const int max)
{
  int counter[max + 1];
  for (int i = 0; i < max + 1; ++i)
  {
    counter[i] = 0;
  }

  for (int i = 0; i < n; ++i)
  {
    ++counter[arr_in[i]];
  }

  for (int i = 0; i < max; ++i)
  {
    counter[i + 1] += counter[i];
  }

  for (int i = n - 1; i >= 0; --i)
  {
    arr_out[counter[arr_in[i]] - 1] = arr_in[i];
    --counter[arr_in[i]];
  }
}

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

  int arr_in[n], arr_out[n];
  for (int i = 0; i < n; ++i)
  {
    std::cin >> arr_in[i];
  }

  counting_sort(arr_in, arr_out, n, 10000);

  for (int i = 0; i < n; ++i)
  {
    if (i != 0)
    {
      std::cout << ' ';
    }
    std::cout << arr_out[i];
  }
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 18744
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc118_d(){
    //入力
    ll n,k;
    cin >> n >> k;
    map<ll,ll> mp;
    REP(i,n){
        ll tmpa,tmpb;
        cin >> tmpa >> tmpb;
        mp[tmpa] += tmpb;
    }
    ll sum = 0;
    ll ans = 0;
    
    //処理
    for(auto i=mp.begin(); sum<k; ++i){
        sum += i->second;
        ans = i->first;
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 4224
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint n, m, v, p;
vector<lint> a;

// めぐる式二分探索
template <typename T>
T meguru_BinarySearch(T ok, T no, function<bool(T)> isVarid) {
    while (abs(ok - no) > 1) {
        T mid = (ok + no) / 2;
        if (isVarid(mid))
            ok = mid;
        else
            no = mid;
    }
    return ok;
}

// a[i]をp位以内にできるか
bool check(lint cand) {
    lint modi = a[cand] + m;
    if (modi < a[n - p]) {
        return false;
    }
    lint l = cand + 1, r = n - p + 1;
    lint limit = 0;
    for (int i = l; i < r; i++) {
        limit += min(m, modi - a[i]);
    }
    return limit >= (v - l - n + r) * m;
}

int main() {
    cin >> n >> m >> v >> p;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << n - meguru_BinarySearch<lint>(n - 1, -1, check) << endl;
}

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

int main(){
    int N;
    cin >> N;
    
    int res = 0;
    int ans = 1;
    for (int i = 1; i <= N; ++i){
        int count = 0;
        int j = i;
        while(true){
            if (j % 2 != 0) break;
            else {
                j /= 2;
                ++count;
            }
        }
        if (count > res){
            res = count;
            ans = i;
        }
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
program C;
const 
  maxN = 1111;
  modulo = Round(1E9) + 7;
var
  n, x, i, j: Longint;
  fact: array[1..maxN] of Longint;
  ans: Int64;
  
begin
  ReadLn(n);
  for i := 1 to n do
    begin
      x := i;
      for j := 2 to n do
        if x mod j = 0 then
          while x mod j = 0 do
            begin
              Inc(fact[j]);
              x := x div j;
            end;
    end;
  ans := 1;
  for i := 2 to n do
    if fact[i] > 0 then 
      ans := ans * (fact[i] + 1) mod modulo;
  WriteLn(ans);
end.

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

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

    ll ave = 0;
    for(int i = 0; i < n; i++){
        a[i] *= n;
        ave += a[i];
    }
    ave /= n;

    ll ans_min = 0;
    for(int i = 1; i < n; i++){
        if(abs(a[i] - ave) < abs(a[ans_min] - ave)){
            ans_min = i;
        }
    }
    cout << ans_min << endl;
    return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 300010;

int k, n;
int A[N];

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

	if(k % 2 == 0){
		printf("%d", k / 2);
		For(i, 2, n) printf(" %d", k);
		puts("");
		return 0;
	}

	For(i, 1, n) A[i] = k / 2 + 1;
	int m = n / 2;
	
	int r = n;
	while(m--){
		if(!A[r]){
			if(A[r - 1] > 1){
				--A[r - 1];
				For(i, r, n) A[i] = k;
				r = n;
			}
			else --r, A[r] = 0;
		}
		else --A[r];
	}

	printf("%d", A[1]);
	For(i, 2, n) if(A[i]) printf(" %d", A[i]); else break;

	return 0;
}

Measured memory_bytes: 3456
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, K = MI()
A = LI()

idx = 0
for i in range(K, N):
    print("Yes" if A[i] > A[idx] else "No")
    idx += 1

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = (a + b) / 2;
	
	if ((a + b) % 2 == 0) cout << ans << endl;
	else cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
// 24/01/20 // 9:53 PM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e2) + 10;

int n;
double memo[MAXN][MAXN][MAXN];

void solve(int x, int y, int z){
    for(int c=0; c<=n; c++)
        for(int b=0; b<=n; b++)
            for(int a=0; a<=n; a++){
                if(a+b+c>n || (a==0 && b==0 && c==0)) continue;

                double& estado = memo[a][b][c];
                double dn=n, da = a, db = b, dc = c;

                estado = dn;
                if(a>0) estado += da * memo[a-1][b][c];
                if(b>0) estado += db * memo[a+1][b-1][c];
                if(c>0) estado += dc * memo[a][b+1][c-1];

                estado /= (da+db+dc);
            }
}

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

    cin >> n;

    int a=0, b=0, c=0;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;

        a += (temp==1);
        b += (temp==2);
        c += (temp==3);
    }

    solve(a, b, c);

    cout.precision(10);
    cout.setf(ios::fixed);
    cout << memo[a][b][c] << endl;

    return 0;
}


Measured memory_bytes: 225536
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    int w = 0;
    for (int i = 0; i <  s.size(); i++) {
        if (char(s[i]) == 'x') w++;
    }
    if (w >= 8) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

bool check(string tmp) {
    // cout << tmp << endl;
    if(tmp.length() % 2 == 1) {
        cout << "nope" << endl;
        return false;
    } else {
        int len = tmp.length();
        string before = tmp.substr(0, len / 2);
        string after = tmp.substr(len / 2);
        // cout << before << ":" << after << endl;
        return before == after;
    }
}
int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    REP(i, n) { cin >> a[i]; }
    deque<long long> b;
    REP(i, n) {
        if(i % 2 == 1) {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }
    if(n % 2 == 0) {
        reverse(b.begin(), b.end());
    }
    REP(i, n) { cout << b[i] << " "; }
    cout << endl;
    return 0;
}

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

int main() {
  ll n, a;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    cin >> a;
    mp[a]++;
  }

  ll ans = mp.size();
  if (ans % 2 == 0) ans--;

  cout << ans << endl;
}


Measured memory_bytes: 8112
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner stdIn = new Scanner(System.in);
		int[] cod = new int[5];
		int[] dist = new int[10];
		
		for (int i = 0; i < 5; i++) {
			cod[i] = stdIn.nextInt();
		}
		int k = stdIn.nextInt();
		
		dist[0] = cod[0] - cod[1];
		dist[1] = cod[0] - cod[2];
		dist[2] = cod[0] - cod[3];
		dist[3] = cod[0] - cod[4];
		dist[4] = cod[1] - cod[2];
		dist[5] = cod[1] - cod[3];
		dist[6] = cod[1] - cod[4];
		dist[7] = cod[2] - cod[3];
		dist[8] = cod[2] - cod[4];
		dist[9] = cod[3] - cod[4];
		
		for (int i = 0; i < 10; i++) {
			if (dist[i] < 0) {
				dist[i] *= -1;
			}
			if (dist[i] > k) {
				System.out.println(":(");
				return;
			}
		}
		
		System.out.println("Yay!");
	
	}
}

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

int main() {
  vector<int> v(5);
  for (int i = 0; i < v.size(); i++) {
    cin >> v.at(i);
  }

  int ans = 0;
  int d = 10;
  for (int i = 0; i < 5; i++) {
    int x = v.at(i) % 10;
    if (x != 0) {
      ans += 10 - x;
      d = min(d, x);
    }
    ans += v.at(i);
  }
  cout << ans - (10 - d) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    init();
   int n;
   cin>>n;
   V<ll> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   ll now=1,cnt=0,num=0;
   mint ans=1;
   ll tol=1;
   for(int i=0;i<n;i++){
       cnt++;
       if(i==0)now+=a[i]-1;
       else now+=a[i]-a[i-1]-1;
       now--;
       if(i!=n-1&&now<0){
          ans*=fac[cnt]*COM(tol+cnt-1,cnt);
           now=1;
           tol+=cnt-1;
           cnt=0;
       }
   }
   ans*=fac[cnt]*COM(tol+cnt-1,cnt);
   cout<<ans<<"\n";
}


Measured memory_bytes: 47872
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
    //fios;
    ll n, d;
    cin >> n >> d;
    ll x, y;
    ll cnt = 0;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt <<endl;
   
}

Measured memory_bytes: 3648
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO
import qualified Data.Set                      as S

main = do
    aN <- getI
    aS <- replicateM aN getLine
    let set = S.fromList aS
    print $ S.size set

getVUIL :: IO (VU.Vector Int)
getVUIL = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readI :: BSC8.ByteString -> Int
readI = fst . fromJust . BSC8.readInt
readIL :: BSC8.ByteString -> [Int]
readIL = map readI . BSC8.words
readIT2 :: BSC8.ByteString -> (Int, Int)
readIT2 bs =
    let words = BSC8.words bs in (readI $ head words, readI $ last words)
getI :: IO Int
getI = readI <$> BSC8.getLine
getIL :: IO [Int]
getIL = readIL <$> BSC8.getLine
getIT2 :: IO (Int, Int)
getIT2 = readIT2 <$> BSC8.getLine

getNIS :: Int -> IO [(Int, BSC8.ByteString)]
getNIS 0 = return []
getNIS n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getNIS (n - 1))
    return ((readI aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show (mod a modNum)

int2MInt :: Int -> Mint
int2MInt a = M (mod a modNum)


Measured memory_bytes: 169944
num=int(input())
date=input().rstrip().split(" ")
list0=[]
for i in range(num-1):
  list0.append([])
for j in range(num-1):
  list0[int(date[j])-1].append(0)
for k in range(num-1):
  print(len(list0[k]))
print(0)

Measured memory_bytes: 45264
n, a, b = map(int, input().split())

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
mod=10**9+7
      
def cmb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print( ((2 ** n -1) - cmb(n, a, mod) - cmb(n, b, mod)) %mod)

Measured memory_bytes: 312248