akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 1, n) cin >> h[i];
    int ans = 1;
    int high = h[1];
    rep(i, 2, n) {
        if (high <= h[i]) {
            ans++;
            high = h[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> vec(100);
  std::iota(vec.begin(), vec.end(), 1);
  rep(i, 100) {
    if (A % vec[i] == 0 && B % vec[i] == 0) {
    } else {
      vec[i] = 0;
    }
  }
  int cnt {};
  drep(i, 100) {
    cnt = i;
    if (vec[i] != 0) --K;
    if (K == 0) break;
  }
  cout << vec[cnt] << '\n';
}


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

int main() {

  int input;

  vector<int> ans;

  for ( int i = 0; i < 5; i++ ) {

    cin >> input;
    ans.push_back(input);

  }

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

  for ( int i = 0; i < 5; i++ ) {
    if ( i != 0 ) cout << " ";
    cout << ans[i];
  }

  cout << endl;

  return 0;

}

Measured memory_bytes: 1216
unittest
{
	assert( [ "2", "1 1", "2 2" ].parse.expand.solve == 1 );
	assert( [ "3", "1 4", "4 6", "7 8" ].parse.expand.solve == 1 );
	assert( [ "4", "1 1", "1 2", "2 1", "2 2" ].parse.expand.solve == 2 );
	
	assert( [ "5", "1 5", "3 4", "5 3", "7 2", "2 1" ].parse.expand.solve == 2 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xys = new long[ 2 ][ n ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
	}
	return tuple( xys );
}

auto solve( long[ 2 ][] xys )
{
	xys.sort();
	
	// ペアの増分を計算
	long[ long[ 2 ] ] ds;
	foreach( i, xy_a; xys )
	{
		foreach( xy_b; xys[ i + 1 .. $ ] )
		{
			ds[ [ xy_b[ 0 ] - xy_a[ 0 ], xy_b[ 1 ] - xy_a[ 1 ] ] ]++;
		}
	}
	
	// 一番多かったペアの増分を検索
	auto pq  = [ 0L, 0L ];
	auto pqc = 0L;
	foreach( d, c; ds )
	{
		if( c <= pqc ) continue;
		pq[] = d;
		pqc = c;
	}
	
	// コストを計算
	auto uft = UnionFind( xys.length );
	foreach( i, xy_a; xys )
	{
		foreach( j, xy_b; xys[ i + 1 .. $ ].enumerate( i + 1 ) )
		{
			if( ( xy_a[ 0 ] - pq[ 0 ] == xy_b[ 0 ] && xy_a[ 1 ] - pq[ 1 ] == xy_b[ 1 ] ) ||
			    ( xy_a[ 0 ] + pq[ 0 ] == xy_b[ 0 ] && xy_a[ 1 ] + pq[ 1 ] == xy_b[ 1 ] ) )
			{
				uft.unite( i, j );
			}
		}
	}
	return uft.rootnum;
}

// UnionFind木
struct UnionFind
{
	private long   num;
	private long[] ps;
	
	public this( long n )
	{
		num = n;
		ps = new long[]( n );
		ps[] = -1;
	}
	
	public long root( long x )
	{
		return ( ps[ x ] < 0 ) ? x : ( ps[ x ] = root( ps[ x ] ) );
	}
	
	public bool same( long x, long y )
	{
		return root( x ) == root( y );
	}
	
	public void unite( long x, long y )
	{
		x = root( x );
		y = root( y );
		if( x == y ) return;
		if( ps[ x ] < ps[ y ] ){ ps[ x ] += ps[ y ]; ps[ y ] = x; }
		else                   { ps[ y ] += ps[ x ]; ps[ x ] = y; }
		num--;
	}
	
	public long rootnum()
	{
		return num;
	}
}


Measured memory_bytes: 380
#include <iostream>
using namespace std;
 
int main(){
  int n,l;
  cin >> n >> l;
  int min,max;
  int ans;
  min=l;
  max=l+n-1;
  if(max*min <= 0){
    cout << (min+max)*n/2 << endl;
  }
  else{
    if (max < 0) cout << (min+max)*n/2-max << endl;
    if (min > 0) cout << (min+max)*n/2-min << endl;
  }
  return 0;
}

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

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int a;
    long double b;
    
    a=read();
    cin>>b;
    
    cout<<(int)((double)a*b)<<endl;
	
	return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    string s, ans = "";
    cin >> s;
    for(auto i : s){
        if(i == '0') ans += '0';
        else if(i == '1') ans += '1';
        else if(i == 'B' && ans.size() == 0) continue;
        else ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  long long n, total;
  vector<long long> v;
  total = 0;
  cin >> n;
  int prev1 = 0;
  int prev2;
  for (int i=0;i<=n;i++) {
    int curr;
    if (i<n) {
      cin >> curr;
    } else {
      curr = 0;
    }
    if (i>0) {
      if ((prev2 <= prev1 && prev1 <= curr) || (curr <= prev1 && prev1 <= prev2)) {
	v.push_back(0);
      } else {
	v.push_back(abs(prev2 - prev1) + abs(prev1 - curr) -abs(abs(prev2 - prev1) - abs(prev1 - curr)));
      }
    }
    total += abs(prev1 - curr);
    prev2 = prev1;
    prev1 = curr;
  }
  for (auto it = v.begin();it != v.end();it++) {
    cout << total - *it << endl;
  }
  return(0);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <cmath> 
using namespace std;

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

    if(b-a+1>2*k){
        for(int i=0;i<k;i++){
            cout<<a+i<<endl;
        }
        for(int i=k-1;i>=0;i--){
            cout<<b-i<<endl;
        }
    }
    else {
        for(int i=a;i<=b;i++)cout<<i<<endl;
    }
}

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

const  long double PI=(acos(-1));

const  long double EPS=0.0000000001;



int main(){
    long double a , b ,x;
    long double ret;

    cin >> a >> b >> x;

    double s = x/a;

    if(s >= a*b/2){
        double h = 2*(a*b - s)/a;
        ret = atan2(h,a);
    }
    else{
        double w = 2*s/b;
        ret = atan2(b,w);
    }

    cout  << fixed << setprecision(10) << ret /PI * 180<< endl;

    return 0;
}

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

typedef long long ll;
#define int ll

using namespace std;

const int N=210;

string s[N];
int dist[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>s[i];
    int ans=-1;
    for(int ft=0;ft<n;ft++)
    {
        memset(dist,255,sizeof(dist));
        dist[ft]=0;
        queue<int> q;
        q.push(ft);
        while(!q.empty())
        {
            int v=q.front();
            q.pop();
            for(int to=0;to<n;to++)
                if(s[v][to]=='1'&&dist[to]==-1)
                {
                    dist[to]=dist[v]+1;
                    q.push(to);
                }
        }
        bool ok=true;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(s[i][j]=='1'&&abs(dist[i]-dist[j])!=1)
                    ok=false;
        if(ok)
            ans=max(ans,*max_element(dist,dist+n)+1);
    }
    cout<<ans;
}


Measured memory_bytes: 384
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
arr = arr_data[1]

arr1=[]
for i in range(n-1,-1,-2):
    arr1.append(arr[i])
    
sposi=0 if n % 2==0 else 1

for j in range(sposi,n,2):
    arr1.append(arr[j])

print(" ".join(arr1))


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

signed main(){

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

    int n, m; cin >> n >> m;
    vector<int> hit(n);
    rep(i,n) cin >> hit[i];
    vector<set<int>> con(n);
    rep(i,n){
        con[i].insert(-1);
    }

    
    int a, b;
    rep(i,m){
        cin >> a >> b;
        con[a-1].insert(b);
        con[b-1].insert(a);
    }
  
    int cnt = 0;
    rep(i,n){
        bool ok = true;
        if (con[i].size() == 1){
            cnt ++;
            continue;
        }
        
        for (auto itr = con[i].begin(); itr != con[i].end(); itr++){
            if (*itr == -1) continue;
            if (hit[i] <= hit[*itr - 1]){
                ok = false;
                break;
            }
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
	int n;
	while (cin >> n, n) {
		int a, ans = 0;
		for (int i = 0; i < n / 4; i++) {
			cin >> a;
			ans += a;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t ans=0;
  int64_t two=1;
  for(int i=0;i<60;i++){
    int64_t cnt0=0,cnt1=0;
    for(int j=0;j<N;j++){
      if(A[j]>>i&1){cnt1++;}
      else{cnt0++;}
    }
    int64_t a=(cnt1*cnt0)%1000000007*two;
    ans=(ans+a)%1000000007;
    two=two*2%1000000007;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5508
import bisect

"""
def wantp(n):

    wq = []
    while p[n] != n:
        wq.append(n)
        n = p[n]

    for i in wq:
        p[i] = n

    return n
"""


N = int(input())

B = list(map(int,input().split()))
B.sort()

A = []
AS = []
for i in range(N):
    if len(A) == 0:
        A.append(B[0])
        AS.append(1)
    else:
        if A[-1] == B[i]:
            AS[-1] += 1
        else:
            A.append(B[i])
            AS.append(1)


"""
p = [i for i in range(N)]
rank = [1] * N
"""
ans = 0

for i in range(len(A)):

    i = len(A) - 1 - i
    now = 2 ** 33

    while A[i] * 2 < now:
        now //= 2

    ind = bisect.bisect_left(A,now-A[i])

    if A[ind] + A[i] == now:

        if ind == i:
            ans += AS[i] // 2
            AS[i] = AS[i] % 2

        else:
            ans += min(AS[i],AS[ind])
            AS[ind] = max(AS[ind] - AS[i] , 0)



    #print (now,na,ind)

print (ans)
        


Measured memory_bytes: 25876
#include <cstdio>
#include <cstdlib>

const int MAXN=100011, MAXV=MAXN<<1, MAXE=MAXV<<1;

int abs(int a){
	return (a>0)?a:(-a);
}

int fu(int a){
	return (a<0)?(-1):1;
}

int N;
int A[MAXN], B[MAXN];
int Ad[MAXN], Bd[MAXN];
int Ar, Br;
int Se[MAXN], Deg[MAXN];

struct Vert{
	int FE;
} V[MAXV];

int Vcnt;
int Av[MAXN], Bv[MAXN], Sour;

struct Edge{
	int y, id, next;
} E[MAXE<<1];

int Ecnt, Ec;
int Vis[MAXE];

void addE(int a, int b){
	++Ec;
	++Ecnt;
	E[Ecnt].y=b;E[Ecnt].id=+Ec;E[Ecnt].next=V[a].FE;V[a].FE=Ecnt;
	++Ecnt;
	E[Ecnt].y=a;E[Ecnt].id=-Ec;E[Ecnt].next=V[b].FE;V[b].FE=Ecnt;
}

void DFS(int at){
	for(int k=V[at].FE;k;k=V[at].FE){
		while(Vis[abs(E[k].id)])	k=E[k].next;
		V[at].FE=k;
		if(k){
			Vis[abs(E[k].id)]=fu(E[k].id);
			DFS(E[k].y);
		}
	}
}

void Show(bool i){
	if(i)	puts("POSSIBLE");
	else	puts("IMPOSSIBLE");
}

void Test_Deg(){
	bool ret=true;
	for(int i=1;i<=N;++i)	ret&=((Ad[i]&1)==(Bd[i]&1));
	if(!ret){
		Show(false);
		exit(0);
	}
}

void Test_Eu(){
	bool ret=true;
	for(int i=1;i<=Ec;++i)
		ret&=(Vis[i]!=0);
	if(!ret){
		Show(false);
		exit(0);
	}
}

int main(){
	
	scanf("%d", &N);
	for(int i=1;i<=N;++i)	scanf("%d", &A[i]);
	for(int i=1;i<=N;++i)	scanf("%d", &B[i]);
	
	for(int i=1;i<=N;++i){
		if(A[i]==-1)	{Ar=i;++Ad[i];}
		else	{++Ad[i];++Ad[A[i]];}
		if(B[i]==-1)	{Br=i;++Bd[i];}
		else	{++Bd[i];++Bd[B[i]];}
	}
	
	Test_Deg();
	
	for(int i=1;i<=N;++i)	Deg[i]=Ad[i]&Bd[i]&1;
	
	Sour=++Vcnt;
	for(int i=1;i<=N;++i)
		{Av[i]=++Vcnt;Bv[i]=++Vcnt;}
	
	addE(Av[Ar], Bv[Br]);
	for(int i=1;i<=N;++i){
		if(A[i]!=-1)	addE(Av[i], Av[A[i]]);
		if(B[i]!=-1)	addE(Bv[i], Bv[B[i]]);
		if(Deg[i])	{addE(Av[i], Bv[i]);Se[i]=Ec;}
	}
	
	DFS(Vcnt);
	
	Test_Eu();
	
	Show(true);
	for(int i=1;i<=N;++i){
		if(!Se[i])	printf("0 ");
		else	printf("%d ", Vis[Se[i]]);
	}
	
	return 0;
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 105;
const int K = 1e5 + 5;

ll n, k, a[N], dp[K], pre[K];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    
    cin >> n >> k;

    for (int i = 0; i < n; ++i)
        cin >> a[i];

    fill(pre, pre + K, 1);
    for (int i = 0; i < n; ++i) {
        for (int j = k; j >= 0; --j) 
            dp[j] = (pre[j] - (j - a[i] - 1 >= 0 ? pre[j - a[i] - 1] : 0)) % MOD;

        pre[0] = dp[0];
        for (int j = 1; j <= k; ++j) 
            pre[j] = (pre[j - 1] + dp[j]) % MOD;
    }

    cout << (dp[k] + MOD) % MOD << endl;
}

Measured memory_bytes: 1792
N,A,B,C,D = map(int,input().split())
x = B-A
flag = 0
for i in range(1,N+1):
    if -(N-i)*D+(i-1)*C<=x<=-(N-i)*C+(i-1)*D:
        flag = 1
        break
if flag==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38896
#include <cstdio>
int map[4][4];
int sum;
int main ()
{
    scanf ("%d%d%d",&map[1][1],&map[1][2],&map[2][2]);
    for (int i=1;i<=101;i++)
    {
        map[3][3]=i;
        sum=map[1][1]+map[2][2]+i;
        map[1][3]=sum-map[1][1]-map[1][2];
        map[3][1]=sum-map[1][3]-map[2][2];
        map[2][1]=sum-map[1][1]-map[3][1];
        if (map[1][3]+map[3][3]==map[2][2]+map[2][1])
        {
            map[2][3]=sum-map[1][3]-map[3][3];
            if (map[1][2]+map[2][2]==map[3][1]+map[3][3])
            {
                map[3][2]=sum-map[1][2]-map[2][2];
                for (int j=1;j<=3;j++)
                    printf ("%d %d %d\n",map[j][1],map[j][2],map[j][3]);
                return 0;	
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

n = int(raw_input())
R_List = []
Max = 0
R_min = 0
for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i])
print Max

Measured memory_bytes: 18948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    vector<ll> acc_a(n + 1);
    vector<ll> acc_b(m + 1);
    for (int i = 0; i < n; i++)
    {
        acc_a[i + 1] = acc_a[i] + a[i];
    }
    for (int i = 0; i < m; i++)
    {
        acc_b[i + 1] = acc_b[i] + b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n + 1; i++)
    {
        ll remain = k - acc_a[i];
        if (remain < 0)
            continue;

        auto iter = upper_bound(acc_b.begin(), acc_b.end(), remain);
        ll index = distance(acc_b.begin(), iter);
        ll books = i + index - 1;
        ans = max(ans, books);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9596
nn, aa, bb = gets.chomp.split(" ").map(&:to_i)
$ONE = '1'.freeze
$BIGMOD = (10**9) + 7
def nCk(n,k)
  a=1
  b=1
  k.times do |i|
    b *= i + 1
    b %= $BIGMOD
  end
  k.times do |i|
    j = i + 1
    a *= n - i
    a %= $BIGMOD
  end
  a * inv(b) % $BIGMOD
end

def nPk(n,k)
	return fact(n) / fact(n-k) % $BIGMOD
end

def fact(n)
  (1..n).inject(1) { |r, i| (r * i) % $BIGMOD }
end

def inv(n)
  PowPow(n, $BIGMOD - 2) % $BIGMOD
end

def PowPow(x, n)
  return 1 if n == 0
	return PowPow(x**2  % $BIGMOD, n / 2) if n.even?
  return PowPow(x, n-1) * x  % $BIGMOD 
end



ngo = PowPow(2, nn) - 1
ngo -= nCk(nn, aa)
ngo -= nCk(nn, bb)
puts ngo % $BIGMOD


Measured memory_bytes: 1788
a1,b1 = map(str, raw_input().split())
a2,b2 = map(str, raw_input().split())
a3,b3 = map(str, raw_input().split())

l = [a1,a2,a3,b1,b2,b3]

if l.count('1')>2 or l.count('2')>2 or l.count('3')>2 or l.count('4')>2:
	print "NO"
else:
	print "YES"

Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  #define int ll
  ll n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  
  
  if(n >= k){
    int now = 0;
    rep(i,k)now = a[now] - 1;
    print(now+1);
    return 0;
  }

  
  int visited[(int)1e6];
  rep(i,1e6)visited[i] = 0;

  int now = 0;
  while(k--){
    static int tmp = 0;
    now = a[now] - 1;
    if(visited[now])break;
    visited[now] = ++tmp;
  }

  ll cnt = 0;
  int next = now;
  while(true){
    cnt++;
    next = a[next] - 1;
    if(next == now)break;
  }
  ll loop = k % cnt;
  while(loop--){
    next = a[next] - 1;
  }
  print(next+1);
  return 0;
}


Measured memory_bytes: 12736
use v5.18;

chomp (my $n = <STDIN>);
my %h;
for my $i (0..$n-1) {
  my $s = <STDIN>;
  my $t = substr($s, 0, 1);
  $h{$t}++;
}
my $ans = 0;
$ans += $h{'M'} * $h{'A'} * $h{'R'};
$ans += $h{'M'} * $h{'A'} * $h{'C'};
$ans += $h{'M'} * $h{'A'} * $h{'H'};
$ans += $h{'M'} * $h{'R'} * $h{'C'};
$ans += $h{'M'} * $h{'R'} * $h{'H'};
$ans += $h{'M'} * $h{'C'} * $h{'H'};
$ans += $h{'A'} * $h{'R'} * $h{'C'};
$ans += $h{'A'} * $h{'R'} * $h{'H'};
$ans += $h{'A'} * $h{'C'} * $h{'H'};
$ans += $h{'R'} * $h{'C'} * $h{'H'};
say $ans;

Measured memory_bytes: 512
unittest
{

assert( q"INPUT
3 3
..#
#..
...
INPUT".split( '\n' ).parse.expand.solve == 2 );

assert( q"INPUT
10 37
.....................................
...#...####...####..###...###...###..
..#.#..#...#.##....#...#.#...#.#...#.
..#.#..#...#.#.....#...#.#...#.#...#.
.#...#.#..##.#.....#...#.#.###.#.###.
.#####.####..#.....#...#..##....##...
.#...#.#...#.#.....#...#.#...#.#...#.
.#...#.#...#.##....#...#.#...#.#...#.
.#...#.####...####..###...###...###..
.....................................
INPUT".split( '\n' ).parse.expand.solve == 209 );

assert( q"INPUT
3 5
.#...
.#.#.
...#.
INPUT".split( '\n' ).parse.expand.solve == 0 );		// 追加ケース

assert( q"INPUT
3 3
...
###
...
INPUT".split( '\n' ).parse.expand.solve == -1 );		// 追加ケース

}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto sss = new string[ hw[ 0 ] ];
	foreach( ref ss; sss )
	{
		input.popFront;
		ss = input.front;
	}
	return tuple( sss );
}

auto solve( string[] sss )
{
	// 最短距離を計算
	auto dss = sss.bfs2d( 0, 0 );
	if( dss[ $ - 1 ][ $ - 1 ] == long.max ) return -1;
	
	// スタート地点と最短距離分のマス以外を全て黒で塗りつぶす（ルートは気にしなくてよい）
	auto ans = -1 - dss[ $ - 1 ][ $ - 1 ];
	foreach( ss; sss )
	{
		foreach( s; ss )
		{
			ans += ( s == '.' );
		}
	}
	return ans;
}

// 2Dマップの始点指定最短経路探索（幅優先探索）
auto bfs2d( dchar w = '#' )( string[] css, long sy, long sx )
{
	import std.container.dlist;
	
	auto dss = new long[][]( css.length, css[ 0 ].length );
	foreach( ref ds; dss ) ds[] = long.max;
	dss[ sy ][ sx ] = 0;
	auto queue = make!DList( tuple( sy, sx ) );
	while( !queue.empty )
	{
		auto fy = queue.front[ 0 ];
		auto fx = queue.front[ 1 ];
		queue.removeFront();
		
		auto d = dss[ fy ][ fx ] + 1;
		foreach( f; [ tuple( fy - 1, fx ), tuple( fy + 1, fx ), tuple( fy, fx - 1 ), tuple( fy, fx + 1 ) ] )
		{
			if( f[ 0 ] < 0 || css.length      <= f[ 0 ] ||
			    f[ 1 ] < 0 || css[ 0 ].length <= f[ 1 ] ||
			    css[ f[ 0 ] ][ f[ 1 ] ] == w ||
			    dss[ f[ 0 ] ][ f[ 1 ] ] < long.max ) continue;
			dss[ f[ 0 ] ][ f[ 1 ] ] = d;
			queue.insertBack( f );
		}
	}
	return dss;
}


Measured memory_bytes: 380
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

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

	cout << max(A + B, max(A - B, A * B)) << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 9 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    ivv(t);
    lv(ans);
    rep(t-1){
        lv(temp);
        ans = __gcd(temp , ans);
    }
    cout<<ans<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
	char ymd[12]={};
    int i, y=0, m=0, d=0;
	scanf("%s", ymd);
  	
	for(i=0;i<4;i++){
	    y=y*10;
		y+= (int)ymd[i]-'0';
    }
    
    for(i=0;i<2;i++){
    	d=d*10;
  		m=m*10;
  		m+= (int)ymd[5+i]-'0';
  		d+= (int)ymd[8+i]-'0';
    }
    
 
  	if(y>2019){
      printf("TBD");
    }else if(y=2019&&m>4){
      printf("TBD");
    }else{
    printf("Heisei");
    }
}

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

int main() {
    int n,m,c; cin >> n >> m >> c;
    vector<int> b(m,0);
    rep(i,m) cin >> b.at(i);

    vector<vector<int>> a(n, vector<int>(m,0));
    rep(i,n) rep(j,m) cin >> a.at(i).at(j);

    int cnt = 0;
    for(int i=0; i<n; i++){
        int sum = c;
        for(int j=0; j<m; j++){
            sum += a.at(i).at(j) * b.at(j);
        }
        if(sum > 0) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
using i64 = long long;

int n, m, q;
std::vector<std::tuple<int, int, int, int>> v;
std::vector<int> w;

int dfs() {
    if (w.size() == n) {
        int ret = 0;
        for (const auto [a, b, c, d] : v) {
            if (w[b] - w[a] == c) ret += d;
        }
        return ret;
    }

    const int last = w.empty() ? 1 : w.back();
    int ret = 0;
    for (int i = last; i <= m; i++) {
        w.push_back(i);
        const int r = dfs();
        if (r > ret) ret = r;
        w.pop_back();
    }

    return ret;
}

int main() {
    std::cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        std::cin >> a >> b >> c >> d;
        v.emplace_back(a - 1, b - 1, c, d);
    }

    std::cout << dfs() << std::endl;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        
        if(a >= b){
          for(int i = 1;i <= a;i++){
            System.out.print(b);
          }
        }else{
          for(int i = 1;i <= b;i++){
            System.out.print(a);
          }
        }
	}
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(void)
{
  int A, B, C, D;
  long long S1, S2;
  
  scanf("%d %d %d %d", &A, &B, &C, &D );
  
  S1 = A*B;
  S2 = C*D;
  
  if( S1 < S2 ) printf("%lld\n", S2);
  else{         printf("%lld\n", S1);}
  
  
  
  return 0;
}       

Measured memory_bytes: 128
// 2014/09/24 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		string s;
		cin >> s;

		if(cin.eof())
			break;

		for(int i=0; i<s.size(); i++){
			if(s[i]==','){
				s[i] = ' ';
			}
		}

		istringstream is(s);
		double x1, y1, x2, y2, xq, yq;
		is >> x1 >> y1 >> x2 >> y2 >> xq >> yq;

//		cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << xq << ' ' << yq << endl;

		double a = y2-y1;
		double b = x1-x2;
		double c = x2*y1-x1*y2;

		double abc = a*xq+b*yq+c;
		double a2b2 = a*a+b*b;

		double xr = xq-(2.0*a*abc/a2b2);
		double yr = yq-(2.0*b*abc/a2b2);

		cout.precision(6);
		cout << fixed << xr << ' ' << fixed << yr << endl;
	}

	return 0;
}

Measured memory_bytes: 1304
#include<stdio.h>
int main(void){
int a,b;
while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0){break;}
if(a>b){
printf("%d %d\n",b,a);
}else{
printf("%d %d\n",a,b);
}
}
return 0;
}

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

int intabs(int a)
{
    if (a < 0)
    {
        a = -a;
    }
    return a;
}

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    --x;
    --y;
    vector<int> c(n - 1, 0);
    rep(i, n)
    {
        rep(j, n)
        {
            if (i == j)
                continue;
            // int idx = 1;
            int idx = intabs(i - j);
            if (idx > intabs(x - i) + 1 + intabs(y - j))
            {
                idx = intabs(x - i) + 1 + intabs(y - j);
            }
            if (idx > intabs(y - i) + 1 + intabs(x - j))
            {
                idx = intabs(y - i) + 1 + intabs(x - j);
            }

            --idx;
            ++c.at(idx);
        }
    }
    rep(i, n - 1)
    {
        printf("%d\n", c.at(i) / 2);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<int> Xs(N); for (auto &xi : Xs) cin >> xi;
    int ans = 1000000;
    // O(100N)<O(10^4)
    for (int p = 1; p <= 100; ++p)
    {
        int tmp = 0;
        for (int i = 0; i < N; ++i)
        {
            tmp += (Xs[i] - p) * (Xs[i] - p);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

int main(){
	int s,w;cin>>s>>w;
	if(s<=w)puts("unsafe");
	else puts("safe");
}

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

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for (int i = 0, N = s.size(); i < N; i++) {
    sum += (int)s[i] - '0';
  }
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3756
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(K[int(input())-1])

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
long koyaku(long a,long b);

int main(){
	long c,d,e;
	unsigned long f;
	while(cin>>c>>d){
		e=koyaku(c,d);
		f=c/e*d;
		cout<<e<<" "<<f<<endl;
	}
	return 0;
}

long koyaku(long a,long b){
	long r=1;
	while(1){
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int n,m,c,ans=0;
    cin >> n >> m >> c;

    VI b(m);
    for(int i=0; i<m ; ++i)cin >> b[i];

    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];
        }
    }
    
    for(int i=0; i<n ; ++i){
        int tmp = 0;
        for(int j=0; j<m ;++j){
            tmp += a[i][j]*b[j];
        }
        if(tmp + c > 0)ans++;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 1 << 29;
 
int N, Ma, Mb, A[40], B[40], C[40];
 
void dfs(int idx, int x, int y, int z, int end, vector< pair< pair< int, int >, int > > &odd)
{
  if(idx == end) {
    odd.emplace_back(make_pair(x, y), z);
  } else {
    dfs(idx + 1, x + A[idx], y + B[idx], z + C[idx], end, odd);
    dfs(idx + 1, x, y, z, end, odd);
  }
}
 
int main()
{
  cin >> N >> Ma >> Mb;
 
  vector< pair< int, int > > range;
  vector< pair< pair< int, int >, int > > a, b;
  for(int i = 1; i <= 400; i++) {
    int low = i * Mb;
    if(low % Ma != 0) continue;
    if(low / Ma > 400) continue;
    range.emplace_back(i, low / Ma);
  }
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  dfs(0, 0, 0, 0, N / 2, a);
  dfs(N / 2, 0, 0, 0, N, b);
 
 
  int call1[401][401], call2[401][401];
  fill_n(*call1, 401 * 401, INF);
  fill_n(*call2, 401 * 401, INF);
  call1[0][0] = 0;
  call2[0][0] = 0;
  for(auto &s : a) {
    auto &q = s.first;
    call1[q.first][q.second] = min(call1[q.first][q.second], s.second);
  }
  int ret = INF;
  for(auto &s : b) {
    auto &q = s.first;
    call2[q.first][q.second] = min(call2[q.first][q.second], s.second);
  }
 
  for(auto &s : range) {
    int sumA = s.first;
    int sumB = s.second;
    for(int j = 0; j <= sumA; j++) {
      for(int k = 0; k <= sumB; k++) {
        ret = min(ret, call1[j][k] + call2[sumA - j][sumB - k]);
      }
    }
  }
  if(ret == INF) cout << -1 << endl;
  else cout << ret << endl;
}


Measured memory_bytes: 32620
using System;

namespace _0134
{
    class Program
    {
        static void Main(string[] args)
        {
            int j = int.Parse(Console.ReadLine());
            long n = 0;
            for (int i = 0; i < j; i++)
            {
                n += int.Parse(Console.ReadLine());
            }
            Console.WriteLine(n / j);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9200
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	int n, k, c = 1;
	string s;
	cin >> n >> k >> s;
	s.push_back('2');
	deque<int> l;
	if (s[0] == '1')l.push_back(0);
	rep(i, 0, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			c++;
		}
		else {
			l.push_back(c);
			c = 1;
		}
	}
	int sum = 0, ans = 0;
	l.push_front(0);
	l.push_back(0);
	l.push_back(0);
	rep(i, 0, min(2 * k + 1, (int)l.size())) {
		sum += l[i];
	}
	ans = sum;
	for (int i = 2; i + 2 * k < (int)l.size() - 1; i += 2) {
		sum += l[i + 2 * k] + l[i + 2 * k - 1] - l[i - 1] - l[i - 2];
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 768
while line = STDIN.gets
	
	ioi = 0;
	joi = 0;
	c = 0;

	while c = line.index("JOI", c)
		if(c.nil?)
			break
		else
			joi+=1
			c+=2
		end
	end	
	
	c = 0;
	
	while c = line.index("IOI", c)
		if(c.nil?)
			break
		else
			ioi+=1
			c+=2
		end
	end
		
	p joi
	p ioi
end

Measured memory_bytes: 2256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;

  vector<long long> x(N);
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
    a[i] = abs(x[i]);
  }

  long long ret = 1000000000000;
  // right to left
  vector<long long>::iterator iter = lower_bound(x.begin(), x.end(), 1);
  int start = distance(x.begin(), iter);
  for (int i = start; i < N; ++i) {
    if (i + 1 - start == K)
      ret = min(ret, x[i]);
    else if (i + 1 >= K)
      ret = min(ret, 2 * x[i] + abs(x[start - (K - (i - start)) + 1]));
  }
  // left to right
  for (int i = start - 1; i >= 0; --i) {
    if (start - i == K)
      ret = min(ret, -x[i]);
    else if (N - i >= K)
      ret = min(ret, -2 * x[i] + x[start + (K - (start - i)) - 1]);
  }

  cout << ret << endl;

  return 0;
}

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

int main() {

    int n, m, c;

    cin >> n >> m >> c;

    vector<int> B(m);
    vector< vector<int> > A;

    A.resize(n);

    for(int i = 0; i < m; i++) {
        cin >> B.at(i);
    }

    for(int i = 0; i < n; i++) {
        A[i].resize(m);
        for(int j = 0; j < m; j++)
            cin >> A[i][j];
    }

    int count = 0;
    for(int i = 0; i < n; i++) {
        int sum = c;
        for(int j = 0; j < m; j++) {    
            sum += A[i][j] * B.at(j);
            // cout << A[i][j] * B.at(j) << endl;
        }
        
        if(sum > 0) count++;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 1e5 + 2;
const int M = 1e3 + 5;
const int Mod = 1e9 + 7;

ll a, b, n;

ll f(ll x)
{
	return a * x / b - a * (x / b);
}

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

Measured memory_bytes: 3608
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	if (N % 2 === 0) console.log(Math.floor(N / 2 - 1))
	else console.log(Math.floor(N / 2))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, k = map(int, input().split())
MOD = 10 ** 9 + 7

max_empty = min(n - 1, k)
comb = Combination(10 ** 6, MOD)
ans = 0
for i in range(0, max_empty + 1):
    box = n - i
    ball = n
    ans += comb.combination(ball - 1, box - 1) * comb.combination(n, box)
    ans %= MOD
print(ans)

Measured memory_bytes: 115568
n=int(input())
a=list(map(int, input().split()))
even_num=[0]*n

for i in range(n):
    cnt=0
    if a[i]%2==0:
        while a[i]%2==0:
            a[i]=a[i]/2
            cnt+=1

    even_num[i]=cnt

ans=sum(even_num)
print(ans)

Measured memory_bytes: 4148
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int n, k, h[100010], memo[100010];

int dp(int pos) {
	int ret;
	if (pos == n)
		return 0;
	if (memo[pos] != -1)
		return memo[pos];
	ret = dp(pos + 1) + abs(h[pos + 1] - h[pos]);
	for (int j = 2; j <= k; j++) {
		if (pos + j > n)
			break;
		ret = min(ret, dp(pos + j) + abs(h[pos + j] - h[pos]));
	}
	memo[pos] = ret;
	return ret;
}

int main() {
	int ans;
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	memset(memo, -1, sizeof memo);
	ans = dp(1);
	printf("%d\n", ans);
	return 0;
}

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

signed main(){
	int N,T; cin>>N>>T;
	int ans=0;
	int tmp1,tmp2; cin>>tmp1;
	for(int i=0;i<N-1;i++){
		cin>>tmp2;
		ans+=min(tmp2-tmp1,T);
		tmp1=tmp2;
	}
	ans+=T;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val map = mutableMapOf<Char, Long>()
    map['M'] = 0
    map['A'] = 0
    map['R'] = 0
    map['C'] = 0
    map['H'] = 0
    for (i in 0 until N) {
        val c = readLine()!![0]
        if (map.containsKey(c)) {
            map[c] = map[c]!! + 1
        }
    }
    val counter = map.values.toList()
    var sol: Long = 0
    for (i in 0 until 5) {
        for (j in i+1 until 5) {
            for (k in j+1 until 5) {
                sol += counter[i] * counter[j] * counter[k]
            }
        }
    }
    println(sol)
}

Measured memory_bytes: 37512
import java.util.Scanner;

public class Main {	
	public static void main(String[]args){
		Scanner scan =new Scanner(System.in);
			int a =scan.nextInt();
			int b =scan.nextInt();
			int c =scan.nextInt();
			
			int cnt =0;
			for(int i =a; i <=b;i++){
				if(c%i==0){
					cnt++;
				}
				
			}
			System.out.println(cnt);				
			}
	}

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

c, d, e = [],[],[]

for i in range(n):
  if p[i] <= a:
    c.append(p[i])
  elif p[i] <= b:
    d.append(p[i])
  else:
    e.append(p[i])
print (min(len(c),len(d),len(e)))

Measured memory_bytes: 9188
#include <stdio.h>

void	compare(int M, int N)
{
	int		ans;

	if (N % M)
		ans = N / M + 1;
	else
		ans = N / M;
	printf("%d\n", ans);
}

int		main()
{
	int		H, W, N;
	int		r;

	r = scanf("%d\n%d\n%d\n", &H, &W, &N);
	if (r != 3)
		return (0);
	if (H > W)
		compare(H, N);
	else
		compare(W, N);
	return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int count_upper(uint64_t v, vector<uint64_t>& as, vector<uint64_t>& bs, vector<uint64_t>& cs, int x, int y, int z, int k)
{
	int count = 0;

	multiset<uint64_t> vals;
	FOR_LT(a, 0, x) {
		if (v <= as[a]) {
			count += y * z;
			continue;
		}

		FOR_LT(b, 0, y) {
			if (v <= as[a] + bs[b]) {
				count += z;
				continue;
			}

			FOR_LT(c, 0, z) {
				if (as[a] + bs[b] + cs[c] < v) break;

				count++;
				if (k < count) return count;
			}
		}
	}

	return count;
}

int main()
{
	int x, y, z, k; cin >> x >> y >> z >> k;

	vector<uint64_t> as(x);
	vector<uint64_t> bs(y);
	vector<uint64_t> cs(z);
	for (auto &a : as) {
		cin >> a;
	}
	for (auto &b : bs) {
		cin >> b;
	}
	for (auto &c : cs) {
		cin >> c;
	}

	sort(as.begin(), as.end(), greater<uint64_t>());
	sort(bs.begin(), bs.end(), greater<uint64_t>());
	sort(cs.begin(), cs.end(), greater<uint64_t>());

	uint64_t h = as.front() + bs.front() + cs.front();
	uint64_t l = as.back() + bs.back() + cs.back();
	uint64_t h_n = 1;
	uint64_t l_n = x * y * z;

	while (true) {
		if (l == h) break;
		uint64_t m = (h + l) / 2;

		int count = count_upper(m, as, bs, cs, x, y, z, k);
		if (count == k) {
			h = l = m;
		}
		else if (count < k) {
			h = max(m - 1, l);
		}
		else {
			l = m;
			if (h - l == 1) {
				h = l;
				break;
			}
		}
	}

	vector<uint64_t> vals;
	FOR_LT(a, 0, x) {
		FOR_LT(b, 0, y) {
			FOR_LT(c, 0, z) {
				if (as[a] + bs[b] + cs[c] < l) break;

				vals.push_back(as[a] + bs[b] + cs[c]);
			}
		}
	}

	sort(vals.begin(), vals.end());

	int count = 0;
	for (auto it = vals.rbegin(); it != vals.rend(); it++) {
		cout << *it << endl;
		count++;
		if (count == k) break;
	}

	return 0;
}

Measured memory_bytes: 263644
#include <bits/stdc++.h>
using namespace std;
/*
vector <int> prime(40);

class Calc
{
    int a;
    public:
        void decompositPrime(int a);
};


void Calc::decompositPrime(int n)
{
    a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            printf("%d ", a);
            prime.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    printf("%d\n", n);
    prime.push_back(n);
}

int main()
{
    int  iNum;
    Calc objCalc;
    
    cin  >> iNum;
    objCalc.decompositPrime(iNum);

    return 0;
}
*/


int main(){
    
    char a,b,c;
    
    cin >> a >> b >> c;
    
    if(b == 'R'){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;
ll N;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return pow_mod(x, y - 1) * x % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

int main()
{
	cin >> N;
	ll ans = 0;

	for (int i = 1; i <= N; i++)
	{
		if (i >= 1 && i <= 9)
		{
			ans++;
		}
		if (i >= 100 && i <= 999)
		{
			ans++;
		}
		if (i >= 10000 && i <= 99999)
		{
			ans++;
		}
	}
	cout << ans << endl;

	int www;
	cin >> www;
}

Measured memory_bytes: 256