akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        int X = sc.nextInt();
        int A = sc.nextInt();

        out.println(X < A ? 0 : 10);

        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

Measured memory_bytes: 20820
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
*/
////////////////////////////////////////////////////



int main()
{
	int t, p, r;
	while (cin >> t >> p >> r&&t&&p&&r)
	{
		vector<pair<int, int> > a;
		vector<int> missing[100];
		pair<int, int > x;
		x.first = 0;
		x.second = 0;
		rep(i,t+1)a.push_back(x);
		rep(i, t + 1)rep(l, p + 1)missing[i].push_back(0);
		rep(i, r)
		{
			int id;
			int pr;
			int time;
			char miss[50];
			cin >> id >> pr >> time >> miss;

			if (miss[0] == 'C')
			{
				a[id].first++;
				a[id].second += missing[id][pr] * 1200 + time;

			}
			else
			{
				missing[id][pr]++;
			}

		}
		a.erase(a.begin());
		int num[100];
		rep(i, 100)num[i] = i + 1;
		bool fl = true;
		while (fl)
		{
			fl = false;
			for (int i = 1; i < a.size(); i++)
			{
				if (a[i].first > a[i - 1].first)
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
				else if (a[i].first == a[i - 1].first&&a[i].second < a[i - 1].second)
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
				else if (a[i].first == a[i - 1].first&&a[i].second == a[i - 1].second&&num[i] < num[i - 1])
				{
					swap(a[i], a[i - 1]);
					swap(num[i], num[i - 1]);
					fl = true;
				}
			}
		}
		for (int i = 0; i < t; i++)
		{
			cout << num[i] << " " << a[i].first << " " << a[i].second << endl;

		}
	}
}

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

using namespace std;

vector< int > g[100000];
int dist[100000], ans[100000];

void dfs1(int idx, int par)
{
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    dist[idx] = max(dist[idx], dist[to] + 1);
  }
}

void dfs2(int idx, int d_par, int par)
{
  vector< pair< int, int > > d_child;
  // d_child.emplace_back(0, -1);
  for(int &to : g[idx]) {
    if(to == par) d_child.emplace_back(d_par + 1, to);
    else d_child.emplace_back(dist[to] + 1, to);
  }
  sort(d_child.rbegin(), d_child.rend());
  ans[idx] = d_child[0].first;
  for(int &to : g[idx]) {
    if(to == par) continue;
    if(par == -1 && g[idx].size() == 1) dfs2(to, 0, idx);
    else dfs2(to, d_child[d_child[0].second == to].first, idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs1(0, -1);
  dfs2(0, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << (N - 1) * 2 - ans[i] << endl;
  }
}

Measured memory_bytes: 26456
from collections import defaultdict
def input_as_int():
    return list(map(int,input().split()))

def get_comb(n):  # n C n まで

    fac = get_fact(n)
    com  = [["error" for _ in range(n+1)] for _ in range (n + 1)]
    for i in range(n + 1):
        for j in range(i + 1):
            if  i >= j:
                com[i][j] = fac[i] // (fac[i-j] * fac[j])
    return com

def get_fact(n):
    temp = 1
    fac = [1]
    for i in range(1, n + 1):
        temp *= i
        fac.append(temp)
    return fac

N,A,B = input_as_int()
Vs = input_as_int()
Vs.sort(reverse= True)
nums = defaultdict(lambda :0)
kose = defaultdict(lambda :0)
com = get_comb(N)
for v in Vs:
    nums[v] += 1
total = 0
for i in range(A):
    total += Vs[i]
    kose[Vs[i]] += 1
av = total / A
i = A
ans = 0
while True:
    temp = 1
    for k,v in kose.items():
        n = nums[k]
        temp *= com[n][v]

    ans += temp
    if i ==B or Vs[i] != Vs[0] :
        break
    else:
        kose[Vs[i]] +=1
        i += 1
print(av)
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x;
    int tmp;
    for(int i = 0; i < m; i++){
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());
    long long ans = 0;
    if(n >= m){
        ans = 0;
    } else {
        vector<int> diff;
        for(int i = 1; i < m; i++){
            diff.push_back(x[i] - x[i-1]);
        }
        sort(diff.begin(), diff.end());
        for(int i = 0; i < m - n; i++){
            ans += diff[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vp a;

int main(){
	cin>>n;
	a=vp(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		if(a[n-1].second==i) cout<<a[n-2].first<<endl;
		else cout<<a[n-1].first<<endl;
	}
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

signed main() {
	rep(i,3) {
		cin >> s;
		cout << s[i];
	}
	cout << ln;
}

Measured memory_bytes: 256
SHIFT = 1 << 20


def main():
    N, Q = (int(i) for i in input().split())
    C = [int(i) for i in input().split()]
    Query = []
    for j in range(Q):
        le, ri = (int(i) for i in input().split())
        Query.append(ri << 40 | le << 20 | j)
    Query.sort()

    # Query復元
    for i in range(Q):
        j = Query[i] % (SHIFT)
        Query[i] >>= 20
        le = Query[i] % (SHIFT)
        Query[i] >>= 20
        ri = Query[i]
        Query[i] = (le, ri, j)
    Query.append((-1, -1, -1))

    def sum(tree, i):
        s = 0
        while i > 0:
            s += tree[i]
            i -= i & -i
        return s

    def add(tree, i, x):
        while i <= N:
            tree[i] += x
            i += i & -i

    lastappend = [-1] * (N + 1)
    bit = [0] * (N + 1)
    idx = 0  # Queryのindex
    ans = [0]*Q

    for i, a in enumerate(C, start=1):
        if lastappend[a] != -1:
            add(bit, lastappend[a], -1)
        lastappend[a] = i
        add(bit, i, 1)
        while i == Query[idx][1]:
            (le, ri, j) = Query[idx]
            ans[j] = sum(bit, ri) - sum(bit, le-1)
            idx += 1

    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e5 + 5;

int n , a[maxn] , b[maxn];
int c[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i];
    for(int i = 1 ; i <= n ; ++i){
        cin >> b[i];
        b[i] = a[i] - b[i];
    }
    sort(b + 1 , b + n + 1);
    int cnt = 0;
    int fn = n;
    for(int i = 1 ; i <= n ; ++i)
    {
        if(b[i] >= 0)continue;
        c[i] = 1;
        while(fn > 0 && b[i] < 0 && b[fn] > 0)
        {
            int can = min(-b[i] , b[fn]);
            if(can < 0)continue;
            b[i] += can;
            b[fn] -= can;
            if(b[fn] == 0)fn--;
            c[fn] = 1;
        }
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        if(b[i] < 0)
        {
            return cout << -1 , 0;
        }
        cnt += c[i];
    }
    cout << cnt;

}


Measured memory_bytes: 1408
n, m = map(int, input().strip().split())
ab_list = [list(map(int, input().strip().split())) for _ in range(m)]
ab_list.sort(key=lambda x: x[1])

res = 0
min_r = 0
for ab in ab_list:
    if min_r <= ab[0]:
        res += 1
        min_r = ab[1]
print(res)


Measured memory_bytes: 28544
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = long.Parse(nm[0]);
        var m = long.Parse(nm[1]);
        var h = (from x in Console.ReadLine().Split(' ') select long.Parse(x)).ToArray();
        var way = new List<long>[n];

        for(var i = 0; i < n; i++)
        {
            way[i] = new List<long>();
        }

        for (var i = 0; i < m; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = long.Parse(ab[0]) - 1;
            var b = long.Parse(ab[1]) - 1;

            way[a].Add(b);
            way[b].Add(a);
        }

        var cnt = 0L;

        for (var i = 0; i < n; i++)
        {
            var me = h[i];
            var flag = true;
            foreach(var next in way[i])
            {
                if (h[next] >= me) flag = false;
            }
            if (flag) cnt++;
        }

        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 43492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((max(a,c)-min(a,c))<=d){
    cout << "Yes" << endl;
  }
  else if((max(a,b)-min(a,b))<=d&&(max(c,b)-min(c,b))<=d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int leftmax[n];
    int rightmax[n];
    leftmax[0]=0;
    rightmax[n-1]=0;
    for(int i=1;i<n;i++)
        leftmax[i]=max(leftmax[i-1],arr[i-1]);
    for(int i=n-2;i>=0;i--)
        rightmax[i]=max(rightmax[i+1],arr[i+1]);

    for(int i=0;i<n;i++)
        cout<<max(leftmax[i],rightmax[i])<<endl;
}

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

using namespace std;

int main(void) {
  string s, t;
  cin >> s >> t;

  vector<string> v;
  int sz = s.size(), tz = t.size();
  for (int i = 0; i < sz - tz + 1; i++) {
    bool flag = true;
    for (int j = 0; j < tz; j++) {
      flag &= (s[i + j] == '?' || s[i + j] == t[j]);
    }

    if (!flag) continue;
    string ss = s;
    for (int j = 0; j < sz; j++) {
      if (j < i && s[j] == '?') ss[j] = 'a';
      if (i <= j && j < i + tz) ss[j] = t[j - i];
      if (i + tz <= j && s[j] == '?') ss[j] = 'a';
    }
    v.push_back(ss);
  }
  sort(v.begin(), v.end());

  cout << (v.size() ? v[0] : "UNRESTORABLE") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sum1,sum2,min,n;


void rec(int,int data[],int s[]);
int sa(int,int);

void rec(int p, int data[], int s[]){
  if(p==n){
    if(min>sa(sum1,sum2))
      min=sa(sum1,sum2);
    return;
  }


  s[p]=1;
  sum1+=data[p];
  rec(p+1,data,s);
  sum1-=data[p];
  s[p]=2;
  sum2+=data[p];
  rec(p+1,data,s);
  sum2-=data[p];
}


int sa(int a, int b){
  if(a>=b) return (a-b);
  else return (b-a);
}

main(){
  int i,data[20],s[20],a,sum;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    sum2=0;
    for(i=0;i<n;i++){
      scanf("%d", &data[i]);
      s[i]=2;
      sum2+=data[i];
    }

    sum1=sum2=0;
    min=1000001;
    rec(0,data,s);

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

Measured memory_bytes: 408
#include <bits/stdc++.h>
using namespace std;
int main(){
 int k;
 string s;
 cin >>k >> s;
 if(s.length() <= k){
 	cout<<s<<"\n";
 }
 else {
 	string str = "";
 	for(int i=0;i<k;i++){
 		str = str+s[i];
 	}
 	str += '.';
 	str += '.';
 	str += '.';
 	cout<<str<<"\n";
 }
  return 0;
	
}


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

using namespace std;

const int DR[] = {-1, 0, 1, 0};
const int DC[] = {0, -1, 0, 1};

int paint(vector<vector<int> > &field, vector<vector<int> > &visited, int r, int c, int color) {
    const int H = field.size();
    const int W = field[0].size();
    visited[r][c] = true;

    int cnt = 1;
    for(int i = 0; i < 4; ++i) {
        int nr = r + DR[i];
        int nc = c + DC[i];
        if(0 <= nr && nr < H && 0 <= nc && nc < W) {
            if(!visited[nr][nc] && field[nr][nc] == field[r][c]) cnt += paint(field, visited, nr, nc, color);
        }
    }
    field[r][c] = color;

    return cnt;
}

int main() {
    while(true) {
        int H, W, C;
        cin >> H >> W >> C;
        if(!H && !W && !C) break;

        vector<vector<int> > v(H, vector<int>(W));
        for(int i = 0; i < H; ++i) {
            for(int j = 0; j < W; ++j) {
                cin >> v[i][j];
            }
        }

        int ans = 0;
        int lim = 1;
        for(int i = 0; i < 4; ++i) lim *= 6;
        for(int pat = 0; pat <= lim; ++pat) {
            vector<vector<int> > field = v;

            int tmp = pat;
            for(int i = 0; i < 4; ++i) {
                int color = tmp%6 + 1;
                tmp /= 6;
                vector<vector<int> > visited(H, vector<int>(W, 0));
                paint(field, visited, 0, 0, color);
            }
            {
                vector<vector<int> > visited(H, vector<int>(W, 0));
                paint(field, visited, 0, 0, C);
            }
            {
                vector<vector<int> > visited(H, vector<int>(W, 0));
                ans = max(ans, paint(field, visited, 0, 0, 7));
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 916
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define REP(i,m,n) for(i=(m);i<((int)(n));i++)
#define rep(i,n) REP(i,0,n)
#define INFTY (1<<21)
#define LLINFTY (1LL<<53)
typedef long long ll;
typedef unsigned long long ull;
int n,a[20],res;
int ab(int n){return n<0?-n:n;}
inline int min(int a,int b)
{
  return a<b?a:b;
}
void solve(int p,int x,int y)
{
  if(p==n){
    res=min(res,ab(x-y));
    return;
  }
  solve(p+1,x+a[p],y);
  solve(p+1,x,y+a[p]);
}
int main(void)
{
  int i;
  for(;;){
    scanf("%d",&n); if(!n)break;
    rep(i,n) scanf("%d",a+i);
    res=INFTY;
    solve(0,0,0);
    printf("%d\n",res);
  }
  return 0;
}

Measured memory_bytes: 412
import sys

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

A, B, C = map(int, read().split())

for t in range(1000):
    if A & 1 or B & 1 or C & 1:
        break
    A, B, C = A // 2, B // 2, C // 2
    A, B, C = B + C, C + A, A + B

t = -1 if t > 100 else t
print(t)

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
// Seiranchan!
    int x1,y1,x2,y2;
    cin >> x1 >> y1>>x2>>y2;

    int X = x2-x1;
    int Y = y2-y1;

    int x3,y3,x4,y4;

    x3 = x2 -Y;
    y3 = y2 +X;
    x4 = x3 -X;
    y4 = y3 -Y;

    cout << x3 << " " <<y3<<" "<<x4<<" " << y4<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<vector<int>> G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> ans(n);
  auto bfs = [&]() {
    queue<int> q;
    vector<bool> vis(n);
    vector<int> d(n, inf);
    q.push(0);
    d[0] = 0;
    while(!q.empty()) {
      int cur = q.front(); q.pop();
      if(vis[cur]) continue;
      vis[cur] = true;
      for(int ne: G[cur]) {
        if(vis[ne]) continue;
        if(d[ne] > d[cur]+1) {
          d[ne] = d[cur]+1;
          ans[ne] = cur;
          q.push(ne);
        }
      }
    }
  };
  bfs();
  cout << "Yes\n";
  rep(i, n) if(i) cout << ans[i]+1 << endk;
  return 0;
}


Measured memory_bytes: 10664
#include <iostream>  
#include <map>  
#include <set>  
#include <string>  
#include<string.h>  
#include <cstring>  
#include <cstdio>  
#include <algorithm>  
#include <cmath>  
#include <queue>  
#include <vector>  
using namespace std;  
typedef long long ll;  
const int maxn=55;  
char mp[maxn][maxn];  
int f[maxn][maxn];  
int main(){  
    int h,w;  
    scanf("%d%d",&h,&w);  
    memset(f,0,sizeof(f));  
    for(int i=0;i<h;i++){  
        scanf("%s",mp[i]);  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#'){  
                if(i-1>=0){  
                    f[i-1][j]++;  
                }  
                if(j-1>=0){  
                    f[i][j-1]++;  
                }  
                if(i+1<h){  
                    f[i+1][j]++;  
                }  
                if(j+1<w){  
                    f[i][j+1]++;  
                }  
                if(i-1>=0&&j-1>=0){  
                    f[i-1][j-1]++;  
                }  
                if(i+1<h&&j-1>=0){  
                    f[i+1][j-1]++;  
                }  
                if(i-1>=0&&j+1<w){  
                    f[i-1][j+1]++;  
                }  
                if(i+1<h&&j+1<w){  
                    f[i+1][j+1]++;  
                }  
            }  
        }  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#') printf("#");  
            else printf("%d",f[i][j]);  
        }printf("\n");  
    }  
    return 0;  
}  

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

const int N = 1000005;

int k, n;
int a[N];

int solve() {
  scanf("%d %d", &k, &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

  int ans = a[n-1] - a[0];
  for (int i = 1; i < n; ++i) ans = min(ans, k - (a[i] - a[i-1]));
  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    s = input()

    ans = 0

    for i in range(10):
        a = s.find(str(i))
        if a == -1:
            continue
        for j in range(10):
            b = s.find(str(j), a + 1)
            if b == -1:
                continue
            for k in range(10):
                c = s.find(str(k), b + 1)
                if c == -1:
                    continue
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9104
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

// #define fio                           \
//     ios_base::sync_with_stdio(false); \
//     cin.tie(Nll);                    \
//     cout.tie(Nll);
#define ll long long
// // #define ll unsigned long long
// #define ll long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    // fio;
    ll t, c, p, a, n, q, k, i, l, m, u, f, j, x, y, b, d;
cin>>a;
if(a)cout<<0;
else cout<<1;

    return 0;
}




Measured memory_bytes: 3684
#include<bits/stdc++.h>
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 < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int A, B;
  char c;
  cin >> A >> c >> B;
  if(c=='+'){
    cout << A + B << endl;
  }else{
    cout << A - B << endl;
  }
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

    vector<int> Num(n, -1);
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        if (Num[s - 1] == -1 or Num[s - 1] == c) {
            Num[s - 1] = c;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (Num[0] == 0) {
        if (n != 1) {
            cout << -1 << endl;
            return 0;
        }
    } else if (Num[0] == -1) {
        if (n != 1)
            Num[0] = 1;
        else
            Num[0] = 0;
    }

    rep(i, n) {
        if (Num[i] == -1) { Num[i] = 0; }
    }

    int mul = 1;
    int ans = 0;
    rep(i, n) {
        ans += Num[n - i - 1] * mul;
        mul *= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
 
n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())
 
LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)
 
C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])
 
for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)

Measured memory_bytes: 106824
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

///ifstream fin("input.txt");
///ofstream fout("output.txt");


bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}

bool cmp(int x, int y)
{
	return x>y;
}



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
	ll r,d,x;
	cin >> r >> d >> x;
	for (int i=0;i<10;i++)
    {
        x=r*x-d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]

l_list = [0] * m
r_list = [0] * m
for i in range(m):
    l_list[i], r_list[i] = [int(x) for x in input().split()]

print(max(min(r_list) - max(l_list) + 1, 0))

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
int util(vector<int> adj[],int s,int dp[])
{
    if(dp[s]!=-1)
        return dp[s];
    if(adj[s].size()==0)
        return 0;
    int m=0;
    for(auto it=adj[s].begin();it!=adj[s].end();++it)
    {
        m=max(m,1+util(adj,*it,dp));
    }
    return dp[s]=m;
}
int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	vector<int> adj[n];
	int a,b;
	for(int i=0;i<m;i++)
	{
	    cin>>a>>b;
	    adj[a-1].push_back(b-1);
	}
	int max_c=0;
	int dp[n];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
	        int c=util(adj,i,dp);
	        max_c=max(max_c,c);
	}
	cout<<max_c<<endl;
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
#define in(A, n)                                                                                                       \
    rep(i, n) {                                                                                                        \
        cin >> f;                                                                                                      \
        A.push_back(f);                                                                                                \
    }

void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
void input() { cin >> n; }
void solve() {
    mint a = 1, b = 1, c = 1;
    rep(i, n) {
        a *= 10;
        b *= 9;
        c *= 8;
    }

    print((a + c - b - b).a);
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3652
import java.util.*

fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map { it.toInt() }

    val g = mutableMapOf<Int, MutableList<Int>>()
    repeat(n - 1) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        g.getOrPut(a) { mutableListOf() }.add(b)
        g.getOrPut(b) { mutableListOf() }.add(a)
    }

    val cnt = IntArray(n + 1)
    repeat(q) {
        val (p, x) = readLine()!!.split(' ').map { it.toInt() }
        cnt[p] += x
    }

    val stack = ArrayDeque<Pair<Int, Int>>()
    stack.addLast(1 to 0)

    while (stack.isNotEmpty()) {
        val (v, p) = stack.removeLast()
        for (u in g[v]!!) {
            if (u == p) continue
            cnt[u] = cnt[v] + cnt[u]
            stack.addLast(u to v)
        }
    }

    println(cnt.slice(1..n).joinToString(" "))
}


Measured memory_bytes: 171928
import java.util.*;
public class Main{
    final static int LineN=3;
    final static int FullN=9;
    final static int[] dx={-1,0,1,0};
    final static int[] dy={0,-1,0,1};
    final static long Goalhash=1234567890;
    final static String[] dir={"u","l","d","r"};//up left down right
    static Queue<Puzzle> que= new ArrayDeque<Puzzle>();
    static Map<Long,Puzzle> mp= new LinkedHashMap<Long,Puzzle>(16,0.75f,true);
    public static void main(String[]args){
	int i;
	String path;
	Puzzle nyu= new Puzzle(FullN);
	Scanner sca = new Scanner(System.in);
	for(i=0;i<FullN;i++){
	    nyu.f[i]=sca.nextInt();
	    if(nyu.f[i]==0){
		nyu.f[i]=FullN;//0<->9
		nyu.space=i;
	    }
	}
	nyu.path="";
	path=play(nyu);
	System.out.println(path.length());
    }
    static long makemyhash(Puzzle p){
	int i;
	long ha=0;
	for(i=0;i<FullN;i++){
	    ha+=p.f[i];//making hash;
	    ha*=10;
	}
	if(p.f[0]==1&&p.kotei==false)p.kotei=true;//fixing 1 to f[0]
 	return ha;
    }
    
    static String play(Puzzle first){
	int sx,sy,i,hzi,tx,ty;
	long hzhash;
	Puzzle u,v;
	que.add(first);
	mp.put(makemyhash(first),first);
	while(!que.isEmpty()){
	    u=que.poll();
	    if(makemyhash(u)==Goalhash)return u.path;
	    sx=u.space/LineN;//5->1(calculate x index of 0)
	    sy=u.space%LineN;//5->2(calculate y index of 0)
	    for(i=0;i<4;i++){
		tx=sx+dx[i];//calculate movement x
		ty=sy+dy[i];
		if(tx<0||ty<0||tx>=LineN||ty>=LineN)continue;
	      	if(tx==0&&ty==0&&u.kotei==true)continue;
		v=myclone(u);
		hzi=v.f[v.space];
		v.f[v.space]=v.f[tx*LineN+ty];//changing
		v.f[tx*LineN+ty]=hzi;
		v.space=tx*LineN+ty;
		v.hash=hzhash=makemyhash(v);
		if(mp.containsKey(hzhash)==false){
		    mp.put(hzhash,v);
		    v.path+=dir[i];//add char
		    que.add(v);
	       	}else{
		}
	    }
	}
	return "impossible";
    }
    public static Puzzle myclone(Puzzle p){
	int i;
	Puzzle im=new Puzzle(FullN);
	for(i=0;i<FullN;i++){
	     im.f[i]=p.f[i];
	}
	im.space=p.space;
	im.path=p.path;
	im.kotei=p.kotei;
      	im.hash=p.hash;
	return im;
    }
}
class Puzzle{
     public int f[];
     public int space;
     public String path;
    public long hash;
    public boolean kotei=false;
    Puzzle(int n){
	f=new int[n];
    }
}


Measured memory_bytes: 99728
x1, y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (y3-y2)
y4 = y3 + (x3-x2)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    vector<int> v;v.clear();
    v.push_back(0);
    int i,j,k;
    int ans=0;
    for(i=0;i<n;i++){
      cin >>k;
      v.push_back(k);
    }
    for(i=0;i<m;i++){
      cin >>k;
      v.push_back(k);
    }
    sort(v.begin(),v.end());
    for(i=0;i<n+m;i++) ans=max(ans,v[i+1]-v[i]);
    cout << ans << endl; 
  }
  return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int ans = 1e9;
	for (int cur = -100; cur <= 100; cur++) {
		int tmp = 0;
		for (auto&& x : a)tmp += (x - cur) * (x - cur);
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
S = list(input())

check_odd = ["R", "U", "D"]
check_even = ["L", "U", "D"]


def Odd():
    for i in S[0::2]:
        if i not in check_odd:
            return True
            break


def Even():
    for j in S[1::2]:
        if j not in check_even:
            return True
            break


if Odd() or Even():
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n,a[100003];
long long ans;

int main() {
    while(1==scanf("%d",&n)) {
        for(int i=1;i<=n;++i) {
            scanf("%d",a+i);
        }
        a[0]=-0x3f3f3f3f;
        ans=0;
        for(int i=n;i>0;--i) {
            ans+=a[i]/2;
            a[i]&=1;
            if(a[i]==1&&a[i-1]>0) {
                ++ans;
                --a[i-1];
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
height = list(map(int,input().split()))
path = [[]for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    path[a] += [b]
    path[b] += [a]
ans=0
for i in range(1,n+1):
    nice = True
    for j in path[i]:
        if height[i-1]<=height[j-1]:
            nice = False
    if nice:
        ans+=1
print(ans)

Measured memory_bytes: 93040
def calc_sum_digits(n):
    sumdigit = 0
    while n > 0:
        sumdigit += n % 10
        n //= 10
    return sumdigit

N, A, B = map(int, input().split())
result = 0
for n in range(1, N+1):
    sumdigit = calc_sum_digits(n)
    if sumdigit >= A and sumdigit <= B:
        result += n
print(result)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int a,b,c;
    int ans[2]={0,0};
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;++i) {
        int l=0,r=0;
        vector<int> a(10);
        for(auto&e:a) {
            scanf("%d",&e);
        }
        int f=1;
        for (int j=0;j<10;++j) {
            if (j==0) l=a[0];
            else if (a[j]<l && a[j]<r) {
                f=0;
                printf("NO\n");
                break;
            } else if (a[j]>l && a[j]<r) {
                l=a[j];
            } else if (a[j]<l && a[j]>r) {
                r=a[j];
            } else if ((a[j]-l)>(a[j]-r)) {
                r=a[j];
            } else {
                l=a[j];
            }
        }
        if (f) printf("YES\n");
    }
    return 0;
}

Measured memory_bytes: 3148
#include <unistd.h>
#include <stdlib.h>

char    *create_array(char *s, char *new_arr, char *t, int size)
{
	int i;
	int j;

	i = -1;
	while (s[++i])
		new_arr[i] = s[i];
	free(s);
	j = 0;
	while (j < size)
		new_arr[i++] = t[j++];   
	new_arr[i] = 0;
	return (new_arr);
}

char    *get_data(char *s)
{
	int     size;
	int     sum_size;
	char    t[1000];
	char    *new_arr;

	sum_size = 0;
	while ((size = read(0, t, 1000)))
	{
		if (size == -1)
			return (NULL);
		sum_size += size;
		if (!(new_arr = (char*)malloc(sum_size + 1)))
			return (NULL);
		s = create_array(s, new_arr, t, size);
	}
	return (s);
}

void    write_num(int num)
{
	char c;

	if (num < 10)
	{
		c = num + '0';
		write(1, &c, 1);
	}
	else
	{
		write_num(num / 10);
		write_num(num % 10);
	}
}

int     get_num(char *s, int pass_flag)
{
	int i;
	int num;
	int count;
	
    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (s[i++] != 10)
			;
	num = 0;
	while ('0' <= s[i] && s[i] <= '9')
		num = num * 10 + s[i++] - '0';
	return (num);
}

void    get_nums(int *array, char *s, int count)
{
	int num;
	int i;

	i = -1;
	while (s[++i] != 10)
	{
		if (s[i] != 32)
		{
			num = 0;
			while ('0' <= s[i] && s[i] <= '9')
			{
				num = num * 10 + s[i++] - '0';
				if (!s[i])
				{
					array[count] = num;
					return ;                    
				}
			}
			array[count++] = num;
			i--;
		}
	}  
}

void    get_nums_pass(int *nums, char *tmp, int pass_flag)
{
	int i;
	int count;

    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	get_nums(nums, &tmp[i], 0);
}

void	ft_swap(int *a, int *b)
{
    int tmp;
    
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void    get_ans(int *nums, int n)
{
	int i;
	int j;
    int ans;
    
    ans = 0;
	i = -1;
	while (++i < n)
	{
		j = i;
		while (++j < n)
		    if (nums[i] < nums[j])
			    ft_swap(&nums[i], &nums[j]);
		if (i % 2 == 0)
			ans += nums[i];
		else
		    ans -= nums[i];
		    				
	}
	write_num(ans);
}

int     main(void)
{
	char    *s;
	int     n;
	int     *nums;

	s = malloc(1);
	if (!(s = get_data(s)))
	    return (-1);
	n = get_num(s, 0);
	nums = (int*)malloc(sizeof(int) * n);
	get_nums_pass(nums, s, 1);
	get_ans(nums, n);
	free(s);
	free(nums);
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    long double A;
    long double B;
    cin >> A >> B;
    long double C=A*B;
    ll D=floorl(C);
    cout << D << endl;

    return 0;
}




Measured memory_bytes: 3784
import sys
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K = I()

q = K//50
p = K%50

ans = [i+q for i in range(50)]
left = 50-p
for i in range(left,50):
  ans[i] += 1

print(50)
print(" ".join(map(str, ans)))

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int cnt[int(1e5+5)];

bool Prime(int num){
  if (num == 1) return false;
  for (int i = 2; i * i <= num; i++){
    if (num % i == 0) return false;
  }
  return true;
}

int main(){
  for (int i = 1; i <= int(1e5); i++){
    cnt[i] = cnt[i-1];
    if (Prime(i) && Prime((i+1)/2) && i%2!= 0) cnt[i]++;
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int L, R; cin >> L >> R;
    cout << cnt[R] - cnt[L - 1] << endl;
  }


  return 0;
}


Measured memory_bytes: 4028
#include <iostream>

using namespace std;

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

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

  int count = 0;
  for (int i = 0; i < n; i++) {
    int item = a[i];
    for (int j = 0; j < 30; j++) {
      if (item % 2 == 0) {
        count++;
        item /= 2;
      }
      else {
        break;
      }
    }
  }

  cout << count << endl;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        set<char> s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        if (s.size() == 3) ans += 2;
        if (s.size() == 2) ans += 1;
    }
    cout << ans << endl;

}


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

int main() {
    ll a, b, c; cin >> a >> b >> c;
    if(c-a-b<0) cout << "No" << endl;
    else if(a*b*4 < (c-a-b) * (c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;    
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
S = sum(A)
cnt = 0
for i in range(M):
    if (A[i] < S/(4*M)):
        cnt += 1
if (cnt>=1):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b,c,d,t;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	t=max(min(b,d)-max(a,c),0);
	printf("%d\n",t);
}


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

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

    vector<int> mod(3100);
    for(int i=0;i<N;i++){
        cin >> mod[i];
    }
    sort(mod.rbegin(),mod.rend());
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=mod[i]-1;
    }
    cout << ans << endl;
   
}

Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7

if N<K:
    print(0)
    exit()

D = [[0]*(K+1) for i in range(N+1)]
D[0][0] = 1

# nはn個のボールをいれるのを1から順番に考える
for n in range(1, N+1):
    D0 = D[n-1]
    # kはkこの箱にnこれいた場合の数
    for k in range(1, K+1):
        # 前回D[n-1][k-1]はk-1個の箱にn-1個入れてるので、それにn個めを新しい箱に入れるとD0[k-1]を足すことになる
        # 前回D[n-1][k-1]はk-1個の箱にn-1個入れてて、それぞれにn個めを1個足してくとそのパターンはk*D0[k]個ある
        # 頭ヨ
        D[n][k] = (D0[k-1] + k * D0[k]) % MOD
print(D[N][K] % MOD)


Measured memory_bytes: 29212