akhauriyash/Code-Regression huggingface dataset:
import numpy as np

n = int(input())
a = np.array(input().split(), np.int64)


def check(x):
    cnt = np.maximum((a + x + 1) // (n + 1), 0)
    return cnt.sum() <= x


l = -1
r = 10 ** 18

while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m

for i in range(max(r - (n - 1) * n, 0), r + 1):
    if check(i):
        print(i)
        exit()


Measured memory_bytes: 12504
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = 302;
const int mod = int(1e9 + 7);

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int mul(int x, int y) {return 1ll * x * y % mod;}

int f[N][N][N], n, m;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m; f[0][1][1] = 1;
    /// f(length, visited vertex, size of component)
    for(int i = 0; i < m; ++i) {
        for(int j = 1; j <= n; ++j) {
            for(int k = 1; k <= n; ++k) {
                if(f[i][j][k] == 0) continue;
                add(f[i + 1][j][k], mul(f[i][j][k], j - k));
                add(f[i + 1][j][j], mul(f[i][j][k], k));
                if(j < n) add(f[i + 1][j + 1][k], mul(f[i][j][k], n - j));
            }
        }
    }
    cout << f[m][n][n];
}


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

using namespace std;

int n;
int a[2019], b[2019];
string s;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    long long Ans = 0;
    for (char ch:s)
    {
        int x = ch - '0';
        b[x]++;
        for (int i = 0; i < 2019; i++)
        {
            b[(i * 10 + x) % 2019] += a[i];
        }
        Ans = Ans + b[0];
        for (int i = 0; i < 2019; i++)
        {
            a[i] = b[i];
            b[i] = 0;
        }
    }
    cout << Ans;
    return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    if(A==1 & B ==2){
        cout << 3 <<endl;
    }else if(A==1 & B ==3){
        cout << 2 <<endl;
    }else if(A ==2 & B ==1){
        cout << 3 <<endl;
    }else if(A ==2 & B ==3){
        cout << 1 <<endl;
    }else if(A==3 & B ==1){
        cout << 2 <<endl;
    }else if(A==3 & B ==2){
        cout << 1 << endl;
    }

}

Measured memory_bytes: 256
N = int(input())
X = [];L =[]
for i in range(N):
  x,l = map(int,input().split())
  X.append(x);L.append(l)
#print(X,L)
Y = []
for i in range(N):
  a = X[i]-L[i];b=X[i]+L[i]
  Y.append([a,b])
#print(Y)
Y.sort(key=lambda x : x[1])
ans = 0
end = - float("inf")
for i in range(N):
  if end > Y[i][0]:
    continue
  ans += 1
  end = Y[i][1]
print(ans)


Measured memory_bytes: 100168
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        label:
        ReadLine();
        WriteLine(ReadLine().Split().Select(Parse).Min(hoge));
        //goto label;
    }

    static int hoge(int c)
    {
        int result = 0;
        while (c % 2 == 0)
        {
            c /= 2;
            ++result;
        }
        return result;
    }
}


Measured memory_bytes: 13396
#include<stdio.h>

int main(void){
	char c;
	scanf("%s",&c);
	if(c=='a'){
		printf("b");
	}else if(c=='b'){
		printf("c");
	}else if(c=='c'){
		printf("d");
	}else if(c=='d'){
		printf("e");
	}else if(c=='e'){
		printf("f");
	}else if(c=='f'){
		printf("g");
	}else if(c=='g'){
		printf("h");
	}else if(c=='h'){
		printf("i");
	}else if(c=='i'){
		printf("j");
	}else if(c=='j'){
		printf("k");
	}else if(c=='k'){
		printf("l");
	}else if(c=='l'){
		printf("m");
	}else if(c=='m'){
		printf("n");
	}else if(c=='n'){
		printf("o");
	}else if(c=='o'){
		printf("p");
	}else if(c=='p'){
		printf("q");
	}else if(c=='p'){
		printf("q");
	}else if(c=='q'){
		printf("r");
	}else if(c=='r'){
		printf("s");
	}else if(c=='s'){
		printf("t");
	}else if(c=='t'){
		printf("u");
	}else if(c=='u'){
		printf("v");
	}else if(c=='v'){
		printf("w");
	}else if(c=='w'){
		printf("x");
	}else if(c=='x'){
		printf("y");
	}else if(c=='y'){
		printf("z");
	}
	return 0;
}


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

using namespace std;

int main() {

    int n;
    cin >> n;
    
    string s = to_string(n);
    int s_num = 0;
    for (int i=0; i < s.size(); i++) {
        s_num += stoi(s.substr(i, 1));
    }

    if (n % s_num == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int n;
vi d(52);

bool dfs(vi d2, int s, int x) {
	if (s == n + 1) {
		return true;
	}
	int d0 = d[s - 1];
	bool flag = true;
	for (int i = 0; i < s; i++) {
		if (min(abs(d2[i] - d0), 24 - abs(d2[i] - d0)) < x) {
			flag = false;
			break;
		}
	}
	if (flag) {
		d2[s] = d0;
		if (dfs(d2, s + 1, x)) {
			return true;
		}
	}
	d0 = 24 - d[s - 1];
	flag = true;
	for (int i = 0; i < s; i++) {
		if (min(abs(d2[i] - d0), 24 - abs(d2[i] - d0)) < x) {
			return false;
			break;
		}
	}
	if (flag) {
		d2[s] = d0;
		if (dfs(d2, s + 1, x)) {
			return true;
		}
		else {
			return false;
		}
	}
}

int main() {
	int i, j;
	cin >> n;
	d.resize(n);
	for (i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int left = 0, right = 13;
	while (left + 1 < right) {
		int mid = (left + right) / 2;
		vi d2(n + 1);
		d2[0] = 0;
		bool flag = dfs(d2, 1, mid);
		if (flag) {
			left = mid;
		}
		else {
			right = mid;
		}
	}
	cout << left << endl;
}

Measured memory_bytes: 256
inputs = list(map(int, list('1222')))
target = 7


def prepare():
    global inputs
    inputs = list(map(int, list(input())))


def dfs(depth, value, form):
    if depth == len(inputs):
        if value == target:
            return True, form + '=' + str(target)
        else:
            return False, form

    result1, form1 = dfs(depth + 1, value + inputs[depth],
                         (form + '+'
                          if depth > 0 else '') + str(inputs[depth]))
    if result1 is True:
        return result1, form1

    result2, form2 = dfs(depth + 1, value - inputs[depth],
                         (form + '-'
                          if depth > 0 else '') + str(inputs[depth]))
    if result2 is True:
        return result2, form2

    return False, ''


def solve():
    result, form = dfs(0, 0, '')
    if result is True:
        print(form)


prepare()
solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
int main(){
	scanf("%lld %lld %lld",&a,&b,&k);
	if(a>=k){
		printf("%lld %lld\n",a-k,b);
	}else if(b>=(k-a)){
		printf("%lld %lld\n",0,b-(k-a));
	} else{
		printf("0 0\n");
	}
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int parent(int);
int left(int);
int right(int);
int main(){
  int i,n;
  scanf("%d",&n);
  int H[n];
  for(i=0;i<n;i++){
    scanf("%d",&H[i]);
  }
  for(i=0;i<n;i++){
    printf("node %d: key = %d, ",i+1,H[i]);
    if(i!=0)printf("parent key = %d, ",H[parent(i+1)-1]);
    if(2*(i+1)<=n)printf("left key = %d, ",H[left(i+1)-1]);
    if(2*(i+1)+1<=n)printf("right key = %d, ",H[right(i+1)-1]);
    printf("\n");
  }
  return 0;
}
int parent(int k){
  return (int)((double)k/(double)2);
}
int left(int k){
  return 2*k;
}
int right(int k){
  return 2*k+1;
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>

using namespace std;

int h;
int field[15][5];
int changed[15][5];
int main(){
	while(1){
		int ans=0;
		cin >>h;
		if(h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				cin >> field[i][j];
			}
		}
		for(int i=0;i<15;i++){
			for(int j=0;j<5;j++){
				changed[i][j]=0;
			}
		}
		int b=0;
		while(1){
			b++;
			bool ok=true;
			for(int i=h-1;i>=0;i--){
				for(int j=0;j<3;j++){
					if(field[i][j]==field[i][j+1]&&field[i][j]>0){
						int cnt=0;
						int copy=field[i][j];
						while(copy==field[i][j]&&j<5){
							cnt++;
							j++;
						}
						if(cnt>2){
							j-=cnt;
							for(int k=j;k<5;k++){
								if(copy==field[i][k]){
									changed[i][k]=1;
								}
								else break;
							}
							j+=cnt;
						}
						j--;
					}
				}
			}
			for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				if(changed[i][j]==1){
					ok=false;

						ans+=field[i][j];
						for(int k=i;k>0;k--){
							field[k][j]=(field[k-1][j]>0?field[k-1][j]:-1);
							
						}
						field[0][j]=0;
				
				}
			}
		}
		for(int i=0;i<12;i++){
			for(int j=0;j<5;j++){
				changed[i][j]=0;
			}
		}
		if(ok)break;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, a, b, c);
  ll d = c - a - b;
  if (d > 0 && d * d > 4 * a * b) {
    print("Yes");
  } else {
    print("No");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
     ll n ; cin >> n;
     ll ans = 1e13;
     for(ll i =1 ; i*i<=n ; i++){
     	if(n%i==0){
     		ans = min(ans,((i-1)+ ((n/i)-1)));
		 }
	 }
	 cout << ans << endl;
}

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

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



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b, c;
	int Q, W;
	cin >> a >> b >> c;
	Q = b - a;	W = c - b;
	if (Q == W)
	{
		cout << "YES \n";
	}
	else {
		cout << "NO \n";
	}

}

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

int main()
{
	string s;
	int sum=0;
	cin>>s;
	for(int i=0; i<s.size(); i++)
		sum+=s[i]-'0';
	if(sum%9==0)	cout<<"Yes";
	else	cout<<"No";
	return 0;
}

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

using namespace std;

int main()
{
	string set;
	int num;

	vector<string>namelist;
	map<string,int>P;
	map<string,int>count;

	int numberlist[1000][101]={};
	int i=0,j=0,k=0,l=0;

	while(cin >> set >> num)
	{
		if(!P[set])
		{
			i++;
			namelist.push_back(set);
			P[set]=i;
		}
		numberlist[P[set]][count[set]]=num;
		count[set]++;
	}

	for(j=0;j<i;j++)
	{

		for(k=j;k<i;k++)
		{
			if(namelist[j]>namelist[k])
			{
				swap(namelist[j],namelist[k]);
			}
		}
	}
	for(j=0;j<i;j++)
	{
		for(k=0;k<count[namelist[j]];k++)
		{
			for(l=k;l<count[namelist[j]];l++)
			{
				if(numberlist[P[namelist[j]]][k]>numberlist[P[namelist[j]]][l])
					swap(numberlist[P[namelist[j]]][k],numberlist[P[namelist[j]]][l]);
			}
		}
	}

	for(j=0;j<i;j++)
	{
		cout << namelist[j] << endl;
		for(k=0;k<count[namelist[j]];k++)
		{
			cout << numberlist[P[namelist[j]]][k];
			if(k!=count[namelist[j]]-1)cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1632
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

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

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long maxi = Integer.MAX_VALUE;
        long mod = (long) (1e9 + 7);
        int n;
        char c[];
        int d;

        void solve() {
            c = sc.sn().toCharArray();
            n = c.length;
            d = sc.ni();
            fill();
            out.println((digit(0, 0, 0)%mod - 1%mod+mod)%mod);
        }

        long dp[][][] = new long[10001][2][101];

        void fill() {
            for (int i = 0; i < 10001; i++) {
                for (int j = 0; j < 2; j++)
                    for (int k = 0; k < 101; k++)
                        dp[i][j][k] = -1;
            }
        }

        long digit(int i, int t, int r) {
            if (i == n) {
                if (r == 0)
                    return 1l;
                return 0l;
            }
            if (dp[i][t][r] != -1)
                return dp[i][t][r];
            int limit = (t == 1) ? 9 : (c[i] - '0');
            long res = 0;
            for (int j = 0; j <= limit; j++) {
                int cur = t;
                if (j < (c[i] - '0'))
                    cur = 1;
                res = (res + digit(i + 1, cur, (r + j) % d)) % mod;
            }
            return dp[i][t][r] = res % mod;
        }
    }
}


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

int main() {
  ll n, k;
  ll mod = 1e9 + 7;
  cin >> n >> k;
  ll ans = 0;
  for (ll i = k; i <= n + 1; i++) {
    ll maxi = (n + n - (i - 1)) * i / 2;
    ll mini = (0 + i - 1) * i / 2;
    ans += (maxi - mini + 1);
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void)
{

	int a;
	cin >> a;
	int hour = a / 3600;
	a -= hour * 3600;
	int sec = a / 60;
	a -= sec * 60;
	cout << hour << ":" << sec << ":" << a << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <string.h> // strmcp(s1, s2)
// contoh soal menggunakan switch case
// 1. scan semua input
// 2. cari jumlah ac, wa, tle, re
//strcmp membandingkan apakah str 1 dgn str2
int main(){
	int N, AC = 0, WA = 0, TLE = 0, RE = 0;
	scanf("%d", &N);
	
	for (int i =0; i<N; i++){
		char str[10];
		scanf("%s", str);
		
		if(strcmp (str, "AC") == 0) {
		AC++;
		} else if(strcmp (str, "WA") == 0) {
		WA++;
	}else if(strcmp (str, "TLE") == 0) {
		TLE++;
	}else if(strcmp (str, "RE") == 0) {
		RE++;
	}
	}
    printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
  	printf("TLE x %d\n",TLE);
  	printf("RE x %d\n", RE);	
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int h,n;
       cin>>h>>n;
       int sum = 0;
       int x;
       rep(i,0,n)
       {
           cin>>x;
           sum+=x;
       }
       if(sum>=h)
        cout<<"Yes"<<el;
       else
        cout<<"No"<<el;
    }
   return 0;
}


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


int main(){


    long long n, i, t, u, d;

    long long k = 0;

    vector<long long> a;

    vector<long long> b;

    vector<long long> c;

 
    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         a.push_back(t);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         b.push_back(t);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         c.push_back(t);

         }


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

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

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


    for( i = 0 ; i < n ; i = i + 1 ){

         u = lower_bound( a.begin(), a.end(), b.at(i) ) - a.begin();

         d = c.end() - upper_bound( c.begin(), c.end(), b.at(i) );

         k += u * d;

         }


    cout << k << endl;
         

    return 0;


    }

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

vector<pair<ll, ll>> prime_factorize(ll n){
    vector<pair<ll, ll>> res;
    for(ll p = 2; p * p <= n; p++){
        if(n % p != 0) continue;
        int num = 0;
        while(n % p == 0){ num++; n /= p;}
        res.push_back(make_pair(p, num));
    }
    if(n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    ll n, p;
    cin >> n >> p;
    auto v = prime_factorize(p);
    ll ans = 1;
    for(int i = 0; i < v.size(); i++){
        if(v[i].second / n == 0) continue;
        ans *= pow(v[i].first, v[i].second / n);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    D = [0] * (k + 1)

    for i in range(1, k + 1):
        D[i] = pow(k // i, n, mod)

    for i in range(k, 0, -1):
        for j in range(2 * i, k + 1, i):
            D[i] = (D[i] - D[j]) % mod

    res = 0
    for i in range(1, k + 1):
        res = (res + D[i] * i) % mod

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11152
import sys
from itertools import permutations
 
 
def input():
    return sys.stdin.readline().strip()
 
 
def main():
    N, M, R = map(int, input().split())
 
    def warshall_floyd(d):
        # d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
 
    r = list(map(int, input().split()))
    d = [[float("inf")] * N for i in range(N)]
    for i in range(M):
        x, y, z = map(int, input().split())
        d[x - 1][y - 1] = z
        d[y - 1][x - 1] = z
    for i in range(N):
        d[i][i] = 0  # 自身のところに行くコストは０
    D = warshall_floyd(d)
    P = list(permutations(r))
    cost = float("inf")
    for p in P:
        c = 0
        for i in range(R - 1):
            c += D[p[i] - 1][p[i + 1] - 1]
        if c < cost:
            cost = c
    print(cost)
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 61532
def main():
    n = int(input())
    *a, = map(int, input().split())

    s = set(a)

    print('YES' if len(s) == n else 'NO')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 26800
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int d[5], k;
  REP(i, 5) cin >> d[i];
  cin >> k;

  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if (abs(d[i] - d[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    L = []
    L.append(2)
    L.append(1)

    while len(L) < N+1:
        L.append(sum(L[-2:]))

    print(L[N])


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>

long long int min(long long int a,long long int b)
{
    if(a<b)
        return a;
    return b;
}

int main()
{
    long long int n,a,b;

    scanf("%lld%lld%lld",&n,&a,&b);

    if ((b - a) % 2 == 0)
        printf("%lld",(b-a)/2);
    else
        printf("%lld",min(a-1,n-b)+1+(b-a-1)/2);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define MAX 36
#define N 36
int main(){
  int n,i,j,k,n1[37],n2[37],minj,tmp;
  char c1[37],c2[37],esc,l;
  int flag=0;
  scanf("%d",&n);
  if(n>N){
    end(1);
  }
  for(i=0;i<n;i++){
    scanf(" %c%d",&c1[i],&n1[i]);
    n2[i]=n1[i];
    c2[i]=c1[i];
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(n1[j]<n1[j-1]){
	tmp=n1[j];
	n1[j]=n1[j-1];
	n1[j-1]=tmp;
	
	esc=c1[j];
	c1[j]=c1[j-1];
	c1[j-1]=esc;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%c%d",c1[i],n1[i]);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
  }
  printf("Stable\n");

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(n2[j]<n2[minj]){
	minj=j;
      }
    }
    tmp=n2[i];
    n2[i]=n2[minj];
    n2[minj]=tmp;
	
    esc=c2[i];
    c2[i]=c2[minj];
    c2[minj]=esc;
  }
   for(i=0;i<n;i++){
    printf("%c%d",c2[i],n2[i]);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
    if(c1[i]!=c2[i] || n1[i]!=n2[i]){
      flag=1;
    }
   }
   if(flag==0){
     printf("Stable\n");
   }
   else if(flag==1){
     printf("Not stable\n");
   }
   return 0;
}



Measured memory_bytes: 2108
# AOJ 0150 Twin Prime
# Python3 2018.6.17 bal4u

MAX = 10000
SQRT = 100     # sqrt(MAX)

prime = [True for i in range(MAX)]
def sieve():
	for i in range(4, MAX, 2):
		prime[i] = False
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False
sieve()
while True:
	n = int(input())
	if n == 0: break
	if (n & 1) == 0: n -= 1
	while not prime[n] or not prime[n - 2]: n -= 2
	print(n-2, n)


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

const int MOD = 1000000007;

int main (){
    int n;  cin >> n;
    string s;
    cin >> s;
    if(n%2 == 1){ 
        cout << "No" << endl;
        return 0;
        }
    for(int i=0;i<n/2;i++){
        if(s.at(i) != s.at((n/2)+i)){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;

int main() {
  ll N,i,j,ans = 0;
  cin>>N;
  for (i=1;i<=N;i++) {
    j=N/i;
    ans += j*(j+1)/2*i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define int long long 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn=1e3+6;
const int mod=1e9+7;
const double pi = acos(-1.0);
int n;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	int r;
	cin>>r;
	double ans=2*pi*r;
	printf("%.2lf\n",ans);
	return 0;
} 


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define w(x) int x; cin>>x; while(x--)
#define mo 998244353
#define d arr0.size()
#define ba back()
using namespace std;
ll p=748683265;
int main(){
	ll n,m,a,sum=0;
  	cin>>n>>m;
  	f(i,0,m){
  	    cin>>a;sum+=a;
  	}
    if(sum>n){
        cout<<-1<<endl;
    }
    else{
        cout<<n-sum<<endl;
    }
  return 0;
}

Measured memory_bytes: 3680
a=input()
b=input()
l1=len(a)
l2=len(b)
if l1==l2:
  for i in range(l1):
    print(a[i]+b[i],end="")
else:
  for i in range(l2):
    print(a[i]+b[i],end="")
  print(a[-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

class Team{
public:
  int num;
  int ans;
  bool operator < (const Team &s)const{
    if(ans==s.ans) return num<s.num;
    else return ans<s.ans;
  }
};

main(){
  Team data[100000];
  int i;
  for(i=0;;i++){
    scanf("%d,%d", &data[i].num, &data[i].ans);
    if(data[i].num==0 && data[i].ans==0) break;
  }
  sort(data, data+i);
  reverse(data, data+i);
  map<int, int> ans;
  for(int j=1, k=1;j<i;j++){
    if(data[j-1].ans!=data[j].ans) ans[data[j-1].num]=k++;
    else ans[data[j-1].num]=k;
    if(j==i-1){
      ans[data[j].num]=k;
    }
  }
  int q;
  while(cin >> q){
    cout << ans[q] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int a[16][16];

int main(void)
{
    int n;
    int i, j;
    
    while (1){
        scanf("%d", &n);
        if (n == 0) break;
        a[n][n] = 0;
        for (i = 0; i < n; i++){
            a[i][n] = 0;
            for (j = 0; j < n; j++){
                scanf("%d", &a[i][j]);
                a[i][n] += a[i][j];
            }
            a[n][n] += a[i][n];
        }
        
        for (i = 0; i < n; i++){
            a[n][i] = 0;
            for (j = 0; j < n; j++){
                a[n][i] += a[j][i];
            }
        }
        
        
        for (i = 0; i <= n; i++){
            for (j = 0; j <= n; j++){
                printf("%5d", a[i][j]);
            }
            printf("\n");
        }
    }
    
    return (0);
}

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

using namespace std;

int main(){
    
    int n;
    int cnt = 0;
    vector<int> v;

    cin >> n;

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        v.emplace_back(tmp);
    }

    for(int i = 0; i < n; i++){

        int tmp = 0;

        while(v[i] % 2 == 0){
            v[i] /= 2;
            tmp++;
        }

        if(i == 0){
            cnt = tmp;
        }else{
            cnt = min(cnt, tmp);
        }
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
#from fractions import gcd
#from functools import* #reduce
#from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
#from operator import mul
#from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
#from math import factorial
#from copy import deepcopy
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)

def DIJKSTRA(point,d,n):
    cost      = {node:float("inf") for node in range(n)}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

def main():
    k=int(input())
    d=defaultdict(list)
    for i in range(k-1): #１加算をつなぐ
        d[i].append([i+1,1])
    d[k-1].append([0,1])
    for i in range(k):  #10倍をつなぐ
        d[i].append([(i*10)%k,0])
    #print(d)
    
    
    print(DIJKSTRA(1,d,k)[0]+1)

    
    
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 122840
from collections import deque
s = deque(input())
ans = 0
while len(s) > 1:
    if s[0] == s[-1]:
        s.popleft()
        s.pop()
    elif s[0] == 'x':
        ans += 1
        s.popleft()
    elif s[-1] == 'x':
        ans += 1
        s.pop()
    else:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 10328
#include <iostream>

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

    int n = (N / 7);
    bool flag = false;
    for(int i = 0;i <= n;i++){
        if(((N - 7 * i) % 4) == 0){
            flag = true;
            break;
        }
    }
    std::cout<<(flag ? "Yes" : "No")<<std::endl;
    return 0;
}

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

int main() {

  int N, K, x, l, M;
  cin >> N >> K;
  l = 0;
  M = K / 2;

  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x <= 0 || x >= K) break;
    else if (x < M) l += x;
    else if (x > M) l += K - x;
    else if (x = M) l += M;
  }

  cout << l * 2 << endl;

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
main () {
    int W, H;
    cin >> H >> W;
  
 for(int i=0;i<H+2;i++){
      if (i==0||i==H+1){
       for (int j=0;j<W+2;j++){
           cout << "#";
       }
       cout << endl;
       continue;
      }
      else { 
       string str;
       cin >> str;
       cout << "#" << str << "#" <<endl;
      }   
 } 
}

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

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

  sort(l.rbegin(), l.rend());
  int a = l[0];
  int b = 0;
  for (int i = 1; i < n; i++) {
    b += l[i];
  }
  if (a < b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Primes extends Iterable[Long] {
  var checked = 2L
  val xs: ListBuffer[Long] = ListBuffer(2L)

  /**
   * Check if n is prime number.
   *
   * @param n number
   * @return true when n is prime number
   */
  def contains(n: Long): Boolean = xs.takeWhile(_ <= n).contains(n)

  /**
   * Get i-th prime number.
   *
   * @param i index (0-)
   * @return i-th prime number
   */
  def apply(i: Int): Long = {
    while (xs.length <= i) {
      var n = checked + 1
      while (xs.takeWhile(j => j * j <= n).exists(n % _ == 0)) {
        n += 1
      }
      xs.append(n)
      checked = n
    }
    xs(i)
  }

  /**
   * Get iterator.
   *
   * @return iterator
   */
  override def iterator: Iterator[Long] = new Iterator[Long] {
    var i = 0

    override def hasNext: Boolean = true

    override def next(): Long = {
      val x = apply(i);
      i += 1;
      x
    }
  }
}

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextLong
    val B = sc.nextLong

    val ab = ArrayBuffer(1L)
    val primes = Primes.iterator
    var a = A
    var b = B
    var p = primes.next
    do {
      while (a % p == 0 && b % p == 0) {
        ab.append(p)
        a /= p
        b /= p
      }
      p = primes.next
    } while (p < a || p < b)

//    println(ab.mkString(","))
//    println("a=" + a + ", b=" + b)
    (a * b * ab.product).toString
  }
}


Measured memory_bytes: 66456
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;
	ll ans=0;
	fx(N){
		int r,l;
		cin>>l>>r;
		ans+=(r-l)+1;
	}
	ce(ans)
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 420;
const int INF = (int) 1e9;

int n;
int a[MAXN];
long long sum[MAXN];
long long dp[MAXN][MAXN];

long long getSum(int l, int r) {
  long long res = sum[r];
  if (l > 0) {
    res -= sum[l - 1];
  }
  return res;
}

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }

  for (int len = 2; len <= n; len++) {
    for (int l = 0; l + len <= n; l++) {
      int r = l + len - 1;
      dp[l][r] = 1ll * INF * INF;
      for (int i = l + 1; i <= r; i++) {
        long long x = dp[l][i - 1], y = dp[i][r];
        long long xs = getSum(l, i - 1), ys = getSum(i, r);
        dp[l][r] = min(dp[l][r], x + y + xs + ys);
      }
      // cerr << l << " " << r << " " << dp[l][r] << endl;
    }
  }

  cout << dp[0][n - 1] << endl;

  return 0;
}


Measured memory_bytes: 1536
a, b, c, x, y = [int(elem) for elem in input().split()]

res = -1
for i in range(0, 10 ** 5 + 1):
  cand = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
  if res == -1:
    res = cand
  else:
    if res > cand:
      res = cand
print(res)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int n,i,j;
	double height;
	int students[6];
	for(i = 0; i < 6; i++){
		students[i] = 0;
	}
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%lf",&height);
		if(height < 165.0){
			students[0]++;
		}else if(height < 170.0){
			students[1]++;
		}else if(height < 175.0){
			students[2]++;
		}else if(height < 180.0){
			students[3]++;
		}else if(height < 185.0){
			students[4]++;
		}else{
			students[5]++;
		}
	}
	for(i = 0; i < 6; i++){
		printf("%d:",i+1);
		for(j = 0; j < students[i]; j++){
			putchar('*');
		}
		putchar('\n');
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int d, t, s;
	cin >> d >>  t >> s;
	bool ans = false;
	if ((t * s) >= d)ans = true;
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

using namespace std;

int main() {
    int n;
    while (cin >> n && n) {
        int cost = 1000 - n;
        int n1 = cost / 500;
        cost -= 500 * (cost / 500);
        int n2 = cost / 100;
        cost -= 100 * (cost / 100);
        int n3 = cost / 50;
        cost -= 50 * (cost / 50);
        int n4 = cost / 10;
        cost -= 10 * (cost / 10);
        int n5 = cost / 5;
        cost -= 5 * (cost / 5);
        cout << n1 + n2 + n3 + n4 + n5 + cost << '\n';
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    rep0(i, h){
        rep0(j, w){
            if ((a > j && b > i) || (a <= j && b <= i)) {
                cout << 0;
            }else{
                cout << 1;
            }
        }
        cout << endl;
    }
    return 0;
}


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

int main(void) {
  int a;
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
  		cin >> vec.at(i);
}
  for(int i=0;i<5;i++){
    if(vec.at(i)==0){
    a=i+1;
    }
  }
  
  cout << a << endl;
}
  
  

Measured memory_bytes: 3620
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

long long x;
map < long long , bool > vis;
map < long long , long long > mem;

long long go(long long cur){
        if(cur == 1)
            return 1;
        if(cur == 0)
            return 0;
        if(vis[cur])
            return mem[cur];
        vis[cur] = true;
        return mem[cur] = go(cur / 2) + go(cur / 2) + 1;
}

int main(){
    cin >> x;
    cout << go(x) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

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

int main(){

	int n,m,kyo,iin,de,max;
	vector<int> a,b;

	cin >> n >> m;
	
	int res[n];

	rep(i,n){
		cin >> kyo;
		a.push_back(kyo);
		res[i] = 0;
	}

	rep(i,m){
		cin >> iin;
		b.push_back(iin);
	}
	
	rep(i,b.size()){
		rep(j,a.size()){
			if(b[i] >= a[j]){ 
				res[j] += 1; 
				break;
			}
		}
	}

	//rep(i,n) cout << i+1 << "," << res[i] << endl;

	de = 1;
	max = res[1];

	rep(i,n){
		if(max <= res[i]){
			de = i + 1;
			max = res[i];
		}
	}
	
	//cout << "max:" << max << endl;

	cout << de << endl;
		
	return 0;	
}

Measured memory_bytes: 1228
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };


int main(void) {
	string s;

	cin >> s;

	if (s.size() == 2) {
		cout << s << endl;
	}
	else {
		cout << s[2] << s[1] << s[0] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = []
p = sum(A)
for j in range(N-1):
    p -= A[j]
    B.append(p%(10**9+7))
count = 0
for i in range(N-1):
    count += (A[i]*B[i])%(10**9+7)
print(count%(10**9+7))

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }
    sort(A.rbegin(),A.rend());
    ll ans = 0;
    REP(i,N){
        ans += A[i / 2];
    }

    ans -= A[0];
    
    cout << ans << endl;

}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
int ans[513][513] = {};
int main(){
  int n;
  cin >> n;
  int level = 0;
  int pw2 = 1;
  for(int j=0; j<502; j++){
    while(pw2<=j){
      pw2*=2;
      level++;
    }
    for(int i=0; i<pw2; i++){
      if(i<pw2/2) ans[i][j] = level;
      else ans[i][j] = ans[i-pw2/2][j-pw2/2];
    }
  }
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int x, n;
	cin >> x >> n;
	vector<bool> p(105, true);
	int input;
	for(int i = 0; i < n; ++i)
	{
		cin >> input;
		p[input] = false;
	}

	if (p[x])
	{
		cout << x;
		return;
	}

	for(int i = 1; i < 100; ++i)
	{
		if (x - i < 0 || p[x - i])
		{
			cout << x - i;
			return;
		}
		if (x + i > 100 || p[x + i])
		{
			cout << x + i;
			return;
		}
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3612
#入力
HWD = list(map(int, input().split()))
H, W, D = HWD[0], HWD[1],  HWD[2]
field_dict = {}
for h in range(H):
    field = list(map(int, input().split()))
    for w in range(W):
        field_dict[field[w]] = (h, w)

#numberからD動かした時の魔力
move_dict = {}
pre_length = 0
for now_point in range(1, H * W + 1):
    pre_point = now_point - D
    if now_point > D:
        pre_length = move_dict[now_point - D]
        now_h = field_dict[now_point][0]
        now_w = field_dict[now_point][1]
        pre_h = field_dict[pre_point][0]
        pre_w = field_dict[pre_point][1]
        move_dict[now_point] = abs(now_h - pre_h) + abs(now_w - pre_w) + pre_length
    else:
        move_dict[now_point] = 0
           
#試験
Q = int(input())
for test in range(Q):
    target = list(map(int, input().split()))
    count = move_dict[target[1]] - move_dict[target[0]]
    print(count)    

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

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

    std::sort(h.begin(), h.end(), std::greater<int>());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if(i + 1 > k) {
            ans += h[i];
        }
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 1532