akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int a,b;
	cin >> a >> b;
	cout << 2 * b - a << endl;
	return 0;
}
//b = (a + ans)/2
//2b = a + ans
//2b - a = ans

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

int main()
{
    int n, k;
    std::cin >> n >> k;
    int value{1};
    for (auto i = 0; i < n; ++i)
    {
        value = std::min(value + k, value * 2);
    }
    std::cout << value << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

cnt = [0] * n
for x in range(1, int(n ** 0.5) + 1):
    for y in range(1, int(n ** 0.5) + 1):
        for z in range(1, int(n ** 0.5) + 1):
            num = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if num <= n:
                cnt[num - 1] += 1
print(*cnt, sep="\n")


Measured memory_bytes: 9616
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  int h[MAX];
  rep(i, 0, n) scanf("%d", &h[i]);

  qsort(h, n, sizeof(int), acs);

  int ans = h[n - 1];
  rep(i, 0, n) {
    if (i + k > n) break;
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int n;
	int s[1002];
	string s1;
	map<string,int>sum;
	cin>>n;
	rep(i,n){
		cin >> s1;
		if(!sum[s1])sum[s1]=1;
		else sum[s1]++;
	}
	int Max=-1;
	map<string,int>::iterator it;
	for(it=sum.begin();it!=sum.end();it++){
		if(it->second>Max){
			Max=it->second;
		}
	}
	for(it=sum.begin();it!=sum.end();it++){
		if(it->second==Max){
			cout<<it->first<<endl;
		}
	}
	return 0;
	
} 

Measured memory_bytes: 25216
#!/usr/bin/env python
while 1:
    n=int(raw_input())
    if n==0: break
    pa,pb=0,0
    a,b=[0]*n,[0]*n
    for i in range(n):
        a[i],b[i] = map(int,raw_input().split())

    ab=zip(a,b)
    for a,b in ab:
        if a<b:
            pb+=(a+b)
        elif a>b:
            pa+=(a+b)
        else:
            pa,pb=pa+a,pb+b

    print pa, pb

Measured memory_bytes: 5536
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    println(n * (n - 1) / 2 + m * (m - 1) / 2)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

total = sum(A)
ans = N - total

if ans >= 0:
    print(ans)
else:
    print(-1)



Measured memory_bytes: 9984
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int N, M;
vector<vector<int>> G, Ginv;
vector<bool> vis;
int id0 = -1;
int id1 = -1;
vector<int> pre, ord;
bool flag = false;
bool ok = false;

void dfs(int cur, int org){
    if(id0 != -1) return;

    if(cur == org && flag){
        id0 = org;
        return;
    }
    flag = true;

    for(int nxt : G[cur]){
        if(id0 != -1) return;
        if(vis[nxt]) continue;
        vis[nxt] = true;
        if(nxt == org) id1 = cur;
        pre[nxt] = cur;
        ord[cur] = nxt;
        dfs(nxt, org);
    }
}

vector<int> func(vector<int> &ans, vector<int> &ord){
    ok = false;

    set<int> st;
    for(int x: ans)
        st.insert(x);

    bool hoge = false;
    for(int x : ans){
        for(int y : G[x]){
            if(ord[x] != y && st.find(y) != st.end()){
                ord[x] = y;
                id0 = x;
                hoge = true;
                break;
            }
        }
        if(hoge)
            break;
    }

    vector<int> ans2;
    ans2.push_back(id0);
    int cur = ord[id0];
    while(cur != id0){
        ans2.push_back(cur);
        cur = ord[cur];
    }
    if(ans.size() == ans2.size())
        ok = true;
    return ans2;
}

int main(){
    cin >> N >> M;
    G.resize(N);
    Ginv.resize(N);
    vis.resize(N);
    pre.resize(N, -1);
    ord.resize(N, -1);
    for(int i=0; i<M; i++){
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        Ginv[B].push_back(A);
    }
    for(int i=0; i<N; i++){
        flag = false;
        fill(vis.begin(), vis.end(), false);
        dfs(i, i);
        if(id0 != -1) break;
    }
    if(id0 == -1){
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    ans.push_back(id0);
    int cur = ord[id0];
    while(cur != id0){
        ans.push_back(cur);
        cur = ord[cur];
    }

    while(!ok)
        ans = func(ans, ord);
    cout << ans.size() << endl;
    for(auto x : ans)
        cout << x+1 << endl;

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int a = 0;
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == 'o') {
      a++;
    }
  }

  cout << 700 + 100*a << endl;
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define all(v) v.begin() , v.end()
 
#define rep(i, a, b,r) for (ll i = a, to = b; i < to; i+=r)
#define ren(i, a, b,r) for (ll i = a, to = b; i > to; i-=r)	
 
#define rll(x) ll x;cin>>x;
#define rll2(x,y) ll x,y;cin>>x>>y;
#define rll3(x,y,z) ll x,y,z;cin>>x>>y>>z;
#define rll4(x,y,z,w) ll x,y,z,w;cin>>x>>y>>z>>w;
 
#define rs(s) string s;cin>>s;
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MOD=998244353;
 
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef deque<ll> dqll;
 
typedef set<ll> sll;
 
const long double PI = acos(-1);
 
const ll MX=2e5 + 10;
 
const ll MX2=9223372036854775806;
const ll MX3=100000+5;
 

/*PLANTILLA*/
bool cmp(pll p1,pll p2){
	if(p1.second<=p2.second) return true;
	else if(p1.ss==p2.ss) return p1.ff>p2.ff;
	else return false;
}

 
int main(){
	ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	ll ans=0;
	rep(i,0,5,1){
		rll(a);
		if(a!=i+1){
			ans=i+1;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
    double s = t-h*0.006;
    return s;
}

int div(int n) {
    int h = 0;
    for (int i=1; i<=n; ++i) {
        if (n%i==0) h++;
    }
    return h;
}

int main() {
    int n;
    cin >> n;
    int res = 0;
    for(int i=1; i<=n; ++i) {
        int r = div(i);
        if (i%2 == 1 && r==8) {
            res++;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define EPS 1e-9
#define rank asadf
using namespace std;

const int MAXN = 3e5 + 111;
const int MOD = 998244353;

int t[4 * MAXN], dp[MAXN], l[MAXN], r[MAXN];

void build(int v, int l, int r) {
    if (l == r - 1) {
        t[v] = dp[l];
        return;
    }
    int mid = (l + r) / 2;
    build(2 * v + 1, l, mid);
    build(2 * v + 2, mid, r);
    t[v] = (t[2 * v + 1] + t[2 * v + 2]) % MOD;
}

void update(int v, int l, int r, int pos, int d) {
    if (pos < l || r <= pos)
        return;
    if (l == r - 1) {
        t[v] = d;
        return;
    }
    int mid = (l + r) / 2;
    update(2 * v + 1, l, mid, pos, d);
    update(2 * v + 2, mid, r, pos, d);
    t[v] = (t[2 * v + 1] + t[2 * v + 2]) % MOD;
}

int query(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr)
        return t[v];
    if (r <= ql || qr <= l)
        return 0;
    int mid = (l + r) / 2;
    int left = query(2 * v + 1, l, mid, ql, qr);
    int right = query(2 * v + 2, mid, r, ql, qr);
    return (left + right) % MOD;
}

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> l[i] >> r[i];
    }
    dp[0] = 1;
    build(0, 0, n);
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            dp[i] = (dp[i] + query(0, 0, n, max(0, i - r[j]), max(0, i - l[j] + 1))) % MOD;
        }
        update(0, 0, n, i, dp[i]);
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 6488
#include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s){int c;
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	double a;
	while (scanf("%lf", &a) != EOF)
		printf("%.8lf\n", a * 211/27);
}


Measured memory_bytes: 2584
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(lst[K - 1])

Measured memory_bytes: 3060
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()

first_ = True

num = 0
pos = 1
while len(S) >= 3:
    ok = False
    for i in range(pos, len(S)-1):
        if S[i-1] == S[i+1]:
            continue
        else:
            S = S[:i] + S[i+1:]
            ok = True
            num += 1
            break
    if not ok:
        break

# print("num = ", num)
if num % 2 == 1:
    print('First')
else:
    print('Second')



Measured memory_bytes: 3444
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    string S; cin >> S;
    int sum = 0;
    for(int i=0;i<(int)S.size();i++){
        char c = S[i];
        if(c == ('o'))
            sum++;
    }
    int a = 15 - S.size();
    a + sum >= 8?cout << "YES"<<endl:cout << "NO" <<endl;
}

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

void main()
{
    auto S = readln.chomp.to!(dchar[]);
    auto N = S.length;
    size_t i = 0, j = S.length - 1;
    auto a = S[0], b = S[0], c = S[$-1], d = S[$-1];

    int x, y;
    foreach (s; S) {
        ++(s == '1' ? x : y);
    }
    if (!x || !y) {
        writeln(N);
        return;
    }

    while (i <= j) {
        if (i + 1 < N - j) {
            a = S[i];
            while (a == b) b = S[++i];
        } else {
            d = S[j];
            while (c == d) c = S[--j];
        }
    }
    writeln(i > N - j - 1 ? i : N - j - 1);
}

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

using namespace std;
typedef long long ll;

int main(){
	ll A, B;
  	cin >> A >> B;
  
  	if((A+B)%2 == 1) cout << "IMPOSSIBLE" << endl;
  	else cout << (A+B)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5+100;
const int P = 998244353;
#define fr(i,low,up,st) for(int i = low;i <= up; i += st)
#define nfr(i,low,up,st) for(int i = low;i >= up; i -= st)
#define SZ(a) a.size()
#define clr(a) memset(a,0,sizeof a)

int n,a[N];
char s[N];
int ct[4],tpe[N];
int main(){
   scanf("%d",&n);
   scanf("%s",s+1);
   fr(i,1,3*n,1)
      if(s[i] == 'R')a[i] = 0;
      else if(s[i] == 'G')a[i] = 1;
      else a[i] = 2;

   fr(i,1,3*n,1){
      ct[a[i]] ++;
      if(ct[0] && ct[1] && ct[2])tpe[i] = 3;
      else if((ct[0] > 0)+(ct[1] > 0)+(ct[2] > 0) > 1 &&
            ct[a[i]] <= ct[0]+ct[1]+ct[2]-ct[a[i]])
         tpe[i] = 2;
      else tpe[i] = 1;
      //cerr << i <<' ' << tpe[i] << endl;
      int w = min(min(ct[0],ct[1]),ct[2]);
      ct[0] -= w; ct[1] -= w; ct[2] -= w;
   }
   clr(ct);
   ct[0] = n;
   int ans = 1;
   fr(i,1,3*n,1){
      ans = 1LL*ans*ct[tpe[i]-1]%P;
      ct[tpe[i]]++;
      ct[tpe[i]-1]--;
   }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 2944
import std.algorithm;
import std.range;
import std.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}

long modPow(long mod)(long x, long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return modPow!mod(x * x % mod, n / 2);
    return x * modPow!mod(x % mod, n - 1) % mod;
}

class RollingHash(long[] Ps, long mod) {
    string s;
    long[][] H;
    this(in string s) { 
        this.s = s; 
        auto N = s.length;
        this.H = new long[][](Ps.length, N + 1); // H[k]: s[0]*Ps[k]^(n-1) + s[1]*Ps[k]^(n-2) + ... + s[n-1]*Ps[k]^0
        foreach (k, P; Ps) {
            foreach (int i, c; s) {
                H[k][i + 1] = (H[k][i] * P + cast(int)(c - 'a' + 1)) % mod;
            }
        }
    }
    long[] hash(int l, int r) { // [l, r)
        auto hs = iota(0, Ps.length, 1).map!(delegate(k) {
                      return (H[k][r] - H[k][l] * modPow!mod(Ps[k], r - l) % mod + mod) % mod;
                  });
        return hs.array;
    }
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;
    auto hasher = new RollingHash!([991, 9999991], cast(long)(1e9+7))(s);
    int l = 0, r = 1;
    bool[long[]] appeared;
    foreach (_; 0 .. M) {
        auto q = readln.chomp;
        switch (q) {
            case "L++": l++; break;
            case "L--": l--; break;
            case "R++": r++; break;
            case "R--": r--; break;
            default: assert(false);
        }
        appeared[hasher.hash(l, r).idup] = true;
    }
    writeln(appeared.keys.length);
}

Measured memory_bytes: 62436
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    ll a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);
    if(a>k)printf("%lld %lld\n",a-k,b);
    else printf("%lld %lld\n",0LL,max(b-(k-a),0LL));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//value->find_by_order(elem), index->order_of_key(elme) [both in O(logn)]
//mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define pre(y,x)        fixed<<setprecision(y)<<x
#define dbg(x)          cerr << "[" << #x << ": " << (x) << "]\n";
#define ff              first
#define ss              second
#define pb              push_back
#define popb            pop_back
#define all(v)          v.begin(), v.end()
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii;
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a,ll b){if(b==0) return 1;ll res;while(b>0){if(b&1) res *= a;a *= a;b >>=1;}return res;}
int is(int n){if(n==1) return 0;for(int i=2;i*i<=n;i++){if(n%i==0) return false;}return true;}
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
const int inf = 1e9;
const ll INF = 1e18;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
int n;

void solve(){
		cin>>n;
		int ans[10050]={};
		for(int i=1;i*i<=n;i++){
			for(int j=1;j*j<=n;j++){
				for(int k=1;k*k<=n;k++){
					int v = i*i + j*j + k*k + i*j + j*k + k*i;
					if(v<10050)
					ans[v]++;	
				}
			}
		}
		for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;	
}
int main()
{
		FIO;
//		ll t; cin>>t;
//		while(t--)
			solve();
		return 0; 
}

Measured memory_bytes: 3620
n, k = input().split()
m = list(map(int, input().split()))

kazu =[]
kai = []
kazu = [(a+1) /2 for a in m]
kitai = sum(kazu[0:int(k)])
ans = kitai


for x in range(int(n) - int(k)):
    kitai -= kazu[x]
    kitai += kazu[x + int(k)]
    if ans < kitai:
        ans = kitai

print(ans)

Measured memory_bytes: 77448
#include<stdio.h>
int main()
{
	long long int a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);
	long long int ans=b/x;
	ans-=a/x;
	if(a%x==0)
	  ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;

long long int search(vector<int> num, int level){
    long long int ans = 0;
    if(level == num.size()){
        long long int coans = 0;
        for(int i = 0; i < q; i++){
            if(num[b[i]-1] - num[a[i]-1] == c[i]) coans += d[i];
        }
        return coans;
    }else{
        int low = (level == 0) ? 1 : num[level-1];
        for(int i = m; i >= low; i--){
            num[level] = i;
            long long int coans = search(num, level+1);
            ans = max(ans, coans);
        }
        return ans;
    }
}

int main(){
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        int tm1, tm2, tm3, tm4;
        cin >> tm1 >> tm2 >> tm3 >> tm4;
        a.push_back(tm1);
        b.push_back(tm2);
        c.push_back(tm3);
        d.push_back(tm4);
    }

    vector<int> num(n, m);

    cout << search(num, 0) << endl;
    return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n){
        cin >> vec.at(i);
    }
    reverse(vec.begin(), vec.end());
    rep(i, n){
        cout << vec.at(i);
        if(i < n - 1) cout << " ";
    }
    cout << endl;
}





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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int d[n];
  for(i=0;i<n;i++)cin>>d[i];
  int sum=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  cout<<sum;
}

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

using namespace std;

vector<int> pre;
vector<int> in;
int p=0;

int recon(int l, int r) {
	if (l >= r) { return 0; }
	
	int c = pre[p++ ];
	int m = 0;
	for (int i = l; i <= r; i++) {
		if (in[i] == c) {
			m = i;
			break;
		}
	}

	recon(l, m);
	recon(m + 1, r);
	if (c != pre[0]) {
		cout << c << " ";
	}
	else {
		cout << c << endl;
	}
	return 0;
}

int main() {

	int n;
	cin >> n ;

	pre=vector<int> (n, 0);
	in=vector<int> (n, 0);

	for (int i = 0; i < n; i++) {
		cin >> pre[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> in[i];
	}

	recon(0, pre.size());
}


Measured memory_bytes: 3108
#15:50
n,m,k = list(map(int,input().split()))
mod = 10 ** 9 + 7
def inv(x):
  y = 1
  while x != 1:
    y *= mod//x+1
    y %= mod
    x -= mod%x
  return y
#print(inv(5))
ans = 1
for i in range(k-2):
  ans *= n*m-2-i
  ans %= mod
  ans *= inv(k-2-i)
  ans %= mod
#print(ans)
zsum = [0]
for i in range(1,max(n,m)):
  zsum.append(zsum[-1]+i)
#print(zsum)
ans1 = 0
for i in range(m):
  ans1 += zsum[i]
  ans1 += zsum[m-1-i]
  ans1 %= mod
ans1 *= n ** 2
ans1 %= mod
ans2 = 0
for j in range(n):
  ans2 += zsum[j]
  ans2 += zsum[n-1-j]
ans2 *= m ** 2
ans2 %= mod
ans *= ans1 + ans2
ans *= inv(2)
ans %= mod
#print(ans1)
#print(ans2)
print(ans)

Measured memory_bytes: 12204
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(3);
  for(int i=0;i<3;i++) cin>>A[i];
  sort(A.begin(),A.end());
  int ans=A[2]-A[0]+A[2]-A[1];
  if(ans%2==0) ans/=2;
  else ans=(ans+3)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <valarray>
#include <tuple>

class Dice {
private:
    std::map<std::tuple<int, int, int>, int> number_map;
    std::map<int, std::valarray<int>> direction_map;
    std::valarray<int> T = {1, 0, 0};
    std::valarray<int> S = {0, 1, 0};
    std::valarray<int> E = {0, 0, 1};
    std::valarray<int> B = {-1, 0, 0};
    std::valarray<int> N = {0, -1, 0};
    std::valarray<int> W = {0, 0, -1};

public:
    Dice(int n1, int n2, int n3, int n4, int n5, int n6) {
        number_map[to_tuple(T)] = n1;
        number_map[to_tuple(S)] = n2;
        number_map[to_tuple(E)] = n3;
        number_map[to_tuple(W)] = n4;
        number_map[to_tuple(N)] = n5;
        number_map[to_tuple(B)] = n6;
        direction_map[n1] = T;
        direction_map[n2] = S;
        direction_map[n3] = E;
        direction_map[n4] = W;
        direction_map[n5] = N;
        direction_map[n6] = B;
    }

    static std::valarray<int> cross(std::valarray<int> d1, std::valarray<int> d2) {
        return d1.cshift(1) * d2.cshift(-1) - d1.cshift(-1) * d2.cshift(1);
    }

    static std::tuple<int, int, int> to_tuple(std::valarray<int> direction) {
        return std::make_tuple(direction[0], direction[1], direction[2]);
    }

    int query(int T_number, int S_number) {
        auto d1 = direction_map[T_number];
        auto d2 = direction_map[S_number];
        auto d3 = cross(d1, d2);
        return number_map[to_tuple(d3)];
    }
};


int main() {
    int n1, n2, n3, n4, n5, n6;
    std::cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    Dice dice = Dice(n1, n2, n3, n4, n5, n6);
    
    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int T_number, S_number;
        std::cin >> T_number >> S_number;
        std::cout << dice.query(T_number, S_number) << std::endl;
    }
}



Measured memory_bytes: 3172
#include <stdio.h>
int m[100][100];
int f[100];
int d[100];
int n;
int t;
 
 
 
void visit(int u){
  int v;
  d[u] = ++t;
  for(v=0;v<n;v++){
    if(m[u][v] && d[v] == 0){
      visit(v);
    }
  }
    f[u] = ++t;
}
 
int main (){
  int i,j,k,u,r;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    d[i] = 0;
    f[i] = 0;
    for(j=0;j<n;j++){
      m[i][j] = 0;
    }
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&r);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&u);
      m[r-1][u-1] = 1;
    }
  }
  t = 0;
  for(i=0;i<n;i++){
    if(d[i] == 0){
      visit(i);
    }
  }
 
 
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}



Measured memory_bytes: 2056
/*input
10 10
3 1 4 1 5 9 2 6 5 3
*/

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

// from atcoder live
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<mint> dp(s+1);
  dp[0] = 1;
  rep(i, n) {
    vector<mint> p(s+1);
    swap(dp, p);
    rep(j, s+1) {
      dp[j] += p[j]*2;
      if (j+a[i] <= s) dp[j+a[i]] += p[j];
    }
  }
  cout << dp[s] << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X, N;
  cin >> X >> N;
  if (N == 0)
  {
    cout << X << endl;
    return 0;
  }
  else
  {
    vector<int> p(N);
    for (auto &it : p)
      cin >> it;
    sort(p.begin(), p.end());
    if (!binary_search(p.begin(), p.end(), X))
    {
      cout << X << endl;
      return 0;
    }
    for (int i = 1; i <= 100; i++)
    {
      bool find1 = false;
      bool find2 = false;
      for (int j = 0; j < N; j++)
      {
        if (X - i == p[j])
          find1 = true;
        else if (X + i == p[j])
          find2 = true;
      }
      if (!find1)
      {
        cout << X - i << endl;
        return 0;
      }
      else if (!find2)
      {
        cout << X + i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3640
package main

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

type ship struct {
	a, b int
}

func main() {
	n := getInt()
	m := getInt()

	ss := make([]ship, m)
	for i := range ss {
		ss[i].a = getInt()
		ss[i].b = getInt()
	}

	checker := make([]bool, n)
	for _, s := range ss {
		if s.a == 1 {
			checker[s.b-1] = true
		}
		if s.b == 1 {
			checker[s.a-1] = true
		}
	}

	ans := "IMPOSSIBLE"
	for _, s := range ss {
		if s.a == n && checker[s.b-1] == true {
			ans = "POSSIBLE"
		}
		if s.b == n && checker[s.a-1] == true {
			ans = "POSSIBLE"
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int n;
int X[53], Y[53];
map<ii,bool> mp;

int cnt(int p, int q)
{
	int res = 0;
	for(int i = 1; i <= n; i++)
	{
		if(!mp[{X[i]+p, Y[i]+q}])
			res++;
	}
	// printf("%d %d %d\n", p, q, res);
	return res;
}

int main()
{
	// freopen("input.in", "r", stdin);

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d %d", &X[i], &Y[i]);
		mp[{X[i], Y[i]}] = 1;
	}
	int mn = 1e9;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i+1; j <= n; j++)
		{
			mn = min(mn, cnt(X[i]-X[j], Y[i]-Y[j]));
		}
	}
	printf("%d\n", (1 == n)? 1 : mn);
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e6+5;
lli n,left1[N],right1[N];
vector<pair<lli,lli>> v1,v2;

bool cmp(pair<lli,lli> &a, pair<lli,lli> &b)
{
    return a.second>b.second;
}

/*https://codeforces.com/blog/entry/77148?#comment-619728*/

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    cin>>n;
    lli i,j,cur,flag=0;
    string s[n];
    
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        
        cur=0;
        for(j=0;j<s[i].length();j++)
        {
            if(s[i][j]=='(') cur++;
            else if(cur)     cur--;
        }
        right1[i]=cur;
        
        cur=0;
        for(j=s[i].length()-1;j>=0;j--)
        {
            if(s[i][j]==')') cur++;
            else if(cur)     cur--;
        }
        left1[i]=cur;
    }
    
    for(i=0;i<n;i++)
    {
        if(right1[i]-left1[i]>=0) v1.push_back({left1[i], right1[i]});
        else                      v2.push_back({left1[i], right1[i]});
    }
    
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end(), cmp);
    
    cur=0;
    for(i=0;i<v1.size();i++)
    {
        cur-=v1[i].first;
        if(cur<0)
        {
            cout<<"No";
            return 0;
        }
        cur+=v1[i].second;
    }
    
    for(i=0;i<v2.size();i++)
    {
        cur-=v2[i].first;
        if(cur<0)
        {
            cout<<"No";
            return 0;
        }
        cur+=v2[i].second;
    }
    
    if(cur) 
    {
        cout<<"No";
        return 0;
    }
    
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 65836
#include<iostream>

using namespace std;

int main() {
	int n, p[2*100000], min;

	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> p[i];
	min = p[0];
	int c = 0;
	for(int i = 0; i < n; i++) {
		if (p[i] < min)
			min = p[i];
		if (p[i] <= min)
			c++;
	}
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{	int n;
	cin >> n;
	if (n % 1000)
		cout << 1000 - (n % 1000) << " ";
	else
		cout << "0";
}


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

li = [ input() for i in range(H) ]
from itertools import chain
li = list(chain.from_iterable(li))
import collections as col
cc = col.Counter(li)

flag = True
if ( H%2==0 and W%2==0 ):
  for k,v in cc.items():
    if (v%4!=0):
      flag = False
if ( H%2==1 and W%2==0 ):
  p=0
  for k,v in cc.items():
    if (v%4!=0):
      if (v%4!=2):
        flag = False
      else:
        p+=v%4
  if ( p > W ):
    flag = False
if ( H%2==0 and W%2==1 ):
  p=0
  for k,v in cc.items():
    if (v%4!=0):
      if (v%4!=2):
        flag = False
      else:
        p+=v%4
  if ( p > H ):
    flag = False
if ( H%2==1 and W%2==1 ):
  p=0
  q=0
  for k,v in cc.items():
    if (v%4==1):
      q += 1
    if (v%4==2):
      p += 2
    if (v%4==3):
      p += 2
      q += 1
  if ( q > 1 ):
    flag = False
  if ( p > (H//2 + W//2)*2 ):
    flag = False
print ( "Yes" if flag else "No" )
    

Measured memory_bytes: 40432
a,b,c,n=map(int,input().split())
x=[0]*n;y=[0]*n;z=[0]*n;s=0
for i in range(n):
    x[i],y[i],z[i]=map(int,input().split())
    s+=(x[i]==a-1)+(y[i]==b-1)+(z[i]==c-1)+(x[i]==0)+(y[i]==0)+(z[i]==0)
for i in range(n):
    for j in range(i+1,n):s+=((abs(x[i]-x[j])+abs(y[i]-y[j])+abs(z[i]-z[j]))==1)
print(2*((a*b+b*c+c*a)+3*n-s))

Measured memory_bytes: 7740
#include <cstdio>
#include <algorithm>
#include <bitset>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	long long A[N];
	for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
	long long x = 0, s = A[0] + A[1];
	for (int i = 2; i < N; ++i) x = x ^ A[i];
	bitset<40> gaps;
	gaps.reset();
	for (int i = 0; i < 40; ++i) {
		if (x & (1LL << i)) s -= 1LL << i;
		else gaps[i] = 1;
	}
	if (s >= 0 && s % 2 == 0) {
		long long ans = 0;
		for (int i = 1; i <= 40; ++i) {
			if (s & (1LL << i)) {
				if (!gaps[i - 1]) {
					printf("-1");
					return 0;
				} else ans += 1LL << (i - 1);
			}
		}
		if (ans <= A[0]) {
			for (int i = 39; i >= 0; --i) {
				if (!gaps[i] && ans + (1LL << i) <= A[0]) ans += 1LL << i;
			}
			if (ans == 0) printf("-1");
			else printf("%lld", A[0] - ans);
		} else printf("-1");
	} else printf("-1");
	return 0;
}

Measured memory_bytes: 1732
h, w, d = map(int, input().split())
a_dict = dict()
for i in range(h):
    A = list(map(int, input().split()))
    for j in range(w):
        a_dict[A[j]] = [i+1, j+1]
q = int(input())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

a_list = [0 for _ in range(h*w+1)]
for i in range(1, h*w+1):
    if i + d <= h*w:
        pos = a_dict[i]
        d_pos = a_dict[i+d]
        a_list[i+d] += a_list[i] + abs(d_pos[0]-pos[0]) + abs(d_pos[1]-pos[1])
for i in range(q):
    l, r = query[i]
    print(a_list[r] - a_list[l])


Measured memory_bytes: 50152
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextInt64(scanner)
	x1 := 0
	y1 := 0
	x2 := int64(1e9)
	y2 := 1
	x3 := x2 - s%x2
	y3 := (x2 + s) / x2

	if s == int64(1e18) {
		y2--
		y3--
	}

	fmt.Fprintf(writer, "%d ", x1)
	fmt.Fprintf(writer, "%d ", y1)
	fmt.Fprintf(writer, "%d ", x2)
	fmt.Fprintf(writer, "%d ", y2)
	fmt.Fprintf(writer, "%d ", x3)
	fmt.Fprintln(writer, y3)
	writer.Flush()
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int sc = scanner.nextInt();
    int sc2 = scanner.nextInt();
    String i = Integer.toString(sc,sc2);
    //System.out.println(i);
//    Integer oi = new Integer(sc);
//    int num1 = Integer.parseInt(sc, sc2);
    int valLen = i.length(); 
    System.out.println(valLen);
}
}

Measured memory_bytes: 23636
#![allow(dead_code)]
#![allow(non_snake_case)]

pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let (N, M) = read_tuple::<i64>();
    let mut A: Vec<i64> = read_vec();
    for i in 0..N as usize {
        A[i] /= 2;
    }
    let lcm = A.iter().fold(A[0], |l, &a| l * a / gcd(l, a));
    for &a in A.iter() {
        if lcm / a % 2 == 0 {
            println!("0");
            return;
        }
    }
    let ans = (M / lcm + 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 8444
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    else:
        s = "#"*b
        t = "."*(b-2)
        print(s)
        for i in range(a-2):
            print(f"#{t}#")
        print(s)
        print()


Measured memory_bytes: 5620
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let [|A;B;C;K|] = reads int64 ()

((min A K)  - (max 0L (K-A-B))) |> printfn "%d"

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

int main(){
  int n,leg[2]={0,0},count=0;
  bool state=false;
  vector<string> f={"lu","ru","ld","rd"};
  string input;

  while(1){
  count =0;
  leg[0]=0;
  leg[1]=0;
  state = false;
  cin >> n;
  if(n==0){
    break;
  }
  for(int i=0;i<n;i++){
    cin >> input;
    if(input==f[0]){
      leg[0]++;
    }
    if(input==f[1]){
      leg[1]++;
    }
    if(input==f[2]){
      leg[0]--;
    }
    if(input==f[3]){
      leg[1]--;
    }

    if(leg[0]==leg[1] && leg[0]==1 && !state){
      count++;
      state=true;
      //cout << input << endl;
      continue;
    }
    if(leg[0]==leg[1] && leg[0]==0 && state){
      count++;
      state=false;
      //cout << input << endl;
      continue;
    }
    
  }
  cout << count << endl;
  }
  return 0;
}
      
    



Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

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

    int len = s.length();
    int ans = len;

    int i;
    int count_s = 0;
    int count_t = 0;
    for(i = 0; i < len; i++) {        
        if(s[i] == 'T' && count_s == 0) continue;

        if(s[i] == 'S' && count_t == 0) {
            count_s++;
            continue;
        } 
        if(s[i] == 'T' && count_s != 0) {
            count_t++;
            continue;
        }
        if(s[i] == 'S' && count_t != 0) {
            ans = ans - 2 * min(count_s, count_t);
            count_s = count_s - min(count_s, count_t) + 1;
            count_t = 0;
        }
        
    }

    if(s[len - 1] == 'T' && count_s != 0) {
        ans = ans - 2 * min(count_s, count_t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int a[10+1],b[10+1],c[10+1],ten[10+1],i,j,n,max,cnt;
    char moziretsu[10+1][20+1];
    cnt=0;
    scanf("%d",&n);
    while(n!=0) {
        if(0<cnt) {
            printf("\n");
        }
        for(i=0;i<n;i++) {
            scanf("%s %d %d %d",moziretsu[i],&a[i],&b[i],&c[i]);
            ten[i]=a[i]*3+b[i]*0+c[i]*1;
        }
        for(j=0;j<n;j++) {
            max=-1;
            for(i=0;i<n;i++) {
                if(max<ten[i]) {
                    max=ten[i];
                }
            }
            for(i=0;i<n;i++) {
                if(max==ten[i]) {
                    printf("%s,%d\n",moziretsu[i],ten[i]);
                    ten[i]=-2;
                }
            }
        }
        cnt++;
    scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
ll const N=1e6+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
   		int h,a;cin>>h>>a;
   		int ans=(h+a-1)/a;
   		cout<<ans<<endl;
    }
    return 0;   
}
 


Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
q = []
for i in A:
    heapq.heappush(q, -i)

for i in range(M):
    expe = heapq.heappop(q)
    expe = -expe // 2
    heapq.heappush(q, -expe)
print(-sum(q))

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

int main(){
  int x, y;
  cin >> x >> y;
  string Ans="No";
  vector<int> A={1, 3, 5, 7, 8, 10, 12}, B={4, 6, 9, 11}, C={2};
  for(i:A){
    for(j:A){
      if(x==i && y==j){
        Ans="Yes";
      }
    }
  }
  for(i:B){
    for(j:B){
      if(x==i && y==j){
        Ans="Yes";
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int n;
  lint k;
  cin>>n>>k;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }

  int u=0;
  if(k<=n){
    rep(i,k){
      u=a[u];
    }
    return u;
  }

  rep(i,n){
    u=a[u];
  }

  int s=u;
  int cycle;
  rep(i,n+1){
    u=a[u];
    if(u==s){
      cycle=i+1;
      break;
    }
  }

  int remain=(k-n)%cycle;
  u=s;
  rep(i,remain){
    u=a[u];
  }

  return u;
}

int main(){cout<<(app()+1)<<endl;return 0;}


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

int main(){
        vector<double> num;
        double h;
        while(cin >> h){
                num.push_back(h);
        }
        sort(num.begin(), num.end());
        cout << num[num.size()-1] - num[0] << endl;
        return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  
  if(a+b+c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}

Measured memory_bytes: 3592