akhauriyash/Code-Regression huggingface dataset:
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

ans = a + b + c + d + e
ans += 10 - (a % 10) if a % 10 != 0
ans += 10 - (b % 10) if b % 10 != 0
ans += 10 - (c % 10) if c % 10 != 0
ans += 10 - (d % 10) if d % 10 != 0
ans += 10 - (e % 10) if e % 10 != 0
datas =  [10 - (a % 10),10 - (b % 10),10 - (c % 10),10 - (d % 10),10 - (e % 10)]
datas.delete(10)
offset = 0
if datas.size != 0
  offset = datas.max
end
ans -= offset
puts ans.to_s

Measured memory_bytes: 1788
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a,b,m;
    cin>>a>>b>>m;
    int aa[a],bb[b];
    for (int i=0;i<a;i++){
    	cin>>aa[i];
    }
    for (int i=0;i<b;i++){
    	cin>>bb[i];
    }
    int xyc[m][3];
    for (int i=0;i<m;i++){
    	cin>>xyc[i][0]>>xyc[i][1]>>xyc[i][2];
    }
    int min1=aa[0];
    for (int i=1;i<a;i++){
    	if (min1>aa[i]){
    		min1=aa[i];
    	}
    }
    int min2=bb[0];
    for (int i=1;i<b;i++){
    	if (min2>bb[i]){
    		min2=bb[i];
    	}
    }
    int min=min1+min2;
    int min3=aa[xyc[0][0]-1]+bb[xyc[0][1]-1]-xyc[0][2];
    for (int i=1;i<m;i++){
    	if (min3>aa[xyc[i][0]-1]+bb[xyc[i][1]-1]-xyc[i][2]){
    		min3=aa[xyc[i][0]-1]+bb[xyc[i][1]-1]-xyc[i][2];
    	}	
    }
    if (min<min3){
    	cout<<min<<endl;
    }
    else{
    	cout<<min3<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#define ULL unsigned long long

using namespace std;

int main()
{
   ULL X;
   cin >> X;
  
  ULL yokin = 100;
  ULL nen = 0;
  while(yokin < X){
    nen++;
    yokin = static_cast<ULL>(yokin * 1.01);
  }
  
  cout << nen << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,a;
    cin>>n;
    bool b=true;
    rep(i,n){
        cin>>a;
        if(a%2==0){
            if(a%3!=0 && a%5!=0){
                b=false;
                break;
            }
        }
    }
if(b)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll = long long;
 
int main()
{
  ll n, d;
  cin >> n >> d;
  vector<ll> x(n);
  vector<ll> y(n);
  
  rep(i, n) cin >> x[i] >> y[i];
  
  int cnt = 0;
  rep(i, n){
    if(x[i]*x[i] + y[i]*y[i] <= d*d) cnt++;
  }
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 6408
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    string s; cin >> s;

    int n = s.length() ;
    vi v(n+1, -1);

    rep (i, 0, n-1) {
    	if (s[i]=='<') {
    		int cur = 0;
    		while (i < n && s[i]=='<') {
    			v[i++] = cur++;
    		}
    	}
    }

    repD (i, n-1, 0) {
    	if (s[i]=='>') {
    		int cur = 1;
    		while (i >= 0 && s[i]=='>')
    			v[i--] = cur++;
    		if (i>=0 && i+1 <= n) {
    			if (v[i+1] > v[i])
    				continue;
    			v[i+1] = v[i] + 1;

    		}
    	}
    }

    v[n] = (s[n-1]=='<' ? v[n-1]+1 : v[n-1]-1);
    ll res = 0;
   // db1(n);
    rep (i, 0, n) {
    	//db2(i, v[i]);
    	res+= (ll)v[i];
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 2844
S=list(input())
K=int(input())

def solve():
    global S,K
    if len(set(list(S)))==1:
        return len(S)*K//2

    initchar=S[0]
    initn=0
    for ss in S:
        if initchar==ss:
            initn+=1
        else:
            break
    count=0
    i=1
    while i<len(S):
        if S[i]==S[i-1]:
            count+=1
            S[i]="."
        i+=1
    
    a=(S[0]==S[-1])
    if initn%2==0:
        a=0


    if len(S)==1:
        return (K*len(S))//2
    else:
        return(count*K+a*(K-1))


print(int(solve()))

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

int main() {
    int N;
    vector<int> data(N);
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> data[i];
    
    sort(data.begin(), data.end(), greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i=0; i < N; ++i) {
        if (i%2 == 0) {
            Alice += data[i];
        } else {
            Bob += data[i];
        }
    }
    
    cout << Alice - Bob << endl;
    
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int lim = 400;
int h, w;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
char grid[lim+1][lim+1];
ll group[lim+1][lim+1];
ll groups = 1;
ll bc = 0, wc = 0;

void dfs(int y, int x) {
  for(int i=0; i<4; i++) {
    int ny = y + dy[i], nx = x + dx[i];
    if(ny >= 0 && ny < h && nx >= 0 && nx < w && !group[ny][nx]) {
      if(grid[y][x] == '#' && grid[ny][nx] == '.') {
        group[ny][nx] = groups;
        wc++; 
        dfs(ny, nx);
      } 
      if(grid[y][x] == '.' && grid[ny][nx] == '#') {
        group[ny][nx] = groups;
        bc++;
        dfs(ny, nx);
      }
    }
  }
}

int main(){
  cin >> h >> w;
  REP(i, h){
    string s; cin >> s;
    REP(j, w) grid[i][j] = s[j];
  }

  ll ans = 0;
  REP(i, h)REP(j, w){
    if(grid[i][j] == '#' && !group[i][j]) {
      group[i][j] = groups;
      bc++;
      dfs(i, j);

      groups++;
      ans += bc * wc;
      bc = 0; wc = 0;
    }
  }

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


Measured memory_bytes: 16640
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!int;
  auto S = readln;
  
  int total = 0;
  foreach(i; 0..N) {
    if (i == 0) {
      total++;
      continue;
    }
    if (S[i-1] == S[i]) continue;
    total++;
  }

  writeln(total);
}


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>

using namespace std;
int main()
{
    typedef long long ll;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if (k % 2 == 0) {
        ans = a - b;
    }
    else {
        ans = b - a;
    }
    if (ans > 1000000000000000000) {
        cout << "Unfair" << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
    int n; cin >> n;
    vector<int> a1(n),a2(n);
    rep(i,n) cin >> a1[i];
    rep(i,n) cin >> a2[i];
    
    rep(i,n-1) {
        a1[i+1] += a1[i];
        a2[i+1] += a2[i];
    }
    
    int ans = 0,ame;
    for(int i = 1; i < n; i++){
        ame = 0;
        ame = a1[i] + a2[n-1] - a2[i-1];
        ans = max(ans, ame);
    }

    cout << max(ans,a1[0] + a2[n-1]) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
	int n,k;
	long long sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	    cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
	    sum+=a[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3588
n = int(input())
x = sorted(list(map(int, input().split())))

if n == 1:
    print(0)
else:
    ans = float('inf')
    for i in range(x[0], x[-1]+1):
        temp = 0
        for j in range(n):
            temp += (i - x[j])**2
        ans = min(ans, temp)
    print(ans)

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 + (y1 - y2);
    int y3 = y2 + (x2 - x1);
    int x4 = x3 + (x1 - x2);
    int y4 = y3 + (x3 - x2);
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	fmt.Println(answer(a, b))
}

func answer(a int, b int) int {
	var ret int

	ret = a-b*2

	if ret < 0 {
		return 0
	}

	return ret
}



Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] x = new int[5];
        int ans = 6;
        for(int i = 0;i<x.length;i++){
            x[i] = sc.nextInt();
            if(x[i]==0){
                ans  = i;
            }
        }
        System.out.println(ans+1);

    }
}


Measured memory_bytes: 35660
s = list(input())

now = '>'
count = 0
nums = []
score = 0

for i in range(len(s)) :
    if s[i] == now :
        count += 1
    else :
        nums.append(count)
        count = 1
        now = s[i]

nums.append(count)

if s[len(s) - 1] == '>' :
    nums.append(0)

for j in range(len(nums)) :
    score += nums[j] * (nums[j] + 1) //2
    if j > 0 and j % 2 == 0 :
        if nums[j - 1] > nums[j] :
            score -= nums[j]
        else :
            score -= nums[j - 1]

print(score)

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

int main()
{
  int	n;
  string str;
  int x=0;
  int ans=x;
  cin>>n>>str;
  for(int i=0 ; i<n ; ++i)
  {
  	if(str[i]=='I')
    ++x;
    else if(str[i]=='D')
    --x;
    ans=max(x,ans);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    if(a%2==1 && b%2==1){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
    
    return 0;
}



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

int main() {
    int x, y, an, bn, cn;
    cin >> x >> y >> an >> bn >> cn;
    priority_queue<int> c;
    int a[an], b[bn];
    rep(i,an) {
        cin >> a[i];
    }
    rep(i,bn) {
        cin >> b[i];
    }
    rep(i,cn) {
        int x;
        cin >> x;
        c.push(x);
    }
    sort(a, a+an, greater<>());
    vector<int> ans;
    rep(i,x) {
        ans.push_back(a[i]);
    }
    sort(b, b+bn, greater<>());
    rep(i,y) {
        ans.push_back(b[i]);
    }
    sort(ans.begin(), ans.end());
    int j = 0;
    rep(i,cn) {
        int aa = c.top();
        if (aa > ans[j]) {
            ans[j] = aa;
            c.pop();
            j++;
        }
    }
    int64_t anss = 0;
    rep(i,ans.size()) {
        anss += ans[i];
    }
    cout << anss << endl;
}

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

using namespace std;

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n),ans(n);
    for(int i=0;i<n;i++) cin >> v[i];
    int index = 0,k = 1;
	for(int i=n-1;i>=0;i--){
		if(k){
			ans[index++] = v[i];
		}else{
			ans[n-index] = v[i];
		}
		k ^= 1;
	}
	for(int i=0;i<ans.size();i++){
		cout << ans[i] << " ";
	}
	cout << "\n";

	return 0;
} 


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
char s[100100];
int a[100];
int main(){
	scanf("%s",s);
	for(int i=0;s[i];i++)
		a[s[i]-'a']++;
	int c=min(a[0],min(a[1],a[2]));
	for(int i=0;i<3;++i)
		if((a[i]-=c)>=2)return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 384
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> h(n);
  rep(i, n) {
    cin>>h[i];
  }
  dump(h);

  int now = h[0]-1;

  rep(i, 1, n){
    if (h[i]>now){
      now = h[i]-1;
    }
    else if (h[i]==now){
      now = h[i];
    }
    else if (h[i]<now){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
a = [list(map(int, s.split()))[0] for s in open(0)][0]

def fn(a):
    if a % 2 == 0:
        return a // 2
    else:
        return 3*a + 1 

cnt = 1
li = [a]
while True:
    a = fn(a)
    cnt += 1
    if a in li:
        print(cnt)
        break
    li.append(a)


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

using namespace std;

int main()
{
	int n, k;
	cin>>n>>k;
	/*cout<<"n: "<<n<<endl;
	cout<<"k: "<<k<<endl;*/
	vector<long long int> v(n);
	for(int i=0; i<n; i++)
		cin>>v[i];

	for(int i=0; i<n; i++)
		v[i]--;

	long long ans = 0;
	for(int i=0; i<k; i++)
		ans += v[i];

	vector<long long> res(n-k+1);
	res[0] = ans;

	for(int i=k; i<n; i++)
	{
		res[i-k+1] = res[i-k] + v[i] - v[i-k];
	}

	for(int i=1; i<n-k+1; i++)
	{
		if(res[i] > res[i-1])
			printf("%s\n", "Yes");
		else
			printf("%s\n", "No");
	}

	return 0;
}

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

int main () {
    string s;
    cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
 
    bool con = 1;
    for (int i = -1; i < 2; i = i + 2)
        for (int j = -1; j < 2; j = j + 2)
            for (int k = -1; k < 2; k = k + 2) {
                if (((a + (b * i) + (c * j) + (d * k)) == 7) && (con)) {
                    cout << a << ((i == 1) ? '+' : '-') << b << ((j == 1) ? '+' : '-') << c << ((k == 1) ? '+' : '-') << d << "=7" << endl;
                    con = 0;
                }
            }
}   

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  rep(i,n){
    cout<<s[i]<<t[i];
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat
const int N = 200005;
bool visited[N];


int main(int argc, char const *argv[])
{
	sync;
	ll n, k;
	cin >> n >> k;
	ll a[n+5];
	rep(i,n){
		cin >> a[i];
	}
	memset(visited,false,sizeof(visited));
	ll cnt = 0, val =1;
	while(!visited[val]){
		visited[val] = true;
		val = a[val-1];
	}
	ll cycbegin = val;
	val = 1;
	//cout << cycbegin << endl;
	while(val!=cycbegin){
		val = a[val-1];
		k--;
		if(k == 0){
			cout << val << endl;
			return 0;
		}
	}
	val = cycbegin;
	while(val!=cycbegin || cnt==0){
		val = a[val-1];
		cnt++;
	}
	//cout << val sp cnt sp cycbegin<< endl;
	k %= cnt;
	rep(i,k){
		val = a[val-1];
	}
	cout << val << endl;
	return 0;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
#define MAXN 300100
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int check(int x){
	int a = sqrt(x);
	if(a*a==x)return true;
	return false;
}

int32_t main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	vector<int> res(n);
	int s=0;
	for(int i=0;i<n;i++)s+=v[i];
	
	int aux=0;
	for(int i=1;i<n-1;i+=2){
		aux+=v[i];
	}
	
	res[n-1] = s - 2*aux;
	for(int i=n-2;i>=0;i--){
		res[i]=2*(v[i+1]-res[i+1]/2);
	}
	cout<<res[n-1]<<" ";
	for(int i=0;i<n-1;i++)cout<<res[i]<<" ";
	cout<<endl;
}

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

int main(){
    int dp[5][4001] = {};
    for(int i = 0; i <= 1000; i++)  dp[1][i] = 1;
    for(int i = 1; i < 3; i++){
        for(int j = 0; j <= 1000*i; j++){
            for(int k = 0; k <= 1000*i; k++){
                dp[i*2][j+k] += dp[i][j]*dp[i][k];
            }
        }
    }

    int n;
    while(cin >> n) cout << dp[4][n] << endl;
    
    return 0;
}


Measured memory_bytes: 3176
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;




int main ( ){

    long long n;
    cin>>n;
    string s;
    cin >>s;
   char c = s[0];
   ll count=1;
    for(int i = 1 ;i<s.size();i++){
       if(c !=s[i]){
       	count++;
       	c=s[i];
	   }
    }
    cout << count;
    return 0;

}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    n=n%10;
    if(n==3){
        printf("bon\n");
    }
    else if(n==0||n==6||n==8||n==1){
        printf("pon\n");
    }
    else printf("hon\n");


    return 0;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	char matr[100][100];
	bool removed[100][100];
	int h,w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> matr[i][j];
		}
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			removed[i][j] = false;
		}
	}

	while (1) {
		bool was_any_change = false;

		for (int i = 0; i < h; ++i) {
			bool all_white = true;
			bool comp_removed = true;
			for (int j = 0; j < w; ++j) {
				if (removed[i][j]) {
					continue;
				}
				comp_removed = false;
				if (matr[i][j] == '#') {
					all_white = false;
					break;
				}
			}

			if (!comp_removed && all_white) {
				for (int j = 0; j < w; ++j) {
					removed[i][j] = true;
					was_any_change = true;
				}
			}
		}

		for (int j = 0; j < w; ++j) {
			bool all_white = true;
			bool comp_removed = true;
			for (int i = 0; i < h; ++i) {
				if (removed[i][j]) {
					continue;
				}
				comp_removed = false;
				if (matr[i][j] == '#') {
					all_white = false;
					break;
				}
			}
			if (!comp_removed && all_white) {
				for (int i = 0; i < h; ++i) {
					removed[i][j] = true;
					was_any_change = true;
				}
			}
		}

		if (!was_any_change)
			break;
	}

	for (int i = 0; i < h; ++i) {
		bool comp_removed = true;
		for (int j = 0; j < w; ++j) {
			if (!removed[i][j]) {
				cout << matr[i][j];
				comp_removed = false;
			}
		}
		if (!comp_removed)
			cout << '\n';
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    /*ll N,A,B;
    cin >> N >> A >> B;
    ll ans = (N / (A + B)) * A;
    ans += min(N % (A+B),A);
    cout << ans << endl;*/
    ll A,B;
    cin >> A >> B;
    rep(i,1000000){
        if(i * 8 / 100 == A && i * 10 / 100 == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String[] values = reader.readLine().split(" ");
            int month = Integer.parseInt(values[0]);
            if (month == 0) {
                break;
            }
            int day = Integer.parseInt(values[1]);
            int total = totals[month] + day;
            out.println(monthNames[total % 7]);
        }
    }

    private static final int[] totals = { 0, 0, 31, 60, 91, 121, 152, 182, 213,
            244, 274, 305, 335 };

    private static final String[] monthNames = { "Wednesday", "Thursday",
            "Friday", "Saturday", "Sunday", "Monday", "Tuesday" };
}

Measured memory_bytes: 9036
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
using namespace std;

#define N 100005
char s[N];

void solve() {
  scanf(" %s ",s+1);
  int n = strlen(s+1);
  if(s[n]=='1' || s[1]!='1') {
    printf("-1\n" );
    return;
  }
  for(int i=1;i<=n-1;++i) {
    if(s[i]!=s[n-i]) {
      printf("-1\n" );
      return;
    }
  }
  int lastRoot= 1,lastSz = 1;
  int nodePos = 2;
  vector<pair<int,int> >edge;
  s[n] = '1';
  for(int sz=2;sz<=n;++sz) {
    if(s[sz]=='1') {
      int curRoot = nodePos++;
      edge.push_back(make_pair(curRoot,lastRoot));
      for(int i=0;i<sz-lastSz-1;++i) {
        edge.push_back(make_pair(curRoot,nodePos++));
      }
      lastSz = sz;
      lastRoot = curRoot;
    }
  }
  assert(edge.size()==n-1);
  for(int i=0;i<edge.size();++i) {
    printf("%d %d\n", edge[i].first,edge[i].second);
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main() {
	int n; cin >> n;
	rep(i, n) {
		string s; cin >> s;
		deque<char>que; que.push_back(s[0]);
		int pos = 0, look = 1;
		while (look + 2 < s.size()) {
			if (s[look + 1] == '>') {
				if (++pos >= que.size()) {
					que.push_back(s[look + 2]);
				}
			}
			else {
				if (pos - 1 < 0) {
					que.push_front(s[look + 2]);
				}
				else pos--;
			}
			look += 3;
		}
		for (char c : que) {
			cout << c;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005,mo=1e9+7;
int dep[N],fa[N],D;
poly v[N];
void dfs(int u){
	dep[u]=dep[fa[u]]+1;
	for(auto k:v[u]){
		if(k==fa[u]) continue;
		fa[k]=u;dfs(k);
	}
}
int f[N][N<<1];
void dfs(int u,int fa,int D,int dep,int t){
	int l=dep-D+t,r=D-dep+t;
	For(i,l+505,r+505) f[u][i]=1;
	for(auto k:v[u]){
		if(k==fa) continue;
		dfs(k,u,D,dep+1,t);
		For(i,l+505,r+505){
			int ssw=(f[k][i-1]+f[k][i+1])%mo;
			f[u][i]=(ll)f[u][i]*ssw%mo;
		}
	}
}
int solve1(int u){
	dfs(u,0,D,0,1);
	int res=0;
	For(i,0,1005) res=(res+f[u][i])%mo;
	return res;
}
int solve2(int u,int v,int t){
	memset(f,0,sizeof(f));
	dfs(u,v,D+(!t),0,0);dfs(v,u,D,0,t);
	int res=0;
	For(i,1,1005){
		int ssw=(f[v][i-1]+f[v][i+1])%mo;
		res=(res+(ll)f[u][i]*ssw)%mo;
	}
	return res;
}
int main(){
	int n=read();
	For(i,1,n-1){
		int x=read(),y=read();
		v[x].pb(y);v[y].pb(x);
	}
	dep[0]=-1;
	int rt=0;dfs(1);
	For(i,1,n) if(dep[i]>dep[rt]) rt=i;
	memset(fa,0,sizeof(fa));dfs(rt);
	For(i,rt=1,n) if(dep[i]>dep[rt]) rt=i;
	if(dep[rt]%2==0){
		D=dep[rt]/2;
		For(i,1,D) rt=fa[rt];
		cout<<solve1(rt);
	}else{
		D=dep[rt]/2;
		For(i,1,D) rt=fa[rt];
		int u=rt,v=fa[rt];
		int res=(solve2(u,v,0)+solve2(v,u,0))%mo;
		int ssw=(solve2(u,v,1)+solve2(u,v,-1))%mo;
		res=(res-ssw+mo)%mo;
		cout<<res;
	}
}

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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var S = Console.ReadLine().ToCharArray();
        var Q = int.Parse(Console.ReadLine());
        var first = new Stack<char>();
        var last = new Stack<char>();
        foreach (var c in S)
            last.Push(c);

        for (var i = 0; i < Q; i++)
        {
            var l = Console.ReadLine().Split().ToArray();

            if (int.Parse(l[0]) == 1)
            {
                var tmp = first;
                first = last;
                last = tmp;
            }
            else
            {
                if (int.Parse(l[1]) == 1)
                {
                    first.Push(l[2][0]);
                }
                else
                {
                    last.Push(l[2][0]);
                }
            }
        }

        Console.WriteLine(string.Join("", first) + string.Join("", last.Reverse()));
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep (i,n) cin >> p[i];
  rep (i,n) cin >> q[i];
  vector<int> a(n);
  rep (i,n) a[i] = i + 1;

  map<vector<int>, int> mp;
  int iter = 0;
  do {
    mp[a] = iter++;
  } while (next_permutation(a.begin(), a.end()));
  cout << abs(mp[p] - mp[q]) << endl;
  return 0;
}


Measured memory_bytes: 5248
S = input()
Q = int(input())
Que = [list(map(str,input().split())) for i in range(Q)]

from collections import deque
count = 0
 
S = list(S)
S = deque(S)
 
for i in range(Q):
    if Que[i][0] == '1':
        #S.reverse()
        count += 1
    elif Que[i][0] == '2':
        if Que[i][1] == '1' and count%2 == 0:
            S.appendleft(Que[i][2])
        elif Que[i][1] == '1' and count%2 == 1:
            S.append(Que[i][2])
        elif Que[i][1] == '2' and count%2 == 0:
            S.append(Que[i][2])
        elif Que[i][1] == '2' and count%2 == 1:
            S.appendleft(Que[i][2])
            
if count%2 == 0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))

Measured memory_bytes: 44644
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
char c;
bool a[1010][1010];
long long b[1010][1010];
int main()
{
	int x,y;
	cin>>x>>y;
	for(int i=1;i<=x;i++)
	{
		for(int j=1;j<=y;j++)
		{
			cin>>c;
			if(c=='.')
			{
				a[i][j]=1;
			}
			else
			{
				a[i][j]=0;
			}
		}
	}
	for(int i=1;i<=x;i++)
	{
		for(int j=1;j<=y;j++)
		{
			if(i==1&&j==1) b[i][j]=1;
			else if(a[i][j]) b[i][j]=b[i-1][j]+b[i][j-1];
			b[i][j]=b[i][j]%1000000007;
		}
	}
	cout<<b[x][y]%1000000007;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  int n,p; string s; cin >>n >>p >>s; ll ans=0;
  for(int i=0; i<n; i++) s[i]-='0';
  if(10%p==0){
    for(int i=0; i<n; i++) if(s[i]%p==0) ans+=i+1;
    cout <<ans;
  }
  else{
    int x=1,v=0; vector<ll>r(p,0);
    for(int i=1; i<=n; i++){
      v=(v+x*s[n-i])%p;
      r[v]++; x=(x*10)%p;
    }
    for(int i=0; i<p; i++) ans+=r[i]*(r[i]-1)/2;
    cout <<ans+r[0];
  }
return 0;}

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

long long int n;
vector<long long int> v;
long long int dp[3005][3005];

long long int solve(long long int l,long long int r)
{
    if(l==r)
        return dp[l][r]=v[l];
    if(dp[l][r]!=-1)
        return dp[l][r];

    dp[l][r]=max(v[l]-solve(l+1,r),v[r]-solve(l,r-1));
    return dp[l][r];
}

int main()
{
    cin>>n;

    for(long long int i=0;i<n;i++)
    {
        long long int y;
        cin>>y;
        v.push_back(y);
    }

    for(long long int i=0;i<3005;i++)
        for(long long int j=0;j<3005;j++)
            dp[i][j]=-1;

    cout<<solve(0,n-1);
}


Measured memory_bytes: 71040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    ll n=s.size(),penable=0,g=0,p=0;
    //ll lastp=0;

    for(int count=0;count<n;count++){
        if(s[count]=='g'){
            penable++;
            g++;
        }
        else if(s[count]=='p'){
            if(penable>0){
                penable--;
            }else{
                p++;
            }
            //lastp=count;
        }
    }

    ll win,even,lose;
    lose=p;
    if(penable>0)
        win=penable/2;
    even=g;

    cout << win-lose << endl;

    return 0;
}


Measured memory_bytes: 512
am = int(input())
val = [[0]*(am+5),[0]*(am+5),[0]*(am+5)]
dp = [[0]*(am+5),[0]*(am+5),[0]*(am+5)]
for i in range(am):
    A,B,C = list(map(int,input().split()))
    val[0][i] = A
    val[1][i] = B
    val[2][i] = C

for i in range(0,am):
    for g in range(3):
        for j in range(3):
            if g!=j:
                dp[g][i+1] = max(dp[g][i+1],dp[j][i]+val[g][i])

print(max(dp[0][am],dp[1][am],dp[2][am]))

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  vector<string> s(n);
  REP(i,n)cin>>s[i];

  map<string,int> m;
  REP(i,n)m[s[i]] += 1;

  vector<pair<ll, string>> p(n);
  REP(i,n){
    p[i].FI = m[s[i]];
    p[i].SE = s[i];
  }

  sort(p.begin(), p.end(), greater<pair<ll, string>>());
  vector<string> ans;
  ll ma = p[0].FI;
  REP(i,n){
    if(p[i].FI == ma)
      ans.push_back(p[i].SE);
  }

  SORT_UNIQUE(ans);
  REP(i,ans.size())
    cout<<ans[i]<<endl;



}


Measured memory_bytes: 30320
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();  
        
        
        if(a<=b && b<=c){ 
                System.out.println(a+" "+b+" "+c);
        }
        else if(a<=c && c<=b){
                System.out.println(a+" "+c+" "+b);
            }
        else if(b<=a && a<=c){
                System.out.println(b+" "+a+" "+c);
            }
            else if(b<=c && c<=a){
                System.out.println(b+" "+c+" "+a);
            }
       else if(c<=a && a<=b){
           System.out.println(c+" "+a+" "+b);
       }
        else if(c<=b && b<=a){
           System.out.println(c+" "+b+" "+a);
        }
    }
}


Measured memory_bytes: 26420
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

struct edge { ll to; ll cost; };
ll n,q,k;
vector<edge> edges[101010];
vector<ll>vis(101010);
vector<ll>dist(101010);

void dfs(ll v, ll p, ll d) {
	dist[v] = d;
	for (auto x : edges[v]) {
		if (x.to == p)continue;
		dfs(x.to,v,d+x.cost);
	}
	
}




int main() {
	cin >> n;
	rep(i,0,n-1){
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--; 
		edges[a].push_back({b,c});
		edges[b].push_back({a,c});
	}
	
	cin >> q >> k;
	k--;
	dfs(k,-1,0);

	rep(i, 0, q) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		cout << dist[x] + dist[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define s 1005
int main()
{int a,b,c,d;
int arr[s][s];
cin>>a>>b>>c>>d;
for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
       if(i<d){
       if(j<c){
           cout<<1;
       }
       else{
           cout<<0;
       }
    }
        else{
            if(j<c){
                cout<<0;
            }
            else{
                cout<<1;
            }
    }
        
    }
    cout<<'\n';
}


    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main(){

	int n;
	cin >> n;
	
	ll ans = 100000;
	rep(i, n){
		ans *= 1.05;
		ans += 999;
		ans -= (ans % 1000);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2972
#if 0
date +%Y.%m.%d

有点恶心。

每个机器人看做一个点，平面上的每个点看做连接机器人的边。
形成的图一定是基环树森林，否则说明有一行或一列为空，直接输出 0 。

单独考虑森林的每一颗基环树。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) // fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 400005, mod = 1000000007;
int head[maxn], nxt[maxn << 2], to[maxn << 2], hp = 1;

inline ll power(ll x, int k) {
	if(k < 0) k += mod - 1;
	ll res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

inline void add(int u, int v, int *h) {
	nxt[++ hp] = h[u];
	h[u] = hp;
	to[hp] = v;
}

int tmp[maxn], tp;
bool vis[maxn];
int cx, cy;
int dfs(int u, int f) {
	/* debug("%d -> %d\n", f, u); */
	tmp[++ tp] = u;
	vis[u] = 1;
	int res = 0;

	for(int i = head[u]; i; i = nxt[i], ++ res)
		if(to[i] != f) {
			if(vis[to[i]]) {
				cx = u;
				cy = to[i];
			} else
				res += dfs(to[i], u);
		}

	/* debug("dfs %d %d\n", u, res); */

	return res;
}

int match[maxn];
void mdfs(int u, int f) {
	/* debug("%d -> %d\n", f, u); */
	for(int i = head[u]; i; i = nxt[i])
		if(to[i] != f and to[i] != cx) {
			match[to[i]] = u;
			mdfs(to[i], u);
		}
}

int Head[maxn];
int deg[maxn];
int stack[maxn], sp;
ll f[maxn];
int size[maxn];
ll fac[maxn], ifac[maxn];

inline ll C(int n, int m) {
	return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int force_count;
void dp(int u) {
	++ force_count;
	if(force_count >= maxn * 2) {
		puts("0");
		exit(0);
	}

	size[u] = 0;
	f[u] = 1;
	for(int i = Head[u]; i; i = nxt[i]) {
		dp(to[i]);
		size[u] += size[to[i]];
		(f[u] *= f[to[i]]) %= mod;
		(f[u] *= C(size[u], size[to[i]])) %= mod;
	}
	++ size[u];
	debug("%d : %lld %d\n", u, f[u], size[u]);
}

int HP;
ll solve() {
	debug("solve %d %d\n", cx, cy);
	mdfs(cx, cy);
	match[cx] = cy;

	hp = HP;
	for(int i = 1; i <= tp; i ++)
		deg[tmp[i]] = Head[tmp[i]] = 0;

	for(int id = 1; id <= tp; id ++) {
		int u = tmp[id];
		for(int i = head[u]; i; i = nxt[i])
			if(to[i] < match[u]) {
				debug("%d -> %d\n", u, to[i]);
				add(u, to[i], Head);
				++ deg[to[i]];
			}
	}

	Head[0] = 0;
	for(int i = 1; i <= tp; i ++)
		if(!deg[tmp[i]])
			add(0, tmp[i], Head);

	dp(0);
	debug("get %lld\n", f[0]);

	return f[0];
}

int main() {
	int n = read;

	int N = n << 1 | 1;
	fac[0] = 1;
	for(int i = 1; i <= N; i ++)
		fac[i] = fac[i - 1] * i % mod;
	ifac[N] = power(fac[N], -1);
	for(int i = N; i; i --)
		ifac[i - 1] = ifac[i] * i % mod;

	for(int i = 1; i < N; i ++) {
		int x = read, y = read;
		add(x, n + y, head);
		add(n + y, x, head);
	}

	HP = hp;
	ll ans = 1;
	int SIZE = 0;

	for(int r = 1; r < N; r ++)
		if(!vis[r]) {
			tp = 0;
			if(dfs(r, 0) != (tp << 1)) return puts("0"), 0;
			ll now = solve();
			std::swap(cx, cy);
			now += solve();
			SIZE += size[0] - 1;
			(ans *= now) %= mod;
			(ans *= C(SIZE, size[0] - 1)) %= mod;
		}

	printf("%lld\n", ans);
}


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

int main() {
  string S;
  cin >> S;
  if(S.size() == 2) {
    cout << S << endl;
  }
  else {
    cout << S.at(2) << S.at(1) << S.at(0) << endl;
  }
}


Measured memory_bytes: 256
object Main extends App {
  val persons = io.StdIn.readLine().split(" ")(0).toInt + 1
  val cakes = io.StdIn.readLine().split(" ").map(_.toInt).sum
  cakes % persons match {
    case 0 => println(cakes / persons)
    case _ => println(cakes / persons + 1)
  }
}


Measured memory_bytes: 44080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	set<int> st;
	FOR(i, 3) {
		int x;
		cin >> x;
		st.insert(x);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int r, g, b;
  std::cin >> r >> g >> b;

  int digit = r * 100 + g * 10 + b;
  if ( digit % 4 == 0 ) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    val A = nextIntList()
    val ans = (N - 1 + K - 2) / (K - 1)
    println(ans)
}

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

const int maxn = 100010;
int n, m, tp, x[maxn], y[maxn], c[maxn], tr[maxn];
bitset<50010> b[50010];
bool chk[maxn];
char s[maxn];

int main() {
    scanf("%d %d %d", &n, &m, &tp);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &x[i], &y[i]);
    }
    auto subtask1 = [&]() {
        for (int i = 1; i <= n; i++) {
            b[i].set(i);
        }
        for (int i = 1; i <= m; i++) {
            b[x[i]] = b[y[i]] = b[x[i]] | b[y[i]];
        }
        for (int i = 1; i <= n; i++) if (b[i].count() == n) {
            chk[i] = 1;
            for (int j = m; j; j--) {
                if (chk[x[j]]) {
                    s[j] = '^', chk[y[j]] = 1;
                } else {
                    s[j] = 'v', chk[x[j]] |= chk[y[j]];
                }
            }
            printf("%s\n", s + 1); return;
        }
        printf("-1\n");
    };
    auto subtask2 = [&]() {
        if (n == 2) { printf("-1\n"); return; }
        for (int i = 1; i <= n; i++) {
            tr[i] = i, c[i] = 1;
        }
        for (int i = m; i; i--) {
            if (c[tr[x[i]]] >= 2) {
                s[i] = 'v';
                c[tr[x[i]]]--, c[tr[x[i]] = tr[y[i]]]++;
            } else {
                s[i] = '^';
                c[tr[y[i]]]--, c[tr[y[i]] = tr[x[i]]]++;
            }
        }
        printf("%s\n", s + 1);
    };
    if (tp == 1) subtask1();
    else subtask2();
    return 0;
}

Measured memory_bytes: 307584