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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int n,m;
int f[7][7][7];
int h[7][7];

inline bool ok(int a)
{
    return (0<=a && a<n);
}

bool check()
{
    //3:one,6:two,4:three _dimension
    int dx[13]={1,0,0,1,1,1,-1,0,0,1,1,1,1};
    int dy[13]={0,1,0,1,-1,0,0,1,1,1,1,-1,-1};
    int dz[13]={0,0,1,0,0,1,1,1,-1,1,-1,1,-1};

    //start point
    rep(i,n)rep(j,n)rep(k,n)
    {
        int col=f[i][j][k];

        if(col==-1) continue;

        //printf("start check %d,%d,%d :col %d\n", i,j,k,col);

        rep(d,13)
        {
            bool valid=true;
            for(int s=1; s<m; ++s)
            {
                int nx=i+s*dx[d];
                int ny=j+s*dy[d];
                int nz=k+s*dz[d];
                if(ok(nx) && ok(ny) && ok(nz))
                {
                    if(f[nx][ny][nz]!=col)
                    {
                        valid=false;
                        break;
                    }
                }
                else
                {
                    valid=false;
                    break;
                }
            }

            //found sequence
            if(valid) return true;
        }
    }

    //failed
    return false;
}

int main()
{
    while(1)
    {
        int p;
        cin >>n >>m >>p;
        if(n==0) break;

        vector<pi> v(p);
        rep(i,p)
        {
            scanf(" %d %d", &v[i].fi, &v[i].se);
            --v[i].fi;
            --v[i].se;
        }

        memset(f,-1,sizeof(f));
        memset(h,0,sizeof(h));

        //simulation
        int ans=-1;
        rep(i,p)
        {
            //0:black, 1:white
            int col=i%2;

            int x=v[i].fi;
            int y=v[i].se;

            f[x][y][h[x][y]++]=col;

            if(check())
            {
                ans=i;
                break;
            }
        }

        //output
        if(ans==-1) printf("Draw\n");
        else
        {
            if(ans%2==0) printf("Black ");
            else printf("White ");

            printf("%d\n", ans+1);
        }
    }
    return 0;
}

Measured memory_bytes: 3124
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

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

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> Ss(A);
    REP(a, A) cin >> Ss[a];
    vector<ll> Ts(B);
    REP(b, B) cin >> Ts[b];
    REP(q, Q) {
        ll x;
        cin >> x;
        vector<ll> S_cand;
        auto s1 = lower_bound(ALL(Ss), x);
        if (s1 != Ss.begin()) S_cand.push_back(*(s1--));
        if (s1 != Ss.end()) S_cand.push_back(*s1);
        vector<ll> T_cand;
        auto t1 = lower_bound(ALL(Ts), x);
        if (t1 != Ts.begin()) T_cand.push_back(*(t1--));
        if (t1 != Ts.end()) T_cand.push_back(*t1);
        
        ll ans = 1e18;
        for(auto s: S_cand) {
            for(auto t: T_cand) {
                ll tmp1 = abs(s - x) + abs(t - s);
                ll tmp2 = abs(t - x) + abs(t - s);
                ans = min(ans, min(tmp1, tmp2));
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	string s;
	cin >> s;
	int cnt = 0;
	int ans = 0;
	rep(i, s.size()) {
		if(s[i] == 'R') cnt++, chmax(ans, cnt);
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int odd = (N+1) / 2;

  cout << std::fixed << std::setprecision(15);
  cout << ((double)odd / N);
}
#endif


Measured memory_bytes: 256
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
A = list(map(int,input().split()))
for i in range(N*2):
  if (X - i) not in A:
    print(X-i)
    exit()
  elif (X + i ) not in A:
    print(X+i)
    exit()

Measured memory_bytes: 9184
#include <stdio.h>

int main(){
    char ch;
    scanf("%c",&ch);
    if(ch=='A'){
        printf("T\n");
    }else if(ch=='T'){
        printf("A\n");
    }else if(ch=='C'){
        printf("G\n");
    }else if(ch=='G'){
        printf("C\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n;
int a[100010][3];
int b[100010][3];
int res=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<3;j++)
		{
			cin >>a[i][j];
		}
	}
	for (int i=0;i<3;i++) b[0][i]=a[0][i];
	for (int i=1;i<n;i++)
	{
		for (int j=0;j<3;j++)
		{
			for (int k=0;k<3;k++)
			{
				if (j==k) continue;
				b[i][j]=max(b[i][j],b[i-1][k]+a[i][j]);
			}
		}
	}
	for (int i=0;i<3;i++) res=max(res,b[n-1][i]);
	cout <<res;
	return 0;
}

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

typedef vector<int> vi;
typedef bitset<20> MASK;
#define ll long long
#define PI 3.14159265359
//#define x first
#define y second
#define point pair<int,int>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
ll a[17][17];
ll cost[1 << 17];
vector<vector<ll>> masks;
ll n;
ll dp[1 << 17];
ll OO = 1e15;
ll solve(MASK mask){
    if(mask.count() == n)
        return 0;

    ll &ret = dp[mask.to_ulong()];
    if(ret != -1)
        return ret;

    ret = -OO;
    for(int i = 0; i < masks[mask.to_ulong()].size(); i++){
        ll c = cost[masks[mask.to_ulong()][i]];
        MASK new_mask = mask.to_ulong() | masks[mask.to_ulong()][i];

        ret = max(ret, solve(new_mask) + c);
    }

    return ret;
}

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    clr(dp, -1);
    cin>>n;
    masks = vector<vector<ll>> (1 << (n + 1));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin>>a[i][j];

    for(ll i = 0; i <= (1 << n); i++){
        MASK mask = i;
        ll ccost = 0;
        for(int k = 0; k < n; k++){
            if(!mask[k]) continue;
            for(int j = k + 1; j < n; j++){
                if(mask[j])
                    ccost+= a[k][j];
            }
        }

        cost[i] = ccost;
    }

    for(ll i = 0; i <= (1 << n); i++){
        MASK mask = i;
        mask.flip();
        int maskCopy = mask.to_ulong() & ((1 << n) - 1);

        for(int sub = maskCopy; sub > 0; sub = (sub - 1) & maskCopy){
            masks[i].push_back(sub);
        }
    }

    cout<<solve(0);
}


Measured memory_bytes: 343032
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt).toTypedArray()
    val map = A.groupBy { it }.map { Pair(it.key, it.value.size) }.filter { it.second > 1 }.associate { it }
    val total = map.map { combination(it.value, 2) }.sum()
    for (k in A.indices) {
        val cnt = map[A[k]]
        if (cnt != null) {
            println(total - combination(cnt, 2) + combination(cnt - 1, 2))
        } else {
            println(total)
        }
    }
}

fun combination(n: Int, k: Int): Long {
    if (n < k) return 0
    var a = 1L
    var b = 1L
    val min = Math.min(n - k, k)
    for (i in n - min + 1..n) {
        a *= i
    }
    for (i in 1..min) {
        b *= i
    }
    return a / b
}

Measured memory_bytes: 100676
import sys
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,d = IL()
    t = 1
    while 0<a and 0<c:
        if t%2:
            c -= b
        else:
            a -= d
        t += 1
    if a<c:
        print('No')
    else:
        print('Yes')
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9356
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
    int n, a; cin >> n >> a;
    vector<int> X(n);
    rep(i, n) cin >> X[i];

    vector<vector<vector<ll>>> dp(55, vector<vector<ll>>(2600, vector<ll>(55, 0)));
    ll sum = 0; dp[0][0][0] = 1;
    
    rep(i, n){
        rep(j, 2501){
            rep(k, i+1){
                dp[i+1][j+X[i]][k+1] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    rep(i, 2501){
        for(int k = 1; k <= 50; k++){
            if(i / (double)k == a){;
                sum +=  dp[n][i][k];             
            }
        }
    }
    cout << sum << ln;
}




Measured memory_bytes: 67328
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
#define ll long long
ll dp[100][100001];


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string k;
    int d;
    cin>>k;
    cin>>d;
    memset(dp, 0,  sizeof(dp));
    for(int i = 0 ; i < 10 && i <  (k[0] - '0') ; i++){
        dp[i%d][0] += 1;
        dp[i%d][0]  = dp[i%d][0]%mod;
    }
    long long pre = 0;
    for(long long j = 0 ;  j < k.size() - 1 ; j++){
        pre += (k[j] - '0');
        pre = pre%d;
        for(int i = 0 ; i < d; i++){
            for(int x = 0; x < 10 ; x++){
                long long z = i + x;
                dp[z%d][j + 1] += dp[i][j];
                dp[z%d][j + 1] = dp[z%d][j + 1]%mod;
            }
        }
        for(int x = 0 ; x < (k[j+1] - '0') ; x++){
            long long z = pre + x;
            dp[z%d][j + 1] += 1;
            dp[z%d][j + 1] = dp[z%d][j + 1]%mod;
        }
    }
    // for(int i = 0 ; i < d ; i++){
    //     for(int j = 0 ; j < k.size() ; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    pre += (k[k.size() -1]-'0');
    pre = pre%d;
    if(pre == 0){
        cout<<(dp[0][k.size()-1])%mod<<endl;
    }else{
        cout<<((dp[0][k.size()-1] - 1) + mod)%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 78464
//package compilers;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int [][]arr=new int[n][2];
		for(int i=0;i<n;i++) {
			for(int j=0;j<2;j++) {
				arr[i][j]=in.nextInt();
			}
		}
		long dp[]=new long [k+1];
		for(int i=0;i<n;i++) {
			for(int j=k;j>=0;j--) {
				if(j-arr[i][0]>=0)
				dp[j]=Math.max(dp[j], dp[j-arr[i][0]]+arr[i][1]);
			}
		}
		System.out.println(dp[k]);
		
	}

}


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

int main() {
	int n;
	cin >> n;

	int answer = n % 1000;
	answer %= 100;
	answer %= 10;

	if (answer == 3) {
		cout << "bon" << endl;
	}
	else if (answer == 0 || answer == 1 || answer == 6 || answer == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}

	return 0;
}

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

typedef long long int ll;
const	int maxn = 2e5+100;
struct SECTION {
	ll l,r;
	SECTION() {}
	SECTION(ll l,ll r):l(l),r(r) {}
	bool operator<(const SECTION& oth) const {
		if(l==oth.l) return r < oth.r;
		return l < oth.l;
	}
	bool operator==(const SECTION& oth) const { return l==oth.l&&r==oth.r; }
};
map<ll,int> idx;
vector<SECTION> sec[maxn];
ll N,X,D;

int main() {
	std::ios::sync_with_stdio(false);
	ll kl=0,kr=0,key,cnt = 0,ans = 0;
	cin >> N >> X >> D;
	if(D==0) {
		if(!X) cout << 1 << endl;
		else cout << N+1 << endl;
		return 0;
	} else if(D<0) {
		X*=-1;
		D*=-1;
	}
	ll l,r;
	for(int i=0; i<=N; i++) {
		key = i*X;
		ll bb = key%D;
		l = r = key/D;
		l+=kl; r+=kr;
		if(l>r) swap(l,r);
		if(idx[bb]==0ll) idx[bb] = ++cnt;
		sec[idx[bb]].push_back({--l,r});
		kl+=i,kr+=N-i-1;
	}
	for(int i=1; i<=cnt; i++) {
		SECTION tp;
		sort(sec[i].begin(),sec[i].end());
		tp = sec[i][0];
		for(SECTION now: sec[i]) {
			if(now.l <= tp.r) tp.r = max(tp.r,now.r);
			else {
				ans += tp.r-tp.l;
				tp = now;
			}

			if(now == sec[i].back()) {
				ans += tp.r-tp.l;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int compare_string(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
}
//  qsort(names, 3, sizeof *names, compare_string);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a, b, c, d, e, X, Y ,r;
  //unsigned long long a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[10000001][11]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
  int min =100000001;
  int len=0;
  int l=0;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//  b=100;
  //  a=0;
  scanf("%d%d%d%d%d", &A[0], &A[1], &A[2], &A[3], &A[4]);
//  printf("%llu\n",);
  for(i=0;i<5;i++){
    if(A[i]==1) B[0]=1;
    else if(A[i]==2) B[1]=1;
    else if(A[i]==3) B[2]=1;
    else if(A[i]==4) B[3]=1;
    else if(A[i]==5) B[4]=1;  
  }
  for(i=1;i<6;i++){
    if(B[i-1]==0) ans=i;
  }
  printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2896
'use strict';
const p = s => console.log(s);
// let a,b,c,d;
// [a,b,c,d] = input[0].trim().split(" ").map(i => parseInt(i));

function main(input) {
  let S = input[0].trim().split("");

  S[1] === 'B' ? p('ARC') : p('ABC');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


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

int main(){

    int i, j, n;
    cin >> n;
    int v[n];
    for(i=0;i<n;i++){
        cin >> v[i];
    }

    std::sort(v, v+n);
    double res=v[0];
    for(i=1;i<n;i++){
        res+=v[i];
        res/=2;
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
vector<ll> a;
vector<ll> ca;

int main()
{
    int n;
    cin >> n;
    a.resize(n);
    ca.resize(n);

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

    ll sum1 = 0, n1 = 0;
    ll sum2 = 0, n2 = 0;

    for (int i = 0; i < n; i++)
    {
        sum1 += a[i];
        sum2 += a[i];
        if (i % 2 == 0 && sum1 <= 0)
        {
            n1 += 1 + abs(sum1);
            sum1 += 1 + abs(sum1);
        }
        if (i % 2 == 1 && sum1 >= 0)
        {
            n1 += 1 + abs(sum1);
            sum1 -= 1 + abs(sum1);
        }
        if (i % 2 == 0 && sum2 >= 0)
        {
            n2 += 1 + abs(sum2);
            sum2 -= 1 + abs(sum2);
        }
        if (i % 2 == 1 && sum2 <= 0)
        {
            n2 += 1 + abs(sum2);
            sum2 += 1 + abs(sum2);
        }
    }

    cout << min(n1, n2) << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

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

  ll ans = 0;
  for (int i = 0; i * i <= N; i++) {
    ans = i * i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
・座標の出力
n==0のとき、再起毎に両端（p1,p2）を出力すると、両端以外の点は二回出力されてしまう。
よって、ｐ１を再起前に出力して、再起内では右端（ｐ２）のみ出力にする。


*/

#include <iostream>
#include <cmath>
#include <cstdio>

const static double PI = 4*atan(1.0);

using namespace std;


int count=0;


 
void Koch_curve(int n, double p1x, double p1y, double p2x, double p2y){
    double sx, sy, tx, ty, ux, uy;
    
	if(n == 0){
		//cout << p2x << ' ' << p2y << endl;
		printf("%.6lf %.6lf\n", p2x, p2y);
		count++;
	}
	else{
		n--;
		sx = p1x + (p2x-p1x)*(1.0/3.0);
		sy = p1y + (p2y-p1y)*(1.0/3.0);
		tx = p1x + (p2x-p1x)*(2.0/3.0);
		ty = p1y + (p2y-p1y)*(2.0/3.0);

		//求め方は http://www.infra.kochi-tech.ac.jp/takagi/Survey2/3PolarRect.pdf　
		// 極座標の回転　（二次元回転行列）
		ux= sx + (tx-sx)*cos(PI/3.0) - (ty-sy)*sin(PI/3.0);
		uy= sy + (tx-sx)*sin(PI/3.0) + (ty-sy)*cos(PI/3.0);

		Koch_curve(n, p1x, p1y, sx, sy);
		Koch_curve(n, sx, sy, ux, uy);
		Koch_curve(n, ux, uy,tx, ty);
		Koch_curve(n, tx, ty, p2x, p2y);
	}
    
}
 
int main() {
    int n;
    
    cin >> n;
	//cout.setf(ios::fixed, ios::floatfield); //固定小数表記 
	//cout << 0.0 << ' ' << 0.0 << endl;
	printf("%.6lf %.6lf\n", 0.0, 0.0);
    Koch_curve(n, 0.0, 0.0, 100.0, 0.0);
        
        return 0;
}

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

#define ll long long 

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

    int poc = 0;
	ll pari = 1000ll;
	ll akcii = 0ll;
	while (poc<n) {

		int x = poc;
		while (x+1<n && a[x]<=a[x+1]) x++;

		ll ostatok = pari % a[poc];
		ll kolkuAkcii = (pari - ostatok) / a[poc];

		akcii += pari/a[poc];
		pari = ostatok;
      
		pari += (ll)akcii*a[x];
		akcii = 0ll;

		poc = x+1;
	}
	cout<<pari<<"\n";
 
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <fstream>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
#define Test ll q ; cin>>q ; while (q--)
#define ph push_back
using namespace std;
int main()
{
    vector<int>a={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} ;
    int n , x  ;
    cin>>n ;
    cout<<a[n-1] ;
}



Measured memory_bytes: 256
#include <stdio.h>
#define max 10000

int main(void)
{
	int n;
	scanf("%d",&n);
	int i , k;
	int c[max];
	unsigned short *a , *b;
	a = malloc(sizeof(short)*n+1);
	b = malloc(sizeof(short)*n+1);

	scanf("%d",&a[0]);
	k = a[0];
	b[0] = 0;
	
	for( i = 1; i < n; i++)
	{
		scanf("%d",&a[i]);
		if(k < a[i])
		{
			k = a[i];
		}
		b[i] = 0;
	}
	
	for( i = 0; i <= k; i++)
	{
		c[i] = 0;
	}
	
	for( i = 0; i < n; i++)
	{
		c[a[i]]++;
	}
	
	for( i = 1; i <= k; i++)
	{
		c[i] = c[i] + c[i-1];
	}
	for( i = n; i >= 0; i--)
	{
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}
	for( i = 1; i <= n; i++)
	{
		if(i != n) printf("%d ",b[i]);
		else printf("%d\n",b[i]);
	}
	
	return 0;
}



Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    int d = 0;
    int ans = 1;
    for(int i = 0; i < n; i++) {
        int l;
        cin >> l;
        d += l;
        ans += d <= x;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define INF (1<<29)
typedef vector<int> Vec;
typedef vector<Vec> Graph;

int minimum_steiner_tree(Graph &d, Vec &heart)
{
    int N = d.size(), T = heart.size();
    if (T <= 1) return T;   
    
    int dp[1<<T][N];
    for (int i = 0; i < (1<<T); i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = INF;
        }
    }

    for (int i = 0; i < T; i++) {
        for (int j = 0; j < N; j++) {
            dp[1<<i][j] = d[heart[i]][j];
        }
    }

    for (int i = 1; i < (1<<T); i++) {
        if (!(i & (i - 1))) continue;
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < i; k++) {
                if ((i | k) == i) {
                    dp[i][j] = min(dp[i][j], dp[k][j] + dp[i-k][j]);
                }
            }
        }
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + d[j][k]);
            }
        }
    }
    int res = INF;
    for (int i = 0; i < (1<<T); i++) {
        for (int j = 0; j < N; j++) {
            res = min(res, dp[i][j] + dp[((1<<T)-1)-i][j]);
        }
    }
    return res + 1;
}

int get_dist(int y1, int x1, int y2, int x2)
{
    return abs(x1 - x2) + abs(y1 - y2);
}

int main()
{
    int H, W, x;
    while (cin >> H >> W, H) {
        Vec heart;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> x;  
                if (x == 1) {
                    heart.push_back(i * W + j);
                }
            }
        }

        Graph G(H*W, Vec(H*W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                for (int k = 0; k < H; k++) {
                    for (int l = 0; l < W; l++) {
                        G[i*W+j][k*W+l] = get_dist(i, j, k, l);
                    }
                }
            }
        }
        cout << H*W - minimum_steiner_tree(G, heart) << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, M;
    cin >> N >> M;

    if(N%2==1){
        rep(i, M) cout << (i+1) << " " << (N-i) << endl;
    }
    else{
        rep(i, M){
            if(i<N/4) cout << (i+1) << " " << (N-i) << endl;
            else cout << (i+1) << " " << (N-i-1) << endl;
        }
    }
}


Measured memory_bytes: 3656
//雋ｰ縺・DP繝ｫ繝ｼ繝・
#include<bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T,typename U>
void Printarray(T f,U n){for(U i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n,k;cin>>n>>k;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<long long> dp(n);
  const long long INF = 1LL << 60;

  dp.assign(n,INF);

  dp[0]=0;

  rep2(i,0,n){
    rep2(j,1,k+1){
      if(i+j<n)chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

long long gcd(long long a, long long b){
    if(b == 0)return a;
    return gcd(b, a%b);
}

long long lcm(long long a, long long b){
    return a * b / gcd(a,b);
}

int main() {
	long long a,b;
    while(cin>>a>>b){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
	return 0;
}

Measured memory_bytes: 2960
S = input()
a = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)

for i in range(len(S) - 1, -1, -1):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)

print(sum(a))


Measured memory_bytes: 29048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m=0,ans=0;
    cin >> n;
    for(int i=0;i<sqrt(n);i++){
        for(int j=0;j<20;j++){
            if((pow(i+1,j))==n){
                m=pow(i+1,j);
                break;
            }else if((pow(i+1,j))>n){
                m=pow(i+1,j-1);
                break;
            }
        }
        ans = max(ans,m);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)

map<int, bool> m;

bool chk(int n) {
  while (n) {
    if (m[n % 10]) {
      return false;
    }
    n /= 10;
  }
  return true;
}

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

  int N, K, k;
  cin >> N >> K;
  rep(i, 0, K) {
    cin >> k;
    m[k] = true;
  }

  while (true) {
    if (chk(N)) {
      cout << N << endl;
      break;
    }
    N++;
  }

  getchar();
}

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

int main()
{
  int N;
  cin >> N;
  vector<string> vec(N);

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

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  cout << vec.size() << endl;
}


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

using namespace std;

int main()
{
    long long int i,j,m,n,ans=0;
    cin >> m >> n;
    if(abs(m-n)<=1)
    {
        cout << "Brown" << endl;
    }
    else
    {
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
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;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;
    rep(i,0,dx)cout<<'R';
    rep(i,0,dy)cout<<'U';
    rep(i,0,dx)cout<<'L';
    rep(i,0,dy)cout<<'D';
    cout<<'D';
    rep(i,0,dx+1)cout<<'R';
    rep(i,0,dy+1)cout<<'U';
    cout<<'L';
    cout<<'U';
    rep(i,0,dx+1)cout<<'L';
    rep(i,0,dy+1)cout<<'D';
    cout<<'R';
    return 0;
}




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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    map<string, int> mp;
    int n, m;
    string s;
    cin >> n;
    rep(i, n) {
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    rep(i, m) {
        cin >> s;
        mp[s]--;
    }
    int maxi = 0;
    for (auto num : mp) {
        maxch(maxi, num.se);
    }
    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    for(i <- 1 to list.length){
      val arr = list(list.length - i).split(Array(' '))

      if(!(arr(0).toInt == 0 && arr(1).toInt == 0)){
        for(i <- 0 until arr(0).toInt){
          for(j <- 0 until arr(1).toInt){
            i match{
              case x if(x % 2 == 0) => j match{
                  case y if(y % 2 == 0) => print("#")
                  case y if(y % 2 == 1) => print(".")
                  case _ => None
                }
              case x if(x % 2 == 1) => j match{
                  case y if(y % 2 == 0) => print(".")
                  case y if(y % 2 == 1) => print("#")
                  case _ => None
                }
              case _ => None
            }
          }
          println
        }
        println
      }
    }
  }
}

Measured memory_bytes: 73884
//Z Algorithm
#include<cstdio>
#include<cstring>
#include<valarray>
using namespace std;
pair<valarray<long long>,long long> f(long long n,long long l,const valarray<long long> &left,long long r,const valarray<long long> &right)
{
	valarray<long long> ans(26);
	if(l+r<=n)
	{
		auto x=f(n,l+r,left+right,l,left);
		ans+=x.first;
		n=x.second;
	}
	if(l<=n)ans+=left,n-=l;
	return make_pair(ans,n);
}
char s[300000];
long long cnt[300000][30],z[300000],n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1)>>1;
	z[1]=n;
	long long l=1,r=1;
	for(long long i=2;i<=n;i++)
		if(i>r)
		{
			z[i]=0;
			while(z[i]+i<=n&&s[z[i]+i]==s[z[i]+1])z[i]++;
			if(z[i])l=i,r=i+z[i]-1;
		}
		else if(z[i-l+1]<r-i+1)z[i]=z[i-l+1];
		else
		{
			z[i]=r-i+1;
			while(z[i]+i<=n&&s[z[i]+i]==s[z[i]+1])z[i]++;
			l=i,r=i+z[i]-1;
		}
	for(long long i=1;i<=n;i++)
	{
		for(long long j=0;j<26;j++)cnt[i][j]=cnt[i-1][j];
		cnt[i][s[i]-'a']++;
	}
	long long k=0;
	for(long long i=n;i>1;i--)
		if(z[i]+i-1==n)k=z[i];
	scanf("%lld%lld",&l,&r);l--;
	if(!k)
	{
		for(long long i=0;i<26;i++)printf("%lld ",cnt[n][i]*(r/n)+cnt[r%n][i]-cnt[n][i]*(l/n)-cnt[l%n][i]);
		putchar('\n');
		return 0;
	}
	valarray<long long> left(26),right(26);
	for(long long i=0;i<26;i++)
	{
		left[i]=cnt[n-k][i];
		right[i]=cnt[n][i]-cnt[n-k][i];
	}
	auto lower=f(l,n-k,left,k,right),upper=f(r,n-k,left,k,right);
	for(long long i=0;i<26;i++)printf("%lld ",upper.first[i]-lower.first[i]+cnt[upper.second][i]-cnt[lower.second][i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 25856
import itertools

n, k = map(int, input().split())
array = {x for x in input().split()}
num_array = {str(x) for x in range(10)}
like_num = array^num_array

res = float("inf")
for i in range(1, 100000):
    tmp = set(list(str(i)))
    if tmp.issubset(like_num):
        if n <= i < res:
            res = i
print(res)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

D = [0] * N
for i in range(N):
  D[i] = A[i] - B[i]
  
if sum(D) < 0:
  print(-1)
  exit(0)

D.sort()
  
minsum = 0
minidx, maxidx = 0, 0
cumsumR = [0] * (N+1)

for i in range(N):
  if D[i] >= 0:
    minidx = i
    break
  minsum += D[i]
  
for j in range(N-1,-1,-1):
  if minsum >= 0:
    maxidx = j
    break
  minsum += D[j]
  
print(N - (maxidx - minidx + 1))

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

int main(void){

  int height,width,i,j;
  
  while(cin >> height >> width){

    if(height == 0 && width == 0) break;
    
    for(j=0; j<height; j++){
      for(i=0; i<width; i++){
	cout << "#";
	if(i == width - 1) cout << endl;
      }
    }
    cout << endl;
  }
  return 0;
}

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

typedef long long ll;
int main() {
	ll N, M, X; cin >> N >> M >> X;
	ll A, a, b;
	while (cin >> A) {
		(X > A) ? b++ : a++;
	}
	cout << min(b, a);

	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = [int(i) for i in input().split()]

A = sorted(A)

B = []
C = []
D = []

for i in range(len(A)):
  if A[i] < 0:
    B.append(A[i])
  elif A[i] == 0:
    C.append(A[i])
  else:
    D.append(A[i])

b = len(B)
c = len(C)
d = len(D)

def f(n):#積がn以下になる組み合わせの個数
  if n < 0:
    i = 0
    j = 0
    k = 0
    while i < b and j < d:
      if B[i]*D[j] > n:
        j += 1
      else:
        i += 1
        k += d-j
    return k
  
  elif n == 0:
    return (c*(c-1))//2 + b*c + b*d + c*d
  
  else:
    i = 0
    j = b-1
    k = 0
    while i < b and j > -1:
      if B[i]*B[j] > n:
        i += 1
        k += j+1
      else:
        j -= 1
    
    k = b**2-k
    
    i = 0
    j = d-1
    while i < d and j > -1:
      if D[i]*D[j] <= n:
        i += 1
        k += j+1
      else:
        j -= 1
        
    l = 0   
    for i in range(b):
      if B[i]**2 <= n:
        l += 1
        
    for i in range(d):
      if D[i]**2 <= n:
        l += 1
        
    return (k-l)//2 + (c*(c-1))//2 + b*c + b*d + c*d
  
l = - 10**18
h = 10**18

while l+1 < h:
  m = (l+h)//2
  if f(m) >= K:
    h = m
  else:
    l = m

print(h)

Measured memory_bytes: 96212
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll calc(int x, int y, int z){
  return (ll)x * x + (ll)y * y + (ll)z * z + (ll)x * y + (ll)y * z + (ll)z * x;
}

int main(void){
  int N; cin >> N;
  map<ll, int> res;
  for (int x = 1; x <= 101; ++x){
    for (int y = 1; y <= 101; ++y){
      for (int z = 1; z <= 101; ++z){
        ++res[calc(x, y, z)];
      }
    }
  }
  for (int i = 1; i <= N; ++i)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
const ll INF = 1e18;

int main(){
    int n, m;
    cin >> n >> m;

    using P = pair<ll, ll>;
    vector<P> v(m);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        ll mask = 0;
        rep(i, b){
            ll c;
            cin >> c;
            c--;
            mask |= (1<<c);
        }
        v[i] = {a, mask};
    }

    ll dp[5000];
    rep(i, 5000) dp[i] = INF;

    dp[0] = 0;
    for(int bit=0; bit<(1<<n); bit++){
        rep(i, m){
            if(dp[bit] == INF) continue;
            ll to = bit | v[i].second;
            dp[to] = min(dp[to], dp[bit]+v[i].first);
        }
    }

    if(dp[(1<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[(1<<n)-1 ] << endl;
}

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

//貪欲法はクソ
int main() {

  int x,a,b; cin >> x >> a >> b;

  int da=abs(a-x),db=abs(b-x);

  if(da<db) cout << 'A' << endl;

  else cout << 'B' << endl;
  

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if (X == 7 || X == 5 || X == 3)
			System.out.println("YES");
		else
			System.out.println("NO");

		sc.close();
	}
}

Measured memory_bytes: 23252
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    said_words = []

    for i in range(N):
        new_word = input()
        if said_words == []:
            said_words.append(new_word)
        elif new_word in said_words:
            print('No')
            break
        elif said_words[-1][-1] != new_word[0]:
            print('No')
            break
        else:
            said_words.append(new_word)
    else:
        print('Yes')


Measured memory_bytes: 3060
n, k = map(int, input().split())
a = list(map(int, input().split()))


g = [aa - 1 for aa in a]

root = []
seen = set()

cur = 0
while True:
    seen.add(cur)
    root.append(cur)

    cur = g[cur]
    if cur in seen:
        break

for i in range(len(root)):
    if root[i] == cur:
        break

p = i
n_loop = len(root) - p

if k <= p:
    print(root[k] + 1)
else:
    idx = ((k - p) % n_loop + p) % len(root)
    print(root[idx] + 1)


Measured memory_bytes: 138032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001];
ll n;ll a[100001];
ll ans(ll ind){
  if(ind>=n-1)return 0;
  if(dp[ind]!=-1)return dp[ind];
  dp[ind] = ans(ind+1) + abs(a[ind]-a[ind+1]);
  if(ind<n-2)dp[ind] = min(dp[ind],ans(ind+2)+abs(a[ind]-a[ind+2]));
  return dp[ind];
}
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;for(ll i=0;i<n;i++)cin>>a[i];
  cout<<ans(0)<<endl;
  return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#define DATA 1000000

int prime[DATA];

void judge(){
  int i,j;

  for(i = 0; i < DATA ; i++) prime[i] = 0;
 
  prime[0] = prime[1] = 1;
  
  for(i = 2; i*i < DATA ; i++){
    if(prime[i] == 0){
      for(j = 2*i ; j < DATA ; j += i){
        prime[j] = 1;
      }
    }
  }

}

int main(void){
  int n,i,sum;

  judge();

  for(;;){
    sum = 0;

    scanf("%d" ,&n);
    if(n == 0) break;

    for(i = 0 ; n > 0 ; i++){
      if(prime[i] == 0){
	 sum += i;
         n--;
	}    
    }

    printf("%d\n" ,sum);   
  }    
  
  return 0;
}

Measured memory_bytes: 4504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
	public static final char[] SUIT = {'S','H','C','D'};
	private int getSuitNum(char suit) {
		switch(suit) {
		case 'S': return 0;
		case 'H': return 1;
		case 'C': return 2;
		case 'D': return 3;
		}
		return -1;
	}
	
    public void exec() throws IOException {
    	boolean[][] trump = new boolean[4][13];
    	try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);){
            int n = Integer.parseInt(br.readLine());
            for(int i=0; i<n; i++) {
            	String[] str = br.readLine().split(" ");
            	char suitChar = str[0].charAt(0);
            	int number = Integer.parseInt(str[1]);
        		trump[getSuitNum(suitChar)][number-1] = true;
            }
            
            StringBuilder sb = new StringBuilder();
            for(int suitNum=0; suitNum<SUIT.length; suitNum++) {
            	for(int number=1; number<=13; number++) {
            		if(!trump[suitNum][number-1]) {
            			sb.append(SUIT[suitNum]).append(' ').append(number).append(EOL);
            		}
            	}
            }
            out.print(sb.toString());
            out.flush();
    	}
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}

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

int main() {
    string w;
    while (1) {
        int b = 0;
        cin >> w;
        if (w == "0") break;
        for (int i = 0; i < w.size(); i++) {
            b += w[i] - '0';
        }
        cout << b << endl;;
    }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,H,W;
  int count = 0;
  cin >> N >> H >> W;
  
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    if(a>=H&&b>=W){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() {

    int tmp;
    int ans = 100000000000;
    int mem = 0;
    int n;

    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> tmp;
        mem = 0;
        while(tmp%2 == 0){
            tmp /= 2;
            mem ++;
        }
        ans = min(ans,mem);
    }

    cout << ans;
    return 0;
}

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

template <typename _tp> inline void read(_tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11!='-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;
}

int calc(ll x,ll b){
	int res = 0;
	if(x&b){
		res ^= (1&(x%b));
	}
	x/=b;
	res ^= 1&x;
	return res;
}

int main(){
	ll A,B;
	read(A),read(B);
	ll ans = 0ll;
	if(1&(B-A+1+(B/2)-((A-1)/2))) ans ^= 1;
	if(!A) {
		ans = 0;
		if(B-(B/2)&1) ans ^= 1;
		for(ll i=2;i<=B;i <<= 1)
			if(calc(B,i))
			ans += i;
		printf("%lld\n",ans);
		return 0;
	}
	--A;
	for(ll i=2;i<=B;i <<= 1)
		if(calc(A,i) ^ calc(B,i))
			ans += i;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

abk = [int(i) for i in stdin.readline().rstrip().split(" ")]

## seeds = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
commons = []
for i in range(1,max(abk[0],abk[1])+1):
    if (abk[0] % i) == 0 and (abk[1] % i) == 0:
        commons.append(i)
print(commons[-abk[2]])

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

string S[110], T[110];  
int main(){
  
  int N, M;
  cin >> N;
  for(int i = 0; i < N; i++) cin >> S[i];
  cin >> M;
  for(int i = 0; i < M; i++) cin >> T[i];
  
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int score = 0;
    for(int j = 0; j < N; j++) if(S[j] == S[i]) score++;
    for(int j = 0; j < M; j++) if(T[j] == S[i]) score--;
    ans = max(ans, score);
  }
  
  cout << ans << endl;
 
  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int X,Y,A,B,C;
    Scd2(X,Y);
    Scd3(A,B,C);
    int Z = X+Y;
    vi p(A);
    vi q(B);
    vi r(C);
    vi pq(Z+20);
    Rep(i,A) Scd(p[i]);
    Rep(i,B) Scd(q[i]);
    Rep(i,C) Scd(r[i]);

    sort( p.begin(), p.end() );
    sort( q.begin(), q.end() );
    sort( r.begin(), r.end() );
    reverse( p.begin(), p.end() );
    reverse( q.begin(), q.end() );
    reverse( r.begin(), r.end() );

    Rep(i,X) pq[i] = p[i];
    Rep(i,Y) pq[i+X] = q[i];

    sort( pq.begin(), pq.end() );
    reverse( pq.begin(), pq.end() );

    vl ps(Z+1);
    vl rs(C+1);
    Rep(i,Z) ps[i+1] = ps[i] + pq[i];
    Rep(i,C) rs[i+1] = rs[i] + r[i];

    ll ans = 0;
    Rep(i,Z+1){
        if( Z-i > C ) continue;
        ans = max( ans, ps[i] + rs[Z-i] );
    }

    printf ("%lld\n", ans );

    return 0;
}




Measured memory_bytes: 4352