akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

string S;
void solve(void){
    cin >> S;
    cout << ((S[0] == S[S.length()-1] xor S.length()%2)?"First":"Second") << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <boost/format.hpp>

using namespace std;

int main(int argc, const char * argv[]) {
    int H, W; cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    vector<string> ansTrack;
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int inp; cin >> inp;
            a[i][j] = inp;
        }
    }
    
    int N = 0;
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H - 1; i++) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--; a[i+1][j]++;
                string oprHistory = (boost::format("%d %d %d %d") % (i+1) % (j+1) % (i+2) % (j+1)).str();
                ansTrack.push_back(oprHistory);
                N++;
            }
        }
    }
    
    for (int j = 0; j < W - 1; j++) {
        if (a[H-1][j] % 2 == 1) {
            a[H-1][j]--; a[H-1][j+1]++;
            string oprHistory = (boost::format("%d %d %d %d") % H % (j+1) % H % (j+2)).str();
            ansTrack.push_back(oprHistory);
            N++;
        }
    }
    
    cout << N << endl;
    for (int i = 0; i < N; i++) {
        cout << ansTrack[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e14;
typedef long long int ll;

#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 llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)


using namespace std;

int main(){
    ll N;
    cin >> N;
    ll ans=1;
    llRep(i,N){
        ans *= i;
        if (ans > (ll)(pow(10,9)+7)) ans %= (ll)pow(10,9)+7;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ll N;
    ll a[100000];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    int next = 0;
    for (int j = 0; j < N; ++j) {
        next = a[next] - 1;
        if(next == 2 - 1){
            cout << j+1 << endl;
            return 0;
        }

    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1152
import sys

sys.setrecursionlimit(10 ** 9)


class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]
        self.size = [1] * (n + 1)

    def find(self, x):
        # If x is root
        if self.parent[x] == x:
            return x
        # If x is not root, search again by using x's parent
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # Make an edge from the root of lower tree to the root of higher tree
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            # If the height of tree the tree is the same, increase one of the heights by 1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def check_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


H, W = map(int, input().split())
s_list = []
for i in range(H):
    s_list.append(input())
check = [[0 for _ in range(W)] for _ in range(H)]

brack_list = []
union_find = UnionFind(H * W)
for i in range(H):
    for j in range(W):
        if s_list[i][j] == "#":
            brack_list.append(i * W + j)
            if i - 1 >= 0 and s_list[i - 1][j] == ".":
                union_find.union(i * W + j, (i - 1) * W + j)
            if i + 1 < H and s_list[i + 1][j] == ".":
                union_find.union(i * W + j, (i + 1) * W + j)
            if j - 1 >= 0 and s_list[i][j - 1] == ".":
                union_find.union(i * W + j, i * W + j - 1)
            if j + 1 < W and s_list[i][j + 1] == ".":
                union_find.union(i * W + j, i * W + j + 1)


black = {}
white = {}
for i in range(H):
    for j in range(W):
        p = union_find.find(i * W + j)
        if s_list[i][j] == "#":
            if p in black:
                black[p] += 1
            else:
                black[p] = 1
        else:
            if p in white:
                white[p] += 1
            else:
                white[p] = 1

p = set(union_find.parent[:-1])
count = 0
for i in p:
    if i in black and i in white:
        count += white[i] * black[i]
print(count)

Measured memory_bytes: 36180
import sys
import math

A = int(sys.stdin.readline())
B = int(sys.stdin.readline())
C = int(sys.stdin.readline())
X = int(sys.stdin.readline())


cnt = 0
for a in range(A + 1):
    ta = 500 * a
    if ta > X:
        break
    for b in range(B + 1):
        tab = ta + 100 * b
        if tab > X:
            break
        for c in range(C + 1):
            tabc = tab + 50 * c
            if tabc > X:
                break
            if tabc == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int p = sc.nextInt();
			int q = sc.nextInt();
			int mod[] = new int[80];
			int div[] = new int[80];
			for (int i = 0; i < 80; i++) {
				mod[i] = p;
				p *= 10;
				div[i] = p / q;
				p %= q;
				if (p == 0) {
					for (int j = 0; j <= i; j++) {
						System.out.print(div[j]);
					}
					System.out.println();
					break;
				}
				for (int j = 0; j <= i; j++) {
					if (mod[j] == p) {
						for (int k = 0; k <= i; k++) {
							System.out.print(div[k]);
						}
						System.out.println();
						for (int k = 0; k <= i; k++) {
							if (k < j)
								System.out.print(" ");
							else
								System.out.print("^");
						}
						System.out.println();
						i = 80;
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
N = int(input())
data = list(map(int,input().split()))
money = 1000
stock = 0

check = ['0']

for i in range(N - 1):
    if data[i] < data[i + 1]:
        check.append("+")
    elif data[i] == data[i + 1]:
        check.append("0")
    else:
        check.append("-")
   
latest_buy = None
for i in range(N - 1):
    price = data[i]
    if check[i + 1] == "+":
        stock += money // price
        money -= price * (money // price)
        latest_buy = i
        
    if check[i + 1] == "-":
        money += price * stock
        stock = 0
        latest_buy = None

if latest_buy != None:
    print(stock * data[latest_buy + 1] + money)
else:
    print(money)

Measured memory_bytes: 9044
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<double,double>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n;cin>>n;int ans=0;
    int mini=0;
    rep(i,0,n){
        int a;cin>>a;//cout<<a<<" ";
        if(a==mini+1)mini++;
        if(a==mini){
            continue;
        }
        else ans+=(a-1)/(mini+1);
        if(i==0)mini=1;
       // cout<<mini<<" "<<ans<<endl;
        
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    int i, n, h[20], ans=0, max=0;
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",h+i);
        if(max <= h[i]) {
            ans++;
        }
        max = MAX(max, h[i]);
    }
    printf("%d",ans);
    return 0;
}


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

int main() {
  int n,q;

  cin >> n;
  int S[n];
  for(int k=0;k<n;k++){
    cin >> S[k];
  }
  cin >> q;
  int T[q];
  for(int l=0;l<q;l++){
    cin >> T[l];
  }

  int count = 0;
  for(int j=0;j<q;j++){
    int left = 0;
    int right = n;
    while(left < right){
      int mid = (left + right)/2;
      if(S[mid] == T[j]){
        count += 1;
        break;
      } else if(T[j] < S[mid]){
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 1744
from math import gcd

K = int(input())

ans = 0

# ３つの数の最大公約数
# ⇒まず２つの数の最大公約数をとり
# その数とのこり１つの数の最大公約数をとる
# for a in range(1,K+1):
#     for b in range(1, K+1):
#         g = gcd(a, b)
#         for c in range(1, K+1):
#             ans += gcd(g, c)

# これでは３重ループとなり200**3 = 8000000 ではLTEとなる

#　そこで、一番内側のループをなくすために、
# gcd(g,1) + gcd(g,2) + ・・・　+gcd(g,K) を先に計算しておく
L = [0] * 201

for g in range(1, K+1):
    for c in range(1, K+1):
        L[g] += gcd(g, c)


for a in range(1, K+1):
    for b in range(1, K+1):
        g = gcd(a, b)
        ans += L[g]

print(ans)

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

using namespace std;

using int64 = long long;

vector< int64 > arr;

void rec(string s, int a, int b, int c) {
  if(s.size() > 10) return;
  rec(s + "3", true, b, c);
  rec(s + "5", a, true, c);
  rec(s + "7", a, b, true);
  if(s.size() && a && b && c) arr.push_back(stoll(s));
}

int main() {
  int N;
  cin >> N;
  int ret = 0;
  rec("", false, false, false);
  for(auto &p : arr) {
    ret += p <= N;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1400
N=int(input())
A=list(input())
B=list(input())
C=list(input())

import collections

cnt=0

for i in range(N):
    tmp=[]
    tmp.append(A[i])
    tmp.append(B[i])
    tmp.append(C[i])
    c = collections.Counter(tmp)
    values, counts = zip(*c.most_common())
    cnt+=3-counts[0]

print(cnt)

Measured memory_bytes: 3316
// package Contest#176;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        StringTokenizer st1 = new StringTokenizer(br.readLine());

        long sum = 0;
        int max = Integer.MIN_VALUE;

        for(int i=1; i<=n; i++){
            int ht = Integer.parseInt(st1.nextToken());
            max = Math.max(max, ht);
            if(ht < max){
                sum += (max-ht);
            }
        }

        out.println(sum);
        out.close();
    }
}

Measured memory_bytes: 54612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_134
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int r = ReadInt();
            WriteLine(3*r*r);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Measured memory_bytes: 11092
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s1=''
t1=''
for j in range(len(s)):
    s1+=s[j]
for k in range(len(t)):
    t1+=t[k]
if s1==t1:
    print('No')
else:
    for i in range(min(len(s),len(t))):
        if s[i]>t[i]:
            print('No')
            break
        elif s[i]==t[i]:
            if i==min(len(s),len(t))-1:
                if len(s)==min(len(s),len(t)):
                    print('Yes')
                else:
                    print('No')
            continue
        else:
            print('Yes')
            break

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

int main(){

string S;
cin >> S;
int cnt = 0;
for(int i = 0; i < 3; i++){ 
     if(S.at(i) == 'o') cnt++;
}
cout << 700 + cnt * 100 << endl; 
}

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

unsigned sourui(int r_, int d_, int x2000_){
    return r_*x2000_ - d_;
}

int main(){
    unsigned r, d, x2000, ans;
    cin >> r >> d >> x2000;
    //2001
    cout << sourui(r, d, x2000) << endl;
    ans = sourui(r, d, x2000);
    for(int i=1; i<10; ++i){
        //2002-2010
        ans = sourui(r, d, ans);
        cout << ans << endl;
    }
}

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


int n,m,K;

char g[10][10];
int check(int s,int t){
	int cnt=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(g[i][j]!='#')continue;
			if((s>>(i-1))&1)continue;
			if((t>>(j-1))&1)continue;
			++cnt;
		}
	}
	return cnt==K;
}

int main(){
	cin>>n>>m>>K;int ans=0;
	for(int i=1;i<=n;++i)cin>>(g[i]+1);
	for(int s=0;s<(1<<n);++s){
		for(int t=0;t<(1<<m);++t){
			if(check(s,t))++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n == 0) return 0;
		int a = 0, b = 0, c = 0;
		for(int i=0; i<n; ++i){
			string s;
			cin >> s;
			if(s == "lu") b += 2;
			else if(s == "ru") b += 1;
			else if(s == "ld") b -= 2;
			else b -= 1;
			if((b == 0 || b == 3) && b != c){
				c = b;
				++a;
			}
		}
		cout << a << "\n";
	}
}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

const long long MOD = 1000000007;
const int BIT_SIZE = 64;
const int MAX = 200001;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];
long long power(long long m, long long n){
    long long ans = 1;
    long long tmp = m;
    for(int i = 0; i < BIT_SIZE; i++){
        //cout << ans << endl;
        if(((n >> i) & 1) == 1){
            ans = ans * tmp % MOD;
        }
        tmp = (tmp * tmp) % MOD;
    }
    return ans;
}

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long f(int bit_length){
    /*
    long long ans = 0;
    for(int one_num = 0; one_num <= bit_length; one_num++){
        ans = (ans + (comb(bit_length, one_num) * power(2, one_num) % MOD)) % MOD;
    }
    */
    return power(3, bit_length);
}

int main(){
    string L;
    cin >> L;
    comb_init();
    int bit_length = L.size();    

    long long ans = f(bit_length - 1);
    //cout << f(bit_length - 1) << endl;
    int prev_one_num = 1;
    for(int second_sig_bit = 1; second_sig_bit < bit_length; second_sig_bit ++){
        if(L[second_sig_bit] == '1'){
            ans = (ans + (power(2, prev_one_num) * f(bit_length - second_sig_bit - 1)) % MOD) % MOD;
            prev_one_num ++;
        }
    }
    ans = (ans + power(2, prev_one_num)) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c, max(a*d, max(b*c, b*d)));

    return 0;
}

Measured memory_bytes: 3692
import bisect
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0 for _ in range(N+1)]
for i in range(1,N+1):
    D[i] = D[i-1]+L[i-1]
ind = bisect.bisect_right(D,X)    
print(ind)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    fast();
    ll c=0,n;
    cin>>n;
    int i,a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        c=c^a[i];
    }
    for(i=0;i<n;i++)
    cout<<(int)(c^a[i])<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4372
//#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
#include <map>

using namespace std;


int main(){

	string in;
	map  <string, int> maps;
	string longer = "";
	string mead;
	int cnt = 0;


	while (cin >> in){
		maps[in]++;
		if (maps[in] > cnt){
			cnt = maps[in];
			mead = in;
		}
		if (in.size() > longer.size())longer = in;
	}

	cout << mead << " " << longer << endl;

	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<bitset>
#include<climits>
using namespace std;

int main(void)
{
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];

        for (int j = 0; j < M; j++)
            cin >> A[i][j];
    }

    const int init = INT_MAX;
    int ans = init;
    for (int i = (1 << N) - 1; i > 0; i--) {
        bitset<12> bit(i);

        int c = 0;
        vector<int> a(M, 0);
        for (int j = 0; j < N; j++) {
            if (bit[j] == false)
                continue;

            c += C[j];
            for (int k = 0; k < M; k++)
                a[k] += A[j][k];
        }

        bool ok = true;
        for (int j = 0; ok == true && j < M; j++)
            if (a[j] < X)
                ok = false;

        if (ok == true)
            ans = min(ans, c);
    }

    if (ans == init)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0

sum_tmp = 0
for j in range(0, N):
    sum_tmp += Ai[j]

for i in range(N1):
    sum_tmp -= Ai[i]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))

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

int main() {
    string str;
    cin >> str;
    int n = str.size();

    int mn = 999999999;
    for (int i = 0; i < n - 2; ++i) {
        stringstream ss;
        ss << str[i] << str[i + 1] << str[i + 2];
        mn = min(mn, abs(atoi(ss.str().c_str()) - 753));
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007LL;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,m,ans=0,i,j;cin>>n>>m;
	vector<llint>oi[3];
	oi[0].res(n);
	oi[1].res(n);
	oi[2].res(n);
	for(i=0;i<n;i++){cin>>oi[0][i]>>oi[1][i]>>oi[2][i];}
	for(int bi=0;bi<8;bi++){
		vector<llint>ca(n);
		for(i=0;i<n;i++){
			for(j=0;j<3;j++){
				if(bi&(1<<j)){ca[i]+=oi[j][i];}
				else{ca[i]-=oi[j][i];}
			}
		}
		SO(ca);REV(ca);
		llint ge=0;
		for(i=0;i<m;i++){ge+=ca[i];}
		maxeq(ans,ge);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N, X, tmp;
    int min_m = 1000;
    cin >> N >> X;
    for(int i=0; i<N; ++i){
        cin >> tmp;
        min_m = min({min_m, tmp});
        X -= tmp;
    }
    int ans = N;
    ans += (X - X%min_m) / min_m;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    while True:
        n,m,a = [int(x) for x in input().split()]
        if n==0 and m==0 and a==0:
            return
        L = []
        for i in range(m):
            h,p,q = [int(x) for x in input().split()]
            L.append((h,p-1,q-1))
        L.sort()
        res = [i+1 for i in range(n)]
        for l in L:
            res[l[1]], res[l[2]] = res[l[2]], res[l[1]]
        print(res[a-1])

if __name__ == '__main__':
    main()

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

int main() {
  int n; cin>>n;
  vector<int> b(n,0);
  REP(i,n-1){
  	int a; cin>>a;
    b[a-1]++;  
  }
  REP(i,n) cout<<b[i]<<endl;
}

Measured memory_bytes: 4012
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define pos first
#define index second
#define mp make_pair
using namespace std;
#define int ll
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=2e5+10;
const int maxm=1e2+10;
const int mod=1e9+7;
int n;
char op[10];
int init()
{
    int k=10;
    for(int i=1;i<=9;i++)
    {
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='N')
            return i;
        k=k*10;
    }
    k=9;
    for(int i=1;i<=9;i++)
    {
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
            return i;
        k=k*10+9;
    }
    return 10;
}
signed main()
{
    //freopen("in.txt","r",stdin);
    int len=init();
    if(len==10)
    {
        printf("! %d\n",(int)1e9);
        return 0;
    }
    int ans=0;
    for(int i=1;i<len;i++)
    {
        int l=0,r=9,t=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            printf("? %d\n",ans*10+mid);
            fflush(stdout);
            scanf("%s",op);
            if(op[0]=='Y')
            {
                t=max(t,mid);
                l=mid+1;
            }
            else
                r=mid-1;
        }
        ans=ans*10+t;
    }
    for(int i=(len==1?1:0);i<=9;i++)
    {
        printf("? %lld\n",((ll)ans*10+i)*10);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
        {
            ans=ans*10+i;
            break;
        }
    }
    printf("! %d\n",ans);
    return 0;
}

Measured memory_bytes: 596
s = list(input())
t = list(input())

n = len(s)
m = len(t)

s.reverse()
t.reverse()

ans = []
for i in range(n-m+1):
    flg = True
    for j in range(m):
        if s[i+j] != '?' and s[i+j] != t[j]:
            flg = False

    if flg == True:
        s2 = s
        for j in range(n):
            if s[j] == '?':
                s2[j] = 'a'
        for j in range(m):
            s2[i+j] = t[j]
        ans.append(s2)
    #print(flg)
#print(ans)
ans.sort()
if len(ans) == 0:
    print('UNRESTORABLE')
else:
    print(''.join(reversed(ans[0])))

Measured memory_bytes: 3064
n = int(input())
s = "abcdefghijklmnopqrstuvwxyz"

l = [26]
for i in range(2, 14):
    a = 26 ** (i) + l[i-2]
    l.append(a)

idx = 0
while True:
    if n <= l[idx]:
        break
    idx += 1

if idx == 0:
    print(s[n-1])
    exit()

q = n - l[idx-1] - 1

ll = []
for j in range(idx+1):
    q, mod = divmod(q, 26)
    ll.append(mod)

ll.reverse()
ans = ""
for e in ll:
    ans += s[e]

print(ans)


Measured memory_bytes: 61844
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

string modify(string s){
    ll ind = -1;
    for(ll i=s.size()-1; i>=0; i--){
        if(s[i] == '9') continue;
        else {
            if(i == 0){
                s[i] = char(s[i]+1);
                ind = i;
                break;
            }
            else if(char(s[i]+1) - s[i-1] <= 1){
                s[i] = char(s[i]+1);
                ind = i;
                break;
            }
        }
    }
    if(ind == -1){
        string t;
        t.pb('1');
        loop(i,0,s.size()) t.pb('0');
        return t;
    }
    for(ll i=ind+1; i<s.size(); i++){
        if(s[i-1] >= '1') s[i] = char(s[i-1]-1);
        else s[i] = '0';
    }
    for(ll i=ind-1; i>=0; i--){
        if(abs(s[i]-s[i+1]) > 1) s[i] = char(s[i]+1);
    }

    return s;
}

void solve(){
    ll k;
    cin>>k;
    string ans = "1";
    for(ll i=0; i<k-1; i++){
        ans = modify(ans);
        // trace(ans);
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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;
}

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for (int i = st; i < ed; ++i) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> x >> y;
    vector<ll> cnt(3000, 0);

    vector<vector<ll>> dp(3000, vector<ll>(3000, 1000000));

    dp[x][y] = 1;

    rep (i, 1, n) {
        rep (j, i + 1, n + 1) {
            if (i < x) {
                if (j >= y) dp[i][j] = x - i + j - y + 1;
                else if (j > x) {
                    dp[i][j] = dp[i][j - 1] + 1;
                    chmin(dp[i][j], x - i + y - j + 1);
                }
                else dp[i][j] = j - i;
            }
            else if (i >= x && i < y) {
                if (j < y) {
                    dp[i][j] = y - j + i - x + 1;
                    chmin(dp[i][j], j - i);
                }
                else if (j >= y) {
                    dp[i][j] = j - y + i - x + 1;
                    chmin(dp[i][j], j - i);
                }
            }
            else {
                dp[i][j] = j - i;
            }
            cnt[dp[i][j]]++;
        }
    }

    rep (i, 1, n) {
        cout << cnt[i] << endl;
    }
    

    return 0;
}


Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int x = n / 2;
    int y = n / 2 - 1;
    int ans[15][15] = {};

    for (int i = 1; i <= n * n; ++i) {
      x = (x + 1 + n) % n;
      y = (y + 1 + n) % n;
      while (ans[x][y]) {
        x = (x + 1 + n) % n;
        y = (y - 1 + n) % n;
      }
      ans[x][y] = i;
    }

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


Measured memory_bytes: 3228
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node
{
    int id,u,v,cost,next;
    bool vis;
}edge[100010],arr[50010];
int T,t,n,m;
int p[50010],Head[510],tot,tot2,tot3,tot4,ans1,ans2;
int vis[510],U[510];
int stack[510],DFN[510],Low[510],Belong[510];
bool instack[510];
int top,cnt,scnt;
bool cmp(node a,node b)
{
    return a.cost<b.cost;
}
int find(int x)
{
    return p[x]==x ? x : p[x]=find(p[x]);
}
void _add(int u)
{
    if(vis[u]!=t)
    {
        vis[u]=t;
        U[++U[0]]=u;
    }
}
void add(int u,int v,int cost)
{
    //printf("%d %d %d\n",u,v,cost);
    edge[tot2].u=u;
    edge[tot2].v=v;
    edge[tot2].next=Head[u];
    edge[tot2].vis=0;
    Head[u]=tot2++;
}
void Tarjan(int u)
{
    //printf("Tarjan %d\n",u);
    int i,j,k,v;
    DFN[u]=Low[u]=++tot4;
    instack[u]=1;
    stack[top++]=u;
    for(i=Head[u];i>=tot;i=edge[i].next)
    {
        v=edge[i].v;
        if(edge[i].vis==1)
          continue;
        edge[i].vis=edge[i^1].vis=1;
        if(DFN[v]<=tot3)
        {
            Tarjan(v);
            Low[u]=min(Low[u],Low[v]);
        }
        else if(instack[v])
          Low[u]=min(Low[u],DFN[v]);
    }
    if(DFN[u]==Low[u])
    {
        scnt++;
        do
        {
            v=stack[--top];
            instack[v]=0;
            Belong[v]=scnt;
        }while(u!=v);
    }
}
int main()
{
    int i,j,k,l,r,u,v;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d%d",&arr[i].u,&arr[i].v,&arr[i].cost);
        arr[i].id=i;
    }
    for(i=1;i<=n;i++)
       p[i]=i;
    memset(Head,-1,sizeof(Head));
    sort(arr+1,arr+1+m,cmp);
    l=r=1;
    while(r<=m)
    {
        while(r<m && arr[r+1].cost==arr[r].cost)
          r++;
        tot=tot2;
        t++;
        U[0]=0;
        for(i=l;i<=r;i++)
        {
            u=find(arr[i].u);
            v=find(arr[i].v);
            if(u==v)
              continue;
            _add(v);_add(u);
            add(u,v,arr[i].cost);
            add(v,u,arr[i].cost);
        }
        tot3=tot4;
        top=cnt=scnt=0;
        for(i=1;i<=U[0];i++)
           if(DFN[U[i]]<=tot3)
             Tarjan(U[i]);
        //for(i=1;i<=U[0];i++)
        //   printf("Belong %d\n",Belong[U[i]]);
        for(i=l;i<=r;i++)
           if(Belong[find(arr[i].u)]!=Belong[find(arr[i].v)])
           {
               ans1++;
               ans2+=arr[i].cost;
           }

        for(i=l;i<=r;i++)
        {
            u=find(arr[i].u);
            v=find(arr[i].v);
            if(u==v)
              continue;
            p[v]=u;
        }
        l=r=r+1;
    }
    printf("%d %d\n",ans1,ans2);
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int x, a, b;
    cin >> x >> a >> b;
    (abs(x - a) < abs(x - b)) ? (puts("A")) : (puts("B"));
    return 0;
}

Measured memory_bytes: 256
a = input()
l = list(a)
year = int(l[0]) * 1000 + int(l[1]) * 100 + int(l[2]) * 10 + int(l[3])
month = int(l[5]) * 10 + int(l[6])
date = int(l[8]) * 10 + int(l[9])

if year < 2019 or month < 5:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define INF 1000000000000000
#define MAXN 100
#define LL long long
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
int len;
char a[MAXN+5],b[MAXN+5];
void Rotate(){
	char c=b[1];
	for(int i=2;i<=len;i++)
		b[i-1]=b[i];
	b[len]=c;
	return ;
}
int main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	len=strlen(a+1);
	if(!strcmp(a+1,b+1)) printf("Yes\n"),exit(0);
	for(int t=1;t<=len-1;t++){
		Rotate();
		if(!strcmp(a+1,b+1)) printf("Yes\n"),exit(0);
	}
	printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,i,I,a,mM=0,x,y,W,H,S,T,P,p;
  int box[100][100];
  while(1){
  cin>>N;
  if(N==0) break;
  else{
  cin>>W>>H;
  for(i=0;i<100;i++){
    for(I=0;I<100;I++){
      box[i][I]=0;
    }
  }
  for(i=0;i<N;i++){
    cin>>x>>y;
    box[x-1][y-1]=1;
  } 
  
  cin>>S>>T;
  mM=0;
  for(i=0;i<W;i++){
    for(I=0;I<H;I++){
      a=0;
      for(p=0;p<S;p++){
	for(P=0;P<T;P++){
	  if(box[p+i][P+I]==1) a++;
	}
      }
     
      if(mM<a) mM=a;
    }
  }
  cout<<mM<<endl;
  }
  }
  return 0;
} 

Measured memory_bytes: 1200
def bubble_sort(arr)
  arr.size.times do |i|
    0.upto(arr.size-i-2) do |j|
      if arr[j] > arr[j+1]
        arr[j], arr[j+1] = arr[j+1], arr[j]
        @c += 1
      end
    end
  end
end

while gets do
  n = $_.to_i
  break if n == 0
  arr = n.times.map{ gets.to_i }
  @c = 0
  bubble_sort(arr)
  puts @c
end

Measured memory_bytes: 6108
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define aintl(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) int a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it<<" ";}cout<<endl; }


int main(int argc, const char * argv[]) {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    pr(max((ll)0,-max(a, c)+
              min(b,d)));
    return 0;
}


Measured memory_bytes: 256
n = input()
if len(n) == 1:
    print(n)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    print((int(n) - 90))
elif len(n) == 4:
    print(909)
elif len(n) == 5:
    print((int(n) - 9090))
elif len(n) == 6:
    print(9 + 900 + 90000)

Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
char maze[1001][1001];
int d[1001][1001];
bool pre[1001][1001];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N,Y,Z,K;
	cin >> N>>M;
	output(N-M+1);
	return 0;
}





Measured memory_bytes: 256
from sys import stdin

def main():
    input = lambda: stdin.readline()[:-1]
    H, W, A, B = map(int, input().split())

    grid = ['1' * A + '0' * (W - A) for _ in range(B)]
    grid += ['0' * A + '1' * (W - A) for _ in range(H - B)]
    print(*grid, sep='\n')

main()


Measured memory_bytes: 5108
// Bismillahirrahmanirrahim
// AgriCoder IPB
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <clocale>
#include <ctime>
#include <climits>
#include <cassert>
//#include <unordered_map>
using namespace std;

#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)
#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)
#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)
//for (auto& it: agricoder)
#define RESET(agri,coder) memset(agri, coder, sizeof(agri))
#define pb push_back
#define mp make_pair
#define NL printf("==========================\n")
#define getchar_unlocked getchar // for codeforces

int arahbar[8] = {0,1,0,-1,1,1,-1,-1};
int arahkol[8] = {1,0,-1,0,1,-1,-1,1};
int kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};
int kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned int UNi;

template<typename T>
T getNum() {
   T res=0;
   char c;
   while(1)
   {
      c=getchar_unlocked();
      if(c==' ' || c=='\n') continue;
      else break;
   }
   bool negatif;
   if (c=='-') {
       negatif = true;
       res = 0;
   }
   else {
       res=c-'0';
       negatif = false;
   }
   while(1)
   {
      c=getchar_unlocked();
      if('0'<=c && c<='9') res=res*10 + c-'0';
      else break;
   }
   if (negatif) res*=-1;
   return res;
}

inline void boost() { //dont use with cstdio, dont use in interactives
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
//freopen("badmilk.in", "r", stdin);
//freopen("badmilk.out", "w", stdout);
//fclose(stdin);
//fclose(stdout);
#define INF 1000000000
#define EPS 1e-9
#define MAX_N 100005
// ================================  TEMPLATE ENDS HERE ================================================== //

int main() {
	string A,B,C;
	cin >> A >> B >> C;
	if (A[A.length()-1] == B[0] and B[B.length()-1]==C[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}
//Alhamdulillahirabbilalamin


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

int main() {
  string s;
  cin>>s;
  int n=s.length();
  int cnt=0;
  for(int i=0;i<n/2;i++){
    if(s[i] != s[n-i-1]){cnt ++;}
  }
  cout<<cnt;
}

Measured memory_bytes: 256
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;



int main(){ 
	speedhack()
	int n; cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		v.push_back(x);
	}
	vector<int> sorted = v;
	sort(all(sorted));
	int cnt = 0;
	for(int i = 0; i < v.size(); i++){
		if(v[i] != sorted[i])
		cnt++;
	}
	if(cnt%2 == 0 && cnt/2 <= 1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B; cin >> A >> B;

    int ans = 0;
    REP(i,2){
        if (A >= B) {
            ans += A;
            A--;
        }
        else {
            ans += B;
            B--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			scanner.nextLine();
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			scanner.nextLine();
			System.out.println((H - h) * (W - w));
		}
	}
}

Measured memory_bytes: 23124