akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    ll a,b;
    cin >> a >> b;
    ll m = __gcd(a,b);
    int cnt = 1;
    for(ll i=2; i*i<m; i++){
        if(m%i==0){
            while(m%i == 0)
                m/=i;
            cnt++;
        }
    }
    if(m>1)
        cout << cnt+1;
    else
        cout << cnt;
}

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

int main(){
  string S;
  cin >> S;
  
  if(S=="Sunny"){
    cout << "Cloudy" << endl;
  }else if(S=="Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N,M;
    cin >> N >> M;
    ll p = 1LL << M;
    ll t = 1900*M + 100*(N-M);
    cout << (t*p) << endl;
}

Measured memory_bytes: 3480
import java.util.*;
class Main {
	static int mod = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		long pre[] = new long[n];
		pre[0] = arr[0];
		for (int i = 1; i < n; i++) {
			pre[i] = arr[i] + pre[i-1];
		}
		long ans = 0l;
		for (int i = 0; i < n - 1; i++) {
			ans = (ans + ((pre[n-1]- pre[i]) % mod) * arr[i]) % mod;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 59712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, Q;
        public string S;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                Q = line[1];
            }
            S = Console.ReadLine();

            int[] SUM = new int[N];
            for (int i = 0; i < N; i++)
            {
                int plus = ((i < N - 1) && (S[i] == 'A' && S[i + 1] == 'C')) ? 1 : 0;
                SUM[i] = (i == 0 ? 0 : SUM[i - 1]) + plus;
            }

            for (int q = 0; q < Q; q++)
            {
                var line = Input.ReadIntArray();
                int l = line[0] - 1;
                int r = line[1] - 1;

                int ret = SUM[r] - (l == 0 ? 0 : SUM[l - 1]);
                if (r < N - 1 && S[r] == 'A' && S[r + 1] == 'C') ret--;
                Console.WriteLine(ret);
            }

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 18492
import java.util.*;

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

        String s  =sc.next();
        String t = sc.next();
        sc.close();
        int count = 0;
        for(int i = 0; i < 3; i++){
            if(s.charAt(i) == t.charAt(i))
                count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	while (A > 0 && C > 0)
	{
		C -= B;
		if (C <= 0)
		{
			break;
		}
		A -= D;
	}

	if (A > 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10, A = 30;

string s;
char t[N], d[N];

int check(int p, int n, int q);

int main() {
	fast_cin();
	int n, q;
	cin >> n >> q >> s;
	for (int i = 1; i <= q; ++i) {
		cin >> t[i] >> d[i];
	}
	int ans = n;
	int lo = 0, hi = n - 1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (check(mid, n, q) < 0) {
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}
	ans -= lo;
	lo = 0; hi = n - 1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (check(mid, n, q) >= n) {
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	ans -= (n - 1 - hi);
	cout << ans << endl;
}

int check(int p, int n, int q) {
	for (int i = 1; i <= q; ++i) {
		if (t[i] == s[p]) {
			if (d[i] == 'L') {
				--p;
			} else {
				++p;
			}
			if (p < 0 or p >= n) {
				return p;
			}
		}
	}
	return p;
}

Measured memory_bytes: 976
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int main() {
    while(true) {
        int n; scanf("%d\n", &n);
        if(n==0) break;
        int die[] = {0,1,2,3,4,5};
        int dsum = 1;
        for(int i = 0; i < n; i++) {
            char command[20]; scanf("%s\n", command);
            if(command[0]=='N') {
                swap(die[0],die[1]); swap(die[1],die[5]); swap(die[5],die[4]);
            } else if(command[0]=='E') {
                swap(die[0],die[3]); swap(die[3],die[5]); swap(die[5],die[2]);
            } else if(command[0]=='W') {
                swap(die[0],die[2]); swap(die[2],die[5]); swap(die[5],die[3]);
            } else if(command[0]=='S') {
                swap(die[0],die[4]); swap(die[4],die[5]); swap(die[5],die[1]);
            } else if(command[0]=='R') {
                swap(die[1],die[2]); swap(die[2],die[4]); swap(die[4],die[3]);
            } else if(command[0]=='L') {
                swap(die[2],die[1]); swap(die[1],die[3]); swap(die[3],die[4]);
            }
            //printf("[%d,%d,%d,%d,%d,%d]\n",die[0],die[1],die[2],die[3],die[4],die[5]);
            dsum += die[0]+1;
        }
        printf("%d\n", dsum);
    }
    return 0;
}

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

int main(){
  int r, d, x, gen;
  
  cin >> r >> d >> x;
  
  gen = x;
  for(int i = 1; i <= 10; i++){
    gen = r * gen - d;
    
    cout << gen << endl;
  }
}

Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int arr[200200];
int rem[200200];
bool done[200200];
int main()
{
	int n,i,j,k,x,y,ans,curr,temp,m;
	int tc;
	ll moves;
	cin >> n >> moves;
	for(i=1;i<=n;i++) {
        cin >> arr[i];
	}
    rem[0] = 1;
    done[1] = 1;
    int now = arr[1];
    int cnt = 1;
    while(!done[now]) {
        done[now] = 1;
        now = arr[now];
    }
    int node = now;
    temp = now;
    memset(rem, 0, sizeof(rem));
    rem[0] = node;
    cnt = 1;
    while(arr[node] != rem[0]) {
        rem[cnt++] = arr[node];
        node = arr[node];
    }
    now = 1;
    while(now != temp) {
        now = arr[now];
        moves--;
        if(moves == 0) {
            cout << now << endl;
            return 0;
        }
    }
    moves %= cnt;
    cout << rem[moves] << endl;
	return 0;
}


Measured memory_bytes: 5364
import java.util.Scanner;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	private static int dp[];
	public static int findMinCost(int arr[],int n){
		if(n>=arr.length)
			return Integer.MAX_VALUE;
		if(n==arr.length-1)
			return 0;
		
		if(dp[n]!=Integer.MAX_VALUE)
			return dp[n];
		
		int n1=n+2<arr.length?findMinCost(arr,n+2)+Math.abs(arr[n]-arr[n+2]):Integer.MAX_VALUE;
		int n2=n+1<arr.length?findMinCost(arr,n+1)+Math.abs(arr[n]-arr[n+1]):Integer.MAX_VALUE;
		
		dp[n] = Math.min(n1,n2);
		return dp[n];
	}
	
	public static void main(String []args){
		int n=sc.nextInt();
		int arr[]=new int[n];
		dp=new int[arr.length];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
			dp[i]=Integer.MAX_VALUE;
		}
		System.out.println(findMinCost(arr,0));
	}
}

Measured memory_bytes: 66540
s=input()
p_count=0 #パーが何回出せるか
total=0
for i in range(len(s)):
    if s[i]=="g" and p_count>=1:
        p_count-=1
        total+=1
    elif s[i]=="g" and p_count==0:
        p_count+=1
    elif s[i]=="p" and p_count==0:
        p_count+=1
        total-=1
    elif s[i]=="p" and p_count>=1:
        p_count-=1
print(total)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll H, W;
	cin >> H >> W;
	REP(i, H)REP(j, W){
		string S;
		cin >> S;
		if(S=="snuke"){
			cout << char('A'+j) << i+1 << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, minNum, minIdx, maxNum, maxIdx;
std::vector<LL>a(100);
std::vector<std::pair<LL, LL>>ans;

int main()
{
	in >> N;
	rep(i, N) { in >> a[i]; }

	minNum = 1123456, maxNum = -1123456;
	rep(i, N)
	{
		if (minNum > a[i])
		{
			minNum = a[i];
			minIdx = i;
		}
		if (maxNum < a[i])
		{
			maxNum = a[i];
			maxIdx = i;
		}
	}
	if (abs(minNum) <= maxNum)
	{
		rep(i, N)
		{
			a[i] += maxNum;
			ans.push_back(std::make_pair(maxIdx, i));
		}
		rep(i, N - 1)
		{
			a[i + 1] += a[i];
			ans.push_back(std::make_pair(i, i + 1));
		}
	}
	else
	{
		rep(i, N)
		{
			a[i] += minNum;
			ans.push_back(std::make_pair(minIdx, i));
		}
		rep(i, N - 1)
		{
			a[N - i - 1] += a[N - i - 2];
			ans.push_back(std::make_pair(N - i - 1, N - i - 2));
		}
	}

	out << ans.size() << std::endl;
	for (auto i : ans) { out << i.first + 1 << " " << i.second + 1 << std::endl; }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 1001


int main(void){
	int i,j;
	char s1[MAX],s2[MAX];
	int n;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%s %s",s1,s2);
		int l1 = strlen(s1);
		int l2 =strlen(s2);
		for(j=l1; j >= 0; j--) s1[j+1]=s1[j];
		s1[0] =' ';
		for(j=l2; j >= 0; j--) s2[j+1]=s2[j];
		s2[0] =' ';
//		printf("%s %s\n",s1,s2);
		printf("%d\n", lcs(s1,s2) );
		}
	return 0;
}

int lcs(char s1[],char s2[]){
	int i,j;
	int m = strlen(s1);
	int n = strlen(s2);
	
	/*
	int **c;
	 c = (int **)malloc(sizeof(int *)*(m+1));
	for(i=0;i<=n;i++){
		c[i] = (int *)malloc(sizeof(int)*(n+1));
	}
	*/
	int c[MAX+1][MAX+1];
//	printf("debug1");
	for(i=0; i<=m; i++) c[i][0] = 0;
	for(i=1; i<=n; i++) c[0][i] = 0;
	
	
	
	for(i=1; i<=m; i++){
//			printf("debug2\n");
		for(j=1; j<=n; j++){
//				printf("debug3\n");
			if(s1[i] == s2[j]){
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else if(c[i-1][j] >= c[i][j - 1]){
				c[i][j] = c[i - 1][j];
			}
			else{
				c[i][j] = c[i][j - 1];
			}
		}
	}
//		printf("debug4\n");


	return c[i-2][j-2];
}



Measured memory_bytes: 5728
def main():

    N, M = map(int, input().split())

    s = set()
    d = dict()
    for i in range(M):
        a, b = map(int ,input().split())
        temp = list(map(int, input().split()))
        v = 0
        for j in range(b):
            s.add(temp[j])
            v |= 1 << temp[j]
        if v in d: d[v] = min(d[v], a)
        else: d[v] = a

    if(len(s) < N): return -1

    M = len(d)
    cur = dict()
    cur[0] = 0
    for g in d:
        temp = cur.copy()
        for v in temp:
            cost = d[g]
            u = v | g
            if u in cur: cur[u] = min(cur[u], cur[v] + cost)
            else: cur[u] = cur[v] + cost

    target = 0
    for i in range(1, N+1): target |= 1 << i
    return cur[target]


if __name__ == '__main__':
    print(main())

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

int main() {
	ios :: sync_with_stdio(false);
	for(int i = 1; i <= 9; i ++)
		for(int j = 1; j <= 9; j ++)
			cout << i << "x" << j << "=" << i * j << '\n';
	return 0;
}

Measured memory_bytes: 3064
n=int(input())
data=[]
t=[[0 for x in range(4)] for w in range(n+1)]
for _ in range(n):
    temp=[int(x) for x in input().split()]
    data.append(temp)
for i in range(1,n+1):
    for j in range(1,4):
        large=0
        for w in range(1,4):
            if(w==j):
                continue
            else:
                if(t[i-1][w]>large):
                    large=t[i-1][w]
        t[i][j]=data[i-1][j-1]+large
print(max(t[-1]))

Measured memory_bytes: 75100
N = int(input())
C = [-1]

for _ in range(N):
    c = int(input())
    if c == C[-1]:
        continue
    else:
        C.append(c)

MOD = 10**9+7
dp = 1
prev = [0]*(max(C)+1)

for c in C[1:]:
    dp = (dp+prev[c]) % MOD
    prev[c] = dp
print(dp)


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

const long long mod = 1e9+7;

void solve() {
  int n;
  cin >> n;
  vector<int> dp(n+1);
  dp[0] = 1;
  for(int i = 1; i < n+1; ++i) {
    if(i >= 3) dp[i] = dp[i-1] + dp[i-3];
    dp[i] %= mod;
  }
  cout << dp[n] << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int p=1,c=0;
    while(true){
        c++;
        if(a[p]==0){
            cout<<-1;
            break;
        }
        if(a[p]==2){
            cout<<c;
            break;
        }
        int q=p;
        q=a[p];
        a[p]=0;
        p=q;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    return 0;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

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

	ll ans = LINF;
	for (ll i = 1; i*i <= n; i++) {
		if (n % i != 0) continue;
		ll j = n / i;
		ans = min(ans, i + j - 2);
	}

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


Measured memory_bytes: 256
using System;

namespace  ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Int32.Parse(Console.ReadLine());
            var h = (input / 60) / 60;
            var m = (input / 60) % 60;
            var s = input % 60;

            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}


Measured memory_bytes: 9188
#include<stdio.h>
#define inf 0x3f3f3f3f
int map[11][11];
int main(void)
{
	int n;
	while(scanf("%d",&n),n!=0)
	{
		for(int i=0;i<=11;i++)
		{
			for(int j=0;j<=11;j++)
			map[i][j]=inf;
			map[i][i]=0;
		}
		int max=0;
		for(int i=0;i<n;i++)
		{
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			if(map[a][b]>c)
			{
				map[a][b]=map[b][a]=c;
			}
			if(a>max)
			max=a;
			if(b>max)
			max=b;
		}
		for(int k=0;k<=max;k++)
		for(int i=0;i<=max;i++)
		for(int j=0;j<=max;j++)
		if(map[i][j]>map[i][k]+map[k][j])
		{
			map[i][j]=map[i][k]+map[k][j];
		}
		int min=inf,k;
		for(int i=0;i<=max;i++)
		{
			int num=0;
			for(int j=0;j<=max;j++)
			num=num+map[i][j];
			if(num<min)
			{
				min=num;
				k=i;
			}
		}
		printf("%d %d\n",k,min);
	}
	return 0;
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

int get(){
	int a,b;read(a);read(b);return a*60+b;
}

int main() {
	int a=get(),b=get();
	int x=b-a;int k;read(k);
	cout<<x-k;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int H, W, a, b, f, t, e;
set<pair<int,int>> st;
multiset<int> ms;
int main(){
	scanf("%d%d", &H, &W);
	rep(i,W){
		st.emplace(i,i);
		ms.insert(0);
	}
	rep(i,H){
		scanf("%d%d", &a, &b);
		auto tl = st.lower_bound({a-1,0}), el = st.lower_bound({b,0});
		e = tl != el;
		for(; tl != el; tl = st.erase(tl)){
			tie(t,f) = *tl;
			ms.erase(ms.find(t-f));
		}
		if(e && b != W){
			st.emplace(b,f);
			ms.insert(b-f);
		}
		printf("%d\n", ms.empty() ? -1 : *ms.begin()+i+1);
	}
}

Measured memory_bytes: 22376
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int N, M; scanf("%d%d", &N, &M);
  vector<vector<int>> holes(M);
  for(int i = 0; i < N; ++i) {
    int X; scanf("%d", &X);
    holes[X % M].push_back(X);
  }
  vector<int> dups(M);
  for(int i = 0; i < M; ++i) {
    sort(holes[i].begin(), holes[i].end());
    int dup = 0;
    for(int j = 1; j < (int)holes[i].size(); ++j) {
      if(holes[i][j-1] == holes[i][j]) {
        ++dup;
        ++j;
      }
    }
    dups[i] = dup;
  }
  int numpairs = 0;
  for(int i = 1; i * 2 < M; ++i) {
    int x = holes[i].size();
    int y = holes[M-i].size();
    if(x > y) {
      numpairs += y + min((x - y) / 2, dups[i]);
    } else {
      numpairs += x + min((y - x) / 2, dups[M-i]);
    }
  }
  numpairs += holes[0].size() / 2;
  if(M % 2 == 0) numpairs += holes[M/2].size() / 2;
  printf("%d\n", numpairs);
  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
#define MAX_P 200010
int fact[MAX_P]; //n! mid p

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
//n! = a p^e -> a mod p
void make_fact()
{
    fact[1] = 1;
    for (int i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
//nCk mod p
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int n, k;
    cin >> n >> k;
    make_fact();
    for (int i = 1; i <= k; i++)
    {
        int a = mod_comb(k - 1, i - 1, mod);
        int b = mod_comb(n - k + 1, i, mod);
        cout << (a * b) % mod << endl;
    }
}

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

//諸機能
#pragma region MACRO 
#define putans(x)  cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define input ifs >>
#else //いい感じにやる
#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

int main() {
	int n; input n;
	vi a;
	ll ans = 0;
	rep(i, n) {
		int k; input k;
		a.push_back(k);
	}
	a.push_back(0);
	rep(i, n) {
		ans += a[i] / 2;
		a[i] -= ( a[i] / 2 ) * 2;
		if (a[i]  % 2 == 1 && a[i+1] > 0) {
			ans++;
			a[i]--;
			a[i + 1]--;
		}
	}
	putans(ans);
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int s = 0;
    int m = n;
    while(m){
        s += m%10;
        m /=10;
    }
    if(n % s == 0){
        cout << "Yes" << endl;   
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>

using namespace std;

long long N, M, H, W;
long long A[200001];
string S;
vector <long long>vl;

int main() {
	cin >> N>>M;
	H = N - 1;
	if (N <= M) {
		H++;
	}

	cout << H << endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
long int n, W;
pair<long int, long int> p[100];
vector<long int> a[4];

long int dfs(long int w0, long int w1, long int w2, long int w3){
    long int res = 0;
    long int weight = 0;
    weight += w0 * p[0].second;
    weight += w1 * (p[0].second + 1);
    weight += w2 * (p[0].second + 2);
    weight += w3 * (p[0].second + 3);
    if (weight > W){
        return res;
    }
    
    for (long int i = 0; i < w0; i++){
        res += a[0][i];
    }
    for (long int i = 0; i < w1; i++){
        res += a[1][i];
    }
    for (long int i = 0; i < w2; i++){
        res += a[2][i];
    }
    for (long int i = 0; i < w3; i++){
        res += a[3][i];
    }
    
    return res;
}

int main(){
    cin >> n >> W;
    rep(i, n) cin >> p[i].second >> p[i].first;
    rep(i, n) a[p[i].second - p[0].second].push_back(p[i].first);
    rep(i, 4){
        sort(a[i].begin(), a[i].end(), greater<long int>());
    }
    
    long int num[4];
    rep(i, 4) num[i] = a[i].size();
    long int ans = 0;
    rep(i, a[0].size()+1)rep(j, a[1].size()+1)rep(k, a[2].size()+1)rep(l, a[3].size()+1){
        ans = max(dfs(i, j, k, l), ans);
    }
    cout << ans << endl;
}


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

int main()
{
    int a,b,W;
    while(scanf("%d%d%d",&W,&a,&b)==3)
    {
        int c;
        int d;
        if(a>b)
        {
            c=b;
            b=a;
            a=c;
        }
        d=b-(a+W);
        if(d>0)
        {
            printf("%d\n",d);
        }
        else printf("0\n");
    }


    return 0;
}


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

int main() {
    int N; cin >> N;
    int ans=0;
    REP(i,N){
     int a=0,b=0;
     cin >> a >> b;
     ans += b-a+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int maxn=3e5+5;
const int mod=998244353;
int n,k;
struct node{
    int l,r,mx;
}t[maxn<<2];
void pushup(int rt){
    t[rt].mx=max(t[rt<<1].mx,t[rt<<1|1].mx);
}
void build(int l,int r,int rt){
    t[rt].l=l;t[rt].r=r;t[rt].mx=0;
    if(l==r)
        return ;

    int mid=l+r>>1;
    build(l,mid,rt<<1);
    build(mid+1,r,rt<<1|1);
}
void update(int pos,int val,int rt){
    int l=t[rt].l,r=t[rt].r;
    if(l==r){
     t[rt].mx=max(t[rt].mx,val);
     return ;
    }
    int mid=l+r>>1;
    if(pos<=mid)update(pos,val,rt<<1);
    else update(pos,val,rt<<1|1);
    pushup(rt);
}

int query(int L,int R,int rt){
    int l=t[rt].l,r=t[rt].r;
    if(L<=l&&r<=R){
        return t[rt].mx;
    }
    int mid=l+r>>1;
    if(R<=mid)return query(L,R,rt<<1);
    else if(L>mid)return query(L,R,rt<<1|1);
    else{
     return max(query(L,mid,rt<<1),query(mid+1,R,rt<<1|1));
    }
}
int main(){
    int N=3e5;
    build(1,N,1);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    int ans=0;

    for(int i=1;i<=n;i++){
        int val;
        cin>>val;

        int res=query(max(0,val-k),min(N,val+k),1)+1;
        ans=max(ans,res);
        update(val,res,1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 16080
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

using namespace std;

int main(void){
  int n;
  int a[3];
  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);

  for(int i = 1 ; i <= a[0] ; i ++){
    if(n==2){
      if(a[0]%i==0 && a[1]%i==0)cout<<i<<endl;
    }else{
      if(a[0]%i==0 && a[1]%i==0 && a[2]%i==0)cout<<i<<endl;
    }
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int>x(N);
    vector<int>y(N);
    for (int i = 0; i < N; ++i) {
      cin >> x[i] >> y[i];
    }

    if(N == 1) {
        cout << 1;
        return 0;
    }

    vector<pair<int, int>> dist;
    dist.reserve(N*(N-1)/2);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if(i != j){
                int p = x[i] - x[j];
                int q = y[i] - y[j];
                dist.push_back(make_pair(p, q));
            }
        }
    }
    sort(dist.begin(), dist.end());
    int ans = 1;
    int streak = 1;
    for (int i = 1; i < dist.size(); ++i) {
        if(dist[i] == dist[i-1]){
            streak++;
            ans = max(ans, streak);
        } else{
            streak = 1;
        }
    }
    ans = N - ans;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int x,y;
    cin >> x >> y;
    vector<int> v(250,0);
    v[0] = 300000;
    v[1] = 200000;
    v[2] = 100000;
    int ans = v[x-1] + v[y-1];
    if (x == 1 && y == 1) ans+= 400000;
    cout << ans;
    rn 0;
    
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 n, a[202020];
i64 cnt[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	if(a[0] <= n) cnt[a[0]]++;
	i64 ans = 0;
	for(i64 i = 1; i < n; i++){
		if(a[i] < i) ans += cnt[i-a[i]];
		if(a[i]+i <= n) cnt[a[i]+i]++;
	}
	
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 6780
# E - NEQ

N, M = map(int, input().split())
MOD = 10 ** 9 + 7

fac = [1, 1]
inv = [0, 1]
finv = [1, 1]

for i in range(2, M+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD)

fixed = (fac[N] * fac[M] * pow(finv[M-N], 2, MOD)) % MOD

def f(k):
    return (fac[M-k] * finv[k] * finv[N-k]) % MOD

ans = 0
for i in range(N+1):
    ans = (ans + fixed * f(i) * pow(-1, i)) % MOD

print(ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll N = nextLong();
  ll M = nextLong();
  ll A = nextLong();
  ll B = nextLong();

  ll ans = atcoder::floor_sum(N, M, A, B);

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

int main() {
  int t = nextLong();
  while (t--)
    main2();
  return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

int h,w,n;
char board[1005][1005];
int x[10],y[10];
bool check(int i, int j) {
	return (i >= 1) && (i <= h) && (j >= 1) && (j <= w) && (board[i][j] == '.');
}
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n+1),b(n);
    for(int i=0;i<n+1;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i])ans+=b[i];
        else{
            ans+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i])ans+=b[i],a[i+1]-=b[i];
            else ans+=a[i+1],a[i+1]=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [int(c) for c in input().split()]
m = 0
t0 = [-1]*n # 最初使える、i以降
t1 = [-1]*n # 使えない
t2 = [-1]*n # 使わないといけない
t0[-1] = a[-1]
t1[-1] = 0
t2[-1] = a[-1]
tmp = 0
for i in range(-1, -n-1, -2):
    tmp += a[i]
    t2[i] = tmp
tmp = 0
for i in range(-2, -n-1, -2):
    tmp += a[i]
    t2[i] = tmp

    
for i in range(-2, -n-1, -1):
    if i%2==0:
        m= a[i]+t1[i+1]
        m = max(m, t2[i+1])
        t0[i] = m
        t1[i] = t0[i+1]
#         t2[i] = a[i] + t1[i+1]
    else:
        m= a[i]+t1[i+1]
        m = max(m, t0[i+1])
        t0[i] = m
        t1[i] = t0[i+1]
#         t2[i] = a[i] + t1[i+1]
        
print(t0[0])

Measured memory_bytes: 93920
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;


int main() {

    string S;
    cin>>S;

    string goal1 = "keyofscience";
    string goal2 = "keyence";
    if(S==goal1 || S==goal2)
    {
        cout<<"YES"<<endl;
        return 0;
    }

    size_t charlen=S.length();

    for(size_t i=0; i<charlen; i++)
    {
        for(size_t j=0; j<charlen-i; ++j)
        {
            string tmp = S;
            tmp.erase(tmp.begin()+i, tmp.begin()+i+j);
            if(tmp==goal1 || tmp == goal2)
            {
                cout<<"YES"<<endl;
                return 0;
            }

        }
    }

    cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#154D
n,k = map(int,input().split())
P = list(map(int,input().split()))

e_p  = []
for i in range(len(P)):
    e_p.append((P[i]+1)/2)

s = [0]*(len(P)+1)
for i in range(len(P)):
    s[i+1] = s[i]+e_p[i]
    
res = 0
for i in range(n-k+1):
    res = max(res,s[i+k] - s[i])
        
print(res)

Measured memory_bytes: 32360
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int s = max(a, c);
  int e = min(b, d);
  if(e - s > 0) cout << e - s << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <bitset>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int N = (int)2e5 + 5;
const int inf = 1e9;
int n, m, d[N];
queue <int> q;
vi v[N];

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	for(int i = 0; i < n; i++)
		d[i] = inf;
	d[0] = 0;
	q.push(0);
	while(!q.empty())
	{
		int t = q.front();
		q.pop();
		for(int to : v[t])
		{
			if(d[to] == inf)
			{
				d[to] = d[t] + 1;
				q.push(to);
			}
		}
	}
	if(d[n - 1] <= 2)
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 13168
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,j,k,l,d[110][110][5];
  while(scanf("%d %d",&m,&n),n||m){
    for(i=0;i<110*110;i++)d[i/110][i%110][0]=d[i/110][i%110][1]=1e9;
    while(m--){
      scanf("%d %d %d %d",&i,&j,&k,&l);
      d[i][j][0]=d[j][i][0]=k;
      d[i][j][1]=d[j][i][1]=l;
    }
    for(i=0;i<2;i++){
      for(j=1;j<=n;j++){
	for(k=1;k<=n;k++){
	  for(l=1;l<=n;l++)d[k][l][i]=MIN(d[k][l][i],d[k][j][i]+d[j][l][i]);
	}
      }
    }
    scanf("%d",&m);
    while(m--){
      scanf("%d %d %d",&i,&j,&k);
      printf("%d\n",d[i][j][k]);
    }
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int prev = a[0], r = 0, ans = n;
  for (int i = 1; i < n; i++) {
    if (a[i] == prev) {
      r ^= 1;
      ans--;
    }
    prev = a[i];
  }
  cout << ans - r << endl;
}

Measured memory_bytes: 640
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w, a, b = list(map(int, input().rstrip('\n').split()))
    for i in range(h):
        if i < b:
            print("".join(["0"] * a + ["1"] * (w - a)))
        else:
            print("".join(["1"] * a + ["0"] * (w - a)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39920
import sys
from collections import Counter
import random
import numpy as np

def fact(n):
    x=1
    for i in range(2,n+1):x*=i
    return x

def comb(n,r):
    return(fact(n)//(fact(r)*fact(n-r)))

n=int(input())
a=list(map(int,input().split()))
a.sort()
z=a.pop(n-1)
#b=[a[i]/2 for i in range(n-1)]
min=10**10
y=z/2
x=0
for i in range(n-1):
    dif=abs(y-a[i])
    if(dif<min):
        min=dif
        x=a[i]
print(z,x)

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

int main() {
  int x,f;
  int a;
  f=0;
  cin >>x;
  a=x;
  for(int i=0;i<10;i++){
   if(x%10==0){
   x=x/10;
   }
   else{  
   f+=x%10;
   x=x/10;
   }
  
  }
  if(a%f==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
    
}

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

using namespace std;

int main() {
    int X;
    cin >> X;
    int num500 = X / 500;
    int num5 = (X % 500) / 5;
    cout << num500 * 1000 + num5 * 5 << endl;
    return 0;
}

Measured memory_bytes: 256
S = gets
if S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]
  puts"Yes"
elsif S[0]!=S[1] && S[1]==S[2] && S[0]==S[3] 
  puts"Yes"
elsif S[1]!=S[2] && S[0]==S[2] && S[1]=S[3]
  puts"Yes"
else
  puts"No"
end

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

int main(){
  int D,L,Dnum=0,Lnum=0;

  cin >> D >> L;

  Dnum = D/L;

  Lnum = D - Dnum*L;


  cout << Dnum + Lnum << endl;
  
  return 0;
}



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

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = b-1;
    if(n < b-1) x = n;
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args)
	{
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		int x=in.nextInt();
		int t=in.nextInt();
		int count=0;
		while(n!=0)
		{
			n-=Math.min(x, n);
			count++;
		}
		System.out.println(count*t);
	}

static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	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: 32560
x_1,y_1,x_2,y_2=map(int,input().split())
x=x_2-x_1
y=y_2-y_1
x_3=x_2-y
y_3=y_2+x
x_4=x_3-x
y_4=y_3-y
print(str(x_3)+" "+str(y_3)+" "+str(x_4)+" "+str(y_4))

Measured memory_bytes: 3060
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = read.to!int;
	int d = read.to!int;
	
	long[][] xs = new long[][](n, d);
	foreach(i; 0 .. n) foreach(k; 0 .. d){
		xs[i][k] = read.to!long;
	}
	
	int ans = 0;
	foreach(i; 0 .. n) foreach(j; 0 .. i){
		long u2;
		foreach(k; 0 .. d) u2 += (xs[i][k] - xs[j][k] ) * (xs[i][k] - xs[j][k]);
		
		long u = (u2.to!real + 0.1).sqrt.to!long;
		if(u * u == u2) ans += 1;
	}
	
	ans.writeln;
	
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


signed main()
{   
    gearup;
    string s; cin >> s;
    int n = s.size();
    vvl d(31,vl(n)); //ダブリング
    rep(i,n){
        if(s[i] == 'R')d[0][i] = i+1;
        else d[0][i] = i -1;
    }
    rep(i,30)rep(j,n)d[i+1][j] = d[i][d[i][j]];
    vl res(n);
    rep(i,n)res[d[30][i]]++;
    rep(i,n){
        if(i)cout << " ";
        cout << res[i];
    }
    cout << endl;
}


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

int a[100010], b[100010];
int n;

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

    for (int i = 1;i<n;i++)
        cout << b[i] << " ";
    cout << b[n];
}

Measured memory_bytes: 1664
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9e18
#define minf -9e18
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
	int a,b;
	cin>>a>>b;
        
    cout<<(6-a-b);    












    return 0;
}

Measured memory_bytes: 256