akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T>
std::istream& operator >> (std::istream& is, std::vector<T>& vec){
  T tmp;
  is >> tmp;
  vec.push_back(tmp);
  return is;
}
template <class T>
auto mkVec(unsigned int x){
  return std::vector<T>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(x, std::vector<T>(y));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(x, std::vector<std::vector<T>>(y, std::vector<T>(z)));
}



#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  ll N;
  cin >> N;
  vector<ll> ev, ov;
  map<ll, int> em, om;
  rep(i, N){
    ll x;
    cin >> x;
    if(i % 2){
      ov.push_back(x);
      om[x]++;
    }else{
      ev.push_back(x);
      em[x]++;
    }
  }
  // debug(e);
  // debug(o);

  ll efst = 0, esnd = 0;
  for(auto && e:em){
    // debug(e.first);
    // debug(e.second);
    if(e.second > em[efst]){
      esnd = efst;
      efst = e.first;
      continue;
    }
    if(e.second > em[esnd]){
      esnd = e.first;
      continue;
    }
  }

  ll ofst = 0, osnd = 0;
  for(auto && e:om){
    // debug(e.first);
    // debug(e.second);
    if(e.second > om[ofst]){
      osnd = ofst;
      ofst = e.first;
      continue;
    }
    if(e.second > om[osnd]){
      osnd = e.first;
      continue;
    }
  }
  // debug(ofst);
  // debug(osnd);
  // debug(efst);
  // debug(esnd);
  if(ofst != efst){
    cout << N - em[efst] - om[ofst];
  }else{
    cout << min(N - em[efst] - om[osnd], N - om[ofst] - em[esnd]);
  }
  
}
#endif



Measured memory_bytes: 7280
A, B, C, D, E, F = map(int, input().rstrip().split())
water = []
for i in range(A+1):
    for j in range(B+1):
        tmp = A*i*100 + B*j*100
        if tmp < F: 
            water.append(tmp)
        else:
            break
water.sort(reverse=True)
water.pop()
maximum = [water[0], 0]
concentration = 0
for i in water:
    multi = i//100
    suger_limit = E*multi if E*multi + i <= F else F - i
    for j in range(100):
        for k in range(100):
            suger = C*j + D*k
            if suger > suger_limit:
                break
            if concentration < 100*suger / (i + suger):
                concentration = 100*suger / (i + suger)
                maximum = [i+suger, suger]
print(*maximum, sep=" ")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;

int n, a, b, c, ans = INF;
VI l;
void search(int i, vector<vector<int>> o) {
	if (i == n) {
		if (o[0].size() && o[1].size() && o[2].size()) {
			int sum = 0, A = 0, B = 0, C = 0;
			FOR(j, o[0].size())A += l[o[0][j]];
			sum += abs(A - a);
			sum += (o[0].size() - 1) * 10;
			FOR(j, o[1].size())B += l[o[1][j]];
			sum += abs(B - b);
			sum += (o[1].size() - 1) * 10;
			FOR(j, o[2].size())C += l[o[2][j]];
			sum += abs(C - c);
			sum += (o[2].size() - 1) * 10;
			ans = min(ans, sum);
		}
		return;
	}

	vector<vector<int>> x = o;
	x[0].push_back(i);
	search(i + 1, x);
	x = o;
	x[1].push_back(i);
	search(i + 1, x);
	x = o;
	x[2].push_back(i);
	search(i + 1, x);
	x = o;
	x[3].push_back(i);
	search(i + 1, x);
}

int main() {

	cin >> n >> a >> b >> c;
	FOR(i, n) {
		int L;
		cin >> L;
		l.push_back(L);
	}
	vector<vector<int>> t(4);
	search(0,t);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

def next_array a
  r = Array.new N, 0
  a.each_with_index do |_a, i|
    min = i - _a
    if min < 0
      min = 0
    end
    max = i + _a
    r[min] += 1
    r[max+1] -= 1 if max < N - 1
  end
  1.upto(N-1) do |i|
    r[i] += r[i-1]
  end
  r
end

def nth_array arr, n
  if n > N
    return Array.new n, n
  end

  result = Array.new N, 0
  arr.each_with_index do |_a, i|
  end
end

now = a
now = next_array now
k -= 1
k.times do |i|
  next_ar  = next_array now
  if next_ar == now
    break
  end
  now = next_ar
end

puts now.join(' ')

Measured memory_bytes: 82820
#pragma GCC optimize ("-O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define vl vector<ll>
#define pb push_back
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define bitcount(a) __builtin_popcountll(a)
#define Tanny_12 {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define MOD 1000000007
#define fr(i,a,b) for(ll i=a ; i<b ; i++)
#define maxS 10000005
using namespace std;
using namespace __gnu_pbds;
// using namespace boost::multiprecision;
typedef long long ll;
typedef tree<ll,null_type,less_equal <ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

template<typename T>
void print(T arr[], ll size)
{
    fr(i,0,size)
        cout<<arr[i]<<" ";
}

int main()
{
    Tanny_12;
    
    // ll t; cin>>t; while(t--)
    {
        ll x, y, z;
        cin>>x>>y>>z;
        
        cout<<z<<" "<<x<<" "<<y<<el;
    }
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
//written by newbiechd
#include <cstdio>
using namespace std;
const int N = 100003;
char s[N], c;
int main() {
    register int n, k, i;
    scanf("%d%s%d", &n, s + 1, &k), c = s[k];
    for (i = 1; i <= n; ++i)
        putchar(s[i] == c ? c : '*');
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string s;
int lz;
int main() {
	cin>>s;
	int e=s.size();
	int l=0,r=e-1;
	int u=0;
	while(l<=r) {
		if(s[l]==s[r]) {
			l++;
			r--;
			continue;
		}
		if(s[l]=='x'&&s[l]!=s[r]) {
			l++;
			lz++;
			continue;
		}
		if(s[r]=='x'&&s[l]!=s[r]&&s[l]!='x') {
			r--;
			lz++;
			continue;
		}
		u=1;
		break;
	}
	if(u==1) {
		cout<<-1<<'\n';
		return 0;
	}
	cout<<lz<<'\n';
	return 0;
}

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



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

    map<char, int> mp;
    rep(i,S.size()) ++mp[S[i]];
    for (auto x : mp) {
        if (x.second >= 2) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
} 



Measured memory_bytes: 3604
from math import ceil
def solve():
    N,D,A = map(int,input().split())
    monster = []
    for i in range(N):
        x,h = map(int,input().split())
        monster.append([x,h])
    
    monster.sort(key=lambda x:x[0])

    S = [0] * (N+1)
    ans = 0
    for i in range(N):
        if S[i] < monster[i][1]:
            left = i-1
            right = N
            while right - left > 1:
                mid = (left + right) // 2
                if monster[mid][0] > monster[i][0] + 2 * D:
                    right = mid
                else:
                    left = mid
            include_end = left
            need = ceil((monster[i][1] - S[i]) / A)
            S[i] += need * A
            S[include_end+1] -= need * A
            ans += need
        S[i+1] += S[i]
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 103356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double mxn=-1;
    pair<pii,pii> ans;
    rep(xa,f/(100*a)+1){
        rep(xb,f/(100*b)+1){
            rep(xc,f/100*e+1){
                rep(xd,f/100*e+1){
                    if(a*xa*100+b*xb*100+c*xc+d*xd>f)continue;
                    if((a*xa+b*xb)*e<c*xc+d*xd)continue;
                    if(chmax(mxn,(double)(c*xc+d*xd)/(double)(a*xa+b*xb+c*xc+d*xd))){
                        ans.F.F=xa;
                        ans.F.S=xb;
                        ans.S.F=xc;
                        ans.S.S=xd;
                    }
                }
            }
        }
    }
    cout << 100*(a*ans.F.F+b*ans.F.S)+c*ans.S.F+d*ans.S.S << ' ' << c*ans.S.F+d*ans.S.S;
}

/*



 */



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
 	string s;
 	cin >> s;
 	int x = 0;
 	for1(s.length()) {
 		if (s[i] == '+') x++;
 		else x--;
	}
	cout << x;
}

Measured memory_bytes: 3608
#include<iostream>

#define MAX  100500
using namespace std;

int main()
{
	int right_person;
	int N, Q;
  	long K;
	cin >> N >> K >> Q;

	int minus[MAX] = { 0 };
	for (int i = 0; i < Q; i++)
	{
		cin >> right_person;
		minus[right_person - 1] ++;
	}

	for (int i = 0; i < N; i++)
		if (minus[i] + K - Q > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    int sum = 0;

    for (int i=0; i<N; i++) {
    	p[i] = sc.nextInt();
    }

    Arrays.sort(p);

    for (int i=0; i<K; i++) {
    	sum += p[i];
    }

    sc.close();
    System.out.println(sum);

  }
}


Measured memory_bytes: 38804
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  for (int n=1; n<=3500; n++){
    for (int h=1; h<=3500; h++){
      long long numerator = (long long)N*h*n;
      long long denomerator = (long long)4*n*h-(long long)N*n-(long long)N*h;
      if(denomerator>0 && numerator%denomerator==0){
        //printf("deno=%lld, nume=%lld\n", denomerator, numerator);
        printf("%d %d %lld\n", n, h, numerator/denomerator);
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
'use strict'
N = int(input())
A = [x-1 for x in (list(map(int, input().split())))]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

satisfy_level = B[A[0]]

for i in range(1,N):
    satisfy_level += B[A[i]]
    if A[i] == A[i-1] + 1:
        satisfy_level += C[A[i-1]]

print(satisfy_level)

Measured memory_bytes: 3064
<?php
    fscanf(STDIN,"%d",$n);
    $sum = 0;
    for($index = 1;$index <= $n; ++$index){
        if($index % 3 === 0 || $index % 5 === 0){
            continue;
        }
        $sum += $index;
    }
    echo $sum.PHP_EOL;
?>

Measured memory_bytes: 16064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <sstream>
#define endl '\n'
#define ll long long
#define pb push_back
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 500010
using namespace std;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int tmp=(r/d)-(l-1)/d;
    cout << tmp << endl;
}


Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
for i in range(n):
    left=min(a[i],b[i])
    ans+=left
    a[i]-=left
    b[i]-=left
    right=min(a[i+1],b[i])
    ans+=right
    a[i+1]-=right
    b[i]-=right
print(ans)


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

const int MAXN = 1000010;
char S[MAXN], T[MAXN];
int n; std::queue<int> q;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> S + 1 >> T + 1;
	int ans = strcmp(S + 1, T + 1) != 0;
	for (int i = n, j = n; i; --i, --j) {
		while (i > 1 && T[i] == T[i - 1]) --i;
		j = std::min(j, i);
		while (j && S[j] != T[i]) --j;
		if (!j) return std::cout << -1 << std::endl, 0;
		if (i == j) { while (!q.empty()) q.pop(); continue; }
		while (!q.empty() && q.front() - q.size() >= i) q.pop();
		q.push(j);
		ans = std::max(ans, (int) q.size() + 1);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int n,d,ans=0;
	double k=0,q=0;
	cin>>n>>d;
	int a[n][d];
	for(int cnt=0; cnt<n; cnt++) {
		for(int cnt2=0; cnt2<d; cnt2++)
			cin>>a[cnt][cnt2];
	}
	for(int cnt=0;cnt<n;cnt++){
		for(int cnt2=cnt+1;cnt2<n;cnt2++){
			k=0;
			for(int cnt3=0;cnt3<d;cnt3++){
				k+=(a[cnt][cnt3]-a[cnt2][cnt3])*(a[cnt][cnt3]-a[cnt2][cnt3]);
			}
			q=sqrt(k);
			if(q-int(q)==0)ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
def c_100_to_105():
    X = int(input())

    if any((1 <= X <= 99,
           106 <= X <= 199,
           211 <= X <= 299,
           316 <= X <= 399,
           421 <= X <= 499,
           526 <= X <= 599,
           631 <= X <= 699,
           736 <= X <= 799,
           841 <= X <= 899,
           946 <= X <= 999,
           1051 <= X <= 1099,
           1156 <= X <= 1199,
           1261 <= X <= 1299,
           1366 <= X <= 1399,
           1471 <= X <= 1499,
           1576 <= X <= 1599,
           1681 <= X <= 1699,
           1786 <= X <= 1799,
           1891 <= X <= 1899,
           1996 <= X <= 1999)):
        return '0'
    return '1'

print(c_100_to_105())

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int A, B;

int main(void)
{
	cin >> A >> B;
	if(A == 1) A = 14;
	if(B == 1) B = 14;
	
	if(A > B) cout << "Alice" << endl;
	else if(A < B) cout << "Bob" << endl;
	else cout << "Draw" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        String[][] list = new String[h][w];
        for (int i = 0; i < h; i++) {
            String[] tmp = sc.next().split("");
            for (int j = 0; j < w; j++) {
                list[i][j] = tmp[j];
            }
        }

        List<Integer> excludeW = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            boolean isBlack = false;
            for (int j = 0; j < h; j++) {
                if (list[j][i].equals("#")) {
                    isBlack = true;
                    continue;
                }
            }
            if (!isBlack) excludeW.add(i);
        }

        List<Integer> excludeH = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            boolean isBlack = false;
            for (int j = 0; j < w; j++) {
                if (list[i][j].equals("#")) {
                    isBlack = true;
                    continue;
                }
            }
            if (!isBlack) excludeH.add(i);
        }

        for (int i = 0; i < h; i++) {
            if (!excludeH.contains(i)) {
                for (int j = 0; j < w; j++) {
                    if (!excludeW.contains(j)) {
                        System.out.print(list[i][j]);
                    }
                }
                System.out.println("");
            }
        }
    }
}

Measured memory_bytes: 32708
S=input()
a=int(S[:2])
b=int(S[2:])
if (a==0 or 12<a) and 0<b<13:
    print('YYMM')
elif 0<a<13 and (b==0 or 12<b):
    print('MMYY')
elif 0<a<13 and 0<b<13:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100,M=400400;
int i,j,k,n,m,ch,ff,x,y,fg,n1,n2,n3,En;
ll ans;
int h[N],z[N];
struct edge { int s,n;} E[M];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int y) {
	z[x]=y;
	for (int k=h[x];k;k=E[k].n) {
		if (!z[E[k].s]) dfs(E[k].s,3-y);
		else {
			if (z[E[k].s]!=3-y) fg=0;
		}
	}
}
int main() {
	R(n);R(m);
	for (i=1;i<=m;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	for (i=1;i<=n;i++) if (!z[i]) {
		if (!h[i]) n1++;
		else {
			fg=1;
			dfs(i,1);
			n2+=fg;
			n3+=fg^1;
		}
	}
	ans=(ll) n1*(2*n-n1)+2ll*n2*n2+(ll) n3*n3+2ll*n2*n3;
	W(ans);puts("");
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{

    int n, m;
    cin >> n >> m;

     queue<int> fav_sport[n];
    rep(i, 0, n)
        rep(j, 0, m)
        {
            int a;
            cin >> a;
            fav_sport[i].push(--a);
        }

    int ans = n;
    vector<bool> used(m, false);
    rep(j, 0, m)
    {
        // cnting;
        vector<int> cnt(m, 0);
        rep(i, 0, n)
            ++cnt[fav_sport[i].front()];
        
        // current score
        int now = 0;
        int rm_sport = -1;
        rep(mm, 0, m)
            if (now < cnt[mm])
            {
                now = cnt[mm];
                rm_sport = mm;
            }
        
        ans = min(ans, now);
        
        // update queue
        used[rm_sport] = true;
        rep(i, 0, n)
            while (fav_sport[i].size() > 0 and used[fav_sport[i].front()])
                fav_sport[i].pop();
    }

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

Measured memory_bytes: 768
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [usize; n],
    }

    if n < 3 {
        println!("{}", 0);
        return;
    }

    l.sort();

    let mut ans = 0;
    for i in 0..n - 2 {
        for j in i + 1..n - 1 {
            for k in j + 1..n {
                if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2188
//ABC076A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, a;
	cin >> n >> a;
	int ans = pow(n,2)-a;
	cout << ans << endl;
	return 0;
}

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

const int maxd = 20;

int l, tl, dl, ce, t = 1;
bool b[maxd];

signed main () {
    scanf("%d", &l);
    tl = l;
    while (l) {
        if (l & 1) {
            b[dl] = 1;
            ce++;
        }
        l >>= 1;
        dl++;
    }
    printf("%d %d\n", dl, (dl - 1) * 2 + ce - 1);
    l = tl;
    for (int i = 1; i < dl; ++i) {
        printf("%d %d %d\n", i, i + 1, 0);
        printf("%d %d %d\n", i, i + 1, t);
        if (b[i - 1]) {
            printf("%d %d %d\n", i, dl, l - t);
            l -= t;
        }
        t <<= 1;
    }
}


Measured memory_bytes: 3704
#include<stdio.h>

#define N 200000
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
int main(){
  int n, i, minv, maxv;
  int A[N];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  maxv = -2000000000;
  minv = A[0];
  
  for (i= 1; i< n; i++){
    maxv = max(maxv, A[i]-minv);
    minv = min(minv, A[i]);
  }

  printf("%d\n",maxv);

  return 0;
}



Measured memory_bytes: 2632
#include <iostream>
#include <iomanip>
#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 <random>
#include <queue>
#include <bitset>

// #define int long long
#define dbl long double
#define pb push_back
#define str string
using namespace std;
const int M = 998244353;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k, a, b;
    cin >> k >> a >> b;
    for (int x= a;  x<= b; x++) {
        if (x % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

Measured memory_bytes: 3652
S = input()
while True:
  if len(S) == 0:
    print("YES")
    break
  if S[-7:] == "dreamer":
    S = S[:-7]
  elif S[-5:] == "dream":
    S = S[:-5]
  elif S[-6:] == "eraser":
    S = S[:-6]
  elif S[-5:] == "erase":
    S = S[:-5]
  else:
    print("NO")
    break

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;


int main(){
    int N,K;
    cin >> N >> K;
    
    int a[100];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    int dp[100001]={};
    dp[0]=2;
    
    for(int i=1; i<=K; i++){
        for(int n=0; n<N; n++){
            if(i-a[n]>=0){
                
                if(dp[i-a[n]]==2){
                    dp[i]=1;
                }
                
            }
        }
        
        if(dp[i]==0){
            dp[i]=2;
        }
       
    }
    
    if(dp[K]==1){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc172/tasks/abc172_a

use proconio::input;

fn main() {
    input! {
        s: String,
        t: String,
    }
    let ans = s
        .chars()
        .zip(t.chars())
        .filter(|(s, t)| s != t)
        .collect::<Vec<_>>()
        .len();
    println!("{}", ans);
}


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

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var S = Console.ReadLine();

        int rl = 0;
        for (int i = 0; i < N - 1; i++)
        {
            if (S[i] == 'R' && S[i + 1] == 'L')
            {
                rl++;
            }
        }
        int edge = (S[0] == 'L' ? 1 : 0) + (S[N - 1] == 'R' ? 1 : 0);

        if (rl > 1)
        {
            var t = Math.Min(rl - 1, K);
            rl -= t;
            K -= t;
        }

        if (K > 0 && rl == 1 && edge >= 1)
        {
            rl = 0;
            K--;
        }
        if (K > 0 && rl == 1 && edge == 0)
        {
            rl = 0;
            edge = 1;
            K--;
        }

        if (K > 0 && rl == 0 && edge == 2)
        {
            edge = 1;
            K--;
        }

        var unhappy = rl * 2 + edge;
        var happy = N - unhappy;

        Console.WriteLine(happy);
    }
}

Measured memory_bytes: 13536
#include<stdio.h>
#include<string.h>
main(){
  int i=0;
  int runner=0;
  char kougeki[8];
  int out=0;
  int b=0;
  int h=0;
  scanf("%d",&i);
  for(b=0;b<i;b++){
    while(out!=3){
      scanf("%s",&kougeki);
      if(strcmp(kougeki,"HIT")==0){
	if(runner==0){
	  runner=1;
	}
	else if(runner==1){
	  runner=2;
	}
	else if(runner==2){
	  runner=3;
	}
	else if(runner==3){
	  h=h+1;
	}
      }
      else if(strcmp(kougeki,"HOMERUN")==0){
	h=h+runner+1;
	runner=0;
      }
      else if(strcmp(kougeki,"OUT")==0){
	out=out+1;
      }
    }
    printf("%d\n",h);
    runner=0;
    out=0;
    h=0;
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int N,M;cin>>N>>M;
    vector<int> digit(N+1,-1);
    int s = 0;
    int alt = 0;
    int ans = 0;
    int end = 0;
    for(int i=0;i<M;i++){
        cin >> s;
        alt = digit[s];
        cin >> digit[s];
        if(alt!=-1&&alt!=digit[s]){
            end = 1;break;
        }
        if(digit[1]==0&&N!=1){
            end = 1;break;
        }else if(digit[1]==0&&N==1){
            end = 2;break;
        }
    }
    if(end==1){
        cout << -1 << endl;
    }else if(end==2){
        cout << 0 << endl;
    }else{
        for(int i=1;i<=N;i++){
            if(digit[i]==-1){
                if(i==1){
                    digit[i] = 1;
                }else{
                    digit[i] = 0;
                }
            }
        }
        for(int i=1;i<=N;i++){
            ans += digit[i]*pow(10,N-i);
        }
        if(M!=0){
            cout << ans << endl;
        }else if(M==0){
            if(N==1){
                cout << 0 << endl;
            }else{
                cout << pow(10,N-1);
            }
        }
    }
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    string s;
    cin >> s;
    vector<int> sub;
    int N = s.size();
    for(int i = 0; i <= N - 3; i++){
        sub.push_back(atoi(s.substr(i, 3).c_str()));
    }
    int min_dif = 999;
    for(int x : sub) min_dif = min(min_dif, abs(x-753));
    cout << min_dif << endl;
}


Measured memory_bytes: 3612
#include <cctype>
#include <iostream>
#include <string>
typedef std::string::const_iterator State;
using namespace std;

int number(State &begin) {
  int ret = 0;
  while (isdigit(*begin)) {
    ret *= 10;
    ret += *begin - '0';
    begin++;
  }
  return ret;
}

int factor(State &begin);

int term(State &begin) {
  int ret = factor(begin);

  for (;;) {
    if (*begin == '*') {
      begin++;
      ret *= factor(begin);
    } else if (*begin == '/') {
      begin++;
      ret /= factor(begin);
    } else {
      break;
    }
  }
  return ret;
}

int expression(State &begin) {
  int ret = term(begin);

  for (;;) {
    if (*begin == '+') {
      begin++;
      ret += term(begin);
    } else if (*begin == '-') {
      begin++;
      ret -= term(begin);
    } else {
      break;
    }
  }
  return ret;
}

int factor(State &begin) {
  if (*begin == '(') {
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  } else {
    return number(begin);
  }
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    State begin = s.begin();
    cout << expression(begin) << endl;
  }

  return 0;
}



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

int main() {
    string b;
    cin >> b;
    if(b[0] == 'A'){
        cout << 'T' << endl;
    }else if(b[0] == 'C'){
        cout << 'G' << endl;
    }else if(b[0] == 'G'){
        cout << 'C' << endl;
    }else if(b[0] == 'T'){
        cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	ll n;
	cin >> n;
	ll ans = 1 + 2 * (n / 11);
	if(n % 11 > 6) ans++;
    if(n % 11 == 0) ans--;
	cout << ans << endl;
	return 0;
}


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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 50 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 78
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

int n, m, k;


int main()
{
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout <<"ABC";

}
/*

*/


Measured memory_bytes: 3624
#include<iostream>
#include <iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <numeric>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

// template < typename T > std::string to_string( const T& n )
// {
//     std::ostringstream stm ;
//     stm << n ;
//     return stm.str() ;
// }

ll combination(ll n,ll u)
{
  ll ans = 1;
  if(n/2 < u)
  {
    u = n-u;
  }
  for(ll i = 1;i <= u;i++)
  {
    ans *= (n-i+1);
    ans /= i;
    ans %= big;
  }
  return ans;
}

ll fanc(ll n)
{
  ll ans = 0;
  if(n == 1)
  {
    ans = 1;
  }
  else
  {
    ans = 2*fanc(n/2)+1;
  }
  return ans;
}

int main()
{
  ll n;
  cin >> n;
  cout << fanc(n) << endl;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
As = [0]+As+[0]
s = 0
for i in range(N+1):
  s += abs(As[i]-As[i+1])
#print(s)
for i in range(1, N+1):
  r = s-abs(As[i]-As[i-1])-abs(As[i]-As[i+1])+abs(As[i-1]-As[i+1])
  print(r)


Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


struct edge{int idx, to;};
vector<vector<edge>> G;
vector<int> vis;
vector<int> col;


void dfs(int r,int rcol){
    vis[r]=1;
    int cnt = 0;
    for(edge e:G[r]){
        if(vis[e.to])continue;
        cnt++;
        if(cnt==rcol)cnt++;
        col[e.idx]=cnt;
        dfs(e.to,cnt);
    }

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    
    G = vector<vector<edge>> (n,vector<edge>(0));
    vis = vector<int>(n,0);
    col = vector<int>(n-1,-1);
    rep(i,n-1){
        int a,b;cin>>a>>b;a--;b--;
        edge add = {i, b};
        G[a].push_back(add);
        add = {i,a};
        G[b].push_back(add);
    }
    dfs(0,-2);
    int Max = 0;
    rep(i,n-1){
        Max = max(Max,col[i]);
    }
    cout<<Max<<endl;
    rep(i,n-1)cout<<col[i]<<endl;
    return 0;
}

Measured memory_bytes: 7296
while 1:
	n = int(raw_input())
	if n == 0:
		break
	w,h = map(int,raw_input().split(" "))
	field = [[0 for i in range(0,w+1)] for j in range(0,h+1)]
	for i in range(n):
		x,y = map(int,raw_input().split(" "))
		field[y][x] = 1
	s,t = map(int,raw_input().split(" "))
	tree_max = 0
	for i in range(1,w-s+2):
		for j in range(1,h-t+2):
			tmp_sum = 0
			for k in range(i,i+s):
				for l in range(j,j+t):
					tmp_sum += field[l][k]	
			tree_max = max(tree_max, tmp_sum)

	print tree_max

Measured memory_bytes: 4372
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static int[] A, m;
    public static int k;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, q;
        int i, j;

        n = sc.nextInt();
        A = new int[n];
        for(i=0;i<n;i++){
            A[i] = sc.nextInt();
        }

        q = sc.nextInt();
        m = new int[q];
        for(i=0;i<q;i++){
            m[i] = sc.nextInt();
        }

        Arrays.sort(A);

        CycleA:
        for(i=0;i<q;i++) {

            k = n;

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

                if (m[i] == A[j]) {
                    System.out.println("yes");
                    continue CycleA;                               
                } else if (m[i] < A[j]) {
                    k = j;
                    break;
                }

            }

            if( solve(0, m[i]) ){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }

        }

    }

    public static boolean solve(int i, int m){

        if(m == 0){
            return true;
        }

        if(i >= k){
            return false;
        }

        boolean res = solve(i+1, m) || solve( i+1, m - A[i]);

        return res;
    }

}



Measured memory_bytes: 26756
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    ll N;
    ll a[5];
    ll min_a = 1e15 + 1;
    
    cin >> N;
    
    rep(i, 5){
        cin >> a[i];
        min_a = min(min_a, a[i]);

    }

    ll answer = ceil((N - 1) / min_a) + 5;
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
// 2019/06/26 Tazoe

#include <iostream>
using namespace std;

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

    int W = C/(A*7+B);
    C %= (A*7+B);
    if(C>A*7){
        W++;
        C = 0;
    }

    int D = C/A;
    C %= A;
    if(C>0){
        D++;
    }

    cout << W*7+D << endl;

    return 0;
}



Measured memory_bytes: 3104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	p := 0
	N := nextInt()
	for i := 0; i < N; i++ {
		x := nextInt()
		p = (x + p) % 2
	}

	if p == 0 || N == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

// --- Input ---
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}


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


int main () {
    int k, x ;
    cin >> k >> x ;
    int t = x + (k - 1) ;
    int p = x - (k - 1) ;
    for(int i = p; i <= t ; i++){
        cout << i <<  " " ;
    }
    cout << endl ;
} 

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n, a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
		return 0;
	}
	return 0;
}

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


int main() {
  
  string S;
  
  cin>>S;
  
  if(S=="SUN"){
    cout<<7<<endl;
  }else if(S=="MON"){
    cout<<6<<endl;
  }else if(S=="TUE"){
    cout<<5<<endl;
  }else if(S=="WED"){
    cout<<4<<endl;
  }else if(S=="THU"){
    cout<<3<<endl;
  }else if(S=="FRI"){
    cout<<2<<endl;
  }else{
    cout<<1<<endl;
  }
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    vector<vector<int>> v(6, vector<int>(0));
    for (int i = 30000; i >= 2; i--) {
        if (i % 2 == 0 || i % 3 == 0) {
            v[i % 6].push_back(i);
        }
    }
    vector<int> res;
    res.push_back(v[2].back());
    v[2].pop_back();
    res.push_back(v[3].back());
    v[3].pop_back();
    res.push_back(v[3].back());
    v[3].pop_back();
    res.push_back(v[4].back());
    v[4].pop_back();
    
    n -= 4;
    if (n % 2 == 1) {
        res.push_back(v[0].back());
        v[0].pop_back();
        n--;
    }
    while (n > 0) {
        if (v[0].size() >= 2) {
            res.push_back(v[0].back());
            v[0].pop_back(); 
            res.push_back(v[0].back());
            v[0].pop_back();
        } else if (v[3].size() >= 2) {
            res.push_back(v[3].back());
            v[3].pop_back(); 
            res.push_back(v[3].back());
            v[3].pop_back();
        } else {
            res.push_back(v[2].back());
            v[2].pop_back();
            res.push_back(v[4].back());
            v[4].pop_back();
        }
        n -= 2;
    }
    for (auto num : res) {
        cout << num << " ";
    }
    cout << endl;
}


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

int main(){
    int b[3][3]; int c[3][3];
    rep(i,3){
        rep(j,3){
            cin >> b[i][j];
            c[i][j]=0;
        }
    }

    int n; cin >> n;
    
    rep(i,n){
        int bb; cin >> bb;
        int f=0;
        rep(j,3){
            rep(k,3){
            if(bb==b[j][k]){
                c[j][k]=1;
                f++;
             }
            }
        if(f) break;
        }
    }

int ans=0;

    rep(i,3){
        if(c[i][0]==1 && c[i][1]==1 && c[i][2]==1) ans++;
    }
    rep(i,3){
        if(c[0][i]==1 && c[1][i]==1 && c[2][i]==1) ans++;
    }
    if(c[0][0]==1 && c[1][1]==1 && c[2][2]==1) ans++;
    if(c[0][2]==1 && c[1][1]==1 && c[2][0]==1) ans++;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll n;
    cin>>n;
    vector<int> v(n,0);
    rep(i,n-1){
        int a;
        cin>>a;
        a--;
        v[a]++;
    }
    rep(i,n) cout<<v[i]<<endl;
    return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
//#define rep(i,a,b) for(int i=a;i<b;i++)
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
const ll maxn=2e5+10;
int main()
{
    ll n;
    scanf("%lld",&n);
    char c[maxn];
    ll r=0,w=0;
    scanf("%s",c);
    for(ll i=0;i<strlen(c);i++)
    {
        if(c[i]=='R')
        {
            r++;
        }
    }
    for(ll i=0;i<r;i++)
    {
        if(c[i]=='W')
            w++;
    }
    cout<<w<<endl;
}


Measured memory_bytes: 3948
#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<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll res[1010][1010];

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

    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    REP(i, H){
    	REP(j, W){
    		if((i<B && j<A)||(i>=B && j>=A)){
    			res[i][j] = 1;
    		}else{
    			res[i][j] = 0;
    		}
    	}
    }
    REP(i, H){
    	REP(j, W){
    		cout << res[i][j];
    	}
    	cout << endl;
    }
    return 0;
}

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

 string a,b;
 int main()
 {
     int num1=0;
     int num2=0;
     cin>>a;
     cin>>b;
     for(int i=0;i<a.size()+b.size();i++)
    {
         if(i%2)
         
             cout<<b[num1++];
         
         else
         
             cout<<a[num2++];
         
     }
     cout<<endl;
     }

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

int A[5][5];
bool check[5][5];

signed main(void){
  
  for(int i = 0; i < 3; i++){ 
    for(int j = 0; j < 3; j++){ 
      
      cin >> A[i][j];
    }
  }
  
  int N; cin >> N;
  for(int i = 0; i < N; i++){
    int b; cin >> b;
    
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){ 
        if( A[j][k] == b ){ 
          check[j][k] = true;
        }
      }
    }
    
    
    //揃っているか調べる
    bool flag = true;
    for(int j = 0; j < 3; j++){ 
      flag = true;
      for(int k = 0; k < 3; k++){
        if( !check[j][k] ){ flag = false;}
      }
      if(flag){ cout <<"Yes" << endl; return 0;}
    }
    
    flag = true;
    
    for(int k = 0; k < 3; k++){
      flag = true;
      for(int j = 0; j < 3; j++){ 
        if( !check[j][k] ){ flag = false;}
      }
      if(flag){ cout << "Yes" << endl; return 0;}
    }
    
    flag = true;
    
    if( check[0][0]&&check[1][1]&&check[2][2] ){ 
      cout <<"Yes" << endl; return 0;
    }

    if( check[0][2]&&check[1][1]&&check[2][0]){
      cout << "Yes" << endl; return 0;
    }

  }

  cout << "No" << endl;
  
  return 0;
}
 

Measured memory_bytes: 256
S = input()
n = len(S)
s1 = "".join([str(i%2) for i in range(n)])
s2 = "".join([str((i+1)%2) for i in range(n)])
S = int(S, 2)
ans1 = bin(int(s1, 2)^S).count('1')
ans2 = bin(int(s2, 2)^S).count('1')
print(min(ans1, ans2))

Measured memory_bytes: 9588
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a < 600){
			System.out.println("8");
        } else if(a < 800){
          	System.out.println("7");
        } else if(a < 1000){
          	System.out.println("6");
        } else if(a < 1200){
         	System.out.println("5");
        } else if(a < 1400){
          	System.out.println("4");
        } else if(a < 1600){
          	System.out.println("3");
        } else if(a < 1800){
          	System.out.println("2");
        } else {
        	System.out.println("1");
        }
	}
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,k,a,pos,ma=0;

int GCD(int a,int b){
	if(b) return GCD(b,a%b);
	else return a;
}

int main(){
	cin >> n >> k >> pos; ma=pos;
	REP(i,1,n) cin >> a,pos=GCD(pos,a),ma=max(ma,a);
	
	if(k%pos or k>ma) cout << "IMPOSSIBLE" << endl;
	else cout << "POSSIBLE" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int n,m,js;char ch[10];
int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=n;++i) {
		scanf("%s",ch+1);
		for(RI j=1;j<=m;++j) js+=(ch[j]=='#');
	}
	if(js==n+m-1) puts("Possible");
	else puts("Impossible");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

constexpr int kN = int(2E5 + 10);
int a[kN], b[kN];

int main() {
	int n;
	long long int ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) b[i] = max(b[i - 1], a[i]);
	for (int i = 1; i <= n; i++) ans += b[i] - a[i];
	printf("%lld\n", ans);
}


Measured memory_bytes: 3268
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int

	a := 0
	b := 0

	fmt.Scanf("%d", &n)

	nums := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	sort.Ints(nums)

	l := len(nums) - 1 //3

	for i, _ := range nums {
		if i%2 == 0 {
			a += nums[l-i]
		} else {
			b += nums[l-i]
		}
	}

	fmt.Println(a - b)
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	ll n=1;
	cin >> n;
	vector< map<ll, ll> > v(n);

	for(ll i = 0; i<n; i++) {
		ll a;
		cin >> a;
		map<ll, ll> m;
		for (ll j = 0; j < a; ++j){
			ll x, y;
			cin >> x >> y;
			m[x] = y;
		}
		v[i]=m;
	}

	ll max = 0;
	ll N = pow(2, n);
	for (ll i = 0; i < N; ++i) {
		bool flag = true;
		for (ll j = 0; j < n; ++j) {
			ll jyes = (i>>j)&1;
			map <ll, ll> m = v[j];
			if (jyes == 1) {
				for (ll k = 0; k < n; ++k){
					if (m.find(k+1) != m.end()) {
						if (m[k+1] != ((i>>k)&1)) {
							flag = false;
							break;
						}
					}
				}
			} 
			if (!flag) {
				break;
			}
		}
		if (flag) {
			ll count = 0;
			for (ll j = 0; j < n; ++j) {
				count += ((i>>j)&1);
			}
			if (count > max) {
				max = count;
			}
		}
	}

	cout << max;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    int n; cin >> n;
    double n3 = n;
    double n2 = n/2;
    if (n%2 == 0) {
        double a = n2/n3;
        cout << a;
    }
    else {
        double a = (n2+1)/n3;
        cout << a;
    }
}

Measured memory_bytes: 256