akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main() {

	string s;
	string inp;

	cin >> inp;

	for(auto &e : inp) {
		switch(e) {
			case '0':
				s += "0";
				break;
			case '1':
				s += "1";
				break;
			default:
				if(s.size())s = s.substr(0,s.size()-1);
				break;
		}
	}

	cout << s << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    int N;
    cin >> N;
    int x[N];
    int y[N];
    rep(i,N){
        cin>>x[i]>>y[i];
    }
    int l[N][N][2];
    rep(i,N){
        rep(j,N){
            l[i][j][0]=x[i]-x[j];
            l[i][j][1]=y[i]-y[j];
        }
    }
    int k=N;
    rep(i,N){
        rep(j,N){
            int a=l[i][j][0];
            int b=l[i][j][1];
            if(a==0&&b==0){continue;}
            int s=N;
            rep(m,N){
                rep(n,N){
                    if(l[m][n][0]==a&&l[m][n][1]==b){
                        l[m][n][0]=0;
                        l[m][n][1]=0;
                        s=s-1;
                    }
                }
            }
            if(s<k){
                k=s;
            }
        }
    }
    if(k>0){
        cout<<k<<endl;
        return 0;
    }else{
        cout<<1<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  vll a(N);rep(i,N)cin>>a[i];
  ll A=0;
  rep(i,N) A = A^a[i];
  rep(i,N){
    ll ans = A^a[i];
    cout<<ans<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 4840
n=gets.to_i
ab=n.times.map{gets.split.map(&:to_i)}.sort{ |l,r| r.last<=>l.last}
cd=n.times.map{gets.split.map(&:to_i)}.sort{ |l,r| l.first<=>r.first}
cd.each{ |e| ab.delete(ab.select{ |f| f[0]<e[0] && f[1]<e[1]}.first)}
p n-ab.size


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

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N, K;

int a, b;
cp2 x[53];
cp2 y[53];
cp2 P[53];

int sum[53][53];

ll num;
ll ans;
int cnt = mod;
int idxx[53];
int idxy[53];
ll l, r, u, d;

int main(){
	
	cin>>N>>K;
	
	fill( sum[0], sum[53], 0 );
	
	REP( i, N ){
		cin>>a>>b;
		x[i] = cp2( a, i );
		y[i] = cp2( b, i );
		P[i] = cp2( a, b );
	}
	
	sort( x, x+N );
	sort( y, y+N );
	
	ans = 8893488147419103230;
	
	REP( i, N ){
		x[i].fi = i+1;
		y[i].fi = i+1;
		swap( x[i].fi, x[i].se );
		swap( y[i].fi, y[i].se );
	}
	
	sort( x, x+N );
	sort( y, y+N );
	
	REP( i, N ){
		swap( x[i].fi, x[i].se );
		swap( y[i].fi, y[i].se );
	}
	
	REP( i, N ){
		int idx = x[i].fi;
		idxx[idx] = i;
		idx = y[i].fi;
		idxy[idx] = i;
	}
	
	/*REP( i, N ){
		cout<<x[i].fi<<"-"<<y[i].fi<<endl;
	}*/
	
	REP( i, N ){
		a = x[i].fi;
		b = y[i].fi;
		sum[a][b] = 1;
	}
	
	REP( i, N+1 ){
		REP( j, N ){
			sum[i][j+1] += sum[i][j];
		}
	} 
	
	REP( i, N ){
		REP( j, N+1 ){	
			sum[i+1][j] += sum[i][j];
		}
	}
	
	FOR( i, 1, N+1 ){
		FOR( j, 1, N+1 ){
			FOR( k, i+1, N+1 ){
				FOR( m, j+1, N+1 ){
					int cnt;
					cnt = sum[k][m]-sum[k][j-1]-sum[i-1][m]+sum[i-1][j-1];
					r = idxx[k];
					l = idxx[i];
					u = idxy[m];
					d = idxy[j];
					r = P[r].fi;
					l = P[l].fi;
					u = P[u].se;
					d = P[d].se;
					num = abs(r-l)*abs(u-d);
					if( cnt >= K ){
						//cout<<num<<endl;
						ans = min( ans, num );
					}
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n,a,b ;
	cin >> n >> a >> b ;
	cout << min(b,n*a) << endl ;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;



int main() {
  int s, w;
  cin >> s >> w;

  if (s <= w) {
    cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }

}

Measured memory_bytes: 3592
function Main(input) {
  input = input.split("\n");

  var N = ~~input[0];
  var A = input[1];
  var a = A.split(" ").map(x => ~~x);

var Cards = function(cards){
  this.cards = cards;
}

var Human = function(){
  this.point = 0;
};

Human.prototype = {
  selectCard: function(cards){
    var maxCard = Math.max(...cards);
    this.point = this.point + maxCard;
    for(var i =0; i< cards.length; i++){
      if(cards[i] == maxCard){
        cards[i] = 0;
        return;
      }
    }
  }
}

var allice = new Human();
var bob = new Human();
var cards = new Cards(a);

for(var i = 0; i<N; i++){
  allice.selectCard(cards.cards);
  bob.selectCard(cards.cards);
}

console.log(allice.point - bob.point);

}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8332
h, w = map(int, input().split())
smap = []
for _ in range(h):
    di = list(input())
    smap.append(di)

dp = [[0]* w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if i == j == 0:
            continue
        if i == 0:
            if smap[i][j-1] != smap[i][j]:
                dp[i][j] = dp[i][j-1]+1
            else:
                dp[i][j] = dp[i][j-1]
        elif j == 0:
            if smap[i-1][j] != smap[i][j]:
                dp[i][j] = dp[i-1][j]+1
            else:
                dp[i][j] = dp[i-1][j]
        else:
            up = 0
            if smap[i][j-1] != smap[i][j]:
                up = dp[i][j-1]+1
            else:
                up = dp[i][j-1]
            lp = 0
            if smap[i-1][j] != smap[i][j]:
                lp = dp[i-1][j]+1
            else:
                lp = dp[i-1][j]
            dp[i][j] = min(up, lp)
result = dp[h-1][w-1] // 2
if dp[h-1][w-1] %2 == 1:
    result += 1
if smap[0][0] == '#' and smap[h-1][w-1] == '#':
    result+=1
print(result)

Measured memory_bytes: 41968
#include<stdio.h>
int gcd(int a,int b){
  if(a<b) return gcd(b,a);
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  int a,b,k;
  scanf("%d %d %d",&a,&b,&k);
  int d=gcd(a,b),i=0;
  while(k){
    i++;
    if(d%i==0) k--;
  }
  printf("%d",d/i);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            int min = 10000;
            int max = 0;
            for (int i = 0; i < input.Length; ++i)
            {
                int t = int.Parse(input[i]);
                if (min > t)
                {
                    min = t;
                }
                if (max < t)
                {
                    max = t;
                }
            }
            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

long long int abso(long long int n) {
    if (n < 0) return (-1) * n;
    else return n;
}

int main(void) {
    long long int n, k;
    cin >> n >> k;
    long long int ret = n % k;
    cout << min(abso(k - ret), ret) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int t,x;
  scanf("%d",&t);
  if(t>=1&&t<=9)
  {
   x=t-0;
   printf("%d",x);
  }
  else if(t>=10&&t<=99)
  {
    x=9;
    printf("%d\n",x);
  }
  else if(t>=100&&t<=999)
  {
    x=(t-100)+1+9;
    printf("%d\n",x);
  }
  else if(t>=1000&&t<=9999)
  {
    x=(999-100)+1+9;
    printf("%d\n",x);
  }
  else if(t>=10000&&t<=99999)
  {
    x=(999-100)+1+9+(t-10000)+1;
    printf("%d\n",x);
  }
  else if(t>=100000&&t<=999999)
  {
    x=(999-100)+1+9+(99999-10000)+1;
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 1716
n,m,l  = gets.chomp.split(" ").map{|item| item.to_i}
a = Array.new(n).map{ Array.new(m,0) }
b = Array.new(m).map{ Array.new(l,0) }

n.times do |i|
    a[i] = gets.chomp.split(" ").map{|item| item.to_i}
end

m.times do |k|
    b[k] = gets.chomp.split(" ").map{|item| item.to_i}
end

c = Array.new(n).map{ Array.new(l,0) }
n.times do |i|
    l.times do |j|
        m.times do |k|
            c[i][j]+=a[i][k]*b[k][j]
        end
        
        if j!=0
            print(" ")
        end
        print(c[i][j])
    end
    puts
end

Measured memory_bytes: 9424
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i, x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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

using namespace std;
/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

ll a[101];
ll dp[101][21];
int main() {
   int n;
   cin >> n;
   rep(i, n) cin >> a[i];
   dp[1][a[0]] = 1;
   reps(i, n-1){
       rep(j, 21){
           ll pl = j + a[i];
           ll mi = j - a[i];
           if(pl <= 20) dp[i+1][pl] += dp[i][j];
           if(mi >= 0) dp[i+1][mi] += dp[i][j];
       }
   }
   cout << dp[n-1][a[n-1]] << endl;
}




Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007,N=3100;
typedef long long ll;
inline void reduce(int&x){x+=x>>31&mod;}
int n,m,f[N][N][2];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<=n;++i)f[0][i][!i]=1;
	for(int i=1;i<=m;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=1;++k)if(f[i-1][j][k]){
				int t=f[i-1][j][k]-mod;
				if(j)reduce(f[i][j][k|(j==1)]+=t),reduce(f[i][j-1][k|(j==1)]+=t);
				if(j!=n)reduce(f[i][j][k]+=t),reduce(f[i][j+1][k]+=t);
			}
	int ans=0;
	for(int i=0;i<=n;++i)reduce(ans+=f[m][i][1]-mod);
	cout<<ans<<'\n';
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if ((a % 2 == 0) || (b % 2 == 0)) {
    cout << "Even" << endl;
  }

  else {
    cout << "Odd" << endl;
  }

}


Measured memory_bytes: 256
h,w = map(int,input().split())
sy, sx = map(int,input().split())
start = (sy-1, sx-1)
gy, gx = (map(int,input().split()))
goal = (gy-1, gx-1)

yukaset = set()

for i in range(h):
	chizu = input()
	for j in range(w):
		if chizu[j] == ".":
			yukaset.add((i, j))

settansaku = {start}
stock = []
listmada = [start]
mode = 1
cost = 0

while len(listmada) > 0:
	for i, j in listmada:
		stock.append((i, j))
		for k in [(i+1, j), (i-1, j), (i, j-1), (i, j+1)]:
			if k in yukaset:
				if k not in settansaku:
					listmada.append(k)
					settansaku.add(k)

	if goal in settansaku:
		mode = 0
		break
	
	listmada = []
	cost += 1
	for i, j in stock:
		for k in [(i-2, j-2), (i-1, j-2), (i, j-2), (i+1, j-2), (i+2, j-2), (i-2, j-1), (i-1, j-1), (i, j-1), (i+1, j-1), (i+2, j-1), (i-2, j), (i-1, j), (i+1, j), (i+2, j), (i-2, j+1), (i-1, j+1), (i, j+1), (i+1, j+1), (i+2, j+1), (i-2, j+2), (i-1, j+2), (i, j+2), (i+1, j+2), (i+2, j+2)]:
			if k in yukaset:
				if k not in settansaku:
					listmada.append(k)
					settansaku.add(k)
	
	stock = []

if mode == 0:
	print(cost)
else:
	print(-1)

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

int n;

main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x = i;
        while (x > 0){
            if (i % 3 == 0 || x % 10 == 3){
                cout << " " << i;
                break;
            }
            else x /= 10;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3104
using System;

namespace _0359
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] ret = new string[] { "thu","fri","sat","sun","mon","tue","wed" };
            Console.WriteLine(ret[n % 7]);
        }
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  ll a,b,c;

  cin >> a >> b >> c;

  if(c-b-a<0){
    cout << "No" << endl;
  }else if( 4 * a * b < (c-b-a)*(c-b-a)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}



Measured memory_bytes: 256
#include<stdio.h>

long long int N, W, w, n;
char c;

int main(){
	c=getchar();
	while(c!=10){
		if(c=='W'){
			W+=N;
			w+=n;
			n++;
		}
		N++;
		c=getchar();
	}
	printf("%lld\n", W-w);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }

  map<string, ll> mp;
  rep(i, n) mp[s[i]]++;
  ll ans = 0;
  for(auto elem : mp) {
    ll tmp = elem.second;
    ans += tmp*(tmp-1)/2;
  }

  cout << ans << '\n';
  return 0;
}


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

#define int long long
#define vc vector<char>
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define pii pair<int,int>
#define SORT(c) sort(c.begin(),c.end())
#define SORTC(c, cmp) sort(c.begin(),c.end(),cmp)
#define mapii map<int,int>
#define pb push_back
#define F first
#define S second
#define rep(i, j, k) for (int i=j;i<k;i++)
#define repb(i, j, k) for (int i=j;i>=k;i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ar array

using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0)


const int mxN = 2e5;


void solve() {
    int n;
    cin >> n;
    cout << 1000-((n % 1000)?(n%1000):1000);
}

int32_t main() {
    fast;

    int tt{1};
//    cin >> tt;
    while (tt--) {
        solve();
        cout << endl;
    }
    return 0;

}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int result[200] = { 0 };
int main(){
		int num;
		int tmp1, tmp2, sc1 = 0, sc2= 0;
		while (cin >> num){
			sc1 = sc2 = 0;
			if (num == 0)break;
			for (int i = 0; i < num; i++){
				cin >> tmp1 >> tmp2;
				if (tmp1 == tmp2){
					sc1 += tmp1;
					sc2 += tmp2;
				}
				else if (tmp1 > tmp2)
					sc1 += tmp1 + tmp2;
				else if (tmp1 < tmp2)
					sc2 += tmp1 + tmp2;
			}
			cout << sc1 << " " << sc2 << endl;
		}
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
	int n,r,x1,x2,h;
	while(1){
		cin>>r>>n;
		if(r==0&&n==0)break;
		map<int,int> mp;
		rep(i,0,n){
			cin>>x1>>x2>>h;
			rep(x,x1,x2){
				mp[x]=max(mp[x],h);
			}
		}

		double ans=inf;
		rep(x,-r,r){
			double p=(x<0?x+1:x);
			ans=min(ans,mp[x]+r-sqrt(r*r-p*p));
		}
		print(setprecision(15)<<ans);
	}
}


Measured memory_bytes: 3256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 1000
ll c[N], s[N], f[N];
int main(){
	ll n;
	cin>>n;
	rep(i, n-1) cin>>c[i]>>s[i]>>f[i];
	rep(j, n){
		ll res = 0;
		for(int i = j; i < n-1; i++){
			if(res<s[i]) res = s[i];
			else res = (res+f[i]-1)/f[i]*f[i];
			res += c[i];
		}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int X,A,B;
    string ans;
    cin >> X >> A >> B;
    if (A-B>=0){
        ans = "delicious";
    }else if (abs(A-B)<=X){
        ans = "safe";
    }else {
        ans = "dangerous";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();

        for (int i = 3; i <= a; i++) {
            if (i % 3 == 0 || String.valueOf(i).contains("3"))
                System.out.print(" " + i);
        }
        System.out.println();
	}
}



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

string s;
int pos,ans;

int main()
{
	cin>>s;
	pos=s.size()-1;
	
	while(pos>=0)
	{
		int cur=pos;
		while(s[cur]==s[pos]&&pos>=0) pos--;
		ans++;
	}
	
	cout<<ans-1;
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <assert.h>
#include <vector>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    //对岛屿1-n都打上false的标记
    //对vis的前n+1个元素都初始化为false
    vector <bool> vis(n+1,false);
    bool ans = false;
    for(int i = 0;i<m;i++){
        int a,b;
        cin>>a>>b;
        assert(1<=a && a<b &&b<=n);
        if(a == 1){
            if(vis[b]){
                ans = true;
                break;
            }
            vis[b] = true;
        }
        if(b == n){
            if(vis[a]){
                ans = true;
                break;
            }
            vis[a] = true;
        }
    }
    if(ans) cout <<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, m, a[][], c[][];
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[n][2];
		c = new int[m][2];
		for(int i = 0; i < n; ++i) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		for(int i = 0; i < m; ++i) {
			c[i][0] = sc.nextInt();
			c[i][1] = sc.nextInt();
		}
		
		int min;
		int min_num;
		int d = 0;
		for(int i = 0; i < n; ++i) {
			min = 2000000000;
			min_num = 0;
			for(int j = 0; j < m; ++j) {
				d = Math.abs(a[i][0] - c[j][0]) + Math.abs(a[i][1] - c[j][1]); 
				if(min > d) {
					min = d;
					min_num = j + 1;
				}
			}
			System.out.println(min_num);
		}
		
		sc.close();
	}

}


Measured memory_bytes: 21972
int main() {
	int n, i;
  static int a[10000000], sum[10000000];
	scanf("%d", &n);
	for (i = 2;i<= n;i++){
      scanf("%d", &a[i]);
    }//n-１人の入力
	for (i = 0; i <= n; i++) {
      sum[i] = 0;
    }
	for (i = 2; i <= n; i++) 
    {
      sum[a[i]]++;
    }
	for (i = 1; i <= n; i++) {
      printf("%d\n", sum[i]);
    }
 
 
	return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

const int MAXN = 1000;
const int MAXV = MAXN*(MAXN-1)/2;
int dp[MAXV];
int visited[MAXV];
int calculated[MAXV];
vector<int> games[MAXV];
int dfs(int v){
    if(visited[v]==1){
        if(calculated[v]==0)return -1;
        return dp[v];
    }
    visited[v] = 1;
    dp[v] = 1;
    for (int u: games[v]){
        int r = dfs(u);
        if (r == -1)return -1;
        dp[v] = max(dp[v],r+1);
    }
    calculated[v] = 1;
    return dp[v];
}


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

  int id[MAXN][MAXN];
  
  int k=0;
  REP(i,n)FOR(j,i+1,n){
      id[i][j] = id[j][i] = k;
      k++;
  } 
  int old;
  REP(i,n)REP(j,n-1){
      cin >> a;
      if (j!=0){
          games[old].push_back(id[i][a-1]);
      }
      old = id[i][a-1];
  }
  REP(i,MAXV){
      dp[i]=0;
      visited[i]=0;
      calculated[i]=0;
  }
  REP(i,MAXV){    
    if (dfs(i)==-1){
        cout << -1 << endl;
        return 0;
    }
  }
  int mx = 0;
  REP(i,MAXV)mx=max(mx,dp[i]);
  cout << mx << endl;
}


Measured memory_bytes: 37376
# coding: utf-8
# Your code here!
from collections import Counter

S = list(input())
A_li = []
B_li = []

for i in range(1, len(S) + 1):
    S_del = S[:-i]
    A_li = S_del[0:len(S_del) // 2]
    B_li = S_del[len(S_del) // 2::]
    if A_li == B_li:
        print(len(A_li) * 2)
        exit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll y,m;
    y=atoi(s.substr(0,4).c_str());
    m=atoi(s.substr(5,2).c_str());
    if(y<2019){
        cout<<"Heisei"<<endl;
    }else if(m<5){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}

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

using namespace std;

const long long MOD = 1000000007;

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

long long mod_inverse(long long x, long long mod) {
  return mod_pow(x, mod - 2, mod);
}

// テーブルを作る前処理
long long fac[10000007], finv[10000007], inv[10000007];

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

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

long long g(long long x, long long y) {
  long long ret = 0;
  for (int i = 2; i <= y + 1; i++) {
    ret += mod_comb(x + i, i, MOD);
    ret %= MOD;
  }
  return ret;
}
int main() {
  COMinit();

  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--, y1--;

  long long ans = 0;

  ans = (ans + g(x2, y2)) % MOD;
  ans = (ans - g(x1, y2)) % MOD;
  ans = (ans - g(x2, y1)) % MOD;
  ans = (ans + g(x1, y1)) % MOD;

  ans = (ans + MOD) % MOD;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 234624
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    from functools import reduce
    s = reduce(lambda x, y: x ^ y, A, 0)
    X = [s^a for a in A]
    print(" ".join(map(str, X)))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 42180
#include <stdio.h>
int main()
{
  int a,y,t,max,m[105][105],i,j,k,l,yo,ta,cou;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    scanf("%d %d",&y,&t);
    for(i=1;i<=t;i++){
      for(j=1;j<=y;j++){
	m[j][i]=0;
      }
    }
    for(i=0;i<a;i++){
      scanf("%d %d",&j,&k);
      m[j][k]=1;
    }
    scanf("%d %d",&yo,&ta);
    //printf("%d %d ",yo,ta);///
    max=0;
    for(i=1;i<=y-yo+1;i++){
      for(j=1;j<=t-ta+1;j++){
	cou=0;
	for(k=i;k<=i+yo-1;k++){
	  for(l=j;l<=j+ta-1;l++){
	    if(m[k][l]==1)cou++;
	  }
	}
	if(max<cou)max=cou;
      }
    }printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 1068
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef vector<int> VI;

static const int MAX_N = 1<<12 + 1;
static const int MAX_M = 1001;
int a[MAX_M];
int b[MAX_M];
int c[MAX_M];
int dp[MAX_M][MAX_N];

static const int LARGE = (int)100000000000;

int main(void)
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a[i] >> b[i];
		c[i] = 0;
		for (int j = 0; j < b[i]; j++)
		{
			int ci;
			cin >> ci;
			ci--;
			c[i] |= (1 << ci);
		}
	}
	for (int i = 0; i < MAX_M; i++)
	{
		for (int j = 0; j < MAX_N; j++)
		{
			dp[i][j] = LARGE;
		}
	}
	for (int i = 0; i <= m; i++)
	{
		dp[i][0] = 0;
	}
	for (int i = 0; i < m; i++) 
	{
		int ci = c[i];
		for (int j = 0; j < MAX_N; j++)
		{
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j | ci] = min(dp[i + 1][j | ci], dp[i][j] + a[i]);
		}
	}
	int t = 0;
	for (int i = 0; i < n; i++) {
		t |= 1 << i;
	}
	if (dp[m][t] == LARGE)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << dp[m][t] << endl;
	return 0;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n; cin >> n;

    long long ans=0;
    if(n%2==0){
        n /= 2;
        while(n>=5){
            ans += n/5;
            n /= 5;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region header
#define _GLIBCXX_DEBUG 
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
signed main() {
    string O,E;
    cin>>E>>O;

        for(int i=0;i<E.size();i++){
            cout<<E[i];
            if(i < O. size () ) cout << O[i];
        }
    
}

Measured memory_bytes: 3628
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    loop {
        let n: usize = sc.read();
        let m: usize = sc.read();
        if n == 0 {
            return;
        }
        let mut max = vec![0; n];
        let mut min = vec![0; n];
        for _ in 0..m {
            let s: u64 = sc.read();
            let k: usize = sc.read();
            for _ in 0..k {
                let i = sc.read::<usize>() - 1;
                max[i] += s;
                if k == 1 {
                    min[i] += s;
                }
            }
        }

        let mut ans = 0;
        for i in 0..n {
            let min = min[i];
            let mut max_max = 0;
            for j in 0..n {
                if i == j {
                    continue;
                }
                max_max = cmp::max(max_max, max[j]);
            }

            if max_max >= min {
                ans = cmp::max(ans, max_max - min);
            }
        }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  string s;
  cin >> s;

  int c = s.length();
  ll ans = 0;
  int cntB = 0;

  REP(i, c){
    if(s[i] == 'B') cntB++;
    else ans += cntB;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	string out;
	out += s1.substr(0,1);out += s2.substr(0,1);out += s3.substr(0,1);
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

ll dp[101][10001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,W;
	cin>>n>>W;
	vl v(n),w(n);
	rep(i,n){
		cin>>v[i]>>w[i];
		rep(j,10001){
			if(w[i]<=j)dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
			else dp[i+1][j]=dp[i][j];
		}
	}
	cout<<dp[n][W]<<endl;
}


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

pair<int, int> calc(double d) {
  int num, den = 0;
  while (++den) {
    num = M_PI * den;
    if (M_PI > (num + 0.5) / den) num++;
    if (abs(M_PI - 1.0 * num / den) < d) break;
  }
  return pair<int, int>(num, den);
}

int main() {
  double d;
  while (true) {
    cin >> d;
    if (d == 0.0) break;
    pair<int, int> a = calc(d);
    cout << a.first << '/' << a.second << endl;
  }
}

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

using namespace std;

int main() {
    long long W, H, x, y;
    cin >> W >> H >> x >> y;

    auto ans = (double) W * H / 2.0;
    cout << fixed << setprecision(10);
    cout << ans << " ";

    if (x * 2 == W && y * 2 == H) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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


int main(void) {
  int n;
  cin >> n;
  map<ll, int> a;
  rep(i, n) {
    ll temp;
    cin >> temp;
    a[temp]++;
  }

  ll ans = 0;
  for (auto x : a) {
    if (x.second % 2 != 0) ans++;
  }

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

Measured memory_bytes: 9788
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	
	cin >> n;
	int last = 0, ans = 0, cur;
	for (int i = 0; i < n; ++i)
	{
		cin >> cur;
		if (cur > last)
			ans += cur-last;
		last = cur;
	}

	cout << ans << endl;

	return 0;
}

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

bool getNum(int num, vector<int>&D){
    string n = to_string(num);
    for(int i = 0; i < n.size(); i++){
        for(int j = 0; j < D.size(); j++){
            if(n[i] - '0' == D.at(j)){
                return false;
            }
        }
    }
    return true;
}

int main(){
    int N;
    int K;
    cin >> N >> K;
    vector<int>D;
    for(int i = 0; i < K; i++){
        int d;
        cin >> d;
        D.push_back(d);
    }
    
    bool flag = true;
    while(flag){
        if (getNum(N,D)){
            cout << N << endl;
            break;
        }
        N ++;
    }
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

const int maxn = 2e5+10;
ll n,a[maxn];
ll sum[maxn];
ll ans = 1e18;

ll calc(ll a, ll b, ll c){
	return abs(2*sum[b]-sum[a-1]-sum[c]);
}

void work(int a,int b, ll &x, ll &xx){
	int l=a,r=b;
	while(l<r){
		int midl = (l+l+r)/3,midr=(l+r+r+2)/3;
		if(calc(a,midl,b)<calc(a,midr,b)){
			r = midr - 1;
		}else{
			l = midl + 1;
		}
		x = min(sum[b]-sum[l], sum[l]-sum[a-1]);
		xx = max(sum[b]-sum[l], sum[l]-sum[a-1]);
	}
}

int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
	}
	for(int i=2;i+2<=n;i++){
		ll x[4]={};
		work(1,i,x[0],x[1]);
		work(i+1,n,x[2],x[3]);
		sort(x,x+4);
		ans = min(ans,x[3]-x[0]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    String[] N=scan.nextLine().split("");
    int count=0;
    for(int i=0;i<4;i++){
      if(N[i].equals("2")){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    long long n,m,sum=0;
    scanf("%lld%lld",&n,&m);
    for(long long i=0;i<m;i++)
    {
        long long x;
        scanf("%lld",&x);
        sum=sum+x;
    }
    if(sum>n)
        printf("-1\n");
    else
        printf("%lld",n-sum);
}


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

int main() {
  int N;
  int j = 0;
  string S;
  cin >> N;

  // ここにプログラムを追記
  for(int i = 0; i < N; i++){
    cin >> S;
    
    if(S == "Y") {
      if(j != 1) {
        cout << "Four" << endl;
        j = 1;
      }
    }
    else if (i == N -1 && j == 0){
      cout << "Three" << endl;
    }
  }
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,M;
    cin >>N>>M;

    vector<int> a(N),b(N),c(M),d(M);
    rep(i,N) cin >> a[i]>>b[i];
    rep(i,M) cin >> c[i]>>d[i];

    rep(i,N){
        int mn=abs(a[i]-c[0])+abs(b[i]-d[0]),mm=0;
        repd(j,1,M){
            if(chmin(mn,abs(a[i]-c[j])+abs(b[i]-d[j])))mm=j;
        }
        cout<<mm+1<<endl;
    }

    return (0);
}

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

using namespace std;

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if (a+b<=n) cout<<0<<endl;
	else cout<<abs(n-(a+b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,max = 0;
    int a[100];
    for(int i=0; i<100; i++){
        a[i] = 0;
    }
    while(scanf("%d",&n)!=EOF){
        a[n]++;
    }
    for(int n=0; n<100; n++){
        if(a[n] > max){
            max = a[n];
        }
    }
    for(int n=0; n<100; n++){
        if(a[n] == max){
            printf("%d\n",n);
        }
    }
    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	int N;
	cin >> N;
	
	int M = (N + 1) / 2;
	int L = 0;
	int R = M - 1;

	cout << 0 << endl;
	string S;
	cin >> S;
	if (S == "Vacant") return 0;
	string saisho = S;

	while (L + 1 < R) {
		int H = (L + R) / 2;
		cout << H * 2 << endl;
		cin >> S;
		if (S == "Vacant") return 0;
		if (saisho == S) L = H;
		else R = H;
	}

	cout << L * 2 + 1 << endl;
	cin >> S;
	if (S != "Vacant") {
		cout << R * 2 << endl;
		cin >> S;
	}

	Would you please return 0;
}

Measured memory_bytes: 852
#include <iostream>
using namespace std;
int main()
{
    int n,r,p,c;
    int card[100],temp[100];
    
    while(cin >> n >> r,n!=0&&r!=0){
        for(int i=0;i<n;i++) card[i] = n-i;
        for(int i=0;i<r;i++){
            cin >> p >> c;
            for(int i=0;i<c;i++) temp[i] = card[p-1+i];
            for(int i=0;i<p-1;i++) temp[i+c] = card[i];
            for(int i=0;i<p+c-1;i++) card[i] = temp[i];
        }
        cout << card[0] << endl;
    }

    return(0);
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s,t; cin >> s >> t;
    cout << t+s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    for (int i = 0; i < A; i++) cin >> s[i];
    for (int i = 0; i < B; i++) cin >> t[i];
    for (int i = 0; i < Q; i++) {
        ll x;
        cin >> x;
        auto sr = lower_bound(s.begin(), s.end(), x);
        auto tr = lower_bound(t.begin(), t.end(), x);
        bool srf = sr != s.end(), trf = tr != t.end();
        bool slf = sr != s.begin(), tlf = tr != t.begin();
        auto sl = sr, tl = tr;
        if (slf) sl--;
        if (tlf) tl--;
        ll res = LLONG_MAX;
        if (srf && trf) {
            res = min(res, max(*sr, *tr) - x);
        }
        if (slf && tlf) {
            res = min(res, x - min(*sl, *tl));
        }
        if (srf && tlf) {
            res = min(res, (*sr - *tl) + min(*sr-x, x-*tl));
        }
        if (slf && trf) {
            res = min(res, (*tr - *sl) + min(*tr-x, x-*sl));
        }
        cout << res << endl;
    }
}

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

int main(){
  int r[200000];
  int N,max,i,v,min;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> r[i];
  }
   
  max=-10000000000;
  min=r[0];
  
    for(i=1;i<N;i++){
       
       v=r[i]-min;
      if(v>max) max=v;
       if(min>r[i]) min=r[i]; 
    }
  
 cout << max << endl;
  return 0;
}


Measured memory_bytes: 3896
import java.util.*;


public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean iseven = n % 2 == 0;
        for(int i = 0;i < n;i++)
            a[i] = sc.nextInt();

        int[] odd,even;
        if(n % 2 == 0) {
            odd = new int[n / 2];
            even = new int[n / 2];
        }
        else {
            odd = new int[(n+1) / 2];
            even = new int[n / 2];
        }
        if(iseven)
            for(int i = 0;i < (n / 2);i++) {
                odd[i] = a[2 * i];
                even[i] = a[2 * i + 1];
            }
        else {
            for (int i = 0; i < (n - 1) / 2; i++) {
                odd[i] = a[2 * i];
                even[i] = a[2 * i + 1];
            }
            odd[odd.length - 1] = a[a.length - 1];
        }
        if(iseven)
        {
            System.out.print(even[even.length - 1]);
            for(int i = even.length - 2;i >= 0; i--)
                System.out.print(" " + even[i]);
            for(int i = 0;i < odd.length;i++)
                System.out.print(" " + odd[i]);
        }
        else
        {
            System.out.print(odd[odd.length - 1]);
            for(int i = odd.length - 2;i >= 0; i--)
                System.out.print(" " + odd[i]);
            for(int i = 0;i < even.length;i++)
                System.out.print(" " + even[i]);
        }

    }

}


Measured memory_bytes: 88816
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - League
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

typedef queue<int> qi;

/* global variables */

int as[MAX_N][MAX_N], cs[MAX_N], ds[MAX_N];
bool wts[MAX_N][MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int m = n - 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &as[i][j]), as[i][j]--;

  int wn = 0, maxd = 0;
  qi q;
  for (int i = 0; i < n; i++) q.push(i);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int v = as[u][cs[u]];

    if (! wts[u][v])
      wts[v][u] = true, wn++;
    else {
      int d = max(ds[u], ds[v]) + 1;
      ds[u] = ds[v] = d;
      if (maxd < d) maxd = d;

      wn--;
      if (++cs[u] < m) q.push(u);
      if (++cs[v] < m) q.push(v);
    }
  }

  printf("%d\n", (wn > 0) ? -1 : maxd);
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 2000000000
#define INFLL 9000000000000000000
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61 z 0x7a

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if (n == 1) {
        cout << (a == b ? 1 : 0) << endl;
        return 0;
    }

    if (a > b) {
        cout << 0 << endl;
        return 0;
    }

    ll min = a * (n - 1) + b;
    ll max = b * (n - 1) + a;
    ll k = max - min + 1;

    cout << k << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a; 
	cin>>a;
	cout<<fixed<<setprecision(20)<<double(2*3.14*a);
	
	return 0;	
}

Measured memory_bytes: 3804