akhauriyash/Code-Regression huggingface dataset:
program main
  implicit none
  integer :: n, m, i, pos, l, r, dice(100000), idice
  character(100001) :: s
  read *, n, m
  read *, s
  pos = n
  idice = 0
  outer: do
    l = max(0, pos - m)
    r = pos - 1
    do i = l, r
      if (s(i + 1:i + 1) == "0") then
        idice = idice + 1
        dice(idice) = pos - i
        pos = i
        if (i == 0) then
          exit outer
        else
          cycle outer
        end if
      end if
    end do
    print "(i0)", -1
    return
  end do outer
  print "(100000(i0, ' '))", dice(idice:1:-1)
end program main


Measured memory_bytes: 1316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	
	static int[] array;
	
	public static void main(String[] args)throws IOException{
		Main app = new Main();
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		
		int n = Integer.parseInt(reader.readLine());
		array = new int[n];
		String string = reader.readLine();
		
		for(int i = 0; i < n; i++)
			array[i] = Integer.parseInt(string.split(" ")[i]);
		
		app.reverse(array);
		
		for(int i = 0; i < n; i++){
			if(i != n - 1)
				System.out.print(array[i] + " ");
			else
				System.out.println(array[i]);
		}
		reader.close();
	}
	public void reverse(int[] array){
		int temp;
		for(int i = 0; i < array.length / 2; i++){
			temp = array[i];
			array[i] = array[array.length - 1 - i];
			array[array.length - 1 - i] = temp;
		}
	}
}

Measured memory_bytes: 26344
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<map>
#include<set>
#include<string>
#include<vector>

#define gec getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)
#define DEBUG fprintf(stderr,"Passing [%s] in Line (%d)\n",__FUNCTION__,__LINE__);
typedef long long ll;
template<class T>
inline void read(T&x)
{
	x=0;bool f=0;char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

const int MAXN(100010);
struct Node{int v,a,b;}L[MAXN<<1];
bool cmp3(Node S,Node T){return S.v<T.v;}
int x[MAXN],y[MAXN],n,now,Ans;
struct Data
{
	int x,y,num;
}A[MAXN];
int f[MAXN];
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}
void Union(int a,int b)
{
	int fa=gf(a),fb=gf(b);
	if(fa!=fb)f[fa]=fb;
}
bool cmp1(Data S,Data T){return S.x<T.x;}
bool cmp2(Data S,Data T){return S.y<T.y;}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)read(A[i].x),read(A[i].y),A[i].num=i;
	std::sort(A+1,A+1+n,cmp1);
	for(int i=2;i<=n;i++)L[++now]=(Node){A[i].x-A[i-1].x,A[i].num,A[i-1].num};
	std::sort(A+1,A+1+n,cmp2);
	for(int i=2;i<=n;i++)L[++now]=(Node){A[i].y-A[i-1].y,A[i].num,A[i-1].num};	
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=n;i++)Union(x[i],y[i]);
	std::sort(L+1,L+1+now,cmp3);
	for(int i=1;i<=now;i++)
	{
		int a=L[i].a,b=L[i].b,v=L[i].v;
		int fa=gf(a),fb=gf(b);
		if(fa!=fb)
		{
			f[fa]=fb;Ans+=v;
		}
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 4352
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let t: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..t)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();
    a.reverse();

    let s = a.iter().sum::<usize>() - a[0];
    println!("{}", a[0].saturating_sub(s + 1));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;
int main () {
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
}


Measured memory_bytes: 256
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())
    ans=[0]*4

    for i in range(N):
        S = input()
        if S=='AC':
            ans[0]+=1
        elif S=='WA':
            ans[1]+=1
        elif S=='TLE':
            ans[2]+=1
        elif S=='RE':
            ans[3]+=1

    print('AC x '+str(ans[0]))
    print('WA x '+str(ans[1]))
    print('TLE x '+str(ans[2]))
    print('RE x '+str(ans[3]))


if __name__ == '__main__':
    main()


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

int main() {
    char a;
    cin >> a;
    if('a' <= a && a <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    int flag = 0;
    if (A == B && B != C) flag = 1;
    if (B == C && A != C) flag = 1;
    if (A == C && B != C) flag = 1;
    cout << (flag ? YES:NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n),b(n);
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        a[i]+=ans;
        if(a[i]%b[i]==0)continue;
        ans+=b[i]-a[i]%b[i];
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






































Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	ans := 0
	for i := 1; i <= n; i++ {
		j := i
		k := 0
		for {
			k += j % 10
			j /= 10
			if j == 0 {
				break
			}
		}

		if a <= k && k <= b {
			ans += i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
   ll n, m, i, j, k, l;
   cin>>n>>m;
   ll res=n*4;
   ll res1=n*2;
   bool ok=false;
   for(i=res1; i<=res; i+=2)
   {
       if(i==m)
       {
           ok=true;
           break;
       }
   }
   if(ok==true)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

typedef long long ll;


ll tree[1600001];
ll a[4*100001];

void build(int k,int s,int e)
{
    if(s==e)
    {
        tree[k]=a[s];
        return;
    }
    int mid=(s+e)/2;
    build(2*k,s,mid);
    build(2*k+1,mid+1,e);
    tree[k]=__gcd(tree[k*2],tree[2*k+1]);
}


bitset<1000001> pr;
vector<ll> primes;
void sieve()
{
    //cout<<pr[0];
    for(ll i=2;i*i<1000001;i++)
    {
        if(pr[i])continue;
        for(int j=i*2;j<1000001;j+=i)
        {
            pr[j]=i;
        }
    }
    for(int i=2;i<=1000001;i++)
    {
        if(!pr[i])primes.push_back(i);
    }
}

void primeFctorization(ll n)
{
    int count=1;
    ll N=n;

    for(int i=0;i<primes.size()&&primes[i]*primes[i]<=n;i++)
    {
        int temp=0;
        while(n%primes[i]==0)
        {
            //th.insert(primes[i]);
            n/=primes[i];
            temp++;
            //ans.push_back(primes[i]);
            //cout<<primes[i]<< " ";
        }
        if(temp)
        {
            count=count*(temp+1);
        }
    }
    if(n>1){
        count=count*2;
    }
    cout<<count<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m,d;
    cin>>m>>d;
    int count=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=22;j<=d;j++)
        {
            int k=j%10;
            int l=j/10;
            if(k>=2&&l>=2&&k*l==i){
                    //cout<<i;cout<<j<<endl;
                    count++;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import math
import keyword

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a,b,c,d = NextInts()

if (a+d-1)//d < (b+c-1)//b:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9184
def readinput():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    return k,n,a

def main(k,n,a):
    dmax=0
    for i in range(n-1):
        dmax=max(dmax,a[i+1]-a[i])
    dmax=max(dmax,k+a[0]-a[n-1])
    return k-dmax

if __name__=='__main__':
    k,n,a=readinput()
    ans=main(k,n,a)
    print(ans)


Measured memory_bytes: 32280
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    v_list = LI()

    v_list = sorted(v_list)

    while True:
        if len(v_list) <= 2:
            break
        newv = (v_list[0] + v_list[1]) / 2
        v_list = [newv] + v_list[2:]
        v_list = sorted(v_list)

    print((v_list[0]+v_list[1])/2)

solve()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>

int main()
{
	int a, b;
	std::cin >> a >> b;
	std::cout << std::fixed;
	std::cout << a / b << " " << a % b << " " << std::setprecision(5) << (double)a / b;

    return 0;
}


Measured memory_bytes: 3276
#!/usr/bin/python

def main():
    n = int(input())
    a, b = [int(x) for x in input().split()]
    p = [int(x) for x in input().split()]
    
    q1count = len([x for x in p if x<=a])
    q2count = len([x for x in p if a+1<=x and x<=b])
    q3count = len([x for x in p if b+1<=x])

    print(min(q1count, q2count, q3count))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int top,S[10000];

void push(int x){
    top++;
    S[top]=x;
}

int pop(){
    top--;
    return S[top+1];
}


int main(){
    char P[2100];
    top=0;
    int64_t x,y;
/*    for(int i=0;i<2100;i++){
        cin>>P[i];
        if(cin.eof()){
            n=i;
            break;
            
        }
        cout<<P[i]<<endl;
    }*/
    while(cin>>P){
        if(P[0]=='+'){
            y=pop();
            x=pop();
            push(x+y);
        }
        else if(P[0]=='-'){
            y=pop();
            x=pop();
            push(x-y);
        }
        else if(P[0]=='*'){
            y=pop();
            x=pop();
            push(x*y);
        }        
        else {
            push(stoi(P));
        }
    }
    cout<<pop()<<endl;
    
    
}






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

int main()
{
	int n;
	scanf("%d", &n);
	int px = 0, py = 0, pt = 0;
	
	for(int i = 1; i <= n; i++)
	{
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		int odl = abs(x - px) + abs(y - py);
		if(odl > t - pt || odl % 2 != (t - pt) % 2)
		{
			printf("No\n");
			return 0;
		}
		px = x;
		py = y;
		pt = t;
	}
	printf("Yes\n");
}

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

int main() {

    string s;

    cin >> s;

    int a_pos = -1,z_pos = 0;

    for(int i=0; i<s.size(); i++){
        if(a_pos == -1 && s[i] == 'A'){
            a_pos = i;
        }
        if(s[i] == 'Z'){
            z_pos = i;
        }
    }

    cout << z_pos - a_pos + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t, r;
	int n, a, b;
	cin >> s >> n;
	while (n--) {
		cin >> t >> a >> b;
		if (t == "print")
			cout << s.substr(a, b - a + 1) << endl;
		else if (t == "reverse")
			reverse(s.begin() + a, s.begin() + b + 1);
		else {
			cin >> r;
			s.replace(a, b - a + 1, r);
		}
	}
}


Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;
int n,k;
char s[100010];
int LR,RL;
int ans=0;

void swap(){
    int tem=LR;
    LR=RL;
    RL=tem;
}

int main(){
    scanf("%d%d%s",&n,&k,s);
    for(int i=0;i<n-1;i++) if(s[i]==s[i+1]) ans++;
    for(int i=1;i<n && k>0;i++){
        if(s[i-1]=='R' && s[i]=='L'){
            if(LR>0 && (i-2<0 || s[i-2]=='R')){
                LR--;
                swap();
                ans+=2;
                k--;
            }
            else RL++;
        }
        else if(s[i-1]=='L' && s[i]=='R'){
            if(RL>0 && (i-1<0 || s[i-1]=='L')){
                RL--;
                swap();
                ans+=2;
                k--;
            }
            else LR++;
        }
    }
    ans+=min(k,LR+RL);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3824
from collections import deque
H, W = map(int, input().split())
si, sj = map(int, input().split())
gi, gj = map(int, input().split())
si, sj, gi, gj = si+1, sj+1, gi+1, gj+1
X = [[1] * (W + 4)] * 2 + [[1] * 2 + [1 if a == "#" else 0for a in input()] + [1] * 2 for _ in range(H)] + [[1] * (W + 4)] * 2
H += 4
W += 4

Y = [(-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)]
Z = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

def BFS():
    Q = deque([(si, sj)])
    D = [-1] * (H * W)
    D[si*W + sj] = 0
    while Q:
        i, j = Q.popleft()
        x = i * W + j
        for di, dj in Y:
            ni, nj = i+di, j+dj
            y = ni * W + nj
            if X[ni][nj] == 0:
                if D[y] == -1 or D[y] > D[x]:
                    D[y] = D[x]
                    Q.appendleft((ni, nj))
        for di, dj in Z:
            ni, nj = i+di, j+dj
            y = ni * W + nj
            if X[ni][nj] == 0:
                if D[y] == -1:
                    D[y] = D[x] + 1
                    Q.append((ni, nj))
    return D[gi * W + gj]

print(BFS())



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

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  if (W/2==x&&H/2==y){
    cout << H*W/2 << ' ' << 1 << endl;
  } else {
    cout << H*W/2 << ' ' << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

typedef pair<double, double> Point;

int main() {
    while(true) {
        Point ps[4];
        for(int i = 0; i < 4; ++i)
            cin >> ps[i].first >> ps[i].second;
        if(cin.eof()) break;

        if(ps[0].first <= ps[3].first && ps[1].first >= ps[2].first && ps[0].second <= ps[3].second && ps[1].second >= ps[2].second) 
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N,M=map(int,input().split())
l=[]
for i in range(N):
    A,B=map(int,input().split())
    l.append([A,B])
l.sort()
left_drinks=M
prices=0
for i in l:
    if left_drinks<=0:
        break
    drinks = min(i[1],left_drinks)
    left_drinks -= drinks
    prices += i[0] * drinks
print(prices)    

Measured memory_bytes: 20072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

string s;
vint ans;

int main(){
    cin >> s;
    int i;
    rep(i, s.length()){
        if(s[i] == '0') ans.push_back(0);
        if(s[i] == '1') ans.push_back(1);
        if(s[i] == 'B' && ans.size() > 0) ans.pop_back();
    }
    rep(i, ans.size()){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  int ans=t.size();
  for(int i=0;i<=s.size()-t.size();i++){
    int n=0;
    for(int j=0;j<t.size();j++){
      if(t[j]!=s[i+j]){
        n++;
      }
    }
    ans=min(ans,n);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>

using namespace std;
typedef long long ll;
 
int main(){
    ll h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
    }
    else {
    cout << (h*w+1)/2<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()

using ll = long long;
using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;
    REP(i, N + 1) {
        REP(j, N - i + 1) {
            int k = (N - i - j);
            if ((i * 10000 + j * 5000 + k * 1000)==Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int a = s[0] - 48, b = s[1] - 48, c = s[2] - 48, d = s[3] - 48;
    if(a+b+c+d == 7){
        cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << "\n";
    }
    else if(a+b+c-d == 7){
        cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << "\n";
    }
    else if(a+b-c+d == 7){
        cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << "\n";
    }
    else if(a-b+c+d == 7){
        cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << "\n";
    }
    else if(a+b-c-d == 7){
        cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << "\n";
    }
    else if(a-b-c+d == 7){
        cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << "\n";
    }
    else if(a-b+c-d == 7){
        cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << "\n";
    }
    else if(a-b-c-d == 7){
        cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << "\n";
    }

    return 0;
}


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

int main() {

    int n, l;
    scanf("%d", &n);

    int maxdata = 0;
    int mysum = 0;
    for (int i = 0; i < n; i++) {

        scanf("%d", &l);
        mysum += l;
        if (maxdata < l) {
            maxdata = l;
        }

    }

    printf("%s",(mysum-maxdata>maxdata ? "Yes":"No"));


    return 0;

}

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

int main(){
  int n, num;
  int count = 0;
  cin >> n;
  
  for(int i = 1; i < n; i++){
    cin >> num;
    if(num != i)count++;
  }
  
  if(count < 3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl; 
  }
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    ll x, y; in >> x >> y;

    ll r = llINF;
    if(x <= y) r = min(r, (y)-(x));
    if(-x <= y) r = min(r, (y)-(-x)+1);
    if(x <= -y) r = min(r, (-y)-(x)+1);
    if(-x <= -y) r = min(r, (-y)-(-x)+2);

    out << r << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

int a[200005],n,Fa[200005],Cnt,Maxv,Minv=2147483647;
bool Vis[200005],b[25];
std::vector<int> g[200005];

void DFS(const int x)
{
    for(int y:g[x])if(!Vis[y])DFS(y);
    for(int y:g[x])if(!Vis[y])b[a[y]]=true;
    while(b[a[x]])++a[x];
    for(int y:g[x])if(!Vis[y])b[a[y]]=false;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&Fa[i]),g[Fa[i]].push_back(i);
    int x=1;
    while(!Vis[x=Fa[x]])Vis[x]=true;
    memset(Vis,false,sizeof Vis);
    while(!Vis[x=Fa[x]])Vis[x]=true;
    for(int i=1;i<=n;++i)if(Vis[i])DFS(i),++Cnt,Maxv=std::max(Maxv,a[i]),Minv=std::min(Minv,a[i]);
    puts(Maxv!=Minv||Cnt%2==0?"POSSIBLE":"IMPOSSIBLE");
    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string o, e; cin >> o >> e;

    for (int i = 0; i < e.size(); ++i) {
        cout << o[i] << e[i];
    }

    if (o.size() - e.size() == 1) {
        cout << o[o.size()-1];
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n;
	vector<int>list;

	cin >> n;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	int sum = list[0] / 2;

	for (i = 1; i < n; i++) {
		sum += list[i];
	}
	cout << sum << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int n; cin >> n;
    int payment=0;
    while(payment < n) payment += 1000;

    cout << (payment - n) << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3628
num = gets.strip.to_i
nums = gets.strip.split(" ").map do |i|
  i.to_i
end

a=[]
b=[]
nums.length.times{|i|
  a.push(-(nums[i]-i-1))
  b.push(nums[i]+i+1)
}
aa= {}
bb = {}
a.each do |i|
  aa[i] = aa[i].nil? ? 1 : aa[i]+=1
end

b.each do |i|
  bb[i] = bb[i].nil? ? 1 : bb[i]+=1
end


sum=0
aa.each do |e,i|
  unless bb[e].nil?
    sum+=bb[e]*i
  end
end


puts sum

Measured memory_bytes: 49668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;

const int maxn = 200010;
const ll INF = 1000000000000000010LL;

int x[maxn], y[maxn];
int colorx[maxn], colory[maxn]; //0 : Red 1:Blue
int n;
ll ans = INF;
vector<int> minv, maxv;
multiset<int> s;
vector<int> red,blue;
vector<pair<int,int> > color;

void solve1()
{
	memset(colorx,-1,sizeof(colorx)); memset(colory,-1,sizeof(colory));
	colorx[minv[0]] = 0;
	colory[maxv[0]] = 1;
	for (int i=1;i<=n;i++)
	{
		if (colorx[i] != -1) colory[i] = 1-colorx[i];
		else if (colory[i] != -1) colorx[i] = 1-colory[i];
		else {colorx[i] = 0; colory[i] = 1;}
	}
	for (int i=1;i<=n;i++)
	{
		if (colorx[i]==0) red.push_back(x[i]);
		else blue.push_back(x[i]);
		if (colory[i]==0) red.push_back(y[i]);
		else blue.push_back(y[i]);
	}
	sort(red.begin(), red.end()); sort(blue.begin(), blue.end());
	ans = min(ans, ((ll)red[red.size()-1] - (ll)red[0]) * ((ll)blue[blue.size()-1] - (ll)blue[0]));
}

void solve2()
{
	memset(colorx,-1,sizeof(colorx)); memset(colory,-1,sizeof(colory));
	if (maxv.size() == 1)
	{
		if (minv.size() == 1) colorx[minv[0]] = 0;
		else colorx[minv[1]] = 0;
		colory[maxv[0]] = 0;
	}
	else
	{
		colorx[minv[0]] = 0;
		colory[maxv[1]] = 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (colorx[i] == -1) color.push_back(make_pair(x[i],i));
		if (colory[i] == -1) color.push_back(make_pair(y[i],i));
	}
	sort(color.begin(), color.end());
	int pi = 0, pj = -1;
	int cnt = 0;
	for (;pi<color.size();pi++)
	{
		while (pj + 1 < color.size() && cnt != n)
		{
			pj++;
			if (s.count(color[pj].second) == 0) cnt++;
			s.insert(color[pj].second);
		}
		//cout<<y[maxv[0]] - x[minv[0]]<<" "<<(ll)color[pj].first - (ll)color[pi].first<<endl;
		if (cnt == n) ans = min(ans, ((ll)y[maxv[0]] - (ll)x[minv[0]]) * ((ll)color[pj].first - (ll)color[pi].first));
		multiset<int>::iterator iter = s.find(color[pi].second);
		s.erase(iter);
		if (s.count(color[pi].second) == 0) cnt--;
	}
}

int main()
{
	//freopen("E.in","r",stdin);
	scanf("%d",&n);
	ll maxval = 0LL, minval = INF;
	for (int i=1;i<=n;i++) 
	{
		scanf("%d%d",&x[i], &y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		maxval = max(maxval, (ll)y[i]);
		minval = min(minval, (ll)x[i]);
	}
	
	ans = INF;
	for (int i=1;i<=n;i++)
	{
		if (x[i] == minval) minv.push_back(i);
		if (y[i] == maxval) maxv.push_back(i);
	}
	solve1();
	if (!(minv.size() == 1 && maxv.size() == 1 && minv[0] == maxv[0])) solve2();
	
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n, m; cin >> n >> m;
  vector<vector<int> > a(n, vector<int>(m));
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> a[i][j];
  vector<pair<pair<int,int>, pair<int,int> > > ans;
  for(int i = 0; i < n; i++){
    int l = 0, r = m, d = 1;
    if(i&1) l = m-1, r = -1, d = -1;
    for(int j = l; j != r; j += d){
      if(a[i][j]&1){
	int x = i, y = j + d;
	if(x != n-1 && y == r){
	  x = x + 1; y = j;
	}
	if(x >= 0 && x < n && y >= 0 && y < m){
	  ++a[x][y];
	  ans.emplace_back(make_pair(i,j),make_pair(x,y));
	}
      }
    }
  }
  cout << ans.size() << endl;
  for(auto p: ans) printf("%d %d %d %d\n",p.first.first+1, p.first.second+1, p.second.first+1, p.second.second+1);
  return 0;
}


Measured memory_bytes: 5236
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    H = list(map(int, input().split()))
    def cost(i, jp):
        return abs(H[i-1] - H[i+jp-1])
    dp = [0]*(N+1)
    dp[2] = cost(1, 1)
    for i in range(3,N+1):
        dp[i] = min(dp[i-1]+cost(i-1, 1),dp[i-2]+cost(i-2, 2))
    print(dp[N])


if __name__=='__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	if(n < a+b-1 || a*b < n){
		puts("-1");
		return 0;
	}
	
	vector<ll> ret;
	for(int i = b ; i >= 1 ; i --){
		ret.push_back(i);
	}
	for(int i = 2 ; i <= a ; i ++){
		ll x = min( b , (ll)(n-ret.size()-(a-i)) );
		ll y = ret.size();
		for(int j = x ; j >= 1 ; j --){
			ret.push_back(y+j);
		}
	}
	for(int i = 0 ; i < ret.size() ; i ++){
		printf("%lld%c",ret[i],(i+1==ret.size())?'\n':' ');
	}
}

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

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

int main()
{_

    ll n , res = 0  , X;
    cin >> n >> X;vl m(n);
    for(ll i = 0; i < n; i++){
        cin >> m[i];
        X -= m[i];
    }
    res += X / *min_element(m.begin(), m.end());
    res += n;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>

int main(void) {
  std::string X;
  std::stack<char> st;
  
  std::cin >> X;
  for(int i = 0; i < X.size(); i++) {
    char c = X[i];
    if(st.empty() || st.top() == 'T' || c == 'S') {
      st.push(c);
    } else {
      st.pop();
    }
  }
  
  std::cout << st.size() << std::endl;
   
  return 0;
}

Measured memory_bytes: 644
# coding:utf-8


def main():
    # N = int(input())
    W, H, x, y = map(int, input().split())
    ans = 0
    # s1a = (W-x)*H
    # s1b = x*H

    # s2a = W*(H-y)
    # s2b = W*y

    # s = max(min(s1a, s1b), min(s2a, s2b))
    # if min(s1a, s1b) == min(s2a, s2b):
    #     ans = 1
    s = W*H/2
    if x == W/2 and y == H/2:
        ans = 1

    print(s, ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38484
import java.util.*;
import java.util.Map.Entry;
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long N;
	 static long K;
	 static Integer[]a;
	 static Integer[]f;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       N = sc.nextInt();
       K = sc.nextLong();

       a = new Integer[(int)N];
       long max=0;
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextInt();
       }
       f = new Integer[(int)N];
       for (int i=0 ; i<N; i++) {
           f[i] = sc.nextInt();
       }

       Arrays.sort(a);
       Arrays.sort(f,Collections.reverseOrder());
       long left=0;
       long right=2200200200200200200l;
//	   right=Long.MAX_VALUE;
//     right=9;
	   left=-1;
	   while(right-left>1) {
		   long mid=left+(right-left)/2;
		   if(IsOK(mid)) right=mid;
		   else left=mid;
	   }
       
       System.out.println(right);
   }
   
   public static boolean IsOK(long p) {
	   long cnt=0;
	   long tmp=0;
	   for(int i=0;i<N;i++) {
		   tmp=a[i]-p/f[i];
		   if(tmp<0) {
			   tmp=0;
		   }   
		   cnt=cnt+tmp;
	   }

	   return cnt<=K;
   }
}

Measured memory_bytes: 115040
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll even = 0;
    ll odd = 0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==0){
            even++;
        }else{
            odd++;
        }
    }
    sort(a.begin(),a.end());
   if(odd>0){
       cout << "first" << endl; 
   }else{
       cout << "second" << endl;
   }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    long long int A,B,C,D;
    scanf("%lld %lld",&a,&b);
    scanf("%lld %lld",&c,&d);

    A=a*c;
    B=b*c;
    C=a*d;
    D=b*d;
    long long int temp = A;
    if(A>B)
    {
        temp = A;
        A=B;
        B=temp;
    }
    if(B>C)
    {

        temp=B;
        B=C;
        C=temp;
    }
    if(C>D)
    {

        temp=C;
        C=D;
        D=temp;
    }
    if(D>A)
    {
        temp=D;
        D=A;
        A=temp;
    }
    if(A>B)
    {

        temp=A;
        A=B;
        B=temp;
    }
    printf("%lld\n",temp);
    return 0;

}

Measured memory_bytes: 2116
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (n, m): (usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        (a, b)
    };

    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		vl left(n-1),right(n-1);
		rep(i,n-1){
			cin>>left[i]>>right[i];
			left[i]--,right[i]--;
		}
		
		vl ps(n,-1);
		rep(i,n-1){
			if(left[i]!=n-1) ps[left[i]]=i;
			if(right[i]!=n-1) ps[right[i]]=i;
		}
		
		vl depth(n);
		repi(i,1,n-1)
			depth[i]=1+depth[ps[i]];
		//dump(depth);
		
		vl size(n,1);
		per(i,n-1)
			size[i]=1+size[left[i]]+size[right[i]];
		//dump(size);
		
		vl unsaved(n);
		per(i,n-1){
			int l=left[i],r=right[i];
			unsaved[i]=unsaved[l]+(size[l]+1)/2+unsaved[r]+(size[r]+1)/2;
		}
		//dump(unsaved);
		
		vl saved(n);
		per(i,n-1){
			int l=left[i],r=right[i];
			ll a=unsaved[i];
			ll b=1+saved[l]+depth[i]+1+saved[r];
			ll c=unsaved[l]+(size[l]+1)/2+1+saved[r];
			ll d=unsaved[r]+(size[r]+1)/2+1+saved[l];
			//dump(vi({i,a,b,c,d}));
			saved[i]=min({a,b,c,d});
		}
		//dump(saved);
		
		cout<<saved[0]<<endl;
	}
}

Measured memory_bytes: 28308
#include<stdio.h>

int main(){

int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int k,p;
scanf("%d%d",&k,&p);
int t=k%p;
if(t==0)t=p;
printf("%d\n",t);
}
return 0;
}

Measured memory_bytes: 1024
var
  c,t,m,i,j,minc,mint,n:longint;
begin
  readln(n,m);
  minc:=10000;
  for i:=1 to n do
    begin
      readln(c,t);
      if t<=m then
        if c<minc then minc:=c;
    end;
  if minc=10000 then write('TLE') else write(minc);
end.


Measured memory_bytes: 128
X1 = list(map(str, input().split()))

X2 = X1[0]

mae = int(X2[0:2])
ushiro = int(X2[2:4])

if(1 <= mae <= 12 and 1 <= ushiro <= 12):
    print("AMBIGUOUS")
elif(1 <= mae <= 12 and (ushiro < 1 or 12 < ushiro)):
    print("MMYY")
elif((mae < 1 or 12 < mae) and 1 <= ushiro <= 12):
    print("YYMM")
elif((mae < 1 or 12 < mae) and (ushiro < 1 or 12 < ushiro)):
    print("NA")


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

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

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    long a, b;
    scan(a, b);
    auto ans = xorsum(b) ^ xorsum(a - 1);
    writeln(ans);
}

long xorsum(long n) {
    if (n <= 0) {
        return 0;
    }
    if (n % 4 == 0) {
        return n;
    }
    else if (n % 4 == 1) {
        return 1;
    }
    else if (n % 4 == 2) {
        return n + 1;
    }
    else {
        return 0;
    }
}

int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        boolean a = false;
        boolean b = false;
        int ans = 0;
        for (int i = 0; i <= 100; i++) {
            if (i == A) {
                a = true;
            }
            if (i == B) {
                a = false;
            }
            if (i == C) {
                b = true;
            }
            if (i == D) {
                b = false;
            }
            if (a && b) {
                ans++;
            }
        }
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, k, s;
  ll x = 1e9;
  cin >> n >> k >> s;
  if (s == x)
	x = 1;
  forll(i, 0, k)
	cout << s << " ";
  forll(i, k, n)
	cout << x << " ";
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define iiordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define MOD (1000*1000*1000+7)
ll power(ll a,ll b, ll m=MOD)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll inverse(ll a,ll m=MOD)
{
    return power(a,m-2,m);
}
int ceil(int a,int b)
{
    return (a+b-1)/b;
}
#define INFl (1e18+5)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<long long>
#define vvl vector<vl>
#define vll vector<pll>
#define vii vector<ii>
#define vvii vector<vii>
#define tri pair<int,ii>
#define F first
#define S second
#define forl(i,n) for(int i=0;i<n;i++)
#define fore(i,n) for(int i=1;i<=n;i++)
#define rforl(i,n)  for(int i=n-1;i>=0;i--)
#define rfore(i,n)  for(int i=n;i>=1;i--)
#define CASE(t) cout<<"Case #"<<(t)<<": ";
#define INF 1020000000
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<it->F<<' '<<it->S<<endl;  
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

bool isPalindrome(string s)
{
	// cout<<s<<endl;
	forl(i,s.length())
	{
		if(s[i]!=s[s.length()-1-i])	return false;
	}
	return true;
}
int main()
{
	string s;
	cin>>s;
	if(isPalindrome(s) && isPalindrome(s.substr(0,s.length()/2)) && isPalindrome(s.substr(s.length()/2+1,s.length())))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random

s = str(input())
yyyy,mm,dd = s.split("/")
ans = True
yyyy = int(yyyy)
mm = int(mm)
dd = int(dd)
if yyyy>=2020:
    ans = False
elif yyyy<=2018:
    pass
else:
    if mm>=5:
        ans = False
    elif mm<=3:
        pass
    else:
        pass

if ans:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 15160