akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int K;
  cin >> K;
  queue<long long int> Q;
  for (int i = 1; i < 10; i++) Q.push(i);
  long long int X = 0;
  for (int i = 1; i <= K; i++) {
    X = Q.front();
    Q.pop();
    if (X % 10 == 0) {
      Q.push(10 * X);
      Q.push(10 * X + 1);
    }
    else if (X % 10 == 9) {
      Q.push(10 * X + 8);
      Q.push(10 * X + 9);
    }
    else {
      Q.push(10 * X + X % 10 - 1);
      Q.push(10 * X + X % 10);
      Q.push(10 * X + X % 10 + 1);
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s;
    cin>>s;
    if(s=="SAT")
    {
        cout<<"1"<<NL;
    }
    else if(s=="SUN")
    {
        cout<<"7"<<NL;
    }
    else if(s=="MON")
    {
        cout<<"6"<<NL;
    }
    else if(s=="TUE")
    {
        cout<<"5"<<NL;
    }
    else if(s=="WED")
    {
        cout<<"4"<<NL;
    }
    else if(s=="THU")
    {
        cout<<"3"<<NL;
    }
    else if(s=="FRI")
    {
        cout<<"2"<<NL;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <assert.h>
#include <functional>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first
#define  sec second
#define  SZ(x) (x.size())
#define  inf 0x3f3f3f3f
#define  PB push_back
#define  MP make_pair
#define  all(x) (x).begin(),(x).end()
#define  PII pair<int,int>
#define  E 2.7182818284590452353602874713527
using namespace std;

/**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const ll mod = 9901;
ll ksm(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
/********************************Head----Template**********************************************/

multiset<int>s;
vector<int>vec;



int main (){
    int n;cin>>n;
    int ans=1;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        s.insert(x);
    }
    for(int x:s) vec.push_back(x);
    int sz=vec.size();
    /**if(sz==1) {
        cout<<vec[0]<<endl;
        return 0;
    }*/

    for(int i=0;i<min(3,sz);i++){
        int cnt=0;
        for(int j=1;j*j<=vec[i];j++){
            if(vec[i]%j==0){
                int cnt=0;
                for(int k=0;k<sz;k++) if(vec[k]%j==0) cnt++;
                if(cnt>=sz-1) ans=max(ans,j);
                cnt=0;
                for(int k=0;k<sz;k++) if(vec[k]%(vec[i]/j)==0) cnt++;
                if(cnt>=sz-1) ans=max(ans,vec[i]/j);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 5628
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int n,k;
  cin >>n>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  sort(vec.begin(),vec.end());
  int ans=1000000000;
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,vec[i+k-1]-vec[i]);
    //cout<<vec[i+k-1]<<vec[i]<<endl;
    //cout <<ans<<endl;
  }
  cout <<ans <<endl;
}
 

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define pn putchar('\n')
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
vector<int>v[26];
int main()
{
string s,t;
cin>>s>>t;
rep(i,0,s.length())
v[s[i]-'a'].push_back(i);

rep(i,0,t.length())
if(v[t[i]-'a'].size()==0)
{
	printf("-1\n");
	return 0;
}
ll cnt=0,now=-1;
rep(i,0,t.length())
{   ll find_pos=t[i]-'a';
//    for(int j=0;j<v[find_pos].size();j++)
//    printf("%d ",v[find_pos][j]);
//    pn;
	ll pos=upper_bound(v[find_pos].begin(),v[find_pos].end(),now)-v[find_pos].begin();
//	printf("#%lld\n",pos);
	if(pos==v[find_pos].size())
	{
	cnt++;	
	now=-1;
	i--;
	}
	else now=v[find_pos][pos];
	
//	cout<<cnt<<" "<<now<<"\n";
}

cout<<cnt*s.length()+now+1<<"\n";



//rep(i,0,26)
//{   if(!v[i].size())continue;
//     printf("%c ",i+'a');
//	 for(int j=0;j<v[i].size();j++)
//	 printf("%d ",v[i][j]);
//	 pn;
//}
}




Measured memory_bytes: 1216
function Main(input){
	input = input.split(" ").map(Number);
	var n = input[0]*(input[0]-1)/2;
	var m = (input[1]<=1)?0:input[1]*(input[1]-1)/2;
	console.log(n+m)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

template<typename T>
void fillall(T& arr, const T& value) {
    arr = value;
}
template<typename T,typename ARR>
void fillall(ARR& arr, const T& value) {
    for(auto& i:arr) fillall(i,value);
}


int T,P,R;
int error[50][10];
std::pair<int,std::pair<int,int>> solve[50];

int main(){
    while(true){
        fillall(error, 0);
        fillall(solve, std::pair<int,std::pair<int,int>>{0,{0,0}});
        cin>>T>>P>>R;
        if(T==0&&P==0&&R==0)break;
        REP(i,T){
            solve[i].second.second = i+1;
        }
        REP(i,R){
            int t,p,time;
            string type;
            cin >> t>>p>>time>>type;--t;--p;
            if(type[0] =='W'){
                error[t][p]+=1;
            }
            else{
                solve[t].second.first += 1200*error[t][p]+time;
                solve[t].first-=1;
            }
        }
        std::sort(solve, solve+T);

        REP(i,T){
            cout << solve[i].second.second << ' '
                << -solve[i].first  << ' '
                 << solve[i].second.first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    exrep(i, 1, n-2) {
        string t = s.substr(0, n-i);
        if(t.size()%2 == 0) {
            ll m = t.size()/2;
            ll ok = 1;
            rep(i, m) {
                if(t[i] != t[i+m]) {
                    ok = 0;
                    break;
                }
            }
            if(ok) {
                out(n-i);
                re0;
            }
        }
    }


    re0;
}

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

int main(){
    int n,m;
    int score = 0;;
    int b[100];
    int sum = 0;
    int lim = 0;
    scanf("%d %d",&n,&m);
    for(int i = 0;i < 100;i++){
        b[i] = 0;
        scanf("%d",&b[i]);
        sum += b[i];
    }
    lim = (sum + (4 * m) - 1) / (4 * m);

    for(int i= 0;i < 100;i++){
        if(b[i] >= lim){
            score++;
        }
    }

    if(score >= m){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

// nの階乗(mod M)
// return: nまでの階乗を示す全値(e.g., fact[5] = 5!を示す値)
func mfactorial(n int, M int) []int {
	fact := make([]int, n+1)
	fact[0] = 1
	for i := 1; i <= n; i++ {
		fact[i] = (fact[i-1] * i) % M
	}
	return fact
}

// x^n (mod M)
// See https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func mpow(x, n, M int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

// nCk (mod M)
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func combi(n int, k int, M int) int {
	if n == 0 && k == 0 {
		return 1
	} else if n < k || n < 0 {
		return 0
	}
	fact := mfactorial(n, M)

	ans := fact[n] * mpow(fact[k], M-2, M) % M
	ans *= mpow(fact[n-k], M-2, M) % M

	return ans % M
}

func mod(a, b int) int {
	for {
		if a < b {
			return a
		}
		a -= b
	}
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	modRoot := 1000000007

	sumX := 0
	sumY := 0
	for i := 1; i < m; i++ {
		sumX += i * (m - i)
		sumX = mod(sumX, modRoot)
	}
	sumX *= mod(n*n, modRoot)
	sumX = mod(sumX, modRoot)
	for i := 1; i < n; i++ {
		sumY += i * (n - i)
		sumY = mod(sumY, modRoot)
	}
	sumY *= mod(m*m, modRoot)
	sumY = mod(sumY, modRoot)

	sum := combi(m*n-2, k-2, modRoot) * (sumX + sumY)

	fmt.Println(mod(sum, modRoot))
}


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

int main() {
    int k;
    cin >> k;
    queue < ll > q;
    for (ll i = 1; i < 10; i++) 
        q.push(i);
    ll ans = 0;
    while (k > 0) {
        ans = q.front(); 
        q.pop();
        if (ans % 10 != 0) 
            q.push(ans * 10 + ans % 10 - 1);
        q.push(ans * 10 + ans % 10);
        if (ans % 10 != 9) 
            q.push(ans * 10 + ans % 10 + 1);
        k--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int solve(int n, const std::vector<long>& heights)
{
  int result = 0;
  int count = 0;
  int current_height = 0;
  for (const auto h : heights) {
    if (h <= current_height) {
      ++count;
    } else {
      result = std::max(result, count);
      count = 0;
    }
    current_height = h;
  }

  return std::max(result, count);
}

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

  std::vector<long> heights(n);
  for (auto& h : heights) {
    std::cin >> h;
  }

  std::cout << solve(n, heights) << std::endl;
}


Measured memory_bytes: 1024
from collections import deque

def f1(x,y,xa,ya):
    if reach[xa][ya] > reach[x][y]:
         if c[xa][ya] == ".":
            reach[xa][ya] = reach[x][y]
            r.append([xa,ya])
            q.append([xa,ya])

def f2(x,y,xa,ya):
    if 0 <= xa <= h+1 and 0 <= ya <= w+1:
    
        if reach[xa][ya] > reach[x][y] + 1:
            if c[xa][ya] == ".":
                reach[xa][ya] = reach[x][y] + 1
                q.append([xa,ya])

h,w = map(int,input().split())
cx, cy = map(int,input().split())
dx, dy = map(int,input().split())

c = [0]*(h+2)
for i in range(1,h+1):
    c[i] = [0] + list(input()) + [0]
c[0]  = [0]*(w+2)
c[-1] = [0]*(w+2)

reach = [[float("Inf") for j in range(w+2)] for i in range(h+2)]
q = deque([])

reach[cx][cy] = 0
q.append([cx,cy])

ans = 0

while q:

    
    
    x,y = q.popleft()
    
    r = deque()
    r.append([x,y])
    while r:
        xx,yy = r.popleft()
        
        f1(xx,yy,xx-1,yy)
        f1(xx,yy,xx+1,yy)
        f1(xx,yy,xx,yy-1)
        f1(xx,yy,xx,yy+1)
    
    for i in range(-2,3):
        for j in range(-2,3):
            f2(x,y,x+i,y+j)

if reach[dx][dy] == float("Inf"):
    print(-1)
else:
    print(reach[dx][dy])


Measured memory_bytes: 212712
from collections import defaultdict
N = int(input())
p = defaultdict(int)
balls = [list(map(int, input().split())) for i in range(N)]

c = 0
if len(balls) <= 2:
    print(1)
else:
    for i in balls:
        for j in balls:
            c += 1
            if i == j:
                continue
            p[(j[0]-i[0]), j[1]-i[1]] += 1
    print(N-max(p.values()))


Measured memory_bytes: 3828
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	d := getInt()

	switch d{
	case 25: fmt.Println("Christmas")
	case 24: fmt.Println("Christmas Eve")
	case 23: fmt.Println("Christmas Eve Eve")
	case 22: fmt.Println("Christmas Eve Eve Eve")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

int main()
{
  int n;
  
  cin >> n;
  
  int a[n];
  for (int i=0;i<n;++i) {
    cin >> a[i];
  }
  
  int gcd[n][2];
  for (int i=0;i<n;++i) {
    gcd[i][0] = 0;
    gcd[i][1] = 0;
  }
  
  //[0-i)のgcd
  for (int i=0;i<n-1;++i) {
    gcd[i+1][0] = calc_gcd(gcd[i][0], a[i]);
  }
 
  // (i-(n-1)]のgcd
  for (int i=n-1;i>0;--i) {
    gcd[i-1][1] = calc_gcd(gcd[i][1], a[i]);
  }
  
/*  
  for (int i=0;i<n;++i) {
    cout << gcd[i][0];
    cout << ',';
    cout << gcd[i][1];
    cout << ',';
    cout << calc_gcd(gcd[i][0], gcd[i][1]);
    cout << endl;
  }
*/
  
  int max_gcd = 0;
  for (int i=0;i<n;++i) {
    int tmp_gcd = calc_gcd(gcd[i][0], gcd[i][1]);
    if (max_gcd < tmp_gcd)
      max_gcd = tmp_gcd;
  }

  int ans = max_gcd;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
//not answered
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> x(m);
  for(int i = 0; i < m; i++)
    cin >> x[i];
  
  //end 0 pattern
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  
  sort(x.begin(), x.end());
  vector<int> section(m-1);
  
  //want to sort greater than
  for(int i = 0; i < m-1; i++)
    section[i] = -(x[i+1] - x[i]);
  
  sort(section.begin(), section.end());
  int sum_greater_sec = 0;
  for(int i = 0; i < n-1; i++)
    sum_greater_sec -= section[i];
  
  cout << x[m-1] - x[0] - sum_greater_sec << endl;
  
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int a,p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
}

Measured memory_bytes: 256
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.io.*;
import java.util.*;

public class Main {
    void run() {
        int T = readInt();
        for (int t = 0; t < T; t++) {
            int N = readInt();
            int K = readInt();
            int[] X = new int[N];

            for (int i = 0; i < N; i++) {
                X[i] = readInt();
            }
            int sum = 0;
            int[] Y = new int[N - 1];
            for (int i = 0; i < N - 1; i++) {
                Y[i] = X[i + 1] - X[i];
                sum += Y[i];
            }
            Arrays.sort(Y);
            for (int i = 0; i < Math.min(N, K) - 1; i++) {
                sum -= Y[Y.length - 1 - i];
            }
            sysout.println(sum);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 56432
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 100000
#define mod 1000000007
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;

int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
ll m,n,row,col;
string s;
ll dp[3006][3006];//dp[i][j] = number of permutations of i+1 length using first i+1 numbers
ll sum[3006][3006];
//with j as last character
void solve()
{
  int ans=0;
	cin>>n>>s;
  dp[1][1]=1;
	for(int i=2;i<=n;i++){
		if(s[i-2]=='<'){
			for(int j=1;j<=i;j++){
				dp[i][j]=(dp[i-1][j-1]+dp[i][j-1])%mod;
			}
		}
		else{
			dp[i][i]=0;
			for(int j=i-1;j>=1;j--){
				dp[i][j]=(dp[i-1][j]+dp[i][j+1])%mod;
			}
		}
	}
  for(int i=1;i<=n;i++){
		ans=(ans+dp[n][i])%mod;
	}
	cout<<ans<<endl;

}



void test()
{
  int t;
  //scanf("%d",&t);
  t = 1;
  for(int test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 71808
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double ans = 0;
		for (int i=0;i<N;i++) {
			ans+=(double)1/N*Math.pow(0.5,binarysearch(K,i+1));
		}
		System.out.println(ans);
	}

	static int binarysearch(int x,int y) {
		int low=0;
		int high=20;
		if (x<=y) {
			return 0;
		}
		while (low+1<high) {
			int mid=(low+high)/2;
			double guess=y*Math.pow(2,mid);
			if (guess==x) {
				return mid;
			} else if (guess > x) {
				high = mid;
			} else {
				low = mid;
			}
		}
		return high;
	}
}

Measured memory_bytes: 23892
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- reverse . sort . map (read::String -> Int) . words <$> getLine
  let (former, latter, _) = foldl (\(f, l, state) val -> if state then (f + val, l, False) else (f, l + val, True)) (0, 0, True) arr
  print $ former - latter



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int main(){
    int N,D;
    cin >> N >> D;
    int flg=0;

    while(N){
        double X,Y;
        cin >> X >> Y;
        if(sqrt(X*X+Y*Y)<=D) flg++;
        N--;
    }
    cout << flg << endl;
    
    
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;
const double rate = 380000.0;

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> CH(M, 0);
	for(int i = 0; i < N; i++){
		int K;
		cin >> K;
		for(int j = 0; j < K; j++){
			int A;
			cin >> A;
			CH.at(A - 1)++;
		}
	}
	int cnt = 0;
	for(int i = 0; i < M; i++){
		if(CH.at(i) == N)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN];
	
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	FOR(x,1,100) FOR(y,1,100) FOR(z,1,100){
		int t = x*x+y*y+z*z+x*y+x*z+y*z;
		A[t]++;
	}
	FOR(i,1,N) cout<<A[i]<<"\n";
}


Measured memory_bytes: 4076
#include <iostream>
#include <vector>
#include <map>
#include <functional>
using namespace std;

int main(){
  int tmp,tmp2;
  while(1){
    map <int,char,greater<int> > pi;
    map <int,char,greater<int> >::iterator itr;
    for(int i=0;i<5;i++){
      cin >> tmp >> tmp2;
      if(tmp == 0 && tmp2 == 0) return 0;
      pi.insert(map<int,char,greater<int> >::value_type(make_pair(tmp+tmp2,i+'A')));
    }
    itr = pi.begin();
    cout << itr->second << " " << itr->first << endl;
  }
}

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

int main(){
	int n,i;
	while(cin>>n){
		int p[n];
		int ret=0,now=0;
		cin>>p[0];
		for(i=1;i<n;i++){
			cin>>p[i];
		}
		sort(p,p+n);
		for(int j=0;j<i;j++){
			now+=p[j];
			ret+=now;
		}
		cout<<ret<<endl;
	}


}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

typedef pair<string,string> pss;

int main(void){
	std::map<pss,int> m;
	int M,f;
	cin>>M>>f;
	int n;
	string s;
	while(M--){
		cin>>n;
		std::vector<string> v;
		for(int i=0;i<n;i++){
			cin>>s;
			v.push_back(s);
		}
		std::sort(v.begin(),v.end());
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				m[make_pair(v[i],v[j])]++;
			}
		}
	}
	int c=0;
	for(map<pss,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second>=f)c++;
	}
	cout<<c<<endl;
	for(map<pss,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second>=f)cout<<(it->first).first<<" "<<(it->first).second<<endl;
	}
	return 0;
}

Measured memory_bytes: 3316
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

print((n+1)//2)

Measured memory_bytes: 77188
#include <iostream>

using namespace std;

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

    int h = s / 3600;
    s %= 3600;
    int m = s / 60;
    s %= 60;

    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    ll N;
    cin >> N;
    string S;
    map<string, int> m;
    rep(i,N){
        cin >> S;
        m[S]++;
    }
    int cnt = 0;
    for (auto ite =  m.begin(); ite != m.end(); ++ite){
        if (cnt < ite->second)cnt = ite->second;
    }
    vector<string> v;
    for (auto ite =  m.begin(); ite != m.end(); ++ite){
        if (cnt == ite->second){
            v.push_back(ite->first);
        }
    }
    sort(ALL(v));
    rep (i, v.size()){
        cout << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 26868
import sys
import re
from decimal import *

l = sys.stdin.readline()
l = sys.stdin.readline()
#l = l.split(' ')
#l = [int(str) for str in l]
s = l

state = 0
count = 0
for i in s:
  if(i == 'A'):
    state = 1
  else:
    if(i == 'B' and state == 1):
      state = 2
    else:
      if(i == 'C' and state == 2):
        state = 0
        count += 1
      else:
        state = 0

print(count)

sys.stdout.flush()


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

ll dp[20][2][1000][2];
int main() {
  string S;
  cin >> S;
  int N = S.size();
  dp[0][0][0][0] = 1;
  rep(i, 0, N) rep(j, 0, 2) rep(k, 0, 1000) rep(l, 0, 2) {
    int x = j ? 9 : S[i] - '0';
    rep(d, 0, x + 1) {
      dp[i + 1][j || d < x][(k % 100) * 10 + d][l || ((k / 10 == 51) && (d == 3))] += dp[i][j][k][l];
    }
  }
  ll ans = 0;
  rep(j, 0, 2) rep(k, 0, 1000) {
    ans += dp[N][j][k][1];
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    int k,a,b;
    int ans=0;
    cin >> k >> a >> b;
    for(int i=a;i<b+1;i++){
        if(i%k==0){
            ans++;
        }
    } 
    if(ans!=0){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum=0;
if(a<b){
sum+=a;
}else{
sum+=b;
}
if(c<d){
sum+=c;
}else{
sum+=d;
}
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int X;
  ci(X);
  if(X == 3 || X == 5 || X == 7){
    co("YES");
  }
  else{
    co("NO");
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,i,d=0;
	while(scanf("%d%d",&a,&b),a)
	{
		if(d++) putchar('\n');
		for(c=0,i=a;i<=b;++i)
		{
			if(i%400 == 0 || (i%100 && (i&3)==0))
				printf("%d\n",i),++c;
		}
		if(!c)
			puts("NA");
	}
	return 0;
}

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

int N;
vector<long long> A;

void solve() {
    vector<long long> plus, minus;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<long long>());
    sort(minus.begin(), minus.end());
    if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();

    vector<pair<long long, long long> > res;
    long long cur = minus[0];
    for (int i = 0; i+1 < plus.size(); ++i) {
        res.push_back({cur, plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(), cur});
    cur = plus.back() - cur;

    for (int i = 1; i < minus.size(); ++i) {
        res.push_back({cur, minus[i]});
        cur -= minus[i];
    }

    cout << cur << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
}

int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    solve();
}

Measured memory_bytes: 5880
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	int ans1 = 0, ans2 = 0;
	int sum = 0;
	REP(i, N) {
		sum += A[i];
		if (i % 2 && sum >= 0) {
			ans1 += sum + 1;
			sum = -1;
		}
		else if (i % 2 == 0 && sum <= 0) {
			ans1 += -(sum - 1);
			sum = 1;
		}
	}
	sum = 0;
	REP(i, N) {
		sum += A[i];
		if (i % 2 && sum <= 0) {
			ans2 -= sum - 1;
			sum = 1;
		}
		else if (i % 2 == 0 && sum >= 0) {
			ans2 += sum + 1;
			sum = -1;
		}
	}
	
	cout << min(ans1, ans2) << endl;

	return 0;
}



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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    vector< int > a(3);
    cin >> a;
    
    whole(sort, a);
    cout << a[0] + a[1] + 10 * a[2] << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  int ans = 0;
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    char a = S.at(i);
    if (i % 2 == 0)
    {
      if (a == 'L')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      if (a == 'R')
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}

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

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

    int length = S.size();

    int ans = 0;
    while (true) {
        --length;
        int cnt = 0;
        for (int j = 0; j < length/2; ++j) {
            if (S[j] == S[j+length/2]) ++cnt;
            else break;
        }
        if (cnt == length/2) {ans = cnt*2; break;}
    }
    cout << ans << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int five = 0;
  int seven = 0;
  if(A == 5) five++;
  else if(A == 7) seven++;

  if(B == 5) five++;
  else if(B == 7) seven++;

  if(C == 5) five++;
  else if(C == 7) seven++;

  if(five == 2 && seven == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,T;

	scanf("%d %d",&N,&T);

	int minimum = BIG_NUM;

	int cost,tmp;

	for(int i = 0; i < N; i++){

		scanf("%d %d",&cost,&tmp);
		if(tmp > T)continue;

		minimum = min(minimum,cost);
	}

	if(minimum == BIG_NUM){

		printf("TLE\n");

	}else{

		printf("%d\n",minimum);
	}

	return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <utility>
#include<iterator>
#include<algorithm>
#include<queue>
using namespace std;
using p = pair<double,string>;
int main()
{  
	int n;
	auto q = queue<p>();
	cin >> n;
	for(int i = 0; i<n;i++){
	    double x;
	    string u;
	    cin >> x >> u;
	   q.push(make_pair(x,u));
	}
	auto ans = 0.0;
	for(int i = 0;i<n;i++){
	    auto pp = q.front();
	    if(pp.second == "JPY"){
	        ans += pp.first;
	    }else if(pp.second == "BTC"){
	        ans += pp.first*380000.0;
	    }
	    q.pop() ;   
	}
	
	cout << ans;
	
}

Measured memory_bytes: 256
// B - Frog 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void vprn(vector<ll> v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }

#define INF 1000000000

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

	vector<ll> h(N+1); for(int i=1; i<=N; i++) cin>>h[i];

	vector<ll> dp(N+1);
	for(int n=2; n<=N; n++){
		ll m = INF;
		for(int k=1; k<=K; k++){
			if(n<=k) break;
			ll d = dp[n-k] + abs(h[n] - h[n-k]);
			if(m>d) m = d;
		}
		dp[n] = m;
		// vprn(dp);
	}
	cout<< dp[N] <<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)
#define For(i,u) for(int i=H[u];i;i=nxt[i])
#define re(i,a,b) for (int i=a;i<b;++i)
#define si(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int N=111111;
//head
char s[N];
int n;
int ans,tot;
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	if(s[1]=='p')ans=-1;tot=1;
	rep(i,2,n){
		if(s[i]=='p'){
			if(tot)tot--;
			else tot++,ans--;
		}
		else if(tot){tot--;ans++;}
		else tot++;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
const int mod = 1e9 + 7;
ll int INF = 1e17;


int k;
string s;
ll int dp[10005][105][2];


ll int kil(int idx, int rem, int small)
{
  if(idx == s.length())
  {
    if(rem == 0)
      return 1;
    return 0;
  }
  if(dp[idx][rem][small] != -1)
    return dp[idx][rem][small];

  dp[idx][rem][small] = 0;

  for(int i=0;i<10;i++)
  {
    if(s[idx] - '0' < i && !small)
      break;
    if(s[idx] - '0' == i && !small)
      dp[idx][rem][small] = (dp[idx][rem][small] + kil(idx + 1, (rem + i) % k, 0)) % mod;
    else
      dp[idx][rem][small] = (dp[idx][rem][small] + kil(idx + 1, (rem + i) % k, 1)) % mod;
  }
  return dp[idx][rem][small] % mod;
}


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

  memset(dp, -1, sizeof dp);
  cin>>s;
  cin>>k;
  int res = kil(0, 0, 0) - 1;
  if(res == -1)
    res = mod - 1;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 17664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        
        String[] str = s.split(" ");
        
        for(int i = 0; i < str.length; i++){
            if(str[i].equals("0")){
                System.out.println(i + 1);
            }
        }
    }
}

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

typedef struct{
  int Num;
  char S[20];
  int P;
} Pair;

int f(const void *a,const void *b){
  return ((Pair*)b)->P-((Pair*)a)->P;
}

int g(const void *a,const void *b){
  return strcmp(((Pair*)a)->S,((Pair*)b)->S);
}

int main(){
  int N;
  scanf("%d\n",&N);
  Pair A[200];
  for(int i=0;i<N;i++){
    A[i].Num=i+1;
    scanf("%s %d\n",A[i].S,&A[i].P);
  }
  qsort(A,N,sizeof(Pair),f);
  qsort(A,N,sizeof(Pair),g);
  for(int i=0;i<N;i++)
    printf("%d\n",A[i].Num);
  return 0;
}
  

Measured memory_bytes: 1732
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        char ans;
        if (s == "A") ans = 'T';
        else if (s == "T") ans = 'A';
        else if (s == "C") ans = 'G';
        else ans = 'C';
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

	typedef pair<int, int> int_pair;
	vector<int_pair> a;

	while (true)
	{
		int H, W;
		cin >> H >> W;

		a.push_back(int_pair(H, W));

		if (H == 0 && W == 0)
			break;
	}

	for (int i = 0; a[i].first != 0 && a[i].second != 0; ++i)
	{
		for (int h = 0; h < a[i].first; ++h)
		{
			for (int w = 0; w < a[i].second; ++w)
				if ((h % 2 == 0 && w % 2 == 0)
					|| (h % 2 == 1 && w % 2 == 1))
					cout << "#";
				else
					cout << ".";
			cout << endl;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b[200],c=0,d=0;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	for(int i=0;i<10000;i++){
		for(int i=0;i<a;i++){	
			if(b[i]%2==1){
				d++;
			}
			b[i]=b[i]/2;
		}
		if(d>0){
			break;
		}
		c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,z=0,x;
	cin>>n;
	int n1=n-1;
	int p[100]={0};
	for(int i=0;i<n;i++)
	  cin>>p[i];
	int t=1;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		z+=x;
	}
	for(int i=0;i<n1;i++)
	{
		cin>>x;
		for(int i=0;i<n;i++)
		  if(p[i]==t&&p[i+1]==t+1) 
		  {
		  	z+=x;
		  	break;
		  }
		t++;
	}
	cout<<z;
	return 0;
}

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

int main(){
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    while(cin >> n && n){
        vector<P> vp(n);
        vector<vector<ll>> dp(n+1,vector<ll>(n+1,INF));
        rep(i,n)cin >> vp[i].second >> vp[i].first;
        sort(ALL(vp));
        dp[0][0] = 0;
        rep(i,n){
            ll t = vp[i].first;
            if(i != 0)t -= vp[i-1].first;
            ll dis = vp[i].second;
            if(i != 0){
                dis -= vp[i-1].second;
                dis = abs(dis);
            }
            ll dis2 = vp[i].second;
            // cout << "!!" << vp[i].first << " " << vp[i].second << endl;
            rep(j,4){
                ll cnt = j+1;
                // cout << dis << " " << cnt << endl;
                if(j != 3 && dis*cnt <= t)dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j] + dis);
                if(i != 0){
                    ll dis3 = vp[i - 1].second;
                    if(dis3*cnt + dis2 <= t)dp[i+1][1] = min(dp[i+1][1],dp[i][j] + dis2 + dis3);
                }
            }
            // cout << endl;
        }
        // cout << "^^^^^^^^^^^" << endl;
        // rep(i,n+1){
        //     rep(j,4){
        //         if(dp[i][j] != INF)cout << dp[i][j] << " ";
        //         else cout << -1 << " ";
        //     }
        //     cout << endl;
        // }
        bool ok = true;
        ll ans1 = INF;
        ll ans2 = -1;
        FOR(i,1,n+1){
            bool f = false;
            rep(j,i+1){
                f |= (dp[i][j] != INF);
                if(i == n){
                    // cout << dp[i][j] << " " << vp[n-1].second << endl;
                    ans1 = min(ans1,dp[i][j]+vp[n-1].second);
                }
            }
            ok &= f;
            if(!f){
                ans2 = i;
                break;
            }
        }
        if(ok)cout << "OK" << " " << ans1 << endl;
        else cout << "NG" << " " << ans2 << endl;
    }
}




Measured memory_bytes: 3028
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int N; cin >> N;
    vector<int> L(N); REP(i, N) cin >> L.at(i);
    sort(ALL(L), greater<int>());
//    DEBUG_VEC(L);

    int topLength = L.at(0);
    int sum = 0;
    REP(i, N) sum += L.at(i);
    sum -= topLength;



    if(topLength < sum) {
        cout << "Yes";
        return 0;
    }else{
        cout << "No";
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
#define mp make_pair
#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;
string s;
int n;


 
signed main()
{
    haha
    int h,w;
    cin>>h>>w;
    if(h==1 || w==1)
    cout<<1;
    else
    cout<<(h*w+1)/2<<endl;
    
  
 
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
string s,s1,s2;

bool check(string t)
{
    int l=0,r=t.length()-1;
    while (l<=r)
    {
        if (t[l]!=t[r]) return false;
        l++;
        r--;
    }
    return true;
}

int main()
{
    cin>>s;
    n=s.length();
    for (int i=0;i<n/2;++i)
        s1+=s[i];
    for (int i=n/2+1;i<n;++i)
        s2+=s[i];
    if (check(s) && check(s1) && check(s2)) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    string s;
    cin >> s;
    map<char,int> mp;
    for(int i=0;i<4;i++){
        mp[s[i]]++;
    }
    for(auto e: mp){
        if(e.second!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256