akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func calc(a, b, x int) int {
	va, vb, vx := float64(a), float64(b), float64(x)
	return int(math.Floor(va*vx/vb) - (va * math.Floor(vx/vb)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	a := nextInt()
	b := nextInt()
	n := nextInt()
	if n < b {
		fmt.Println(calc(a, b, n))
	} else {
		fmt.Println(calc(a, b, b-1))
	}
}


Measured memory_bytes: 1756
H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]

def search(h,w):
        if s[h][w]=='#':
                return '#'
        count=0
        for i in range(-1,2):
                for j in range(-1,2):
                        if 0<=h+i and h+i<H and 0<=w+j and w+j<W:
                                if i!=0 or j!=0:
                                        if s[h+i][w+j]=='#':
                                                count+=1
        return count

for h in range(H):
        for w in range(W):
                print(search(h,w),end='')
        print()

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int x = sc.NextInt();
        int y = sc.NextInt();
        int z = sc.NextInt();

        int answer = (x - z) / (y + z);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
long long a[100005];
int main(){
	int n=read(); long long l=2,r=2,x,y;
	for(int i=n;i>=1;--i) a[i]=read();
	For(i,1,n){
		x=l/a[i]; if (l%a[i]!=0) ++x; y=r/a[i];
		if (x>y) printf("-1\n"),exit(0);
		l=x*a[i]; r=(y+1)*a[i]-1;
	}
	printf("%lld %lld\n",l,r);
	return 0;
}

Measured memory_bytes: 1024
/************************************************
* Author        :RunningTime
* Created Time  :2017/7/29 20:13:52
* File Name     :C.cpp
 ************************************************/

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

typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
vector<int> edge[N];
int n, m;

bool DFS(int u, int step) {
    if (step == 2) {
        return u == n;
    }
    for (int v: edge[u]) {
        if (DFS(v, step+1)) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=1; i<=m; ++i) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    if (DFS(1, 0)) cout << "POSSIBLE" << '\n';
    else cout << "IMPOSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int par[MAX_N];
int nrank[MAX_N];
int weight[MAX_N];

void initial(int n){		//?????????
	for(int i=0;i<n;i++){
		par[i] = i;
		nrank[i] = 0;
        weight[i] = 0;
	}
}

P find(int x){		//??¨??????????±???????
	if(par[x] == x){
		return P(x,0);
	}else{
		P p = find(par[x]);
		par[x] = p.fi;
		weight[x] = p.se + weight[x];
		return P(par[x],weight[x]);
	}
}

void unite(int x,int y,int w){
	int bx = x;
	int by = y;
	x = (find(x)).fi;
	y = (find(y)).fi;
	if(x == y) return;
	if(nrank[x] < nrank[y]){
		par[x] = y;
		weight[x] = -weight[bx] - w + weight[by];
	}else{
		par[y] = x;
        weight[y] = weight[bx] + w - weight[by];
		if(nrank[x] == nrank[y])
			nrank[x]++;
	}
}

bool same(int x,int y){
	return (find(x)).fi == (find(y)).fi;
}

int main()
{
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        initial(n+1);
        rep(i,m){
            int a,b,w;
            string s;
            cin >> s ;
            if(s == "!"){
                cin >> a >> b >> w;
                unite(a,b,w);
            }else{
                cin >> a >> b;
                if(same(a,b)){
                    cout << weight[b] - weight[a] << "\n";
                }else{
                    cout << "UNKNOWN\n";
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4164
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    
    char a[100010]={0};
    char b[100010]={0};
    gets(a);
    int sum=0;
    for(int i=0;i<strlen(a);i++){
    	if(i==0){
    		cout<<a[i];
		}
		else if(i==strlen(a)-1){
			cout<<sum<<a[i];
		}
		else sum++;
	}
    return 0;
    
}

Measured memory_bytes: 384
H,W = map(int,input().split())

S = [list(input()) for i in range(H)]

for i in range(H):
    for j in range(W):
        b = 0
        if S[i][j] == "#":
            bottomi = i-1 if i > 0 else 0
            bottomj = j-1 if j > 0 else 0
            topi = i+1 if i < H-1 else H-1
            topj = j+1 if j < W-1 else W-1
            for k in range(bottomi,topi+1):
                for l in range(bottomj,topj+1):
                    if (k == i and l != j) or (k != i and l == j) :
                        if S[k][l] == "#":
                            b = 1
            else:
                if b == 0:
                    break
        else:
            b = -1
    if b == 0:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int num[n];
    for(i = 0;i < n;i++)
        cin>>num[i];
    sort(num,num+n);
    cout<<num[n-1]-num[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[10001];
	int i,x,y,n;
	while(scanf("%s",a)!=EOF){
		n=strlen(a);
		x=0; y=0;
		for(i=0;i<n-2;i++){
			if(a[i]=='J' && a[i+1]=='O' && a[i+2]=='I') x++;
			if(a[i]=='I' && a[i+1]=='O' && a[i+2]=='I') y++;
		}
		printf("%d\n%d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll combi(ll n,ll r){
    if(n < r)return 0;
    ll num = 1;
    for(ll i = 1;i <= r;i++){
        num = (n-i+1)*num / i;
    }
    return num;
}
main(){
    int N,A,B;
    cin >> N >> A >> B;
    map<ll,int> mp;
    rep(i,0,N){
        ll a;
        cin >> a;
        mp[a]++;
    }
    auto itr = mp.end();
    itr--;
    int cnt = (*itr).second;
    if(cnt >= A){
        cout << (*itr).first << endl;
        ll ans = 0;
        rep(i,A,B+1)ans += combi(cnt, i); 
        cout << ans << endl;
    }else{
        ll sum = (*itr).first * (*itr).second;
        while(1){
            itr--;
            if(A - cnt <= (*itr).second){
                sum += (*itr).first * (A - cnt);
                printf("%.9lf\n", 1. * sum / A);
                cout << combi((*itr).second, A - cnt) << endl;
                return 0;
            }
            sum += (*itr).first * (*itr).second;
            cnt += (*itr).second;
        }
    }
}

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


int main(void){
   string S,T;
   cin>>S;
   cin>>T;
   int ans=T.size()+1;
   int N=S.size();
   int M=T.size();
   for(int i=0;i<N-M+1;i++){
      int cnt=0;
      string temp=S.substr(i,T.size());
      for(int j=0;j<M;j++){
         if(temp[j]!=T[j]) cnt++;
      }
      ans=min(cnt,ans);
   }
   cout<<ans<<endl;
   return 0;
}


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

int main()
{
    int price,n,sum=0,cnt=0;
    double average=0;
    while (scanf("%d,%d",&price,&n) != EOF)
    {
       cnt++;
       sum+=price*n;
       average+=n;
    }
    average/=cnt;
    cout << sum << endl << round(average) << endl;
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int H, W, h, w;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def countingSort(A, B, k):
    C = [0] * (k + 1)

    for j in range(0, len(A)):
        C[A[j]] += 1

    for i in range(1, k + 1):
        C[i] += C[i - 1]

    B = [0] * (max(C) + 1)
    for j in range(len(A) - 1, -1, -1):
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1

    del B[0]
    print " ".join([str(b) for b in B])

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = map(int, lines[1].split())
    B = []
    countingSort(A, B, max(A))

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x[ohara],y,sum=0,pos,dp[51][51][2501];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>a;
      rep(i,n)cin>>x[i],sum+=x[i];
      dp[0][0][0]=1;
      rep(i,n){
        rep(j,n+1){
          rep(k,sum+1){
            dp[i+1][j][k]+=dp[i][j][k];
            if(k>=x[i]&&j>=1)dp[i+1][j][k]+=dp[i][j-1][k-x[i]];
          }
        }
      }
      rep(i,n+1){
        ans+=dp[n][i][i*a];
        //cout<<i<<" "<<dp[n][i][i*a]<<"\n";
      }
      Cout(ans-1);

return 0;
}


Measured memory_bytes: 50432
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	int n, count = 0;
	string tmp;
	vector<string> m, a, r, c, h;
	unsigned long long int result = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		if (tmp[0] == 'M') {
			m.push_back(tmp);
		}
		else if (tmp[0] == 'A') {
			a.push_back(tmp);
		}
		else if (tmp[0] == 'R') {
			r.push_back(tmp);
		}
		else if (tmp[0] == 'C') {
			c.push_back(tmp);
		}
		else if (tmp[0] == 'H') {
			h.push_back(tmp);
		}
	}
	if (m.size() > 0) ++count;
	if (a.size() > 0) ++count;
	if (r.size() > 0) ++count;
	if (c.size() > 0) ++count; 
	if (h.size() > 0) ++count;
	if (count < 3) {
		cout << 0 << endl;
		return 0;
	}
	else {
		result += a.size()*r.size()*c.size() + a.size()*r.size()*h.size() + a.size()*h.size()*c.size() + h.size()*r.size()*c.size();
		result += m.size()*r.size()*c.size() + m.size()*r.size()*h.size() + m.size()*h.size()*c.size();
		result += a.size()*m.size()*c.size() + a.size()*m.size()*h.size();
		result += a.size()*r.size()*m.size();
		cout << result << endl;
		return 0;
	}
	
	
	return 0;
}

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

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

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

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

string S[305];
ll A[305][305];
ll T[305];
int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    REP(i, H)
    {
        cin >> S[i];
    }

    memset(A, 0, sizeof(A));
    memset(T, 0, sizeof(T));
    REP(i, W)
    {
        REP(j, H)
        {
            if (S[j][i] == '#')
                T[i]++;
        }
    }

    int index = 1;
    ll prev = 0;
    for (ll w = 0; w < W; ++w)
    {
        if (T[w] == 0)
            continue;

        for (ll h = 0; h < H; ++h)
        {
            ll p = T[w];
            for (ll k = prev; k <= w; ++k)
            {
                A[h][k] = index;
                if (S[h][k] == '#')
                    T[w]--;
            }

            if (p != T[w] && T[w] > 0)
                index++;
        }
        index++;
        prev = w + 1;
    }
    REP(i, H)
    {
        REP(j, W)
        {
            if (A[i][j] == 0 && j > 0)
                A[i][j] = A[i][j - 1];
        }
    }

    REP(i, H)
    {
        REP(j, W)
        {
            cout << A[i][j];
            if (j < W - 1)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        boolean[][] b = new boolean[m][n];

        for(int i=0; i<m; i++) {
            int k = sc.nextInt();
            for(int j=0; j<k; j++) {
                b[i][sc.nextInt()-1] = true;
            }
        }
        int[] p = new int[m];
        for(int i=0; i<m; i++) {
            p[i] = sc.nextInt();
        }

        int res = 0;
        A: for(int i=0; i<(1<<n); i++) {
            for(int j=0; j<m; j++) {
                int sum = 0;
                for(int l=0; l<n; l++) {
                    if(b[j][l] && (i>>l)%2 == 1) {
                        sum++;
                    }
                }
                if(sum % 2 != p[j]) continue A;
            }
            res++;
        }

        System.out.println(res);

    }

}


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

int main(){
   int n,k,d;
   int res=0;
   cin >> n >> k;
   vector<int> A(n,0);
   for (int i=0;i<k;++i){
       cin >> d;
       for (int j=0;j<d;++j){
           int tmp;
           cin >> tmp;
           ++A[tmp-1];
       }
   }
   for (int i=0;i<n;++i){
       if(A[i]==0){
           ++res;
       }
   }
   cout << res << endl;

}

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

long long hcf(long long a, long long b) {
    if(a % b == 0)
        return b;
    return hcf(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a, b;
    cin >> a >> b;
    long long n = hcf(a, b);
    unordered_map<long long, long long> primefactor;
    while(n % 2 == 0) {
        primefactor[2]++;
        n /= 2;
    }
    for(long long i = 3; i <= sqrt(n); i += 2) {

        while(n % i == 0) {
            primefactor[i]++;
            n /= i;
        }
    }
    if(n > 2)
        primefactor[n]++;
    cout << primefactor.size() + 1 << endl;
    return 0;
}


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

int main() {
	long long l,r,min=20000;
	cin>>l>>r;
	//l=l%2019;
	//r=r%2019;
	if(l>=r)
	min=0;
	for(long long i=l;i<=r-1;i++){
		for(long long j=i+1;j<=r;j++){
			if(((i%2019)*(j%2019))%2019<min)
			min=((i%2019)*(j%2019))%2019;
			
			if(min==0)
			break;
		}
		if(min==0)
		break;
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split(" ")))
h = list(map(int, input().split(" ")))

ans = [1] * n

for i in range(m):
    a, b = list(map(int, input().split(" ")))
    a,b = a-1,b-1

    if h[a] < h[b]:
        ans[a] = 0
    elif h[b] < h[a]:
        ans[b] = 0
    else:
        ans[a] = 0
        ans[b] = 0

print(ans.count(1))




Measured memory_bytes: 20116
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<vi> a(n, vi(3));
	rep(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2];

	vector<vi> dp(n + 1, vi(3));
	rep(i, n) rep(j, 3) rep(k, 3) if(j != k) {
		chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

using namespace std;

#define ll long long

int main(){
	int N;
	cin >> N;
	int ans=0;
	for(int i=1;i<=N;i++) {
		if(i&&(!(i&(i-1)))) {
			ans=i;
		}
	}
	printf("%d",ans);
	return 0;
}




Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long N;
  cin >> N;
  if (N % 2) {
    cout << 0 << endl;
    return 0;
  }
  N /= 2;
  long long ans = 0;
  while(N) {
    N /= 5;
    ans += N;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;


int main()
{
	ll H;
	scanf("%lld", &H);


	ll height = (ll)log2((double)H) + 1;
	//printf("%lld\n", height);
	ll ans = (1LL << height) - 1;
	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 512
import bisect


def m():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    AR = [0] * (N + 1)
    BR = [0] * (M + 1)
    for i in range(N):
        AR[i + 1] = AR[i] + A[i]
    for i in range(M):
        BR[i + 1] = BR[i] + B[i]

    ai = bisect.bisect_right(AR, K)
    for a in range(ai-1, -1, -1):
        bk = K - AR[a]
        bi = bisect.bisect_right(BR, bk)

        ans = max(a + bi - 1, ans)
    return ans


print(m())


Measured memory_bytes: 110920
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

signed main(){
  roflan;
  int n, W;
  cin >> n >> W;
  vector <pii> a(n);
  vector <int> dp(W + 1);
  for (int i = 0; i < n; i++){
    cin >> a[i].F >> a[i].S;
    for (int w = W - a[i].F; w >= 0; w--){
      dp[a[i].F + w] = max(dp[a[i].F + w], dp[w] + a[i].S);
    }
  }
  int ans = 0;
  for (int i = 0; i <= W; i++)
    ans = max(ans, dp[i]);
  cout << ans;
  return 14 / 88;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
   
  public static void main(String[] args)
  {
     
   Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    long totalWt=s.nextLong();
    long wt[]=new long[n];
   int profit[]=new int[n];
    int sum=0;
    for(int i=0;i<n;i++ )
    {
    	wt[i]=s.nextLong();
    	profit[i]=s.nextInt();
    	
    }
    for(int i=0;i<n;i++)
    	sum+=profit[i];
    
    long dp[][]=new long[n][sum+1];
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<=sum;j++)
    		dp[i][j]=0;
    }
    dp[0][profit[0]]=wt[0];
    
    for(int i=1;i<n;i++)
    {
    	
    	for(int j=0;j<=sum;j++)
    	{
    		
           		if(j-profit[i]>=0)
           		{
           			if((dp[i-1][j]!=0&&dp[i-1][j-profit[i]]!=0)||(j-profit[i]==0)&&(dp[i-1][j]!=0))
           			dp[i][j]=Math.min(wt[i]+dp[i-1][j-profit[i]], dp[i-1][j]);
                    else if((j-profit[i]==0)||dp[i-1][j-profit[i]]!=0)
                     dp[i][j]=wt[i]+dp[i-1][j-profit[i]];
           			else
           				dp[i][j]=dp[i-1][j];
           		}
           		else
           			dp[i][j]=dp[i-1][j];
    	}
    }
    
    

    
    for(int p=sum;p>0;p--)
    {
    	if(dp[n-1][p]!=0&&dp[n-1][p]<=totalWt)
    	{
    		System.out.println(p);
    		break; 
    	}
    }
   
  
    s.close();
    
  }
}


Measured memory_bytes: 127572
#include <iostream>
using namespace std;
int main(void){
    
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        
        if(op == '?'){
            break;
        }
        
        else if(op == '+'){
            cout << a+b << endl;
        }
        
        else if(op == '-'){
            cout << a-b << endl;
        }
        
        else if(op == '*'){
            cout << a*b << endl;
        }
        
        else if(op == '/'){
            cout << a/b << endl;
        }
    }
    return 0;
}    




Measured memory_bytes: 3112
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for(int i=0;i<N;i++)A[i]=sc.nextLong();
		sc.close();
		
		//累積和
		long v[] = new long[N+1];
		for(int i=0;i<N;i++) {
			v[i+1]=v[i]+A[i];
		}
		
		long sum = v[N];
		
		long ans = Long.MAX_VALUE;
		for(int i=0;i<N+1;i++) {
			long tmp = Math.abs(v[i]*2-sum);
			ans = Math.min(ans, tmp);
		}
	
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 95396
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> dp(200,E);
    dp[0]=0;
    for(int i=0;i<100;i++){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        dp[i+5]=min(dp[i+5],dp[i]+1);
        dp[i+10]=min(dp[i+10],dp[i]+1);
        dp[i+25]=min(dp[i+25],dp[i]+1);
    }
    ll ans=n/100*4;
    n%=100;
    ans+=dp[n];
    cout<<ans<<endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

struct Doubling
{
    const int LOG;
    vector< vector< int > > table;

    Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_clzll(lim_t))
    {
        table.assign(LOG, vector< int >(sz, -1));
    }

    void set_next(int k, int x)
    {
        table[0][k] = x;
    }

    void build()
    {
        for(int k = 0; k + 1 < LOG; k++) {
            for(int i = 0; i < table[k].size(); i++) {
                if(table[k][i] == -1) table[k + 1][i] = -1;
                else table[k + 1][i] = table[k][table[k][i]];
            }
        }
    }

    int query(int k, int64_t t)
    {
        for(int i = LOG - 1; i >= 0; i--) {
            if((t >> i) & 1) k = table[i][k];
        }
        return k;
    }
};


int main() {
    int64 n,k;
    cin >> n >> k;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];

    Doubling db(n+1, -1);
    vector<bool> used(n+1, false);
    for (int i=0; i<n; i++) {
        db.set_next(i+1,a[i]);
    }
    db.build();

    cout << db.query(1, k) << endl;
//    debug(db.table);
}

Measured memory_bytes: 55352
def main():
  N, A, B = map(int, input().split())

  if N == 1:
    if A != B:
      ans = 0
    else:
      ans = 1
  else:
    if A > B:
      ans = 0
    elif A == B:
      ans = 1
    else:
      ans = (A + (N - 1) * B) - (A * (N - 1) + B) + 1

  print(ans)

main()


Measured memory_bytes: 61888
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

tuple<int,int> dfs(const vector<vecint>& g, int i, int k, int p) {
  int mxd = 0;
  int cnt = 0;
  for (auto&& ch : g[i]) {
    int d, c;
    tie(d, c) = dfs(g, ch, k, i);
    mxd = max(mxd, d);
    cnt += c;
  }
  if (mxd == k-1) {
    if (p == 0) {
      return make_tuple(0, cnt);
    } else {
      return make_tuple(0, cnt+1);
    }
  } else {
    return make_tuple(mxd+1, cnt);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  vector<vecint> g(n);
  int ans = 0;
  REP(i,n) {
    int a;
    cin>>a;
    --a;
    if (i > 0) {
      g[a].push_back(i);
    } else if (a != 0) {
      ++ans;
    }
  }
  int depth, cnt;
  tie(depth, cnt) = dfs(g, 0, k, 0);
  ans += cnt;
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define LL long long
using namespace std;
template<typename T>void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int n,a[100010],b[100010],c[200010];
LL s[200010];
LL ans,s1,s2;
int main(){
	read(n);
	for(int i=1;i<=n;++i) {read(a[i]),s1+=a[i],c[i]=a[i];read(b[i]),s2+=b[i],c[i+n]=b[i];}
	ans=min(s1,s2);
	sort(c+1,c+1+n+n);
	for(int i=1;i<=n+n;++i) s[i]=s[i-1]+c[i];
	for(int i=1;i<=n;++i){
		int nw=n;
		LL cnt=0;
		if(a[i]>=c[nw]) --nw,cnt+=a[i];
		if(b[i]>=c[nw]) --nw,cnt+=b[i];
		ans=min(ans,cnt+s[nw]);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
   string s,t;
    cin>>s;
    cin>>t;
    int k=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            k++;
    }
    cout<<k;

	return 0;
}

Measured memory_bytes: 3852
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	ll k, n;
	cin >> k >> n;
	vl arr(n);
	fr(i, 0, n) {
		cin >> arr[i];
	}
	ll total = k;
	ll maxDist = INT_MIN;
	fr(i, 0, n - 1) {
		maxDist = max(maxDist, arr[i + 1] - arr[i]);
	}
	maxDist = max(maxDist, arr[0] + k - arr[n - 1]);
	cout << total - maxDist;

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 1792
let () =
  let n = read_int () in
  let rec doit i m ans =
    if i >= n then ans
    else let r = read_int () in doit (i + 1) (min m r) (max ans (r - m))
  in
  Printf.printf "%d\n" (doit 1 (read_int ()) min_int)

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;

const int N = 22, MOD = 1e9 + 7, INF = 1e9 + 5;
int n;
int c[N][N], dp[(1 << N)];

int add(int x, int y) { return ((x % MOD) + (y % MOD)) % MOD; }

int f(int i, int mask) {
    if (i >= n) return mask == 0;
    if (dp[mask] > -1) return dp[mask];
    int ans = 0;
    for (int j = 0; j < n; j++) {
        if (c[i][j]) {
            if (mask & (1 << j)) ans = add(ans, f(i + 1, mask ^ (1 << j)));
        }
    }
    return dp[mask] = ans;
}

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    cin >> n;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> c[i][j];
    for (int i = 0; i <= (1 << n); i++) dp[i] = -1;
    cout << f(0, (1 << n) - 1);
}

Measured memory_bytes: 11816
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010
vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    if (s==1){
        cout << 1;
        for (ll i=1;i<k;i++){
            cout << " " << 1;
        }
        for (ll i=k;i<n;i++){
            cout << " " << 2;
        }
        cout << endl;
        return 0;
    }
    if (k==n){
        cout << s;
        for (ll i=1;i<n;i++){
            cout << " " << s;
        }
        cout << endl;
        return 0;
    }
    cout << 1;
    for (ll i=1;i<=k;i++){
        if (i%2==0){
            cout << " " << 1;
        }else{
            cout << " " << s-1;
        }
    }
    if (s/2+2==s){
        for (ll i=k+1;i<n;i++){
            cout << " " << s/2+3;
        }
        cout << endl;
        return 0;
    }
    for (ll i=k+1;i<n;i++){
        cout << " " << s/2+2;
    }
    cout << endl;
    return 0;
}






Measured memory_bytes: 1280
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
  static int h;

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

    h = Integer.parseInt(sc.nextLine()) + 1;
    int[] a = new int[h];

    int[] input = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    for (int i = 1; i < h; i++) {
        a[i] = input[i-1];
    }

    buildMaxHeap(a);
    for (int i = 1; i < h; i++) {
      System.out.print(" " + a[i]);
    }

    System.out.println();
  }

  static void buildMaxHeap (int[] a) {
    for (int i = h/2; i >= 1; i--) {
      maxHeapify(a, i);
    }
  }

  static void maxHeapify (int[] a, int i) {
    int leftId = i * 2;
    int rightId = i * 2 + 1;
    int largest = 0;

    if (leftId < h && a[leftId] > a[i]) {
	    largest = leftId;
    } else {
      largest = i;
    }

    if (rightId < h && a[rightId] > a[largest]) {
      largest = rightId;
    }

    if (largest != i) {
      int tmp = a[i];
      a[i] = a[largest];
      a[largest] = tmp;
      maxHeapify(a, largest);
    }
  }
}


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

const ll INF = 1LL << 60;

int main(void) {
  ll N, M;
  while(cin >> N >> M, N && M) {
    vector<ll> S(N), D(M);
    REP(i, 0, N) cin >> S[i];
    REP(i, 0, M) cin >> D[i];

    sort(D.begin(), D.end());

    vector<ll> sum(1 << N, 0);
    REP(s, 0, 1 << N) REP(i, 0, N) if(s & (1 << i)) sum[s] += S[i];

    vector<vector<ll>> dp(M + 1, vector<ll>(1 << N, INF));
    REP(s, 0, 1 << N) dp[0][s] = 0;

    REP(i, 0, M) {
      REP(s, 0, 1 << N) dp[i + 1][s] = dp[i][s] + abs(sum[s] - D[i]);
      REP(s, 0, 1 << N) {
        REP(j, 0, N) if(!(s & (1 << j))) {
          dp[i + 1][s | (1 << j)] = min(dp[i + 1][s | (1 << j)], dp[i + 1][s]);
        }
      }
    }

    cout << dp[M][(1 << N) - 1] << endl;
  }
}



Measured memory_bytes: 29720
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if n == i * j:
                print('Yes')
                return
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    String[] array = new String[n];
		    
		    for(int i = 0; i < n; i++) 
		    {
		    	array[i] = scanner.next();
		    }
		    int matigai = 0;
		    
		    for(int i = 0; i < n - 1; i++) 
		    {
		    	if(array[i].substring(array[i].length() - 1).equals(array[i+1].substring(0,1))) 
		    	{
		    		
		    	}
		    	else 
		    	{
		    		matigai++;
		    	}
		    }
		    for(int i = 0; i < n; i++) 
		    {
		    	for(int j = 0; j < i; j++) 
		    	{
		    		if(array[i].equals(array[j])) 
		    		{
		    			matigai++;
		    		}
		    	}
		    }
		    
		    if(matigai == 0) 
		    {
		    	System.out.println("Yes");
		    }
		    else 
		    {
		    	System.out.println("No");
		    }
		    
		    scanner.close(); }
		  }


Measured memory_bytes: 35756
program sample
    implicit none
  
    integer(8) :: i,j,m,n,b
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n
    allocate(a(n),y(n))
    read(*,*)a
    y(:)=0
    do i=1,n
        b=a(i)
        y(b)=y(b)+1
    end do
    m=0
    do i=1,n
        b=y(i)
        m=m+b*(b-1)/2
       
    end do
    do i=1,n
        b=a(i)
        if(y(b)<2)then
            write(*,*)m
        else
            write(*,*)m-y(b)+1
        end if
    end do
  
    stop
end program sample
  



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

typedef pair<int, int> ii;
typedef long long ll;
const int INF = 1e9;
const int MAXN = 1e5 + 5;
const ll LINF = 1e18;
const double pi = acos(-1);
const double EPS = 1e-9;
template <class T> using MinPQ = priority_queue<T, vector<T>, greater<T>>;
template <class T> using MaxPQ = priority_queue<T>;

int n;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) if (a[i] > i) return cout << "-1\n", 0;
    for (int i = 0; i < n; i++) {
        if (i && a[i] > a[i - 1] + 1) return cout << "-1\n", 0;
        if (i && a[i] == a[i - 1] + 1) ans++;
        else ans += a[i];
    }
    cout << ans << "\n";
    return 0;
}


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

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

    long long correct = n-m;
    long long point = 100*correct + 1900*m;

    double m2 = pow(2, m);
    double y = 1 - 1/m2;

   long long ans = (long long)point/(1-y);

   printf("%lld\n", ans);

   return 0;
    
}

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

const int MOD = 1000000007;

int n, k;

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

  int ans = 0;
  for (int i = k; i <= n+1; ++i) {
    ans = (1LL * (n-i+1) * i + 1 + ans) % MOD;
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3872
#include<stdio.h>
int main(void){
    int N;
    int A;
    int B;
    scanf("%d",&N);
    if(N==1){
        printf("Hello World");
    }
    if(N==2){
        scanf("%d",&A);
        scanf("%d",&B);
        printf("%d",A+B);
    }
    return 0;
}

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

public class Main {
    public static void main(String[] args){
        Scanner std = new Scanner(System.in);
        int n = Integer.parseInt(std.next());

        int defaultpip[][] = new int[n][6];
        ArrayList<Dice> dc = new ArrayList<Dice>();

        for(int j=0; j<n; j++){
            for(int i=0; i<6; i++){
                defaultpip[j][i] = Integer.parseInt(std.next());
            }
            dc.add(new Dice(defaultpip[j]));
        }
        Dice dcarray[] = (Dice[])dc.toArray(new Dice[n]);
        dc.clear();
        //??¬???????????¬???
        String query[] = {"S", "W", "N", "E"};

        boolean diff = false;
        ALLLOOP:
        for(int k=0; k<n-1; k++){
        for(int j=k+1; j<n; j++){
            diff = false;
            for(int i = 0; i<100; i++){
                if(dcarray[j].issame(dcarray[k])){
                    break ALLLOOP;
                }else{
                    dcarray[j]=dcarray[j].newnowpips(query[(int)(Math.random()*4)]);
                }
            }
            diff = true;
        }
        }
        if(diff){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

class Dice {
	int pips[];
	int nowpip;
	int spip;
	int epip;
	int wpip;
	int npip;
	int rpip;

	public Dice(int pip[]){
		this(pip, 0, 1, 2, 3, 4, 5);
	}

	public Dice(int pip[], int now, int s, int e, int w, int n, int r){
		pips = pip;
		nowpip = now;
		spip = s;
		epip = e;
		wpip = w;
		npip = n;
		rpip = r;
	}

	public Dice newnowpips(String query){
		if(query.equals("N")){
			return new Dice(pips,spip,rpip,epip,wpip,nowpip,npip);
		}else if(query.equals("E")){
			return new Dice(pips,wpip,spip,nowpip,rpip,npip,epip);
		}else if(query.equals("S")){
			return new Dice(pips,npip,nowpip,epip,wpip,rpip,spip);
		}else if(query.equals("W")){
			return new Dice(pips,epip,spip,rpip,nowpip,npip,wpip);
		}else {	//clockwise
			return new Dice(pips,nowpip,epip,npip,wpip,spip,rpip);
		}
	}

	public String showdice(){
		return pips[nowpip] +" "+ pips[spip] +" "+ pips[epip] +" "+ pips[wpip] +" "+ pips[npip] +" "+ pips[rpip];
	}

	public boolean issame(Dice d2){
		return pips[nowpip] == d2.pips[d2.nowpip] && pips[npip] == d2.pips[d2.npip] && pips[epip] == d2.pips[d2.epip] &&
				pips[spip] == d2.pips[d2.spip] && pips[wpip] == d2.pips[d2.wpip] && pips[rpip] == d2.pips[d2.rpip];
	}
}

Measured memory_bytes: 50304
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a[4],e,f,i,i2,tmp;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>e>>f;
    for(i=0;i<4;i++){
        for(i2=i;i2<4;i2++){
            if(a[i]<a[i2]){
                tmp=a[i];
                a[i]=a[i2];
                a[i2]=tmp;
            }
        }
    }
    if(e<f)cout<<a[0]+a[1]+a[2]+f<<endl;
    else cout<<a[0]+a[1]+a[2]+e<<endl;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int a, p;
    scanf("%d%d",&a, &p);
    printf("%d",(a*3+p)/2);
}


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

using namespace std;
using ll = long long;

ll A, B, C, D;
map<ll, ll> memo;

ll solve(ll N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    ll l2 = (N/2)*2;
    ll r2 = ((N+1)/2)*2;
    ll l3 = (N/3)*3;
    ll r3 = ((N+2)/3)*3;
    ll l5 = (N/5)*5;
    ll r5 = ((N+4)/5)*5;

    ll res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        ll N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << endl;
    }
}


Measured memory_bytes: 4304
<?php
error_reporting(0);
//$X = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
$A = trim(fgets(STDIN));
//list($X,$K) = explode(" ",trim(fgets(STDIN)));
$r = $N % 500;
if ($r <= $A) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


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

int main() {

  int n;
  cin>>n;

  int a[n+1];
  a[0] = 1;
  a[1] = 1;

  for(int i = 2; i <= n; i++) {
    a[i] = a[i-1] + a[i-2];
  }

  cout<<a[n]<<endl;
  
  return 0;
}



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

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

    ll n, sum = 0;
    cin >> n;
    for(int i = 1; i<=n; i++) {
        if (i%3!=0 && i%5!=0) {
            sum+=i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3692
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int k = in.nextInt();
		
		int answer = k;
		for (int i = 1; i < n; i++) {
			answer *= (k - 1);
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 20948
x,y=map(int,input().split());n=0;mod=10**9+7;ans=0
if not (x+y)%3:
  n=(x+y)//3;x-=n;y-=n
  if x>=0 and y>=0:
    ans=1
    for i in range(x):ans=ans*(n-i)*pow(i+1,mod-2,mod)%mod
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
void exgcd(long long a,long long b,long long &d,long long &x,long long &y)
{
	if(!b)
		d=a,x=1,y=0;
	else 
		exgcd(b,a%b,d,y,x),y-=(a/b)*x;
}
int main()
{
	scanf("%lld",&n);
	n*=2;
	ans=n-1;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			long long d,x,y;
			exgcd(i,n/i,d,x,y);
			if(d>1)
				continue;
			if(x>0&&i*x-1>0)
				ans=min(ans,i*x-1);
			if(x<0&&i*(-x)>0)
				ans=min(ans,i*(-x)); 
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

void main() {
    int a,b,c,x;
    scan(a);
    scan(b);
    scan(c);
    scan(x);

    int ans;

    foreach(i;0..a+1){
        foreach(j;0..b+1){
            foreach(k;0..c+1){
                if(500*i+100*j+50*k == x) ans++;
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
// include<studio.h>
#include<iostream>
using namespace std;
int main()
{
	int a = 0;
	std::cin >> a;
	int h = a / 3600;
	int min = (a % 3600) / 60;
	int un = a % 60;
	cout << h << ":" << min << ":" << un<<endl;
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    string ans="Yes";
    vector<int> t(n), x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> t.at(i);
        cin >> x.at(i);
        cin >> y.at(i);
    }
    for(int i=0; i<n; i++){
        int dt, dx, dy;
        if(i == 0){
            dt = abs(t.at(i));
            dx = abs(x.at(i));
            dy = abs(y.at(i));
        }else{
            dt = abs(t.at(i) - t.at(i-1));
            dx = abs(x.at(i) - x.at(i-1));
            dy = abs(y.at(i) - y.at(i-1));
        }
        if(dt >= (dx+dy) && (dt-(dx+dy))%2==0){
        }else{
            ans="No";
            break;
        }
    }
    cout << ans;

}

Measured memory_bytes: 4520