akhauriyash/Code-Regression huggingface dataset:
import * as fs from 'fs';

namespace AtCoder {
    export interface Pramable {
        args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc117 {
    export class TaskB implements AtCoder.Pramable, AtCoder.Task {
        constructor(public args: string[][]) {
        }

        public main(this: TaskB): void {

            const l: number[] = this.args[1].map(Number);
            const max: number = Math.max(...l);
            const sum: number = l.reduce((acc: number, cur: number) => acc + cur, 0);

            if (max < sum - max) {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: TaskB = new TaskB(args);
    task.main();
}

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

int main() {
  ll n,m;
  cin>>n>>m;
  ll a[m];
  for(int i=0;i<m;i++)
  {
    cin>>a[i];
  }
  if(m<=n)
  {
    //cout<<"if"<<endl;
    cout<<0<<endl;
  }
  else
  {
  sort(a,a+m);
  vector<ll>v;
  for(int i=1;i<m;i++)
  {
      v.push_back(abs(a[i]-a[i-1]));
  }
  sort(v.begin(),v.end(),greater<ll>());

  for(int i=0;i<n-1;i++)
  {
    v[i]=0;
  }
  /*for(int i=0;i<v.size();i++)
  { 
  cout<<v[i]<<" ";
  }
  cout<<endl<<endl;;
  */
  ll sum=0;
  for(int i=0;i<v.size();i++)
  { 
    sum+=v[i];
  }
  cout<<sum<<endl;
  }
  
}

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

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

  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(g[i]<g[j]){
        temp=g[i];
        g[i]=g[j];
        g[j]=temp;
      }
    }
  }

  for(int i=0;i<k;i++){
    sum+=g[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

int main()
{
    int n, k, ans{1};
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        if (ans < k) ans *= 2;
        else ans += k;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
ll MOD = 1e9+7;

int main() {
    double A,B,H,M; cin>>A>>B>>H>>M;
    double tyosin, tansin;
    tyosin = H / 12 + (M / 60 / 12);
    tansin = M / 60;

    double thita = min((abs(tyosin-tansin)*360),abs((abs(tyosin-tansin)*360 - 360)));
    double ans = 0;
    double tmp = cos(M_PI*(thita/180) );
    ans = sqrt(A*A+B*B - 2*A*B*tmp);
    //cout<<ans<<endl;
    printf("%.10lf", ans);
}

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

int count;
int num;
int block[100];
int big, small;

int main(){
	cin >> count;
	for(int p=0; p < count; p++){
		big = -100; small = 100;
		for(int i=0; i < 100; i++) block[i] = 0;

		cin >> num;
		for(int i=0; i < num; i++){
			cin >> block[i];
		}
		for(int i=0; i < num-1; i++){
			if(block[i] < block[i+1]){
				big = max(big, block[i+1]-block[i]);
			}
			else small = min(small, block[i+1]-block[i]);
		}
		if(big == -100) cout << 0 << ' ';
		else cout << big << ' ';
		if(small == 100) cout << 0 << endl;
		else cout << -small << endl;
	}
}

Measured memory_bytes: 1160
s = int(input())

test = [s]

i=0
while True:
    i += 1
    if test[i-1] % 2 == 0:
        ad = test[i-1]/2
        if ad in test:
            print(i+1)
            exit()
        else:
            test.append(ad)
    else:
        ad = 3*test[i-1]+1
        if ad in test:
            print(i+1)
            exit()
        else:
            test.append(ad)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mk make_pair
#define ll long long

const int maxn=100;
int a[maxn],b[maxn],c[maxn];
int n,s;
signed main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    //freopen("../in.txt", "r", stdin);
    //freopen("../out.txt", "w", stdout);
	cin>>n;
	rep(i,1,n)cin>>a[i];
	rep(i,1,n)cin>>b[i];
	rep(i,1,n-1)cin>>c[i];
	for(int i=1;i<=n;++i){
		s+=b[a[i]];
		if(i==1)continue;
		if(a[i]-a[i-1]==1)s+=c[a[i-1]];
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
c=[]
for i in range(k):
    if a+i<=b:
        c.append(a+i)
for i in range(k):
    if b-k+i+1>=a:
        c.append(b-k+i+1)
[print(i) for i in sorted(set(c))]

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
#define pi acos(-1.0)
#define nl "\n"
#define ms(a,b) memset(a,b,sizeof(a))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}

const int N = 3e5+5;

string s;

int main()
{
    int n, r = 0, b = 0;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='R') r++;
        else b++;
    if(r>b) cout<<"Yes"<<nl;
    else cout<<"No"<<nl;

    return 0;
}


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

int main() {
    string day[] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};
    int x; cin >> x;
    int d = x - 9;
    while(d < 0) d += 7;
    cout << day[d % 7] << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int A,B;
    cin>>A>>B;

    cout<<(B+A-3)/(A-1) <<endl;
    

    



}




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

using namespace std;

#define MOD 1000000007
#define N 22
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int a[N][N];
int dp[1<<N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, i, j, mask, tot, po;
    cin>>n;
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            cin>>a[i][j];
        }
    }
    dp[0] = 1;
    tot = (1<<n);
    for(mask=0; mask<tot; mask++){
        i = __builtin_popcount(mask);
        for(j=0; j<n; j++){
            po = (1<<j);
            if(!(mask & po)){
                dp[mask | po] = (dp[mask | po] + a[i][j] * dp[mask]) % MOD;
            }
        }
    }
    cout<<dp[tot-1];
    return 0;
}

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

bool isPrime(int n){

    if(n == 1) return 1;

    for(int x=2;x*x<=n;x++)
        if(n % x == 0) return 0;
    
    return 1;

}

int32_t main(){


    int a, b;
    cin >> a >> b;
    int g = __gcd( a, b);

    vector<int> f;

    for(int x=1;x*x<=g;x++){

        if(g % x == 0){
            f.push_back(x);
            if(g/x != x)
                f.push_back(g/x);
        }

    }
    int cnt = 0;

    for(auto x : f)
        cnt += isPrime(x);

        cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 384
using System;

	public class Dice
	{

		public static void Main(String[] args)
		{

			string yesNo = "No";
			string dataA = Console.ReadLine();
			string dataB = Console.ReadLine();
      		string[] diceA = dataA.Split();
     		string[] diceB = dataB.Split();
     		
           	int i = 0;
			int j = 0;
			do {
				do {
                  
					for (int k = 0; k < diceA.Length; k++) {
						if (!diceA[k].Equals(diceB[k])) {
							yesNo = "No";
							break;
						}
						if (k == diceA.Length - 1) {
							yesNo = "Yes";
						}
					}
					if (yesNo == "Yes") {
						break;
					}
					turn(3, 5, 2, 0, diceB);                   
					j++;
				} while (j < 4);

				if (yesNo == "Yes") {
					break;
				}
				
				j = 0;
				
				if (i == 3) {
                   
					turn(4, 5, 1, 0, diceB);//????????§?????????
					turn(2, 5, 3, 0, diceB);

				
				} else if (i == 4) {
					//??????????????§diceB[1]=east
					//west ???south????????????????????????                   
					turn(4, 5, 1, 0, diceB);                       
				}

				turn(4, 5, 1, 0, diceB);
				
				i++;
			} while (i < 6);
			
			Console.WriteLine(yesNo);
		}

		public static void turn(int a, int b, int c, int d, string[] dice)
		{
			string temp = dice[a];
			dice[a] = dice[b];
			dice[b] = dice[c];
			dice[c] = dice[d];
			dice[d] = temp;
            
		}
	}

Measured memory_bytes: 8888
#include<iostream>
#include<stack>
#include<queue>
using namespace std;
int main(){
  int n,i;
  queue<int> a;
  cin>>i;
  while(i--){
    for(int i=0;i<10;i++){cin >> n; a.push(n);}
    stack<int> b,c;
    b.push(0); c.push(0);
    while(a.size()){
      int n = a.front();
      if(n>b.top()) b.push(n);
      else if(n>c.top()) c.push(n);
      else break;
      a.pop();
    }
    if(a.size()) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}
    
  

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b);

  if (a > 9 || b > 9)
    cout << -1 << endl;
  else
    cout << a * b << endl;

  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int sum = 0;
  for (int i = A; i < B; i++) {
    for (int j = C; j < D; j++) {
      if (i == j) sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
void fail()
{
	printf("No\n");
	exit(0);
}
vector<int> g[100010];
int b[100010];
int l[100010];
int r[100010];
void dfs(int x,int fa)
{
	if(~b[x])
		l[x]=r[x]=b[x];
	else
	{
		l[x]=-3000000;
		r[x]=3000000;
	}
	for(auto v:g[x])
		if(v!=fa)
		{
			dfs(v,x);
			l[x]=max(l[x],l[v]-1);
			r[x]=min(r[x],r[v]+1);
		}
	if(l[x]>r[x])
		fail();
}
void dfs2(int x,int fa)
{
	if(!fa)
	{
		if(b[x]==-1)
			b[x]=l[x];
	}
	else
	{
		if(~b[x])
		{
			if(b[x]!=b[fa]-1&&b[x]!=b[fa]+1)
				fail();
		}
		else if(b[fa]-1>=l[x]&&b[fa]-1<=r[x])
			b[x]=b[fa]-1;
		else
			b[x]=b[fa]+1;
	}
	if(b[x]<l[x]||b[x]>r[x])
		fail();
	for(auto v:g[x])
		if(v!=fa)
			dfs2(v,x);
}
int main()
{
//	open("arc063c");
	int n,m;
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	memset(b,-1,sizeof b);
	scanf("%d",&m);
	int rt;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		b[x]=y;
		rt=x;
	}
	dfs(rt,0);
	dfs2(rt,0);
	printf("Yes\n");
	for(i=1;i<=n;i++)
		printf("%d\n",b[i]);
	return 0;
}

Measured memory_bytes: 15104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int cntNums[] = new int[2];


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

			int inputNums = sc.nextInt();
			cntNums[i] = inputNums;

		}

		if (cntNums[0] < cntNums[1]) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}

	}

}


Measured memory_bytes: 21716
n=int(input())
h=list(map(int,input().split()))
a=0
for i in range(1,max(h)+1):
    s=0
    while s<n:
        if h[s]>=i:
            a+=1
            while s<n and h[s]>=i:
                s+=1 
        s+=1
print(a)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7

int myMax(int num[], int length);

int N, T[200];
int M,P2[200],X[200];


int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &T[i]);
	}
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &P2[i], &X[i]);
	}

	int origin = 0;
	for (int i = 0; i < N; i++) {
		origin += T[i];
	}


	for (int i = 0; i < M; i++) {
		printf("%d\n", origin - (T[P2[i]-1] - X[i]));
	}






}

int myMax(int num[], int length) {
	int temp = c_mINF;
	for (int i = 0; i < length; i++) {
		temp = max(temp, num[i]);
	}
	return temp;
}


Measured memory_bytes: 128
//abc165_b.cpp
//Sun May 24 22:03:58 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	ll x;
	cin >> x;

	ll ans = 0;
	ll yokin = 100;
	while (yokin<x){
		yokin += yokin/100;
		ans++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    ll x,bank=100,ans = 0;
    
    double rate = 1.01;
    cin>>x;
    while(bank < x){
        bank *=rate;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
n = gets.to_i
h = gets.split.map(&:to_i)

res = true
for i in 0..n-2 do
    r = n - i - 1
    l = n - i - 2

    if h[l] - 1 > h[r]
        res = false
        break
    elsif h[l] > h[r]
        h[l] -= 1
    else
        # do nothing
    end
end

puts res ? "Yes" : "No"

Measured memory_bytes: 8580
import java.util.Scanner;

public class Main {

    static String DRM = "dream";
    static String DRMR = "dreamer";
    static String ERS = "erase";
    static String ERSR = "eraser";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();

        String n1 = N.replace(ERSR, "");
        String n2 = n1.replace(ERS, "");
        String n3 = n2.replace(DRMR, "");
        String n4 = n3.replace(DRM, "");
        System.out.println(n4.equals("") ? "YES" : "NO");
    }

}


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

int used[4];

int main(){
    int a,b; cin >> a >> b;
    used[a]=true;used[b]=true;
    for(int i=1;i<=3;i++){
        if(!used[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,x,i,j,cnt=0;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);

	x/=50;

	for(i=0;i<=a && i*10<=x;i++){
		for(j=0;j<=b && i*10+j*2<=x;j++){
			if(x-(i*10+j*2)<=c){
				cnt++;
			}
		}
	}

	printf("%d",cnt);

	return 0;

}

Measured memory_bytes: 128
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//REPマクロ
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int N,cnt;
    
    cin >> N;
    vector<int> p(N);
    cnt=0;
    REP(i,N){
        cin >> p[i];
    }
    int tmp;
    REP(i,N){
        if(p[i]==i+1){
            if(i+1<=N-1){
                tmp=p[i];
                p[i]=p[i+1];
                p[i+1]=tmp;
            }
            cnt++;
        }
    }
    cout << cnt << endl;
    
}

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

const int MAXN = 100005;

int n, x;
struct test{
	long long b, l, u;
	test(){}
	
	bool operator <(const test& y) const{
		return u * x - u * b + l * b > y.u * x - y.u * y.b + y.l * y.b;
	}
} t[MAXN];

long long calc(test& z, int r){
	if(r <= z.b){
		return (z.l * (r - z.b));
	}else{
		return (z.u * (r - z.b));
	}
}

bool check(long long h){
	if(h % x == 0){
		long long s = 0;
		
		for(int i = 0; i < h / x; i++)
			s += calc(t[i], x);
		for(int i = h / x; i < n; i++)
			s += calc(t[i], 0);
		
		return (s >= 0);
	}
	
	int rem = h % x;
	
	long long s = 0;
	for(int i = 0; i < h / x + 1; i++)
		s += calc(t[i], x);
	for(int i = h / x + 1; i < n; i++)
		s += calc(t[i], 0);
	
	long long r = -1;
	for(int i = 0; i < h / x; i++)
		r = max(r, s - calc(t[i], x) + calc(t[i], rem));
		
	s += calc(t[h / x], 0) - calc(t[h / x], x);
	
	for(int i = h / x; i < n; i++)
		r = max(r, s - calc(t[i], 0) + calc(t[i], rem));
		
	return (r >= 0);
}

int main(){
	scanf("%d %d", &n, &x);
	for(int i = 0; i < n; i++)
		scanf("%lld %lld %lld", &t[i].b, &t[i].l, &t[i].u);
	sort(t, t + n);
	
	long long L = 0, R = 1LL * x * n;
	while(L < R){
		long long mid = (L + R) / 2;
		
		if(check(mid))R = mid;
		else L = mid + 1;
	}
	printf("%lld\n", L);
	
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int main(){
	int n,c=0,s=0;
	scanf("%d",&n);
	while(s<n){
		c++;
		s+=c;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a_list=[int(input()) for i in range(n)]
a_list.reverse()
INF=10**10
dp=[INF]*n
import bisect
for i in range(n):
    a=a_list[i]
    x=bisect.bisect_right(dp,a)
    dp[x]=a
ans=0
for i in range(n):
    if dp[i]!=INF:
        ans=i+1
print(ans)


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

using namespace std;

int* inputArray(int num){
    int* ans;
    ans = new int[num];
    for(int i = 0; i < num; i++){
        scanf("%d", &ans[i]);
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    int *a = inputArray(n);
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] whites = new int[n+1];
        int[] blacks = new int[n+1];
        for(int i = 1; i <= n; i++){
            if(s[i-1] == '#'){
                blacks[i]++;
            }else{
                whites[i]++;
            }
            blacks[i] += blacks[i-1];
            whites[i] += whites[i-1];
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i <= n; i++){
            ans = Math.min(ans, blacks[i] + whites[n]-whites[i]);
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
            return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 28660
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>s1>>s2;
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) cout<<"YES";
	else cout<<"NO";
	cout<<endl;
	return 0;
}


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

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		if(int m=(ok+ng)/2; [&](){
			int64_t c = 0;
			rep(i, N) c += (A[i] - 1) / m;
			return c <= K;
		}()) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
static const int64_t MOD = 1e9 + 7;
static const int T = 0, A = 1, G = 2, C = 3;
int n;
int64_t dp[101][4][4][4];

void add(int64_t &a, int64_t b) {
	a = (a+b) % MOD;
}

bool ng(int a, int b, int c) {
	return (a == A && b == G && c == C);
}

void solve() {
	for(int i = 0; i < n; i++) for(int a = 0; a < 4; a++) for(int b = 0; b < 4; b++) for(int c = 0; c < 4; c++) for(int d = 0; d < 4; d++){
		if(ng(b, c, d) || ng(c, b, d) || ng(b, d, c)) continue;
		if(ng(a, c, d) || ng(a, b, d)) continue;
		add(dp[i+1][b][c][d], dp[i][a][b][c]);
	}
	int64_t sum = 0;
	for(int a = 0; a < 4; a++) for(int b = 0; b < 4; b++) for(int c = 0; c < 4; c++) {
		add(sum, dp[n][a][b][c]);
	}
	cout << sum << endl;

}

int main() {
	dp[0][0][0][0] = 1;
	cin >> n;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>arr(n);
  for(int i=0;i<n;++i){
    cin>>arr[i];
  }
  vector<int> shadow(arr);
  sort(arr.begin(),arr.end());
  int a = arr[n-1];
  int b = arr[n-2]; 
  for(int i=0;i<n;++i){
    if(shadow[i]==a){
      cout<<b<<endl;
    }else{
      cout<<a<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int inf = 2e9;

struct union_find{ //uniteするときに、最小要素をrootに持っておくことに注意
   
  vector<int> par; vector<P> minimum;//根に対し、それの部分技の最小要素を保持する
  
  //コンストラクタ
  union_find(const vector<int> &B){
    
    int n = (int)B.size();
    par.resize(n);
    for(int i = 0; i < n; i++){ par[i] = i;}
    
    minimum.resize(n);
    
    for(int i = 0; i < n; i++){
      minimum[i] = {B[i],i}; //{最小値、index}
      
      
    }
  }
  
  int min_index(int a){
    
    return minimum[root(a)].second;
  }
  
  int root(int a){
    if(par[a] == a){ return a;}
    else{ return par[a] = root(par[a]);}
  }
  
  bool same(int a, int b){ 
    return root(a) == root(b);
  }
  
  void unite(int a, int b){
    if( root(a) == root(b)){ return ;}
    else{

      if(minimum[root(b)].first > minimum[root(a)].first){ 
        minimum[root(b)] = minimum[root(a)];
      }//{最小値、それを示すindex}
      
      par[root(a)] = root(b);
      
     return ;
    }
  }
  
};
  

int main(){
  
  int N,M; cin >> N >> M;
  
  int edge = 2*(N-M-1);
  
  if( M == N-1){ cout << 0 << endl; return 0;}
  if( N < edge ){ cout << "Impossible" << endl; return 0;}
  
  vector<int> A(N);
  
  for(int i = 0; i < N; i++){ cin >> A[i];} //頂点コスト
 
  union_find uf(A);
  
  for(int i = 0; i < M; i++){
    int x,y; cin >> x >> y; uf.unite(x,y);
  }
  
  vector<bool> ismin(N,false);//頂点iが、ある木の最小値ならtrue
  
  for(int i = 0; i < N; i++){
    ismin[uf.min_index(i)] = true;
  }
  
  ll ans = 0;
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){ 
    if(ismin[i]){ ans += A[i]; cnt++;}
  } //まずそれぞれの木の最小要素を選ぶ
 
  priority_queue<int,vector<int>,greater<int>> Q;
  
  for(int i = 0; i < N; i++){
    if(ismin[i]){ continue;}
    //次に最小要素以外で、小さい方から合計2(N-M-1)個となるまで選び続ける
     
    Q.push(A[i]);
    
  }
  
  while( cnt < edge){
    ans += Q.top(); Q.pop();
    cnt++;
  }

  cout << ans << endl;
   
  return 0;
}

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

int main(){
    int N, D; cin >> N >> D;
    vector<vector<int>> X(N,vector<int> (D));

    rep(i,N){
        rep(j,D){
            cin >> X[i][j];
        }
    }

    int dist=0;
    int ans=0;

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            dist=0;

            rep(k,D){
                dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
            }

            for(int l=0; l*l<=dist; l++){
                if(dist == l*l){
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, n;
  cin >> h >> w >> n;
  int c = 0;
  bool flag = true;
  string line = "";
	rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      if(c == w){
        c = 0;
        flag = !flag;
        cout << line << endl;
        line = "";
      }
      if(flag) line += (line==""?line:" ") + to_string(i+1);
      else line = to_string(i+1)+ (line==""?line:" ") + line;
      c++;
    }
  }
  cout << line << endl;
  return 0;
}


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

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

	int A,B;
	int i,j;
	int counter=0;
	int ans;
	int tmp=0;
	double ave;
	vector<int> given;

	cin >> A >> B;
	
	if(B==1){
		cout << 0 << endl;
		return 0;
	}

	while(1){
		if(counter==0){
			tmp+=A;
		}else{
			tmp+=A-1;
		}
		
		counter++;
		if(tmp>=B) break;
	}

	cout << counter << endl;

	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int h=fs.nextInt(), w=fs.nextInt(), k=fs.nextInt();
		char[][] board=new char[w][h];
		for (int y=0; y<h; y++) {
			char[] line=fs.next().toCharArray();
			for (int x=0; x<w; x++)  board[x][y]=line[x];
		}
		int ans=0;
		for (int mask=0; mask<1<<(w+h); mask++) {
			int count=0;
			for (int x=0; x<w; x++) {
				for (int y=0; y<h; y++) {
					if (board[x][y]!='#') continue;
					if ((mask&((1<<x) | (1<<(w+y))))!=0) continue;
					count++;
				}
			}
			if (count==k) ans++;
		}
		System.out.println(ans);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32784
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x==3||x==5||x==7){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  5
  1 2 3 4 5
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

ar = line[1].split(" ")
puts ar.reverse.join(" ")

Measured memory_bytes: 8632
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>

using namespace std;

int w, h, c[50][50];

void rec(int y, int x) {
    if (y < 0 || x < 0 || y >= h || x >= w) return;
    if (c[y][x] == 0)
        return;
    c[y][x] = 0;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            rec(y + i, x + j);
        }
    }
}

int main() {
    while (1) {
        scanf("%d %d", &w, &h);
        if (w == 0 && h == 0) break;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) {
                scanf("%d", &c[i][j]);
            }
        int r = 0;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) {
                if (c[i][j] == 0) continue;
                r++;
                rec(i, j);
            }
        printf("%d\n", r);
    }
}


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

int main() {
	ll n, x, t;
	cin >> n >> x >> t;
	if (n % x == 0) {
		cout << n / x * t << endl;
	}
	else {
		cout << n / x * t + t << endl;
	}
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

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

    long long ans;
    if(N == 1){
        ans = 1;
    }else{
        long long l0 = 2, l1 = 1;
        for (int i = 2; i <= N ; i++){
            ans = l0 + l1;
            l0 = l1;
            l1 = ans;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

bool sw[11];
vector<int> con[11];
int ps[11];

int dfs(int cur, int n, int m) {
  if (cur == n) {
    int lsum = 0;
    for (int i = 0; i < m; i++) {
      int sum = 0;
      for (int j = 0; j < con[i].size(); j++) {
        sum += sw[con[i][j] - 1] ? 1 : 0;
      }
      //cout << (sum % 2 == ps[i] ? "l " : "d ");
      lsum += sum % 2 == ps[i] ? 1 : 0;
    }
    //cout << endl;

    // for (int i = 0; i < n; i++) {
    //   cout << (sw[i] ? "on " : "off ");
    // }
    //cout << (lsum == m ? "l" : "d") << endl;

    return lsum == m ? 1 : 0;
  }  
  else {
    int res = 0;
    sw[cur] = true;
    res += dfs(cur + 1, n, m);
    sw[cur] = false;
    res += dfs(cur + 1, n, m);
    return res;
  }
}

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

  //int a, b, c; cin >> a >> b >> c;
  
  for (int i = 0; i < m; i++) {
     int k; cin >> k;
     for (int j = 0; j < k; j++) {
       int s; cin >> s;
       con[i].push_back(s);
     }
  }

  for (int i = 0; i < m; i++) {
    int p; cin >> p;
    ps[i] = p;
  }
  
  cout << dfs(0, n, m) << endl;

  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const args = input.split(' ');
	const a = parseInt(args[0], 10);
	const b = parseInt(args[1], 10);
    const c = parseInt(args[2], 10);
    
    var res = Math.max(0,b+c-a)

    console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  rep(i, n - 1) loop(j, i + 1, n) {
    if ((a[i] - a[j]) % (n - 1)) continue;
    cout << a[i] << ' ' << a[j] << endl;
    return 0;
  }
}


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

typedef struct tokuten{
int num;
int ten;
int jyun;
}tokuten;

int compareInt(const void* a, const void* b)
{
	int aNum = ((const tokuten*)a)->num;
	int bNum = ((const tokuten*)b)->num;
    if( aNum < bNum ){
        return -1;
    }
    else if( aNum > bNum ){
        return 1;
    }
    return 0;
}

int desc_ten(const void* a,const void* b){
	return ((tokuten*)b)->ten-((tokuten*)a)->ten;
}

int desc_num(const void* a,const void* b){
	return ((tokuten*)a)->num-((tokuten*)b)->num;
}

int main(void){
int num=1,ten=100;
int N=0;
int Maxid=INT_MIN;
int Minid=INT_MAX;
tokuten* tok=(tokuten*)calloc(1,sizeof(tokuten));
int ban=1;
tokuten T;
while(scanf("%d,%d",&num,&ten)>0 && (num!=0||ten!=0)){
	tok=(tokuten*)realloc(tok,ban*sizeof(tokuten));
	T.num=num,T.ten=ten;T.jyun=0;
	if(num>Maxid){Maxid=num;}
	if(num<Minid){Minid=num;}
	
	tok[ban-1]=T;
	N++;
	ban++;
}

qsort(tok,N,sizeof(*tok),desc_ten);
tok[0].jyun=1;
for(int i=0;i<N;i++){
	if(tok[i].ten==tok[i+1].ten)tok[i+1].jyun=tok[i].jyun;
	else{tok[i+1].jyun=tok[i].jyun+1;}
}

qsort(tok,N,sizeof(*tok),desc_num);

char *line=NULL;
size_t len=0;;
getline(&line,&len,stdin);
while(getline(&line,&len,stdin)>0){
	if(line[0]=='\n')break;
	ten=atoi(line);
	tokuten* res=bsearch(&ten,tok,N,sizeof(*tok),(int(*)(const void*,const void*))compareInt);
	if(res!=NULL)printf("%d\n",(*res).jyun);
}

free(tok);

return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
long long fib[233],x,y,ans;
int now;long long all;
void dfs(long long u,long long v,int c,int err)
{
	//cout<<u<<' '<<v<<' '<<c<<' '<<err<<' '<<(((u>=fib[c+2])&&(v>=fib[c+3]))||(u>x)||(v>y))<<endl;
	if (((u>=fib[c+2])&&(v>=fib[c+3]))||(u>x)||(v>y)) return;
	//if (c==now) {ans+=(int)((u<=x)&&(v<=y))+(int)((v<=x)&&(u<=y));return;}
	if (c==now-1)
	{
		ans+=max(0ll,(y-u)/v)*(v<=x)+max(0ll,(x-u)/v)*(v<=y);
		return;
	}
	if (!err)
	{
		dfs(v,u+v,c+1,0);
		dfs(v,u+v+v,c+1,1);
		//v,u+kv
		//p=fib[now-c-2]*v+fib[now-c-1]*(u+kv)
		//q=fib[now-c-1]*v+fib[now-c]*(u+kv)
		//p<=x q<=y
	}
	else if (err==1)
	{
		if ((double)u*fib[now-2-c]+(double)v*fib[now-1-c]>1.1e18) return;
		if ((double)u*fib[now-1-c]+(double)v*fib[now-0-c]>1.1e18) return;
		long long uu=u*fib[now-2-c]+v*fib[now-1-c],vv=u*fib[now-1-c]+v*fib[now-0-c];
		ans+=max(0ll,(y-uu)/vv)*(vv<=x)+max(0ll,(x-uu)/vv)*(vv<=y);
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	fib[0]=0;fib[1]=1;for (int i=2;i<=90;i++) fib[i]=fib[i-1]+fib[i-2];
	int q;scanf("%d",&q);
	while (q--)
	{//if (q%1000==0) cerr<<q<<endl;
		scanf("%lld%lld",&x,&y);if (x>y) swap(x,y);
		if (x==1) {printf("1 %lld\n",y%1000000007);continue;}
		if (y==2) {printf("1 4\n");continue;}
		now=0;while ((fib[now+2]<=x)&&(fib[now+3]<=y)) now++;
		printf("%d ",now);
		ans=0;dfs(1,1,0,0);
		printf("%lld\n",ans%1000000007);
	}
	cerr<<all<<endl;
}

Measured memory_bytes: 3968
#include <vector>
#include <iostream>
using namespace std;
struct edge {
	int to, id;
	edge() : to(-1), id(-1) {};
	edge(int to_, int id_) : to(to_), id(id_) {};
};
int n, eid = -1; vector<int> a, b, c; vector<long long> s, t; vector<vector<edge> > g;
void dfs(int pos, int pre) {
	c[pos] = 1;
	for (edge e : g[pos]) {
		if (e.to != pre) {
			dfs(e.to, pos);
			c[pos] += c[e.to];
			if (c[e.to] * 2 != n) {
				t[e.id] = (s[e.to] - s[pos]) / (n - 2 * c[e.to]);
			}
			else eid = e.id;
		}
	}
}
long long calc(int pos, int pre, long long cumdist) {
	long long ret = cumdist;
	for (edge e : g[pos]) {
		if (e.to != pre) {
			ret += calc(e.to, pos, cumdist + t[e.id]);
		}
	}
	return ret;
}
int main() {
	cin.tie(0);
	cin >> n;
	a = vector<int>(n - 1);
	b = vector<int>(n - 1);
	s = vector<long long>(n);
	g = vector<vector<edge> >(n);
	for (int i = 0; i < n - 1; ++i) {
		cin >> a[i] >> b[i]; --a[i], --b[i];
		g[a[i]].push_back(edge(b[i], i));
		g[b[i]].push_back(edge(a[i], i));
	}
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	c = vector<int>(n);
	t = vector<long long>(n - 1);
	dfs(0, -1);
	if (eid != -1) {
		long long cur = calc(a[eid], -1, 0);
		t[eid] = (s[a[eid]] - cur) / (n / 2);
	}
	for (int i = 0; i < n - 1; ++i) {
		cout << t[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
 
int main() {
 
	LL h, w, a, b; cin >> h >> w >> a >> b;
 
	for (int i = 0; i < h; i++) {
		if (0 <= i && i < (h - b)) {
			for (int j = 0; j < w; j++) {
				if (0 <= j && j < a) {
					cout << '1';
				}
				else {
					cout << '0';
				}
			}
 
			cout << endl;
			
		}
		else {
			for (int j = 0; j < w; j++) {
				if (0 <= j && j < a) {
					cout << '0';
				}
				else {
					cout << '1';
				}
			}
 
			cout << endl;
		
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;

int main(void) {
	ll n, k;
	cin >> n >> k;
	double ans = 0.0, p = 0,x=1;
	for (ll i = 1;i <= n;i++) {
		p = (double)1 / n;
		if (i >= k)ans += (double)p;
		else {
			ll x = 1;
			for (ll j = 1;;j++) {
				if (i*x * 2 >= k) {
					x = x * 2;
					break;
				}
				else x = x * 2;
			}
			ans += (double)p * 1 / x;
		}
	}
	printf("%.15f\n", ans);
	return 0;
}

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

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

    int n,m;
    cin>>n>>m;
    int num=m/n;
    int ans=1;
    for(int i=num;i>0;i--){
        if(m%i==0){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
 
main(){
    int a,b,c;
    int i;
     
    scanf("%d %d %d",&a,&b,&c);
     
    for(i=0;a<=b;a++){
        if(c % a == 0){
            i++;
        }
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <bitset>
#include <limits>
#include <iostream>

long long solve(int n, int k, const std::vector<long long> & a) {
    long long cost { std::numeric_limits<long long>::max() };
    for (int i = 0; i < (1 << n); ++i) {
        const std::bitset<15> bits(i);
        if (bits.count() < k) {
            continue;
        }

        long long cur_cost { 0L };
        long long height { 0L };
        for (int j = 0; j < n; ++j) {
            const bool can_build { ((i >> j) & 1) && (a[j] <= height) };
            if (can_build) {
                cur_cost += (height - a[j] + 1);
                ++height;
            }
            height = std::max(height, a[j]);
        }
        cost = std::min(cost, cur_cost);
    }

    return cost;
}

int main() {
    int n;
    int k;
    std::cin >> n >> k;

    const auto a = [&] {
        std::vector<long long> v;
        for (int i = 0; i < n; ++i) {
            long long h;
            std::cin >> h;
            v.push_back(h);
        }
        return v;
    }();

    std::cout << solve(n, k, a) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef __int128_t lll;
typedef pair<int, int> P;

int main()
{
    ll n, m, a, b, p, q;
    cin>>n>>m>>a>>b>>p>>q;
    if(a==1 && b==1){
        if(p+q<=m/n) cout<<m-(p+q)*n<<endl;
        else cout<<min(m%(p+q), p+q-m%(p+q))<<endl;
        return 0;
    }
    vector<ll> v;
    lll x=p, y=q;
    ll ans=m;
    for(int i=0; i<n; i++){
        v.push_back(x+y);
        if(i<n-1 && x*a+y*b>=m){
            if(x*a+y*b<2*m){
                ans=min((ll)(x*a+y*b-m), ans);
            }
            break;
        }
        x*=a, y*=b;
    }
    int k=v.size();
    ll s1[1<<21], s2[1<<21];
    for(int i=0; i<(1<<(k/2)); i++){
        s1[i]=0;
        for(int j=0; j<k/2; j++){
            if(i&(1<<j)) s1[i]+=v[j];
        }
    }
    for(int i=0; i<(1<<(k-k/2)); i++){
        s2[i]=0;
        for(int j=0; j<k-k/2; j++){
            if(i&(1<<j)) s2[i]+=v[k/2+j];
        }
    }
    sort(s2, s2+(1<<(k-k/2)));
    for(int i=0; i<(1<<(k/2)); i++){
        if(s1[i]>=m){
            ans=min(ans, s1[i]-m);
            continue;
        }
        int t=lower_bound(s2, s2+(1<<(k-k/2)), m-s1[i])-s2;
        if(t<(1<<(k-k/2))) ans=min(ans, s1[i]+s2[t]-m);
        ans=min(ans, m-s1[i]-s2[t-1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19464
#include <stdio.h>
#include <stdlib.h>

typedef struct vector{
    int *a;
    int length, size;
}vector;

vector *init(){
    vector *v = (vector *)malloc(sizeof(vector));
    v->length = v->size = 0;
    v->a = (int *)malloc(sizeof(int));
    return v;
}

int get(vector *v, int i){
    return v->a[i];
}

void set(vector *v, int i, int x){
    v->a[i] = x;
}

void resize(vector *v){
    int *b = (int *)malloc(sizeof(int) * (v->size == 0 ? 1 : v->size * 2));
    for(int i=0; i<v->size; ++i) b[i] = v->a[i];
    free(v->a);
    v->a = b;
    v->length = (v->size == 0 ? 1 : v->size * 2);
}

void insert(vector *v, int i, int x){
    if(v->size == v->length) resize(v);
    for(int k=v->size-1; k>=i; --k) v->a[k+1] = v->a[k];
    v->a[i] = x;
    ++v->size;
}

void erase(vector *v, int i){
    for(int k=i; k<v->size; ++k) v->a[k] = v->a[k+1];
    --v->size;
    if(v->length >= 3 * v->size) resize(v);
}

void push_back(vector *v, int x){
    insert(v, v->size, x);
}

void pop_back(vector *v){
    erase(v, v->size);
}

int main(){
    vector *v = init();
    int q;
    scanf("%d", &q);
    while(q--){
        int t, x;
        scanf("%d", &t);
        if(t == 0){
            scanf("%d", &x);
            push_back(v, x);
        }
        else if(t == 1){
            scanf("%d", &x);
            printf("%d\n", get(v, x));
        }
        else pop_back(v);
    }
}


Measured memory_bytes: 2636
N = int(input())
K = list()
for _ in range(N):
    x, l = map(int, input().split())
    K.append((x-l, x+l))
K = list(sorted(K, key=lambda x: x[1]))
ans = N
for i in range(N-1):
    if K[i][1] > K[i+1][0]:
        ans -= 1
        if K[i][1] < K[i+1][1]:
            K[i+1] = K[i]
        else:
            K[i] = K[i+1]
print(ans)

Measured memory_bytes: 19016
#include <iostream>
// #include <cmath>
// #include <string.h>
// #include <bits/stdc++.h>
using namespace std;

int main(){
	char c;
	cin>>c;
	// cout<<int(c)<<endl;
	if(65 <= int(c) and int(c) <= 90){
		cout<<"A";
	}
	else
		cout<<"a";

	return 0;
}

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

int main(void){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    int check;
    if(2 * x == w && 2 * y == h)
        check = 1;
    else
        check = 0;

    printf("%.10f %d", w * h / 2.0, check);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define M (1<<20)-1
#define MAX 100000000
#define MIN -100000000
#define mod 998244353 
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main(){
	string s;
	cin>>s;
	int n = s.length();
	bool check1 = true,check2 = true,check3 = true;
	for(int i=0;2*i<n;i++)
		if(s[i] != s[n-i-1])
			check1 = false;
	int l = (n-1)/2;
	for(int i=0;2*i<l;i++)
		if(s[i] != s[l-i-1])
			check2 = false;
	l = (n+3)/2;
	int cnt = 0;
	for(int i=l-1;2*i<n;i++)
		if(s[i] != s[n-cnt-1])
			check3 = false;
//	cout<<check1<<" "<<check2<<" "<<check3<<endl;
	if(check1 && check2 && check3)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

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

  int ans = 0;
  int cur = 0;
  rep(i, 3) {
    if(s[i] == 'R') {
      cur++;
    } else {
      cur=0;
    }
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620