akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using P = pair<int, int>;

const int INF = 100100100;

int c[10][1005];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans;
  rep(div, 1<<(h-1)) {
    int g = 0;
    vector<int> id(h);
    rep(i, h) {
      id[i] = g;
      if (div>>i&1) ++g; // 区切り線にきたらg数を増やす
    }
    ++g;

    rep(i,g)rep(j,w) c[i][j] =0;
    rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
    int num = g-1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i,g) now[i] += c[i][j];
      bool ok = true;
      rep(i,g) if (now[i]>k) return false;
      return true;
    };
    rep(j,w) {
      if (!add(j))
      {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<chrono>
using namespace std;
// using namespace std:chrono;
#define ll long long
#define pb push_back
#define mk make_pair
#define fori0 for(ll i=0;i<n;i++)
#define fori1 for(ll i=1;i<=n;i++)
#define modu 1000000007
ll mod_power(ll n,ll x,ll mod)
{
	ll res = 1; 
	n=n%mod;
	if(n==0)
	{
		return 0;
	}  
    while(x>0) 
    {   
        if(x&1)
        { 
            res=(res*n)%mod; 
        }   
        x=x>>1; 
        n=(n*n)%mod;
    } 
    return res; 
}
ll power(ll n,ll x)
{
	ll res = 1;   
    while(x>0) 
    {   
        if(x&1)
        { 
            res=res*n; 
        }   
        x=x>>1; 
        n=n*n;
    } 
    return res; 
}
ll countDigit(ll n) 
{ 
    if (n == 0) 
        return 0; 
    return 1 + countDigit(n / 10); 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w", stdout);
	ll t;
	// cin>>t;
	t=1;
    ll z=t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> arr;
        for(ll i=0;i<n;i++)
        {
            ll temp;
            cin>>temp;
            arr.push_back(temp);
        }
        // sort(arr.begin(),arr.end());
        ll sum=0;
        for(ll i=1;i<n;i++)
        {
            if(arr[i]<arr[i-1])
            {
                sum+=arr[i-1]-arr[i];
                arr[i]=arr[i-1];
            }
        }
        cout<<sum<<"\n";
    }
	return 0;
}

Measured memory_bytes: 5312
#include <stdio.h>

#define M_TATE 17
#define M_YOKO 17

void map_make(int n);
void map_print(int n);

int map[M_TATE][M_YOKO];

int main(void)
{
    int n;

    while (1)
    {
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        map_make(n);
        map_print(n);
    }
    return (0);
}
void map_make(int n)
{
    int i,j;
    int x,y;

    /*マップ初期化と１の入力*/

    for (i = 0; i < n ; i++){
        for (j = 0; j < n ; j++){
            map[i][j] = 0;
        }
    }
    y = (n / 2) + 1;
    x = n / 2;
    
    for (i = 1; i <= n * n; i++){
        while (y > n - 1 || x < 0 || x > n - 1 || map[y][x]){
            if (y > n - 1){
                y = 0;
            }else if(x > n - 1){
                x = 0;
            }else if(x < 0){
                x = n - 1;
            }else if(map[y][x]){
                y++;
                x--;
            }
        }
        map[y][x] = i;
        x++;
        y++;
    }    

}
/*マップの表示*/
void map_print(int n)
{
    int i,j;

    for (i = 0; i < n; i++){
        for (j = 0; j < n; j++){
            printf("%4d", map[i][j]);
        }
        printf("\n");
    }

}



Measured memory_bytes: 2020
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b = LI()
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print("Possible")
else:
    print("Impossible")
#B

#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
"""
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = deque()
q.append(0)
d_f[0] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static int[] days;

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        long sum = 0;
        for (int a = 1; a <= n; a++) {
            for (int b = 1; b <= n; b++) {
                for (int c = 1; c <= n; c++) {
                    //long max = 0;
                    //for(int i=1; i<=n; i++) {
                    //    if(i<=a && i<=b && i <= c) {
                    //        if(a % i==0 && b % i==0 && c % i == 0) {
                    //            max = i;
                    //        }
                    //    }
                    //}
                    //sum += max;
                    sum += Gcd(a, Gcd(b, c));
                }
            }
        }
        return sum;
    }

    static long Gcd(long m, long n) {
        //ユークリッド互除法
        if (m < n) { var t = m; m = n; n = t; }

        while (true) {
            var mod = m % n;
            if (mod == 0) return n;
            m = n;
            n = mod;
        }
    }
}


Measured memory_bytes: 27452
N,M=map(int,input().split())
H=list(map(int,input().split()))
H.insert(0,0)
s=set()
for i in range(M):
  a,b=map(int,input().split())
  if H[a]<=H[b]:s.add(a)
  if H[a]>=H[b]:s.add(b)
print(N-len(s))

Measured memory_bytes: 20104
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,ans=0,d=0,c[10000005]={};
  	long long e[1000005]={};
	cin>>a>>b;
	while(a!=1 && d==0){
		for(int i=2;i<=1000000;i++){
			if(a%i==0){
				c[i]++;
				a/=i;
				break;
			}
			if(i==1000000){
				d++;
			}
		}
	}
	d=0;
	while(b!=1 && d==0){
		for(int i=2;i<=1000000;i++){
			if(b%i==0){
				e[i]++;
				b/=i;
				break;
			}
			if(i==1000000){
				d++;
			}
		}

	}
	for(int i=2;i<=1000000;i++){
		if(c[i]>0 && e[i]>0){
			ans++;
		}
	}
	if(a==b&& a!=1){
		ans++;
	}
	cout<<ans+1<<endl;
  return(0);
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int p[] = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = fs.nextInt();
        }

        int cnt = 1;
        int min = p[0];
        for (int i = 1; i < n; i++) {
            if (p[i] <= min) {
                cnt++;
                min = p[i];
            }
        }

        System.out.println(cnt);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll ans;
	ll num=x-x/d*d;
	if(x/d>=k){
		ans=x-k*d;
	}
	else{
		k-=x/d;
		if(k%2)ans=d-num;
		else ans=num;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int inf = 0x3fffffff;
int main()
{
	int n,ans,mi;
	while(scanf("%d",&n)!=EOF)
	{
		ans=0;
		mi=inf;
		for(int i=0;i<n;i++)
		{
			int s;
			scanf("%d",&s);
			ans+=s;
			if(s%10!=0&&s<mi)
			{
				mi=s;
			}
		} 
		if(ans%10!=0)
			printf("%d\n",ans);
		else if(mi==inf)
			printf("0\n");
		else 
			printf("%d\n",ans-mi);
	}
	return 0;
} 

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


int main() {
  long long n;
  cin >> n;
  string s;
  set<string> a;
  for(int i=0;i<n;i++){
    cin >> s;
    a.insert(s);
  }
  
  cout << a.size() << endl;
    
  return 0;
}


Measured memory_bytes: 19184
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

const int dy[] = {0, -1, 0, 1};
const int dx[] = {-1, 0, 1, 0};
map<int, int> table;

int main()
{
	int depth = 0;
	int next  = -1;
	map<int, int> table;
	queue<int> Q;
	Q.push(01234567);
	while(!Q.empty()){
		int num = Q.front();
		Q.pop();
		if(table.count(num))
			continue;
		
		if(num == next){
			next = -1;
			++depth;
		}
		table[num] = depth;
		
		int zero;
		rep(i, 8){
			if(((num>>(3*i)) & 7) == 0){
				zero = i;
				break;
			}
		}
		
		rep(i, 4){
			int py = zero / 4 + dy[i];
			int px = zero % 4 + dx[i];
			if(py<0 || 2<=py || px<0 || 4<=px)
				continue;
			
			int dst = py*4 + px;
			int tmp[] = {(num >> (3*dst)) & 7, (num >> (3*zero)) & 7};
			int ko = (num | (7<<(3*zero))) & (((1<<24)-1-(7<<(3*zero))) | (tmp[0] << (3*zero)));
			ko = (ko | (7<<(3*dst))) & (((1<<24)-1-(7<<(3*dst))) | (tmp[1] << (3*dst)));
			if(!table.count(ko)){
				Q.push(ko);
				if(next == -1)
					next = ko;
			}
		}
	}

	for(;;){
		int num = 0;
		rep(i, 8){
			int a;
			if(scanf("%d", &a) == EOF)
				return 0;
			num = num*8 + a;
		}
		printf("%d\n", table[num]);
	}
}

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

class unionFindTree{
public:
  int parent;
  int rank;
  int num;

  //コンストラクタ parent=ノード番号・rank=0に初期化
  unionFindTree(){
    rank = 0;
    parent=n;
    num=n;
    n++;
    v.push_back(this);
  }

  //木の根を求める
  static int find(int x){
    if(v[x]->parent==x) return x;
    else return v[x]->parent = find(v[v[x]->parent]->num);
  }

  //集合を併合
  static void unite(int x, int y){
    x = find(x), y = find(y);

    //もし2つのノードの親が同じならば併合する必要がない
    if(x==y) return;

    if(v[x]->rank < v[y]->rank){
      v[x]->parent = y;
    }else{
      v[y]->parent = x;
     // if(v[x]->rank == v[y]->rank) v[x]->rank++;
    }

  }

  //xとyが同じ集合に属するか否か
  static bool same(int x, int y){
    return find(x)==find(y);
  }

private:
  static int n;
  static vector<unionFindTree*> v;
};

int unionFindTree::n=0;
vector<unionFindTree*> unionFindTree::v;

int main(){
  int n, q; cin >> n >> q;
  unionFindTree node[n];

  int operate, x, y;
  int ans[q]; int j=0;
  for(int i=0; i<q; i++){
    cin >> operate >> x >> y;
    if(operate==0) unionFindTree::unite(x, y);
    else if(operate==1) {
      if(unionFindTree::same(x, y)) ans[j++]=1;
      else ans[j++]=0;
    }
  }
  for(int i=0; i<j; i++) cout << ans[i] << endl;

  return 0;
}



Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    for (int i=0;i<n;i++)
    scanf("%d",&a[i]);
    for (int i=k;i<n;i++)
    {
        double val=a[i]/(1.0*a[i-k]);
        if (val>1.0)
        printf("Yes\n");
        else
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 4464
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int lw = sc.nextInt();
        int[] w = new int[n + 1];
        int[] v = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long[][] dp = new long[n + 1][100001];
        for (int i = 0; i < n + 1; i++) {
            for (int j = 1; j < 100001; j++) {
                dp[i][j] = lw + 1;
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 100001; j++) {
                if (v[i] > j) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = Math.min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]);
                }
            }
        }
        for (int i = 100000; i > 0; i--) {
            if (dp[n][i] <= lw) {
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 128724
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const int MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int bit[100001], N;
int sum(int a){
    int res = 0;
    for(int x = a; x > 0; x-=x&-x) res += bit[x];
    return res;
}

void add(int a, int w){
    for(int x = a; x <= N; x+=x&-x) bit[x] += w;
}

int main(){
    int Q;
    cin >> N >> Q;
    rep(i,Q){
        int com, x, y;
        scanf("%d%d%d", &com, &x, &y);
        if(com) printf("%d\n", sum(y)-sum(x-1));
        else add(x,y);
    }
}


Measured memory_bytes: 3608
import sys
input=sys.stdin.readline
n = int(input())
s = input()

def solve(first,second):
    sheep=[]

    sheep.append(first)
    sheep.append(second)

    for i in range(1,n):
        rep= s[i] == "o"
        if not rep ^ sheep[i]:
            sheep.append(sheep[i-1])
        else:
            sheep.append(not sheep[i-1])

    if sheep[0] == sheep[-1]:
        rep= s[0] == "o"
        same = sheep[-2] == sheep[1]
        if sheep[0] ^ rep != same:
            for a in sheep[:-1]:
                if a:
                    print("S",end="")
                else:
                    print("W",end="")
            exit()

fir=[True,False]
sec=[True,False]

for i in fir:
    for j in sec:
        solve(i,j)
print(-1)

Measured memory_bytes: 63408
#include<iostream>
using namespace std;
int main(){
  string s;
  getline(cin,s);
  for(int i=0; i<s.size(); i++)
    if(s[i]>='a' && s[i]<='z') s[i]+='A'-'a';
  cout <<s<<endl;
  return 0;
}

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


typedef struct tree_t{
	int key;
	struct tree_t *left;
	struct tree_t *right;
}TREE_T;

TREE_T *TREE;


void insert(TREE_T *z)
{
	TREE_T *y = NULL;	// x の親
	TREE_T *x = TREE;	// 木の根

	while(x != NULL){
		y = x;	// 親を設定
		if(z->key < x->key)
			x = x->left;	// 左の子へ移動
		else
			x = x->right;	// 右の子へ移動
	}

	if (y == NULL)	// T が空の場合
		TREE = z;	// Tの根 = z
	else if(z->key < y->key)
		y->left = z; // z を y の左の子にする
	else
		y->right = z; // z を y の右の子にする
}

int WALK_COUNT;

// kind = 0 : 通りがけ　1 : 行きがけ
void Walk_tree(TREE_T *p, int kind)
{
	if(kind == 1)
		printf(" %d", p->key);

	if(p->left != NULL)
		Walk_tree(p->left, kind);

	if(kind == 0)
		printf(" %d", p->key);

	if(p->right != NULL)
		Walk_tree(p->right, kind);
}


int main()
{
	TREE_T *p;
	int n;
	char command[10];
	int num;
	int i;

	scanf("%d", &n);

	TREE = NULL;

	for(i = 0; i < n; i++){
		scanf("%s", command);
		if(!strcmp(command, "print")){
			// 木をなぞる
			Walk_tree(TREE, 0);
			printf("\n");
			Walk_tree(TREE, 1);
			printf("\n");
		}else{
			scanf("%d", &num);
			p = (TREE_T *)malloc(sizeof(TREE_T));
			p->key = num;
			p->left = NULL;
			p->right = NULL;
			insert(p);
		}
	}

	return 0;
}


Measured memory_bytes: 17324
n, m = gets.split.map(&:to_i)
a = []
m.times do
  an = gets.to_i
  a[an] = true
end

b = []
b[0] = 1
b[1] = 1 unless a[1]

(2..n).each do |i|
  b[i] = b[i-2].to_i + b[i-1].to_i unless a[i]
end

puts b[n] % 1_000_000_007



Measured memory_bytes: 433020
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A1 = arg[0].split(" ").map(n=>parseInt(n));
    const A2 = arg[1].split(" ").map(n=>parseInt(n));
    const A3 = arg[2].split(" ").map(n=>parseInt(n));
    const N  = arg[3];
    const B  = arg.slice(4, N + 3).map(n=>parseInt(n));
    
    let as = [A1, A2, A3];
    
    for(let i in B) {
        for(let j in as) {
            let del = as[j].indexOf(B[i]);
            
            if(del !== -1) {
                as[j][del] = "x";
            }   
        }
        
        const vert1 = [A1[0], A2[0], A3[0]]; 
        const vert2 = [A1[1], A2[1], A3[1]]; 
        const vert3 = [A1[2], A2[2], A3[2]]; 
        
        const cross1 = [A1[0], A2[1], A3[2]];
        const cross2 = [A3[0], A2[1], A1[2]];
    
        let temp = [A1, A2, A3, vert1, vert2, vert3, cross1, cross2];
        
        for(let j in temp) {
            if(temp[j].filter(n=>n === "x").length === temp[j].length) {
                console.log("Yes");
                return;
            }
        }
    }
    
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define debug(x) std::cerr<<"L: "<<__LINE__<<" f("<<__FUNCTION__<<") Var: "<<#x<<" Val: "<<x<<"\n";
typedef long long ll;
const int inf = 0x7f7f7f7f;
 
inline void gettime() {
	debug(clock());
}
inline int read() {
	static char c;
	static int x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}
 
int n;
int ns[200100];
 
int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif
 
	n = read();
	for (int i = 1; i <= n; ++i)
		ns[i] = read() - i;
	std::sort(ns + 1, ns + 1 + n);
	int k = ns[(1 + n) / 2];
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += std::abs(ns[i] - k);
	printf("%lld\n", ans);
}

Measured memory_bytes: 1152
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  if (ans+l[n-1-i][0])%l[n-1-i][1]!=0:
    ans+=l[n-1-i][1]-(l[n-1-i][0]+ans)%l[n-1-i][1]
print(ans)

Measured memory_bytes: 27508
N,K = map(int,input().split())
if K > (N-1)*(N-2)//2:
    print(-1)
else:
    print(N*(N-1)//2-K)
    for i in range(2,N+1):
        print('{} {}'.format(1,i))
    rest = (N-1)*(N-2)//2-K
    for i in range(2,N+1):
        if rest==0:
            break
        for j in range(i+1,N+1):
            if rest==0:
                break
            print('{} {}'.format(i,j))
            rest -= 1

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int H,W;cin >> H >> W;
   string a[H];
   rep(i,H)cin >> a[i];
   vector<bool> row(H,false),col(W,false);
   rep(i,H){
      rep(j,W){
         if(a[i][j] == '#'){
            row[i] = true;
            col[j] = true;
         }
      }
   }
   rep(i,H){
      if(row[i]){
         rep(j,W){
            if(col[j]){
               cout << a[i][j];
            }
         }
         cout << endl;
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

struct Query {
    int num;
    long long after;
    Query(int num, long long after){
        this->num = num;
        this->after = after;
    }
};

bool operator> (const Query& q1, const Query& q2){
    return q1.after > q2.after;
}
bool operator< (const Query& q1, const Query& q2){
    return q1.after < q2.after;
}

int main(){
    int n,m; cin >> n >> m;
    vector<long long> a(n);
    priority_queue<long long, vector<long long>, greater<long long> > pq;
    rep(i, n){
        cin >> a[i];
        pq.push(a[i]);
    }
    sort(a.begin(), a.end());
    vector<int> b(m);
    vector<long long> c(m);
    vector<Query> q;
    rep(i, m){
        cin >> b[i] >> c[i];
        q.push_back(Query(b[i], c[i]));
    }
    sort(q.begin(), q.end(), greater<Query>());
    long long sum = 0;
    auto current = a.begin();
    for(int i = 0; i < q.size(); i++){
        auto back = lower_bound(current, a.end(), q[i].after);
        int diff = back - current;
        if(diff > q[i].num) {
            sum += q[i].num*q[i].after;
            current += q[i].num;
        } else {
            sum += q[i].after*diff;
            current += diff;
            break;
        }
    }
    for(auto it = current; it != a.end(); it++){
        sum += *it;
    }
    cout << sum << endl;
}





Measured memory_bytes: 5108
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"a b c"# => r#"ABC"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: chars,
        b: chars,
        c: chars,
    }

    if &b[0] == a.last().unwrap() && &c[0] == b.last().unwrap() {
        "YES"
    } else {
        "NO"
    }.to_string()
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n, k; scanf("%d %d", &n, &k);
  vll a(n);
  vector<ll> st;
  ll su = 0;
  for(int i=0;i<n;++i) {
    scanf("%ld", &a[i]);
    a[i] -= k;
    su += a[i];
    //cout << su << endl;
    st.push_back(su);
  }
  sort(st.begin(), st.end());

  ll minus = 0;
  ll cnt = 0;
  for(int i=0;i<n;++i) {
    //cout << i << endl;
    auto it = lower_bound(st.begin(), st.end(), minus);
    cnt += distance(it, st.end());
    //cout << distance(it, st.end()) << endl;
    auto del = find(st.begin(), st.end(), a[i] + minus);
    st.erase(del);
    minus += a[i];
  }

  cout << cnt << endl;  
}



Measured memory_bytes: 4724
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	deque<int> q;
	cin>>n;
	FOR(i,0,n){
		int nn;
		cin>>nn;
		if(i%2==0){
			q.push_front(nn);
		}else{
			q.push_back(nn);
		}
	}
	if(n%2==1){
		FOR(i,0,n-1){
			cout<<q[i]<<" ";
		}
		cout<<q[n-1]<<endl;
	}else{
		FORD(i,n,1){
			cout<<q[i]<<" ";
		}
		cout<<q[0]<<endl;
	}
    return 0;
}


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

int main() {
  int N;
  int f = 0;
  int i = 1;
  cin >> N;
  while(i <= N){
    f += N % (i * 10) / i;
    i *= 10;
  }
  if(N % f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
} 


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

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

    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    int i;
    for (i = 0; i < x-z;) {
        i += (z+y);

        ans++;
    }
    if (i + z == x)
        cout << ans << endl;
    else
        cout << ans -1 << endl;


    return 0;
}



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

using namespace std;

int main(){
    int N, M, x;
    cin >> N >> M;
    vector<int> Xs(M);
    vector<int> distTable(M);
    int prev = 0;
    for(int i = 0; i < M; ++i){
        cin >> x;
        Xs[i] = x;
    }

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

    if(M == 1 || M <= N){
        cout << "0" << endl;
        return 0;
    }
    for(int i = 0; i < M-1; ++i){
        distTable[i] = abs(Xs[i+1] - Xs[i]);
    }
    sort(distTable.begin(), distTable.end(), greater<int>());

    long long sumDist = 0;
    sumDist += abs(Xs[M-1] - Xs[0]);
    
    for(int i = 0; i < N-1; ++i){
        sumDist -= distTable[i];
    }
    cout << sumDist << endl;



    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, H;
    cin >> N >> H;
    vector<ll> a(N, 0), b(N, 0);
    REP(i, N)
    {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());

    ll aMax = a[0];
    // aMax より大きいb の要素の和を計算
    ll bSum = 0;
    ll ans = 0;
    REP(i, N)
    {
        if (b[i] <= aMax) 
        {
            break;
        }
        bSum += b[i];
        ans++;
        if (bSum >= H) break;
    }

    if (H - bSum > 0)
    {
        if ((H - bSum) % aMax == 0)
        {
            ans += (H - bSum) / aMax;
        }
        else
        {
            ans += (H - bSum) / aMax + 1;
        }
        
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	ll res = 0;
	vector <vector <char>> grid(n, vector <char>(m));
	vector <vector <int >> dp(n, vector <int > (m, 0));
	rep(i, 0, n) {
		rep(j, 0, m) cin >> grid[i][j];
	}

	rep(i, 1, n) {
		if(grid[i][0] == '#') {
			while(i < n) {
				dp[i][0] = 0; i++;
			}
		}
		else dp[i][0] = 1;
	}

	rep(j, 1, m) {
		if(grid[0][j] == '#') {
			while(j < m) {
				dp[0][j] = 0; j++;
			}
		}
		else dp[0][j] = 1;
	}
	
	rep(i, 1, n) {
		rep(j, 1, m) {
			if(grid[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = ((dp[i - 1][j] % hell) + (dp[i][j - 1] % hell)) % hell;
		}
	}
	cout << dp[n - 1][m - 1] << endl;
}


int main() {
	int t = 1;
	//cin >> t;
	while(t--)
		solve();

	return 0;
}


Measured memory_bytes: 5248
n = int(input())
aa = list(map(int, input().split()))
num = sum(aa)
bb = list(map(int, input().split()))
for i in range(n):
    c = min(aa[i], bb[i])
    aa[i] -= c
    aa[i + 1] -= min(aa[i + 1], bb[i] - c)
print(num - sum(aa))

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

int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("/home/shubham/Desktop/codes/input.txt", "r", stdin);
	freopen("/home/shubham/Desktop/codes/output.txt", "w", stdout);
	#endif*/
	ll n;
	cin>>n;
	bool res = false;
	for(ll i=1; i<10; i++){
		for(ll j=1; j<10; j++){
			if(n == i*j && !res){
				res = true;
				cout<<"Yes"<<endl;
				break;
			}
		}
	}
	if(!res){
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto ab = readln.chomp.split.to!(int[]);
  writeln(((ab[0]+ab[1])/2.0).round);
}


Measured memory_bytes: 508
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (ll& x : a) {
        cin >> x;
    }
    vector<pii> v;
    int lst = 0;
    a.pb(-300);
    for (int i = 0; i < n; ++i) {
        if (a[i] > a[i+1]) {
            if (lst != i) {
                v.pb({lst, i});
            }
            lst = i+1; 
        }
    }
    ll m = 1000;
    for (pii x : v) {
        m = max(m/a[x.x] * a[x.y] + (m%a[x.x]), m);
    }
    cout << m;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3660
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var n int 
  fmt.Scan(&n)
  cnt := 30
  for i := 0; i < n; i++ {
    var a int 
    fmt.Scan(&a)
    tmp := 0
    for a % 2 == 0 {
      a /= 2
      tmp++
    }
    cnt = minInt(cnt, tmp)
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main() {
 string number;
 int sum;

 while(1) {
  cin >> number;
  if (number.length() == 1 && number[0] - '0' == 0) break;
  sum = 0;
  for (int i = 0; i < number.length(); i++) sum += number[i] - '0';
  cout << sum << endl;
 }

 return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

int main(){
    long N,A,B,sumA,rem;
    scanf("%ld %ld %ld",&N,&A,&B);

    sumA = (N/(A+B))*A;
    rem = N%(A+B);
    if(rem>A)rem=A;
    sumA += rem;

    printf("%ld\n",sumA);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#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 = 1LL<<60;
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,K;
  cin >> N >> K;
  ll ans = 0;
  for(ll i=1; i<=N; i++){
    ans += (ll)(max(0LL,i-K))*(N/i);
    ll r = N%i;
    ans += max(0LL,r-K+1);
  }
  if(K == 0) ans -= N;
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char* argv[]) {
  int N;
  double ret = 0.0;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    double x;
    std::string u;
    std::cin >> x >> u;
    if (u == "JPY") {
      ret += x;
    } else if (u == "BTC") {
      ret += x * 380000.0;

    } else {
      return 1;
    }
  }
  std::cout << std::setprecision(6) << ret << std::endl;
  return 0;
}


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

namespace _0150
{
    public class Program

    {
        public static void Main(string[] args)
        {
            SortedSet<int> primes = new SortedSet<int>();
            for (int i = 2 ; i <= 10000 ; i++) if (IsPrime(i)) primes.Add(i);

            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                if (n % 2 == 0) n--;
                for (int i = n ; i >= 5 ; i -= 2)
                {
                    if (primes.Contains(i) && primes.Contains(i - 2))
                    {
                        Console.WriteLine("{0} {1}", i - 2, i);
                        break;
                    }
                }
            }
        }

        /// <summary>
        ///素数判定
        /// </summary>
        public static bool IsPrime(long number)
        {
            long boundary = (long)Math.Floor(Math.Sqrt(number));

            if (number == 1) return false;
            if (number == 2) return true;

            for (long i = 2 ; i <= boundary ; ++i)
            {
                if (number % i == 0) return false;
            }
            return true;
        }


        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

int main() {
  int a, b, c, x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  int count=0;
  for(int i=0;i<=a;i++){
  	for(int j=0;j<=b;j++){
    	for(int l=0;l<=c;l++){
        	if(i*500+j*100+l*50==x){count++;}
        }
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 3624
N, X = [int(i) for i in input().split()]
p = [1]
l = 1
for i in range(N):
    p.append(p[-1] * 2 + 1)
    l = 2 * l + 3
ban_l = 1
ban_r = l
pate = l//2+1
cnt = 0
for i in range(N+1):
    if X == pate:
        if pate == ban_l:
            cnt += 1
            break
        else:
            cnt += p[N-(i+1)] + 1
            break
    elif X == ban_l:
        break
    elif X < pate:
        ban_l = ban_l + 1
        ban_r = pate - 1
        pate = (pate+ban_l)//2
    elif X < ban_r:
        cnt += p[N-(i+1)] + 1
        ban_l = pate + 1
        pate = (pate+ban_r)//2
        ban_r = ban_r - 1
    else:
        cnt += p[N-i]
        break
print(cnt)

Measured memory_bytes: 3064
def divisor(n):
    l = []
    ll = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            l.append(i)
            # ll.append(n//i)
    # l += reversed(ll)
    # l = sorted(list(set(l)))
    return l


n = int(input())
l = divisor(n)
ans = 100100100100

for i in l:
    a = len(str(i))
    b = len(str(n//i))
    ans = min(ans, max(a, b))

print(ans)



Measured memory_bytes: 9364
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int l = scanner.nextInt();
        int all = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            all += l + i;
            if (Math.abs(l + i) < Math.abs(min)) {
                min = l + i;
            }
        }
        System.out.println(all - min);
    }
}

Measured memory_bytes: 22612
N = int(input())
S = []
for _ in range(N):
    S.append(input())
T = sorted(S)
T.append("uuuuuuuuuuuuu")
s = 0
t = 0
u = 0
d = []
for i in range(0,N):
    if T[i] != T[i+1]:
        s = i + 1 -t
        t = i + 1
        if s > u:
            d = [T[i]]
            u = s
        elif s == u:
            d.append(T[i])
            u = s
s_n = '\n'.join(d)
print(s_n)

Measured memory_bytes: 25668
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll a,b;
ll tot;
int main()
{
	a=read();//当前的值 
	b=read();//预期的值
//	start: 
//	if(a==b)
//	{
//		cout<<0;
//	}
//	else if(b==0)
//	{
//		if(a>0)// 5 0==6
//		{
//			cout<<1+a;
//			return 0; 
//		}
//		else//a<0 -1 0==1
//		{
//			cout<<-a;
//			return 0;			
//		}
//	}
//	else if(a==0)
//	{
//		if(b>0)
//		{
//			cout<<b;
//			return 0;
//		}
//		else
//		{
//			cout<<-b+1;
//			return 0;
//		}
//	}
//	else if(a==-b)
//	{
//		cout<<1;
//	}
//	else if(b>0&&a<b&&a>=0)
//	{
//		cout<<b-a;
//	} 
//	else if(b>0&&a>b)
//	{
//		cout<<a-b+2;
//	}
//	else if(b>0&&a<0&&a<b&&-a<b)
//	{
//		cout<<b+a+1;
//	}
//	else if(b>0&&a<0&&a<b&&-a>b)
//	{
//		cout<<-a-b+1;
//	}
//	else 
//	{
//		a=-a;
//		b=-b;
//		goto start;
//	}
//----------------------------------------------------------------------------------	
	if(a==b)
	{
		cout<<0;
		return 0;
	}
	if(b==0)
	{
		if(a>0)// 5 0==6
		{
			cout<<1+a;
			return 0; 
		}
		else//a<0 -1 0==1
		{
			cout<<-a;
			return 0;			
		}
	}
	else if(a==0)
	{
		if(b>0) //0 5==5
		{
			cout<<b;
			return 0;
		}
		else// 0 -5 ==6
		{
			cout<<-b +1;
			return 0;
		}
	}
	else if(b>0)
	{
		if(a>0&&a<b)//3 4 == 1
		{
			cout<<b-a;
			return 0;
		}
		else if(a>0&&a>b)// 4 3==3
		{
			tot++;
			cout<<2+a-b;
			return 0;
		}
		else if(a<0&&-a<b)//-2 3==2
		{
			cout<<b+a+1;
			return 0;
		} 
		else if(a<0&&-a>b)// -3 2==2
		{
			cout<<-a-b+1;
			return 0;
		}
		else if(a<0&&-a==b)//-5 5=1
		{
			cout<<1;
			return 0;
		}
	}
	else if(b<0)
	{
		if(a>0)
		{
			if(-b>a)// 5 -6==2
			{
				cout<<(-b-a)+1;
				return 0;
			}
			else if(-b==a)// 6 -6==1
			{
				cout<<1;
				return 0;
			}
			else //5 -4 ==2
			{
				cout<<a+b+1;
				return 0;
			}
		}
		else //a<0
		{
			if(a>b)//-1 -3 ===3
			{
				cout<<-b+a+2;
				return 0;
			}
			else // a<b -5 -4 ==1
			{
				cout<<-a+b;
				return 0;
			}
		}
	}
	
}

Measured memory_bytes: 256
def main():
    n=int(input())
    b=[]
    amax=0
    amaxx=-1
    memo=-1
    A=list([] for i in range(n))
    for i in range(n):

        temp=int(input())
        b.append(temp)
        if amax<=temp:
            memo=i
            amaxx,amax=amax,temp
    b.sort()  
    for i in range(n):
        if i==memo:
            print(b[-2])
        else:
            print(amax)

main()

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

void dfs(vector<vector<int>>& g, vector<int>& score, vector<int> &totalScore, int tempTotalScore, int v, int parent) {

    tempTotalScore += score[v];
    totalScore[v] = tempTotalScore;
    for (auto it = g[v].begin(); it != g[v].end(); it++) {
        if (*it != parent) {
            dfs(g, score, totalScore, tempTotalScore, *it, v);
        }
    }

}

int main() {

    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    vector<int> score(n, 0);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        score[p - 1] += x;
    }
    vector<int> totalScore(n);
    dfs(g, score, totalScore, 0, 0, -1);
    for (auto it = totalScore.begin(); it != totalScore.end(); it++) {
        if (it == totalScore.end() - 1) {
            cout << *it;
        }
        else {
            cout << *it << " ";
        }        
    }

    return 0;

}

Measured memory_bytes: 30464