akhauriyash/Code-Regression huggingface dataset:
import sys
S = str(input())
A = S[0]
B = S[1]
C = S[2]
D = S[3]

for i in range(2 ** 3):
    tmp = [(i >> t) & 1 for t in range(3)]
    sign = ['+' if t == 1 else '-' for t in tmp]
    string = A + sign[0] + B + sign[1] + C + sign[2] + D
    y = eval(string)
    if y == 7:
        print(string+'=7')
        sys.exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size());
#define pb push_back;
#define all(x) (x).begin(),(x).end()
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll K; cin >> K;
    string S; cin >> S;
    string a = "...";
    if(S.size() <= K){
        cout << S;
    }else{
        string m = "";
        for(int i=0; i<K; i++){
            m.push_back(S[i]);
        }
        m = m + a;
        cout << m;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 1005
using namespace std;
using LL = long long;
int X, Y, Z, K;
LL A[M], B[M], C[M];
bool check(LL x) {
    LL cnt = 0;
    REP(i,1,X) {
        int k = Z+1;
        REP(j,1,Y) {
            while (k-1>=1 && A[i]+B[j]+C[k-1]>=x) k--;
            cnt += Z+1 - k;
        }
    }
    return cnt >= K;
}
vector<LL> out_greater(LL x) {
    vector<LL> res;
    REP(i,1,X) {
        int k = Z+1;
        REP(j,1,Y) {
            while (k-1>=1 && A[i]+B[j]+C[k-1]>x) k--;
            REP(k2, k, Z) res.push_back(A[i]+B[j]+C[k2]);
        }
    }
    return res;
}
int main()
{
    while (~scanf("%d %d %d %d",&X,&Y,&Z,&K)) {
        REP(i,1,X) scanf("%lld", &A[i]);
        REP(i,1,Y) scanf("%lld", &B[i]);
        REP(i,1,Z) scanf("%lld", &C[i]);
        sort(A+1, A+X+1);
        sort(B+1, B+Y+1);
        sort(C+1, C+Z+1);

        LL ok=0, ng=10000000000LL*3 + 1, mid;
        while (abs(ok-ng) > 1) {
            mid = (ok+ng) / 2;
            if (check(mid)) ok = mid;
            else ng = mid;
        }
        //printf("ok = %lld\n", ok);

        vector<LL> ans = out_greater(ok);
        sort(ans.begin(), ans.end(), greater<LL> ());
        while ((int)ans.size() < K) ans.push_back(ok);
        for (auto i: ans) printf("%lld\n", i);
    }
    
    return 0;
}



Measured memory_bytes: 384
N,K = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(N) ]

kbit = []
k = K
for i in range(100000000):
  if (k == 0):
    break
  kbit.append( k%2 )
  k//=2
keta = len(kbit)

def chk(c):
  #print (c)
  s = 0
  for k,v in li:
    if ( (c^k)|c == c ):
      #print ( k,v,"ok" )
      s += v
  return s

ma = 0

if (K<100):
  for i in range(K+1):
  	ma = max(ma, chk(i))
else:
  ma = max(ma, chk( 0 ))
  ma = max(ma, chk( 1 ))
  ma = max(ma, chk( 2 ))
  ma = max(ma, chk( 3 ))
  ma = max(ma, chk( 4 ))
  ma = max(ma, chk( (1<<(keta-1))-1) )
  ma = max(ma, chk ( K ) )

  for i in range(keta):
    if ( kbit[keta-1-i] == 0 ):
      continue
    else:
      bit = [0]*(keta)
      for j in range(keta):
        if (i<j):
          bit[keta-1-j]=1
        elif (j<i):
          bit[keta-1-j]=kbit[keta-1-j]
        else:
          bit[keta-1-j]=0

      v = 0
      for j in range(keta):
        if (bit[j]==1):
          v += 2**(j)
      #print ( v , bit )
      ma = max(ma, chk ( v ) )
print ( ma )


Measured memory_bytes: 62220
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String S = Console.ReadLine();
        int ans = 0;
        for (int i = 0; i < S.Length / 2; i++)
            if (S[i] != S[S.Length - i - 1]) ans++;
        Console.WriteLine(ans);
        return;
    }
}

Measured memory_bytes: 25940
class obj:
    def __init__(self,w,v):
        self.w = w
        self.v = v
        self.r = v/w

x = input().split()
N = int(x[0])
M = int(x[1])
item = []
item = []
for i in range(N):
    x = input().split()
    item.append(obj(int(x[0]),int(x[1])))

maxV = 0


def getKey(x):
    return x.r


item.sort(key=getKey, reverse=True)
	
def Bound(i, C):	# object i -> n-1, capacity = C
    global item, N
    
    sw = 0
    sv = 0
    j = i
    f = 1.0
    while j < N and f == 1.0:
        wj = min(C-sw, item[j].w)
        f = float(wj)/item[j].w
        sw += f*item[j].w
        sv += f*item[j].v
        j += 1
    return sv



def dfsv4(i, sumW, sumV):
    """prning bounding, branching"""
    global maxV, item, N, M
    if i == N:
        if sumW <= M:
            maxV = max(maxV, sumV)
    else:   
        temp1 = Bound(i+1, M-sumW) + sumV
        temp2 = Bound(i,M-sumW) + sumV
        is1 = False

        if temp1 > temp2:
            is1 = True

        if is1:
            if temp1 > maxV:
                dfsv4(i+1, sumW, sumV)
            if sumW + item[i].w <= M:
                if temp2 > maxV:
                    dfsv4(i+1, sumW+item[i].w, sumV+item[i].v)
        else:
            if sumW + item[i].w <= M:
                if temp2 > maxV:
                    dfsv4(i+1, sumW+item[i].w, sumV+item[i].v)
            if temp1 > maxV:
                dfsv4(i+1, sumW, sumV)


dfsv4(0,0,0)

print(maxV)





    


Measured memory_bytes: 3188
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val result = Array.fill(26)(0)
  val head = 'a' to 'z'
  while (sc.hasNext) {
    val cAry = sc.nextLine.toLowerCase.toCharArray.filter(inAToZ)
    cAry.foreach(countUp)
  }
  for (i <- result.indices) println(s"${head(i)} : ${result(i)}")

  def inAToZ(c: Char): Boolean = c >= 'a' && c <= 'z'

  def countUp(c: Char): Unit = result(c - 'a') += 1
}

Measured memory_bytes: 45804
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> r(n);
  for(int i = 0; i < n; i++)
    r.at(i) = s.at(i) - '0';
  int a = r.at(0)*100 + r.at(1)*10 + r.at(2) - 753;
  if(a < 0)
    a *= -1;
  for(int i = 1; i < n - 2; i++){
    int b = r.at(i)*100 + r.at(i+1)*10 + r.at(i+2) - 753;
    if(b < 0)
      b *= -1;
    a = min(a, b);
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long sum = 0;
    long tmp = n;
    long i;
    while( tmp > 0 ) {
        sum += tmp % 10;
        tmp = tmp / 10;
    }

    if(n % sum == 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
 
    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ans = n // 11 * 2
if 1 <= n % 11 <= 6:
    ans += 1
elif 7 <= n % 11 <= 10:
    ans += 2
print(ans)


Measured memory_bytes: 2940
from collections import deque

def bfs(maze,visited,sy,sx,gy,gx):
    Step = ([1,0],[0,1],[-1,0],[0,-1])
    
    que = deque([[sx,sy]])
    visited[sx][sy] = 1
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in Step:
            ny,nx = y+j , x+k
            if 0 <= ny <= gy and 0 <= nx <= gx:
                if maze[ny][nx] == '.' and visited[ny][nx] == INF:
                    visited[ny][nx] = visited[y][x] + 1
                    que.append([ny,nx])


h,w = map(int,input().split())
maze = [input().strip() for _ in range(h)]

cntSharp = 0
for i in range(h):
    cntSharp += maze[i].count('.')

INF = 10**5
visited = [[INF]*w for _ in range(h)]

sx,sy = 0,0
gy,gx = h-1,w-1

minStep = bfs(maze,visited,sy,sx,gy,gx)
print(cntSharp - minStep if visited[gy][gx] != INF else -1)

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

int main() {
    
    int x, a, b;
    cin >> x >> a >> b;
    a*=-1;
    a += b;
    if (a <= 0)cout << "delicious" << endl;
    else if (a <= x)cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

struct St
{
	int a;
	int b;
	int len;

	St(int a, int b, int len) :a(a), b(b), len(len) {}

	bool operator<(const St &n) const { return len > n.len; }
};

int N;
int A[300][300];
int fix[300][300];

vector<int> connect[300];
struct DikSt
{
	int n;
	int len;
	DikSt(int n, int len) : n(n), len(len) {}
	bool operator<(const DikSt &n) const { return len > n.len; }
};
int ans[300];
int dikstra(int from, int to)
{
	REP(i, N) ans[i] = INT64_MAX;
	ans[from] = 0;
	priority_queue<DikSt> q;
	q.push(DikSt(from, 0));
	while (q.size() > 0)
	{
		DikSt st = q.top();
		q.pop();
		for (int next : connect[st.n])
		{
			int len = st.len + fix[st.n][next];
			if (ans[next] > len)
			{
				ans[next] = len;
				q.push(DikSt(next, len));
			}
		}
	}
	return ans[to];
}

signed main()
{
	cin >> N;
	REP(x, N) REP(y, N) cin >> A[x][y];

	priority_queue<St> q;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			q.push(St(i, j, A[i][j]));
		}
	}

	while(q.size() > 0)
	{
		St st = q.top();
		q.pop();

		int len = dikstra(st.a, st.b);
		if (len == INT64_MAX || len > A[st.a][st.b])
		{
			connect[st.a].push_back(st.b);
			connect[st.b].push_back(st.a);
			fix[st.a][st.b] = A[st.a][st.b];
			fix[st.b][st.a] = A[st.a][st.b];
		}
		else if (len == A[st.a][st.b])
		{
			continue;
		}
		else
		{
			cout << -1 << endl;
			return 0;
		}
	}

	int sum = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += fix[i][j];
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 2804
#include<stdio.h>
int main()
{
    int n,temp,r,c;

    scanf("%d",&n);

    temp = n;

    c=0;

    while(temp!=0)
    {
        r = temp%10;
        if(r==7)
        {
            ++c;
            break;
        }

        temp/=10;
    }

    if(c!=0)
        printf("Yes\n");

    else if(c==0)
        printf("No\n");

    return 0;


}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
vs32 color;
vs32 degree;
int idx;

s64 dfs(int x, vector<vs32>& t, vs32& c, vs32& num)
{
    s64 ret = 0;

    color[x] = GRAY;
    for (auto a : t[x])
    {
        if (color[a] != WHITE) continue;
        color[a] = GRAY;
        ret += dfs(a, t, c, num);
    }
    if (color[x] != BLACK)
    {
        color[x] = BLACK;
        num[x] = c[idx];
        ret += c[idx];
        ++idx;
    }

    return ret;
}

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

    int n;
    cin >> n;
    vector<vs32> t(n);
    degree.resize(n, 0);
    color.resize(n, WHITE);
    int a, b;
    rep (i, n - 1)
    {
        cin >> a >> b;
        --a; --b;
        t[a].push_back(b);
        t[b].push_back(a);
        ++degree[a];
        ++degree[b];
    }

    vs32 c(n);
    rep (i, n) cin >> c[i];
    sort(c.begin(), c.end());

    vs32 ans(n);
    s64 score = dfs(0, t, c, ans);

    cout << score - c[n - 1] << "\n";
    rep (i, n)
    {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  ll a,b,c,ans;
  cin >> a >> b >> c;
  ans = b/c- a/c;
  if(a%c==0)ans++;
  cout << ans;
}

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

bool fun(const pair<int,int>& p1, const pair<int,int>& p2){
  if(p1.first!=p2.first) return p1.first>p2.first;
  return p1.second>p2.second;
}

int main(){
  //freopen("input.txt","r",stdin);
  int n;
  cin >> n;
  map<pair<int,int>,int> mm;
  vector<pair<int,int> > pts;
  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    mm[make_pair(x,y)]=1;
    pts.push_back(make_pair(x, y));
  }
  sort(pts.begin(), pts.end(), fun);

  int ans = n;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      int p = pts[i].first-pts[j].first;
      int q = pts[i].second-pts[j].second;

      int temp_ans=0;
      for(int k = 0; k < n; k++){
      	if(mm.find(make_pair(pts[k].first+p, pts[k].second+q))!=mm.end()) continue;
      	temp_ans++;
      }

      ans = min(ans, temp_ans);
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=2e5+10;
const ll mod=998244353;


int main() {
  	fast;
  	ll n,flag=0,d,s=0,cnt=0;
  	cin>>n;
  	for(ll i=1;i<=n;i++)
  	{
  		if(i%3!=0 && i%5!=0 && cnt<=n)
  		{
  			cnt++;
  			s+=i;
		}
  			
	}
	
  	cout<<s;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define LL              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)

#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define ON(n,i)         (n|(1<<i))
#define OFF(n,i)        (n&(~(1<<i)))
#define CHK(n,i)        (n&(1<<i))

#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)

#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())

#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )

#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)

using namespace std;
#define lim 200009

LL x[lim],sum[lim],n;
LL BS( LL pos ){
    LL l = pos, r = n;
    LL ret = pos;
    while(l<=r){
        LL m = (l+r)/2;
        if( (x[m]^x[pos-1]) == sum[m]-sum[pos-1] ){
            ret = m;
            l = m + 1;
        }
        else r = m - 1;
    }
    return ret - pos + 1;
}


int main(){

    SL(n);
    FOR(i,1,n){
        LL a;
        SL(a);
        x[i] = x[i-1]^a;
        sum[i] = sum[i-1]+a;
    }

    LL ans = 0;
    FOR(i,1,n){
        ans+=BS(i);
    }
    cout<<ans<<endl;

return 0;}




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

#define MAX 200000

int N;
long long L;
long long X[MAX];

long long Xr[MAX];
long long suml[MAX + 1];
long long sumr[MAX + 1];

int main() {
	cin >> L >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> X[i];
	}

	for( int i = 0; i < N; i++ ) {
		Xr[i] = L - X[N - 1 - i];
	}
	for( int i = 1; i <= N; i++ ) {
		suml[i] = suml[i - 1] + X[i - 1];
	}
	for( int i = 1; i <= N; i++ ) {
		sumr[i] = sumr[i - 1] + Xr[i - 1];
	}
	long long ans = 0;
	for( int i = 1; i <= N; i++ ) {
		int pos = i + (N - i) / 2;
		int neg = N - pos;
		long long d1 = (suml[pos] - suml[i - 1]) * 2 + (sumr[neg] - sumr[0]) * 2;
		if( (N - i) % 2 ) {
			d1 -= Xr[neg - 1];
		}
		else {
			d1 -= X[pos - 1];
		}
		long long d2 = (sumr[pos] - sumr[i - 1]) * 2 + (suml[neg] - suml[0]) * 2;
		if( (N - i) % 2 ) {
			d2 -= X[neg - 1];
		}
		else {
			d2 -= Xr[pos - 1];
		}
		ans = max( ans, max( d1, d2 ) );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace arc080_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var al = GetLongList();
 
            var c4 = 0; //4の倍数
            var c2 = 0; //4の倍数でない2の倍数
            var c1 = 0; //奇数
 
            for (int i = 0; i < al.Count; i++)
                if (al[i] % 4 == 0) c4++;
                else if (al[i] % 2 == 0) c2++;
                else c1++;
 
            if ((c1 - 1 == c4 && c2 == 0) || (c1 <= c4))
                Console.WriteLine(" Yes");
            else
                Console.WriteLine(" No");
        }
 
        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());
 
        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();
 
    }
}

Measured memory_bytes: 20064
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else if(n == 1) cout << 1 << endl;
        else{
            int count = 0;
            FOR(i, n + 1, 2 * n + 1){
                bool flag = true;
                FOR(j, 2, sqrt(i) + 1){
                    if(i % j == 0){
                        flag = false;
                        break;
                    }
                }
                if(flag) count++;
            }
            cout << count << endl;
        }
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")

using ll = long long int;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll N, M, K;
ll A[200010], B[200010];
//累積和
ll a[200010] = {}, b[200010] = {};
ll ans = 0;
ll ai = 0, bi = 0;

int main() {
    cin >> N >> M >> K;
    A[0] = 0;
    a[0] = 0;
    B[0] = 0;
    b[0] = 0;
    REP(i, 1, N + 1 + 1) {
        if (i != N + 1) {
            cin >> A[i];
            a[i] = a[i - 1] + A[i];
        }
        else a[i] = (ll)1e17;

        if (a[i] > K && a[i - 1] <= K) {
            ai = i - 1;
        }
    }
    REP(i, 1, M + 1 + 1) {
        if (i != M + 1) {
            cin >> B[i];
            b[i] = b[i - 1] + B[i];
        }
        else b[i] = (ll)1e17;
    }

    ans = ai;

    for (int i = 0; i <= ai; i++) {
        //どんどん引いてく
        //0~ai冊Aからとってきたときの時間の総和
        int aii = ai - i;
        //あとひとつ足したらK超えるギリギリのBの総和
        while (K >= a[aii] + b[bi + 1]) {
            bi++;
        }
        int bookNum = aii + bi;
        if (bookNum > ans) {
            ans = bookNum;
        }
    }

    std::cout << ans << endl;

}

Measured memory_bytes: 9884
n = gets.to_i

backet = {}
n.times do |i|
  backet[i+1] = gets.to_i
end

idx = 1
count = 0
loop do
  idx = backet[idx]
  count += 1
  break if idx == 2
  
  if count > n
    count = -1
    break
  end
end

puts count

Measured memory_bytes: 10620
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int rx[100], ry[100];
int bx[100], by[100];
bool usedR[100];
bool usedB[100];

int main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> rx[i] >> ry[i];
	rep(i, n) cin >> bx[i] >> by[i];
	
	int ans = 0;
	
	//赤い点をx座標が大きいほうから見る
	rep(i, n) {
		int id = -1;
		rep(j, n) {
			if (usedR[j]) continue;
			if (id == -1 || rx[id] < rx[j]) {
				id = j;
			}
		}
		
		//ペアになれる青い点のうち、最もy座標が小さいものを優先して使う
		int id2 = -1;
		rep(j, n) {
			if (usedB[j] || (rx[id] >= bx[j] || ry[id] >= by[j])) continue;
			if (id2 == -1 || by[id2] > by[j]) {
				id2 = j;
			}
		}
		
		if (id != -1 && id2 != -1) {
			usedR[id] = true;
			usedB[id2] = true;
			ans++;
		}
		else {
			usedR[id] = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int mt(int a,int b)
{
	if(b==0)
	{
		return 1;
	}
	int c=mt(a,b>>1);
	c=(long long)c*c%998244353;
	if(b&1)
	{
		c=(long long)c*a%998244353;
	}
	return c;
}
int jc[524288],injc[524288];
int main()
{
	injc[1]=1;
	for(int i=2;i<=500000;i++)
	{
		injc[i]=(long long)998244353/i*injc[998244353%i]%998244353;
		injc[i]=998244353-injc[i];
	}
	jc[0]=1;
	injc[0]=1;
	for(int i=1;i<=500000;i++)
	{
		jc[i]=(long long)jc[i-1]*i%998244353;
		injc[i]=(long long)injc[i-1]*injc[i]%998244353;
	}
	int n,m;
	scanf("%d%d",&n,&m);
	int ans=0;
	for(int i=0;i<=n&&i<=m;i++)
	{
		int inc=jc[n];
		inc=(long long)inc*injc[n-i]%998244353;
		inc=(long long)inc*jc[m]%998244353;
		inc=(long long)inc*injc[m-i]%998244353;
		inc=(long long)inc*injc[i]%998244353;
		inc=(long long)inc*mt(n+1,m-i)%998244353;
		inc=(long long)inc*mt(m+1,n-i)%998244353;
		if(i&1)
		{
			ans-=inc;
			if(ans<0)
			{
				ans+=998244353;
			}
		}
		else
		{
			ans+=inc;
			if(ans>=998244353)
			{
				ans-=998244353;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    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;
}


Measured memory_bytes: 256
/**
 *  Circle and Points (PKU 1981)
 *  by Kenji Inoue, 2007-01-05
 **/

#include <iostream>
#include <math.h>

using namespace std;

#define EPS (1e-6)

double x[300], y[300];

int sign[] = {+1, -1};

int main(void) {
  int n;
  while (cin >> n, n) {
    for (int i=0; i<n; i++) {
      cin >> x[i] >> y[i];
    }

    int ans = 1;
    for (int i=0; i<n; i++) {
      for (int j=i+1; j<n; j++) {
        double d = hypot(x[i]-x[j], y[i]-y[j]);
        if ( d > 2.0 + EPS ) { continue; }

        double mx = (x[i] + x[j]) / 2;
        double my = (y[i] + y[j]) / 2;
        double vx = (x[j] - x[i]) / d;
        double vy = (y[j] - y[i]) / d;
        double e = sqrt(1.0 - d*d/4.0);

        for (int s=0; s<2; s++) {
          double px = mx + sign[s]*e*vy;
          double py = my - sign[s]*e*vx;

          int cnt = 2;
          for (int k=0; k<n; k++) {
            if (k==i || k==j) { continue; }
            if ( (px-x[k])*(px-x[k]) + (py-y[k])*(py-y[k]) < 1.0 + EPS ) { cnt++; }
          }
          if (cnt > ans) { ans = cnt; }
        }
      }
    }

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


Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

std::vector<int> masu(int num, int H, int W){
  int a = num % H;
  int b = num / H;
  std::vector<int> ret(2);
  if(b % 2 == 0){
    ret[0] = a;
    ret[1] = b;
  }else{
    ret[0] = H - a - 1;
    ret[1] = b;
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  int H, W;
  std::cin >> H >> W;
  vvi A = vv(H, W, 0, int);
  vvi ans = vv(0, 4, 0, int);
  range(i, H) range(j, W) std::cin >> A[i][j];
  range(i, H * W - 1){
    int row = masu(i, H, W)[0];
    int col = masu(i, H, W)[1];
    //std::cout << masu(i, H, W)[0] << masu(i, H, W)[1] << '\n';
    if(A[row][col]%2 == 1){
      int nrow = masu(i+1, H, W)[0];
      int ncol = masu(i+1, H, W)[1];
      if(i == H * W - 2 && A[nrow][ncol]%2==0) continue;
      A[nrow][ncol]++;
      std::vector<int> an(4);
      an[0] = row;
      an[1] = col;
      an[2] = nrow;
      an[3] = ncol;
      ans.push_back(an);
    }
  }
  std::cout << ans.size() << '\n';
  range(i, ans.size()) std::cout <<ans[i][0]+1<< " "<<ans[i][1]+1<<" "<<ans[i][2]+1<<" "<<ans[i][3]+1<<'\n';
  return 0;
}


Measured memory_bytes: 10288
n,t = map(int,input().split())
routes = [list(map(int,input().split())) for _ in range(n)]
routes = sorted(routes,key=lambda x:x[0])
ans = "TLE"
for i in range(n):
  if routes[i][1] <= t:
    ans = str(routes[i][0])
    break
print(ans)

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

int main(void)
{
    int n = 0, max = -1000001, min = 1000001, a;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        sum += a;
        if (a < min)
            min = a;
        if (a > max)
            max = a;
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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 main(){
    int n ;cin>>n;
    string s;
    s=to_string(n);
    int x =s[s.size()-1]-'0';
    if(x==3){
        cout<<"bon"<<endl;

    }
    else if(x==0||x==1||x==6||x==8){
        cout<<"pon"<<endl;

    }
    else cout<<"hon"<<endl;


}

Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const int inf = 1e9 + 7;
const long long INF = 1LL << 60;
typedef long long ll;

int min_ = 100000000;
int idx;

int main()
{
	int N, K, time = 0;
	cin >> N >> K;
	vector<int> X(N);
	int i;
	rep(i, N) cin >> X[i];
	int min_ = inf;

	for (int i = 0; i <= N - K; i++)
	{
		int ans = abs(X[i] - X[i + K - 1]) + min(abs(X[i]), abs(X[i + K - 1]));
		min_ = min(min_, ans);
	}

	cout << min_ << endl;
	return 0;
}


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

#define max 100001
#define nil -1

struct Node {int p, l, r;};

Node T[max];
int n, D[max];

void print (int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if (T[u].p == nil) cout << "root, ";
    else if (T[u].l == nil) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    
    for (i = 0, c = T[u].l; c != nil; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != nil) rec(T[u].r, p);
    if (T[u].l != nil) rec(T[u].l, p+1);
    return p;
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].r = T[i].l = nil;
    
    for (i = 0; i < n; i++) {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++) {
        if(T[i].p == nil) r = i;
    }
    
    rec(r, 0);
    
    for (i = 0; i < n; i++) print(i);
    
    return 0;
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int h,w,n;cin>>h>>w>>n;
  vector<int> a(n);
  int i,j;
  rep(i,n)cin>>a[i];
  vector<vector<int>> ans(h,vector<int>(w));
  int now=0;
  rep(i,h)rep(j,w)
  {
    if(a[now]==0)
    {
      now++;
      ans[i][j]=now+1;
      a[now]--;
    }
    else
    {
      ans[i][j]=now+1;
      a[now]--;
    }
  }
  rep(i,h)
  {
    rep(j,w)
    {
      if(i%2==0)
      {
        if(j!=0)cout<<' ';
        cout<<ans[i][j];
      }
      else
      {
        if(j!=0)cout<<' ';
        cout<<ans[i][w-1-j];
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
ll l,a[100005],s=0;
cin>>n>>l;
rep(i,1,n)cin>>a[i],s+=a[i];

rep(i,1,n-1)
{
	if(a[i]+a[i+1]>=l)
	{
		ol("Possible\n");
		rep(j,1,i-1)
		{
			ol(j);on;
		}
		ren(j,n-1,i)
		{
			ol(j);on;
		}
		return 0;
	}
}
ol("Impossible");

return 0;
}


Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using BigInt = long long;
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int N;
    cin >> N;
    rep(i, 8){
        if (pow(2, i) > N){
            cout << pow(2, (i - 1)) << endl;
            break;
        }
    }
}

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

#define PI 3.1415926535

int main() {
    int a, b, x;
    bool flag = false;
    cin >> a >> b;
    if(b==100) x = a * 1000 + b;
    else if(b>=10)
        x = a * 100 + b;
    else
        x = a * 10 + b;
    for (int i = 3; i < 317; i++)
    {
        if(x==i*i)
            flag = true;
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll L, R, d;
    cin >> L >> R >> d;

    ll ans = 0;
    for(ll i=L; i<=R; i++){
        if(i%d == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

string divide[4]={"dream", "dreamer", "erase", "eraser"};

bool dfs(string s, int start, int end){
    if(end > s.length()){
        return false;
    }
    if(end - start<5){
        if(dfs(s, start, start+5))return true;
        if(dfs(s, start, start+6))return true;
        if(dfs(s, start, start+7))return true;
    }
    for(int i=0;i<4;++i){
        if(s.substr(start,end-start)==divide[i]){
            if(end == s.length())return true;
            if(dfs(s, end, end+5) || dfs(s,end,end+6) || dfs(s,end,end+7))return true;
        }
    }
    return false;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    dfs(s, 0, 0) ? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 2944
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0

for i in range(n):
    ans += min(A[i],B[i])
    
    if B[i] > A[i]:
        x = B[i] - A[i]
        ans += min(A[i+1],x)
        A[i+1] = max(0,A[i+1]-x)
        
print(ans)

Measured memory_bytes: 19116
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int N;
    cin >> N;
    vector<P> pos;
    for (int i = 0; i < N; i++) {
        int tx, ty;
        cin >> tx >> ty;
        pos.push_back(make_pair(tx, ty));
    }

    int minimum = N;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int score = N;
            int p = pos[j].first - pos[i].first;
            int q = pos[j].second - pos[i].second;
            for (int x = 0; x < N; x++) {
                for (int y = x + 1; y < N; y++) {
                    if ((pos[y].first - pos[x].first == p && pos[y].second - pos[x].second == q) || (pos[x].first - pos[y].first == p && pos[x].second - pos[y].second == q)) {
                            score--;
                        }
                }
            }
            minimum = min(score, minimum);
        }
    }

    cout << minimum << endl;

    return 0;
}

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

using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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 COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

char c[1010][1010];
ll dp[101010];
ll v[110], w[110];

//long longしか使わない
//素数は1より大きい
int main() {
	ll N, W;
	cin >> N >> W;
	rep(i, N) {
		cin >> v[i] >> w[i];
	}
	rep(i, W+1) {
		rep(j, N) {
			if (i - w[j] < 0)dp[i] = dp[i];
			else {
				dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
			}
		}
	}
	ll ans = 0;
	rep(i, W + 1) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3180
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string cal(int a){
	string ret="";
	rep(i,3){
		ret+=('0'+(a%10));
		a/=10;
	}
	reverse(All(ret));return ret;
}
int main()
{
	int n;cin>>n;
	if(n>999) cout<<"ABD"<<endl;else cout<<"ABC"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main()
{
    int op=read();
    if(op==1){
        puts("Hello World");
    }
    else{
        int a=read(),b=read();
        cout<<a+b<<endl;
    }
    return 0;
}
/*
3
UDU
0 3
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class B {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int N;
        Input(out N);
        int[] A;
        Inputs(out A);
        int count = 0;
        for(int i = 0; i < N; i++) {
            if(A[A[i] - 1] - 1 == i) {
                count++;
            }
        }
        count = count / 2;
        Print(count);
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 26204
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

vector<ll>v;
int main()
{
	ll n,a;
	sl(n);
	int i;
	FOR(i,0,3*n){
		sl(a);
		v.pb(a);
	}
	sort(v.rbegin(), v.rend());
	i=0;
	int j=1;
	ll sum=0;
	while(i<n){
		sum += v[j];
		j+=2;
		i++;
	}
	pl(sum);

	return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define C getchar()
#define LL long long
#define mod 1000000007
using namespace std;
inline int read() {
	int num = 0;
	char c=C;
	for(;c<'0' || c>'9';c=C);
	for(;c>='0'&&c<='9';c=C) num = (num << 1) + (num << 3) + (c ^ 48);
	return num;
}

int n , k;
int nxt[10000],head[10000],to[10000],fr[10000],tot;

inline void add(int u,int v) {
	nxt[++tot] = head[u] , head[u] = tot , to[tot] = v , fr[tot] = u;
}

int ans = 0;
int dep[10000];
inline void dfs(int x,int fa){
    for(int i=head[x];i;i=nxt[i]){
        if(to[i] == fa) continue;
        dep[to[i]] = dep[x] + 1;
        dfs(to[i] , x);
    }
}


int main() {
	
	n = read() , k = read();
	for(int i=1;i<n;++i) {
		int u = read() , v = read();
		add(u , v);
		add(v , u);
	}
	
	int sum = 1 << 30;
	if (k & 1) {
		for(int i=1;i<=tot;i+=2) {
			for(int j=1;j<=n;++j) dep[j] = 0;
			ans = 0;
		    dfs(to[i] , fr[i]);dfs(fr[i] , to[i]);
		    for(int j=1;j<=n;++j) if (dep[j] > k >> 1) ++ ans;
		    sum = min(sum , ans);
		}
	}
	 else {
		for(int i=1;i<=n;++i) {
			for(int j=1;j<=n;++j) dep[j] = 0;
			ans = 0;
		    dfs(i , 0);
		    for(int j=1;j<=n;++j) if (dep[j] > k >> 1) ++ ans;
		    sum = min(sum , ans);
		}
	 }
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 384
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

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

    ll n, W;
    cin >> n >> W;

    vi val(n), w(n);

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

    ll maxW = (ll)(1e5 + 5);
    ll dp[n + 1][maxW];

    for (int i = 0; i < maxW; i++)
        dp[0][i] = W + 1;
    dp[0][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < maxW; j++)
        {
            if (j < val[i - 1])
                ll a = dp[i][j] = dp[i - 1][j];
            else
                ll a = dp[i][j] = min(dp[i - 1][j - val[i - 1]] + w[i - 1], dp[i - 1][j]);
        }
    }

    for (int i = maxW - 1; i >= 0; i--)
    {
        if (dp[n][i] <= W)
        {
            cout << i << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 79232
#include <stdio.h>
#include <stdlib.h>

int main() {
    int n, min, max, i, a;
    min=1000;
    max=0;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
          scanf("%d", &a);
          if(a<min)
             min=a;
          if(a>max)
             max=a;
   }
   printf("%d", max-min);
   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin >>  A.at(i);
  }
 vector<int> count(1000);
  rep(i,N) {
    while(A.at(i) % 2 == 0) {
      count.at(i)++;
      A.at(i) /= 2;
    }
 }
  int  mini = 1e100;
  rep(i,N) {
    mini = min(mini,count.at(i));
  }
cout << mini << endl;
  return 0;
}


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

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

    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256