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

// #define DEBUG
#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

#define EL cout<<endl

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999LL;
const double EPS = 1e-10;

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

const double PI=3.141592653589793;
//==================================================================
/* I/O */
//scan
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(Pii *a){scanf("%d",&a->fi);scanf("%d",&a->se);}     //scan for type pair<int, int>
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array

//print 
void PRINT(int a){printf("%d\n",a);}
void PRINT(int *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%d%c",a[i],c);}}
void PRINT(Vi a,char c='\n'){REP(i,a.size()){if(i==a.size()-1){c='\n';}printf("%d%c",a[i],c);}}
void PRINT(LL a){printf("%lld\n",a);}
void PRINT(LL *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%lld%c",a[i],c);}}
void PRINT(double a){printf("%.15f\n",a);}
void PRINT(double *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%f%c",a[i],c);}}
void PRINT(char a){printf("%c\n",a);}
void PRINT(string a){printf("%s\n",a.c_str());}
//==================================================================
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int w,a,b;
	SCAN(&w);SCAN(&a);SCAN(&b);
	if(abs(a-b)<=w){
		PRINT(0);
	}else{
		PRINT(abs(a-b)-w);
	}

	return 0;
}

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

bool can_make(int b, vector<long long>& bs, int k) {
    int n = bs.size();
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (bs[i] >> b & 1) {
            cnt++;
        }
    }
    if (cnt < k) return false;
    vector<long long> nxt;
    for (int i = 0; i < n; i++) {
        if (bs[i] >> b & 1) {
            nxt.push_back(bs[i]);
        }
    }
    bs = move(nxt);
    return true;
}

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

    long long ans = 0;
    vector<long long> bs;
    bs.reserve(n * (n + 1) / 2);
    vector<long long> sum(n + 1);
    for (int i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + as[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            bs.push_back(sum[j + 1] - sum[i]);
        }
    }
    assert(bs.size() == n * (n + 1) / 2);
    
    for (int i = 60; i >= 0; i--) {
        if (can_make(i, bs, k)) {
            ans |= 1ll << i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;
void mainsolve(){

	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		rep(j,n){
			ll tmp;
			cin >> tmp;
			a[i] += tmp * (1<<(n-1-j));
		}
	}
	vector<ll> dp(1<<n);
	rep(k,n){
		if(a[0] & (1<<k)) dp[(1<<n)-1 - (1<<k)]++;
	}


	for(ll j = (1<<n)-1; j >= 0; j--){
		ll cnt = __builtin_popcount(j);
		ll canmatch = a[n-cnt] & j;

		rep(k,n){
			if((canmatch & (1<<k)) && j-(1<<k) >= 0) (dp[j-(1<<k)] += dp[j]) %= MOD;
		}
	}

	cout << dp[0] << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    int h,w;
    cin >> h >> w;
    char c[h][w];
    char ans[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    int dx[8] = {-1,-1,-1,0,0,1,1,1};
    int dy[8] = {-1,0,1,-1,1,-1,0,1};
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int cnt = 0;
            if(c[i][j] == '.'){
                for(int k = 0; k < 8; k++){
                    if(i+dx[k] >= 0 && i+dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w && c[i+dx[k]][j+dy[k]] == '#'){
                        cnt++;
                    }
                }
                ans[i][j] = '0' + cnt;
            }else{
                ans[i][j] = '#';
            }
            
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
def main():
  N, M = map(int, input().split())

  inter, goalable = set(), set()
  for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
      inter.add(b)
    
    if b == N: 
      goalable.add(a)
      
  flag = inter & goalable
  print("POSSIBLE" if flag else "IMPOSSIBLE")
  
if __name__ == "__main__":
    main()

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

int main(){
  int n,d;
  cin>>n>>d;
  if(n%(d*2+1)==0){
    cout<<n/(d*2+1)<<endl;
  }
  else{
    cout<<n/(d*2+1)+1<<endl;
  }
}
    
    


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);

    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int K = sc.nextInt();

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int INF = 1 << 30;

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;
    vector<int> dp(N + 1, INF);
    dp[N] = 0;
    queue<int> q;
    q.push(0);
    for (int i = N - 1; i >= 0; i--) {
        while (1) {
            if (q.size() == 0) {
                puts("-1");
                return 0;
            }

            if (q.front() != INF && q.size() <= M) break;
            q.pop();
        }
        if (S[i] == '0') dp[i] = q.front() + 1;
        q.push(dp[i]);
    }

    vector<int> ans;
    int x = 0;
    int rest = dp[0];
    while (x < N) {
        --rest;
        int i = 1;
        while (dp[x + i] != rest) ++i;
        ans.push_back(i);
        x += i;
    }

    rep(i, ans.size()) {
        printf("%d%c", ans[i], i == int(ans.size()) - 1 ? '\n' : ' ');
    }
}


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

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = r.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = r.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                ans += (arr[i] * arr[j]);
            }
        }
        pw.println(ans);
        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 23124
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2000

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int field[21][21];
int now_x, now_y;
int jewel;

void init()
{
		jewel=0;
		fill((int*)field, (int*)(field+21), 0); 
		now_x=10; now_y=10;
}

void move(string d, int l)
{
	rep(i,l)
	{

		if(d == "N"){
			now_y += 1;
		}
		else if(d == "E"){
			now_x += 1;
		}
		else if(d == "S"){
			now_y -= 1;
		}
		else if(d == "W"){
			now_x -= 1;
		}

		if(field[now_y][now_x] == 1)
		{
			field[now_y][now_x] = 0;
			jewel+=1;
		}
	}
}

int main() 
{
	int N;
	
	while(cin >> N && N)
	{
		init();

		int X,Y;
		rep(i,N)
		{
			cin >> X >> Y;
			field[Y][X] = 1;	
		}

		int M;
		string D; int L;

		cin >> M;
		rep(i,M)
		{
			cin >> D >> L;
			move(D,L);
		}

		if(jewel == N){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    long long minSumC = INF;
    bool isThereAnser = false;
    for (int bit = 0; bit < (0x1 << N); bit++) {
        vector<long long> sum(M, 0);
        long long sumC = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (0x1 << i)) {
                sumC += C[i];
                for (int j = 0; j < M; j++) {
                    sum[j] += A[i][j];
                }
            }
        }

        bool isComplet = true;
        for (int j = 0; j < M; j++) {
            if (sum[j] < X) {
                isComplet = false;
            }
        }

        if (isComplet) {
            isThereAnser = true;
            minSumC = min(minSumC, sumC);
        }
    }

    if (isThereAnser) {
        cout << minSumC << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
S=input()
flag=1#Yes
for i in range(len(S)):
  if (i+1)%2==0:
    if S[i] != "L" and S[i] != "U" and S[i] != "D":
      flag=0
  elif (i+1)%2==1:
    if S[i] != "R" and S[i] != "U" and S[i] != "D":
      flag=0

if flag==0:
  print('No')
elif flag==1:
  print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    char str[200];
    int i,j,k,l,m;
    ll n;
    scanf("%s",str);
    scanf("%lld",&n);
    ll sum=0;
     m=strlen(str);
    for(int i=0;i<m;i+=2)
    {
      if(i==0)
      {
          sum=str[i]-48;
          continue;
      }
      if(str[i-1]=='*')
      {
          sum=sum*(str[i]-48);
      }
      else sum=sum+str[i]-48;
    }
    ll sum2=0;
    for(int i=0;i<m;)
    {
       // cout<<i<<endl;
        for(j=i+1;j<m;j+=2){
            if(str[j]=='*')continue;
            break;
        }
        ll mul=1;
        for(int k=i;k<j;k+=2)
        {
            mul=mul*(str[k]-48);
        }

        sum2+=mul;
       // cout<<mul<<" "<<j<<" "<<(j+1)<<endl;
        i=j+1;
    }
    if(n==sum&&sum==sum2)
    {
        printf("U\n");
    }
    else if(n!=sum&&n!=sum2)
    {
         printf("I\n");
    }
    else if(sum==n)
    {
        printf("L\n");
    }
    else printf("M\n");



}



Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	int l[100];
	int sum = 0;
	int cnt = 0;
	rep(i, n + 1) {
		cin >> l[i];
		if (sum <= x) {
			sum += l[i];
			cnt++;
		}
	} 
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b < a){
            System.out.println(a-1);
        }else{
            System.out.println(a);
        }
    }
}

Measured memory_bytes: 22996
x,y=map(int,input().split())
if abs(x)==abs(y):
  print((x*y<0)+0)
elif x*y==0:
  print(abs(abs(x)-abs(y))+(x>0 or y<0))
elif x*y<0:
  print(abs(abs(x)-abs(y))+1)
else:
  print(abs(abs(x)-abs(y))+(x>=y)*2)


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

int main() {
    long long n, ret;
    std::cin >> n;
    std::vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.begin(), a.end());
    std::reverse(a.begin(), a.end());
    while (a[0] >= n) {
        long long sub = 0;
        for (int i = 0; i < n; i++) {
            auto c = a[i] - (n - 1);
            b[i] = c / n + (c % n > 0);
            sub += b[i];
            a[i] -= n * b[i];
        }
        for (int i = 0; i < n; i++) a[i] += sub - b[i];
        ret += sub;
        std::sort(a.begin(), a.end());
        std::reverse(a.begin(), a.end());
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class Main {

        public static void main(String[] args) throws IOException {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int K = Integer.parseInt(br.readLine());
            String [] l = br.readLine().split(" ");
            int A = Integer.parseInt(l[0]);
            int B = Integer.parseInt(l[1]);

            if(A%K == 0 || B%K == 0){
                System.out.println("OK");
            }
            else {
                int x = A/K + 1;
                if((x*K) > B){
                    System.out.println("NG");
                }
                else {
                    System.out.println("OK");
                }
            }
        }
    }

Measured memory_bytes: 32664
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    string s;
    cin >> s;
    cout << int(s.rfind('Z') - s.find('A')) + 1 << endl;
}


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

int main()
{
	int a, b, c, i, x = 0;
	cin >> a >> b >> c;
	
	for(i = a; i <= b; i++)
	{
		if(c % i == 0)
		x = x + 1;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = [0] * 8
for bit in range(2 ** 3):
    cand = [0] * N
    for i in range(N):
        for j in range(3):
            cand[i] += [1, -1][bit >> j & 1] * X[i][j]

    cand = sorted(enumerate(cand), key=lambda x: -x[1])
    res = [0] * 3
    for i, _ in cand[:M]:
        for j in range(3):
            res[j] += X[i][j]
    ans[bit] = sum(map(abs, res))

print(max(ans))


Measured memory_bytes: 44400
H = int(input())

count = 0
split = 0

mons_HP = H

while mons_HP != 0:
    if mons_HP == 1:
        mons_HP = 0
        count += 2**(split)
    else :
        crnt_HP = mons_HP
        mons_HP = int(crnt_HP/2)
        count += 2**(split)
        split += 1

print(count)

Measured memory_bytes: 3060
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1e9 + 7

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main() {
    ios_base::sync_with_stdio(false);

    int k;
    cin >> k;
    ll ans = 0;
    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= k; j++) {
            for(int l = 1; l <= k; l++) {
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#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 rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

LL A;
LL B;

LL df(LL x) {
  LL ret = x * (1-x%2);
  if (x%4 == 1 || x%4 == 2) ret++;
  return ret;
}

int main() {
  scanf("%lld%lld", &A, &B);
  LL ans = df(B);
  if (A > 0) ans ^= df(A-1);
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

bool f(ll bit, ll n) {
    return ((bit & (1LL << n)) != 0);
}

ll g(ll bit, ll n) {
    ll ans = 0;
    reps(i, n + 1, 20) {
        if (f(bit, i)) ans++;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    const ll mv = 50;
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<vector<ll>> dp(1 << n, vector<ll>(mv + 1, inf));
    dp[0][0] = 0;
    rep(bit, 1 << n) {
        ll pc = __builtin_popcountll(bit);
        rep(i, n) {
            if (f(bit, i)) continue;
            ll v = ((i % 2) == (pc % 2)) ? a[i] : b[i];
            rep(j, v + 1) {
                if (dp[bit][j] == inf) continue;
                dp[bit | (1 << i)][v] = min(dp[bit | (1 << i)][v], dp[bit][j] + g(bit, i));
            }
        }
    }
    ll ans = inf;
    rep(i, mv + 1) {
        ans = min(ans, dp[(1 << n) - 1][i]);
    }
    cout << ((ans == inf) ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 115936
using System;
 
namespace Sample
{
  class Program
  {
    static void Main()
    {
      string source = Console.ReadLine();
      char[] separator = new char[] {' '};
      string[] splitted = source.Split(separator);
      
      int[] array = new int[3];
      for(int i=0; i<splitted.Length; ++i)
      {
          array[i] = int.Parse(splitted[i]);
      }
      if(array[0] > array[2]){
        Console.Write("0");
      }else{
        int res = (array[2] / array[0]) * array[1];
        Console.Write(res);
      }

    }
  }
}

Measured memory_bytes: 13140
#!/usr/bin/env python3

N, M = map(int, input().split())

D = {} # 親；子
T = {}
for i in range(1, N+1):
    D[i] = []
    T[i] = 0

for i in range(1,M+1):
    A, B = map(int, input().split())
    D[A].append(B)
    D[B].append(A)

child = D[1]
parent = [1]


while len(parent) > 0:
    child2 = []
    for p in parent:
        for c in D[p]:
            if T[c] != 0: continue
            T[c] = p
            child2.append(c)
    parent = child2

for i in range(2, N+1):
    if T[i] == 0:
        print('No')
        exit()

print('Yes')
for i in range(2, N+1):
    print(T[i])
    




Measured memory_bytes: 99900
w, h, n = map(int, input().split())
a = [[] for _ in range(4)]
for _ in range(n):
    x, y, z = map(int, input().split())
    if z == 1 or z == 2:
        a[z-1].append(x)
    else:
        a[z-1].append(y)

x_count = 0
for i in range(w):
    flag = False

    for k in a[0]:
        if i < k:
            flag = True
            break
    if flag:
        continue
    
    for k in a[1]:
        if i >= k:
            flag = True
            break
    if flag:
        continue
    
    x_count += 1

y_count = 0
for i in range(w):
    flag = False

    for k in a[2]:
        if i < k:
            flag = True
            break
    if flag:
        continue
    
    for k in a[3]:
        if i >= k:
            flag = True
            break
    if flag:
        continue
    
    y_count += 1

print(x_count * y_count)

Measured memory_bytes: 64488
#include <iostream>
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;


//---- Print a Rectangle
int main(){
    int H,W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0){break;}
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define pii pair<int, int>
#define ld long double

const int INF = 2e9 + 1;
const int mod = 1e9 + 7;

vector<int> z_function(string &s) {
	int n = (int)s.size();
	vector<int> z(n);
	for (int i = 1, l = 0, r = 0; i < n; i++) {
		if (i <= r) z[i] = min(r - i + 1, z[i - l]);
		while (i + z[i] < n && s[z[i]] == s[i + z[i]]) z[i]++;
		if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
	}
	return z;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    while ((int)s.size() < 2 * (int)t.size()) s += s;
    s += s;
    string t1 = t;
    while ((int)t1.size() < (int)s.size()) t1 += t;
    string lol = t1 + "#" + s;
    int st1 = t1.size() + 1, end1 = t1.size() + 1 + (int)s.size() / 2;
    vector<int> z = z_function(lol);
    s += s;
    while ((int)t1.size() < (int)s.size()) t1 += t;
    string kek = t1 + "#" + s;
    int st2 = t1.size() + 1;
    vector<int> newz = z_function(kek);
    int ans = 0;
    int j = st2;
    for (int i = st1; i < end1; i++) {
        int cnt1 = z[i] / (int)t.size();
        int cnt2 = newz[j] / (int)t.size();
        if (cnt2 > cnt1) {
            cout << -1;
            return 0;
        }
        ans = max(ans, cnt1);
        j++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 139916
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}



int main(void) {
    FAST_IO;
    
    int n;
    cin >> n;
    int pre = 0;
    int ans = 0;
    int temp = -1;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (pre == 0 || pre >= h) {
            temp++;
            ans = max(temp, ans);
        } else {
            temp = 0;
        }
        pre = h;
    }
    ans = max(temp, ans);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int N=2e5+5,mod=998244353;
int n;
int k;
std::pair<int,int> c[12];
ll dp[N];
ll s[N];
int main(){
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    if(1){
    scanf("%d%d",&n,&k);
    for(int i=0;i<k;i++) scanf("%d%d",&c[i].first,&c[i].second);
    std::sort(c,c+k);
    dp[1]=1;
    s[1]=1;
    for(int i=2;i<=n;i++){
        for(int j=0;j<k;j++){
            if(i-c[j].first<1) break;
            if(i-c[j].second<0)
                dp[i]+=s[i-c[j].first];
            else
                dp[i]+=s[i-c[j].first]-s[i-c[j].second-1]+mod;
            dp[i]%=mod;
        }
        s[i]=s[i-1]+dp[i];
        s[i]%=mod;
    }
    printf("%lld\n",dp[n]);
    }return 0;
}


Measured memory_bytes: 6940
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

res = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                if j < w - 1:
                    a[i][j+1] += 1
                    res.append([i+1, j+1, i+1, j+2])
                elif i < h - 1:
                    a[i+1][j] += 1
                    res.append([i+1, j+1, i+2, j+1])
    else:
        for j in range(w-1, -1, -1):
            if a[i][j] % 2 == 1:
                if j > 0:
                    a[i][j-1] += 1
                    res.append([i+1, j+1, i+1, j])
                elif i < h - 1:
                    a[i+1][j] += 1
                    res.append([i+1, j+1, i+2, j+1])

print(len(res))
for y1, x1, y2, x2 in res:
    print(y1, x1, y2, x2)

Measured memory_bytes: 94736
import sys
sys.setrecursionlimit(10**7)

n,m,q = map(int,input().split())
abcd = [[int(i) for i in input().split()] for j in range(q)]

s = [1] * (n)

ans = []

def dfs(k, c,old,ans):
    #ans = 0
    #print(s,k)
    if k == n:
        tmp = 0
        for i in range(q):
            if s[abcd[i][1]-1] - s[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        #ans = max(ans,tmp)
        ans.append(tmp)
        return# ans
    for i in range(old,c+1):
        #print(old,c+1)
        s[k] = i
        dfs(k+1, m,i,ans)
        #print(k+1,c)
    #s[k] = chr(c+ord('a'))
    #dfs(k+1, c+1)
    return ans

print(max(dfs(0, m,1,ans)))

Measured memory_bytes: 12500
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> A;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        A.push_back(x);
    }
    int index = 0;
    int flag2 = 0;
    for (int i = 1; i <= n; i++)
    {
        int flag = 0;
        for (int j = index; j < n; j++)
        {
            if (i == A[j])
            {
                index = j + 1;
                flag = 1;
                break;
            }
            flag2 = 1;
        }
        if (flag == 0)
        {
            if (i == 1)
            {
                std::cout << "-1" << endl;
                return 0;
            }
            std::cout << n - i + 1 << endl;
            return 0;
        }
    }
    if (flag2 == 0)
    {
        std::cout << n - index << endl;
        return 0;
    }
    std::cout << n - index + 1 << endl;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp2
{
    struct Point { public int x, y; };
    class Program {
        static int Manh(Point x,Point y) {
            return Math.Abs(x.x - y.x) + Math.Abs(x.y - y.y);
        }

        static void Main(string[] Args) {
            var l = new List<string>(ReadLine().Split(' ')).Select(int.Parse).ToList();


            var StudentPoint = new List<Point>();
            List<int> tmp;
            for (int i = 0; i < l[0]; i++) {
                tmp = new List<string>(ReadLine().Split(' ')).Select(int.Parse).ToList();
                StudentPoint.Add(new Point { x = tmp[0], y = tmp[1] });
            }
            var CheckPoint = new List<Point>();
            for (int i = 0; i < l[1]; i++) {
                tmp = new List<string>(ReadLine().Split(' ')).Select(int.Parse).ToList();
                CheckPoint.Add(new Point { x = tmp[0], y = tmp[1] });
            }

            List<int> Ans = new List<int>();
            List<int> dist;
            for(int i = 0;i < l[0]; i++) {
                dist = new List<int>();
                for (int j = 0; j < l[1]; j++) {
                    dist.Add(Manh(StudentPoint[i], CheckPoint[j]));
                }
                Ans.Add(dist.IndexOf(dist.Min()));
            }

            foreach (var e in Ans)
                WriteLine(e + 1);

            ReadLine();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int main() {
	long long int A, B, N;
	cin >> A >> B >> N;
	long long int x = 0;
	x = min(B - 1, N);
	cout << ((A * x) / B) - A * (x / B);
}


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

int main()
{
    int n;
    while(cin >> n, n){
        int m, p, q, r;
        cin >> m >> p >> q >> r; --p;
        vector<pair<int, int>> a;
        a.emplace_back(0, n);
        while(m--){
            int x, y;
            cin >> x >> y;
            vector<pair<int, int>> t[3] = {};
            int it = 0, id = 0;
            for(auto pp : a){
                int c = pp.second - pp.first;
                id += it == x || it == y;
                if(it < x && y < it + c){
                    t[id].emplace_back(pp.first, x - it + pp.first);
                    id += 1;
                    t[id].emplace_back(x - it + pp.first, y - it + pp.first);
                    id += 1;
                    t[id].emplace_back(y - it + pp.first, pp.second);
                }
                else if(it < x && x < it + c){
                    t[id].emplace_back(pp.first, x - it + pp.first);
                    id += 1;
                    t[id].emplace_back(x - it + pp.first, pp.second);
                }
                else if(it < y && y < it + c){
                    t[id].emplace_back(pp.first, y - it + pp.first);
                    id += 1;
                    t[id].emplace_back(y - it + pp.first, pp.second);
                }
                else{
                    t[id].push_back(pp);
                }
                it += c;
            }
            a.clear();
            for(int i = 2;i >= 0;i--){
                for(auto& pp : t[i]){
                    a.push_back(pp);
                }
            }
        }
        int res = 0;
        int it = 0;
        for(auto pp : a){
            int c = pp.second - pp.first;
            if(it <= p && q <= it + c){
                int s = pp.first + p - it;
                int t = pp.first + q - it;
                res += max(0, min(t, r) - s);
            }
            else if(it <= p && p < it + c){
                int s = pp.first + p - it;
                int t = pp.second;
                res += max(0, min(t, r) - s);
            }
            else if(it < q && q <= it + c){
                int s = pp.first;
                int t = pp.first + q - it;
                res += max(0, min(t, r) - s);
            }
            else if(p <= it && it + c <= q){
                int s = pp.first;
                int t = pp.second;
                res += max(0, min(t, r) - s);
            }
            it += c;
        }
        cout << res << endl;
    }
    return 0;
}



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

int main() {

	std::string S;
	std::cin >> S;

	int res = 0;

	for (int i = 0; i < 3; i++) {
		if (S[i] =='o') res++;
	}

	std::cout << (700 + res * 100) << std::endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll gcd(ll x,ll y){
    if(x<y) return gcd(y,x);
    if(y==0) return x;
    return gcd(y,x%y);
}

int main(){
    ll n;cin>>n;
    ll t[n];
    ll ans=1;
    rep(i,0,n-1){
        cin>>t[i];
        if(i==0){
            ans=t[i];
        }else{
            ans=(t[i]/gcd(t[i],ans))*ans;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){
  int n, m;
  cin  >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  for(int i=0; i<n; ++i) cin >> h[i];
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    if(h[a] <= h[b]) ok[a] = false; 
    if(h[b] <= h[a]) ok[b] = false;
  }
  int ans = 0;
  for(int i=0; i<n; ++i){
    if(ok[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var num = 0
    for(i in 0..a) {
        for(j in 0..b) {
            for(k in 0..c) {
                if(x == i * 500 + j * 100 + k * 50) {
                   num = num + 1
                }
            }
        }
    }
    println(num)
}

Measured memory_bytes: 31680
#include<iostream>
using namespace std;
#define INFTY (1 << 30)

enum Color {
	WHITE,
	GRAY,
	BLACK,
};

void Prim(int verValWeight[][100], int verNum) {
	int distance[100];
	Color color[100];
	int parent[100];
	for (int i = 0; i < verNum; i++) {
		color[i] = WHITE;
		distance[i] = INFTY;
		parent[i] = -1;
	}
	distance[0] = 0;

	while (true) {
		int min_cost = INFTY;
		int subScript;
		for (int i = 0; i < verNum; i++) {
			if (color[i] != BLACK && distance[i] < min_cost) {
				min_cost = distance[i];
				subScript = i;
			}
		}

		if (min_cost == INFTY)
			break; //end

		color[subScript] = BLACK;

		for (int i = 0; i < verNum; i++) {
			if (color[i] != BLACK && verValWeight[subScript][i] != INFTY) {
				if (verValWeight[subScript][i] < distance[i]) {
					distance[i] = verValWeight[subScript][i];
					parent[i] = subScript;
					color[i] = GRAY;
				}
			}
		}
	}

	int weight_sum = 0;
	for (int i = 0; i < verNum; i++)
		if (parent[i] != -1)
			weight_sum += verValWeight[i][parent[i]];
	cout << weight_sum << endl;

}

int main() {
	int verNum;
	int verValWeight[100][100];
	int parent[100];

	cin >> verNum;
	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++) {
			cin >> verValWeight[i][j];
			if (verValWeight[i][j] == -1) verValWeight[i][j] = INFTY;
		}

	Prim(verValWeight, verNum);

	return 0;
}

Measured memory_bytes: 3112
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
import math 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
#-------------------game starts now----------------------------------------------------
# n,q=map(int,input().split())
# l=list(map(int,input().split()))
n=(int)(input())
d=n%10
if(d==2 or d==4 or d==5 or d==7 or d==9):
    print('hon')
elif(d==1 or d==0 or d==6 or d==8):
    print('pon')
elif(d==3):
    print('bon')

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

int main(void){
	int s;
	cin >> s;
	int a[1000005];
	a[1] = s;
	int i = 1;
	while(1){
		if (a[i]%2 == 0) a[i+1] = a[i]/2;
		else a[i+1] = 3*a[i] + 1;
		rep (j,i) {
			if (a[i+1] == a[j]){
				cout << i+1 << endl;
				return 0;
			}
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(N,1);
  int now = 0;
  vector<bool> can(N,false);
  for(int i=0; i<M; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    a[x]--;
    if(can[x]){
      can[y] = true;
    }
    if(a[x] == 0){
      can[x] = false;
    }
    if(x == now){
      now = y;
      can[y] = true;
    }else if(y == now){
      if(a[y] >= 1){
        can[y] = true;
      }
    }
    a[y]++;
  }
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(can[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << 5 + (n - 1) / min({a, b, c, d, e}) << endl;
    return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


vector <int> v(3);


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,3){cin >> v[i]; }

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


    cout << (v[2]- v[1] )+ (v[1] -v[0]) << endl;




    return 0;
}


Measured memory_bytes: 256
#lang racket

(define (count-rgb S r g b)
  (if (null? S)
      (* r g b)
      (cond [(char=? (car S) #\R) (count-rgb (cdr S) (+ r 1) g b)]
            [(char=? (car S) #\G) (count-rgb (cdr S) r (+ g 1) b)]
            [(char=? (car S) #\B) (count-rgb (cdr S) r g (+ b 1))])))

(define (solve N S)
  (let ([total (count-rgb S 0 0 0)]
        [colors (list->vector S)])
    (define (nonnon i j)
      (let ([k (+ j (- j i))])
        (and (not (char=? (vector-ref colors i) (vector-ref colors j)))
             (not (char=? (vector-ref colors i) (vector-ref colors k)))
             (not (char=? (vector-ref colors j) (vector-ref colors k))))))
    (define (j-iter i j subs)
      (if (>= (+ j (- j i)) N)
          subs
          (j-iter i (+ j 1) (+ (if (nonnon i j) 1 0) subs))))
    (define (i-iter i subs)
      (if (>= (+ i 2) N)
          subs
          (+ (i-iter (+ i 1) (j-iter i (+ i 1) subs)))))
    (- total (i-iter 0 0))))

(let ([N (read)]
      [S (string->list (symbol->string (read)))])
  (display (solve N S)))


Measured memory_bytes: 85364
import sys


def union(parent, rank, i, j):
    i_id = find(parent, i)
    j_id = find(parent, j)

    if i_id == j_id:
        return
    if rank[i_id] > rank[j_id]:
        parent[j_id] = i_id
    else:
        parent[i_id] = j_id
        if rank[i_id] == rank[j_id]:
            rank[j_id] += 1

def find(parent, i):
    v = list()
    while i != parent[i]:
        i = parent[i]
        v.append(i)
    for j in v:
        parent[j] = i
    return i


def main():
    input = sys.stdin.read()
    data = list(map(int, input.split()))

    n, m = data[0], data[1]
    rank = [0]*(n+1)
    parent = [i for i in range(n+1)]

    for i in range(2,len(data)-1,2):
        union(parent, rank, data[i], data[i+1])

    s = [0]*(n+1)

    # data = data[2:]
    # print(data)

    for i in range(1,n+1):
        s[find(parent,i)] += 1
        # print(i, find(parent, i))

    print(max(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 57312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

int main() {

	long long  A, B;

	cin >> A >> B;

	auto GreatestCommonDivisor = [](long long  a, long long  b) {
		long long  x, y;

		if (a >= b)
		{
			x = a;
			y = b;
		}
		else
		{
			x = b;
			y = a;
		}
		long long  ret = 1;

		long long  res;
		res = x % y;
		while (res != 0)
		{
			x = y;
			y = res;
			res = x % y;

		}

		return y;
	};


	long long  GCD = GreatestCommonDivisor(A, B);
	long long  ret;
	ret = A / GCD * B;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        String s = String.valueOf(n);
        
        char[] ch = s.toCharArray();
        
        int sum = 0;
        
        for(char c : ch){
            sum += c - '0';
        }
        System.out.println(n%sum==0?"Yes":"No");
    }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i = 1;
    while (true){
        int x;
        cin >> x;
        if (x == 0) break;
        cout << "Case " << i << ": " << x << endl;
        i++;
    }

    return 0;
}


Measured memory_bytes: 3136