akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

N = 0
A = 0
B = 0
C = 0
D = 0
cost_result = {} # ある数に達するために必要なコインの枚数
each_cost = {} # 与えられたコスト

def cost(target):
    """
    Args:
        target: 目標とする数字

    Returns:
        result: その数字に達するまでに必要なコスト
    """
    if target in cost_result:
        return cost_result[target]

    else:
        result_dict = {}
        for i in [2, 3, 5]:
            if target % i == 0:
                result_dict[i] = cost(target//i) + each_cost[i]
            else:
                result_dict[i] = min(
                    cost(target//i) + each_cost[i] + D * (target % i),
                    cost((target//i)+1) + each_cost[i] + D * (i - target % i)
                )
        simplest = target * D
        result = min(min(result_dict.values()), simplest)
        cost_result[target] = result
        return result



if __name__ == "__main__":
    T = int(input())
    for _ in range(T):
        N, A, B, C, D = list(map(int, input().split()))

        each_cost[2] = A
        each_cost[3] = B
        each_cost[5] = C
        cost_result[1] = D
        cost_result = {0:0, 1:D}

        print(cost(N))

Measured memory_bytes: 10968
#include <stdio.h>

int main(void)
{
    char s[20];
    int i;
    scanf("%s",s);
    for(i=0;i<19;i++){
        if(i==5||i==13){
            printf(" ");
            continue;
        }
        printf("%c",s[i]);
    }
    return 0;
}

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

int main(){
  int W, H, N;
  cin >> W >> H >> N;

  vector<vector<int>> ans(W+1,vector<int>(H+1,0)); 
  vector<int> x;
  vector<int> y;
  vector<int> a;

  int x1,y1,z;
  for(int i = 0; i < N; i++){
    cin >> x1 >> y1 >> z;
    x.push_back(x1);
    y.push_back(y1);
    a.push_back(z);
  }
  for(int i = 0; i < N; i++){
    if(a[i] == 1){
      for(int k = 0; k < x[i]; k++){
        for(int j = 0; j < H; j++){
          ans[k][j] = 1;
        }
      }
    } 
    if(a[i] == 2){
      for(int k = x[i]; k < W; k++){
        for(int j = 0; j < H; j++){
          ans[k][j] = 1;
        }
      }
    }  
    if(a[i] == 3){
      for(int k = 0; k < W; k++){
        for(int j = 0; j < y[i]; j++){
          ans[k][j] = 1;
        }
      }
    }   
    if(a[i] == 4){
      for(int k = 0; k < W; k++){
        for(int j = y[i]; j < H; j++){
          ans[k][j] = 1;
        }
      }
    }    
  }
  int sum = 0;
  for(int k = 0; k < W; k++){
    for(int j = 0; j < H; j++){
      if(ans[k][j] == 0) sum += 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int dp[100020];

int main(){
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int ipt;
		cin >> ipt;
		dp[ipt] = -1;
	}

	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		if (dp[i] == -1)continue;
		if (dp[i + 1] != -1)dp[i + 1] += dp[i]%MOD;
		if (dp[i + 2] != -1)dp[i + 2] += dp[i] % MOD;

	}
	print(dp[N]%MOD);









	return 0;
}

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

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

  if(A=='1'){
    A='9';
  }
  else if(A=='9'){
    A='1';
  }

  if(B=='1'){
    B='9';
  }
  else if(B=='9'){
    B='1';
  }

    if(C=='1'){
    C='9';
  }
  else if(C=='9'){
    C='1';
  }

  cout << A << B << C << endl;

return 0;  
}

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

int N;
vector<int> L;
vector<int> A; // A, B, C

int main() {
    cin >> N;
    A.resize(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    L.resize(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    int res = 1LL<<29;
    vector<int> bit(3);
    for (bit[0] = 1; bit[0] < (1<<N); ++bit[0]) { // 0 は含めない
        for (bit[1] = 1; bit[1] < (1<<N); ++bit[1]) { // 0 は含めない
            // 共通要素あったらダメ
            if (bit[1] & bit[0]) continue;
            for (bit[2] = 1; bit[2] < (1<<N); ++bit[2]) { // 0 は含めない
                // 共通要素があったらダメ
                if (bit[2] & bit[0]) continue;
                if (bit[2] & bit[1]) continue;
                
                // sums: A〜C に選んだ竹の長さの合計、nums: A〜C に選んだ竹の本数
                vector<int> sums(3, 0), nums(3, 0);
                for (int i = 0; i < N; ++i) {
                    for (int j = 0; j < 3; ++j) {
                        if (bit[j] & (1<<i)) {
                            sums[j] += L[i];
                            nums[j]++;
                        }
                    }
                }

                // score を求める
                int score = 0;
                for (int i = 0; i < 3; ++i) {
                    score += abs(sums[i] - A[i]); // +1, -1 のコスト
                    score += (nums[i] - 1) * 10; // 合体のコスト
                }
                res = min(res, score);
            }
        }
    }
    cout << res << endl;
}
              


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,n,s,i,j,m2,cnt,a[1000];
int main()
{
    cin>>n>>m;
    // int a[n];
    s=0;
    for(i=0; i<n; i++)
        cin>>a[i],s+=a[i];
    //  s=accumulate(a,a+n,0);
//   m2=s/(4*m);
    sort(a,a+n);
    for(i=0; i<n; i++)
        if(a[i]>=s/(4.0*m))
            cnt++;
    if(cnt>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

using namespace std;

void solve(void)
{
	int l;
	cin >> l;
	int n = log2(l);
	l--;
	vector<pair<int, int>> g[n + 1];
	int es = 2 * n;
	for (int i = 0; i < n; i++)
	{
		g[i].push_back(make_pair(i + 1, 0));
		g[i].push_back(make_pair(i + 1, 1 << i));
	}
	int x = l, m = n, s = 0;
	while (m)
	{
		int y = x - (1 << m);
		if (y == -1)
			break;
		int k = log2(y + 1);
		s += 1 << m;
		g[k].push_back(make_pair(n, s));
		x = y;
		m = k;
		es++;
	}
	cout << n + 1 << ' ' << es << endl;
	for (int i = 0; i <= n; i++)
	{
		for (auto &p : g[i])
		{
			cout << i + 1 << ' ' << p.first + 1 << ' ' << p.second << '\n';
		}
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; int B[110];
    int sum=0;
    for(int i=0; i<N-1;i++){
      int bb; cin>>bb; B[i]=bb;
    }
    sum += B[0]; sum += B[N-2];
    for(int i=0; i<N-2;i++){
      sum+=min(B[i], B[i+1]);
    }

    cout<<sum<<endl;
    return 0;
}


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

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1)a--;
			b += a / 2;
			a /= 2;
		}
		else if (i % 2 == 1) {
			if (b % 2 == 1)b--;
			a += b / 2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define loop for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)


int main(int argc,char* argv[])
{
    ZOOM

    long double a,b,c;
    cin>>a>>b>>c;
    long double d;
    d=2*sqrt(static_cast<long double>(a*b));
    if((c-(a+b))>d) cout<<"Yes";
    else cout<<"No";



    return 0;
}



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

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int W = 1e5+10;

int n, w;
ll dp[W];

int main () {
	memset (dp, -1, sizeof dp);
	scanf ("%d %d", &n, &w);
	dp[0] = 0;
	for (int k = 0; k < n; k++) {
		int wi, vi;
		scanf ("%d %d", &wi, &vi);
		for (int i = w; i >= wi; i--)
			if (dp[i-wi] != -1)
				dp[i] = max (dp[i], dp[i-wi] + vi);
	}

	ll ans = -1;
	for (int i = 0; i <= w; i++) ans = max (ans, dp[i]);
	printf ("%lld\n", ans);
	
	return 0;
}
	

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b; cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
ll dp[301][90001];
ll dp2[301][90001];
int a[300];
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	dp[0][0] = 1;
	dp2[0][0] = 1;
	ll t = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= t; j++) {
			(dp[i + 1][j] += dp[i][j] * 2) %= MOD;
			(dp[i + 1][j + a[i]] += dp[i][j]) %= MOD;
			(dp2[i + 1][j] += dp2[i][j]) %= MOD;
			(dp2[i + 1][j + a[i]] += dp2[i][j]) %= MOD;
		}
		t += a[i];
	}
	ll sum = 0;
	for (int i = (t + 1) / 2; i <= t; i++) {
		(sum += dp[N][i]) %= MOD;
	}
	(sum *= 3) %= MOD;
	if (t % 2 == 0) (sum += MOD - (dp2[N][t / 2]*3) % MOD) %= MOD;
	cout << (mod_pow(3, N) + MOD - sum) % MOD << endl;
}

Measured memory_bytes: 421504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<pair<int,int>> vp;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = 1;
    if (s[0] == '0' || s[n-1] == '1') flag = 0;
    rep(i, n-1){
        if (s[i] != s[n-i-2]) flag = 0;
    }

    if (!flag){
        cout << -1 << endl;
        return 0;
    }
    int p = n;
    rrep(i, n-1){
        if (s[i] == '1') {
            vp.push_back({p, i+1});
            p = i+1;
        }
        else vp.push_back({p, i+1});
    }

    for(auto e : vp) cout << e.first << " " << e.second << endl;

    return 0;
}


Measured memory_bytes: 4472
#include<stdio.h>

int main(void)
{
	int tmp,i,x,y,r;
	scanf("%d",&x);
	scanf("%d",&y);
	
	if(x<y)
	{
		tmp=x;
		x=y;
		y=tmp;
	}
	while(y>0)
	{
		r=x%y;
		x=y;
		y=r;
	}
	printf("%d\n",x);

	return 0;
	
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=0;
    int inc=0;
    for(int i=0;i<n-1;i++){
        int preinc=inc;
        if(a[i]<a[i+1]) inc=1;
        else if(a[i]>a[i+1]) inc=-1;
        else inc=preinc;
        if(abs(inc-preinc)>1){
            ans++;
            inc=0;
        }
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
H = list(map(int, input().split()))

ans = [True] * N

for i in range(M):
    a, b = map(int, input().split())
    if H[a - 1] > H[b - 1]:
        ans[b - 1] = False

    elif H[a - 1] < H[b - 1]:
        ans[a - 1] = False
    else:
        ans[a - 1], ans[b - 1] = False, False
        
print(sum(ans))

Measured memory_bytes: 86388
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {
	int n;
	int total = 0;

	cin >> n;
	vector<int> l(n);
	FOR(i, 0, n-1) {
		cin >> l[i];
		total += l[i];
	}
	sort(l.begin(), l.end());

	if (total - l[n - 1] > l[n - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))

a.sort()
ans = 0
ans += a[2] - a[1]
diff = a[2] - (a[0] + (a[2] - a[1]))
if diff % 2 == 0:
    ans += diff // 2
else:
    ans += diff // 2 + 2
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int x = Integer.parseInt(sc.next());
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
if(abs(a-x)<abs(b-x)){
    out.println("A");
}else{out.println("B");}
}
}

Measured memory_bytes: 23636
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    ret = []
    x, sign = 0, 1
    for i in range(N):
        x += sign * A[i]
        sign *= -1
    ret.append(x)

    for i in range(N-1):
        x = 2 * A[i] - x
        ret.append(x)

    print(*ret)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 14024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007

struct SegmentTree{
  int siz;
  vector<ll>tree_min,tree_max;
  SegmentTree(int temp){
    siz=temp;
    for (int i=0;i<siz*2;i++){
      tree_min.push_back(INF);
      tree_max.push_back(-INF);
    }
  }
  void update(int pos, ll val){
    pos+=siz;
    tree_min[pos]=val;
    tree_max[pos]=val;
    for (pos/=2;pos>=1;pos/=2){
      tree_min[pos]=min(tree_min[pos*2],tree_min[pos*2+1]);
      tree_max[pos]=max(tree_max[pos*2],tree_max[pos*2+1]);
    }
  }
  ll query_min(int L, int R){
    L+=siz;
    R+=siz;
    ll s=INF;
    while (L<=R){
      if (L%2==1)//Right node
	s=min(s,tree_min[L++]);
      if (R%2==0)//Left node
	s=min(s,tree_min[R--]);
      L/=2;
      R/=2;
    }
    return s;
  }
   ll query_max(int L, int R){
    L+=siz;
    R+=siz;
    ll s=-INF;
    while (L<=R){
      if (L%2==1)//Right node
	s=max(s,tree_max[L++]);
      if (R%2==0)//Left node
	s=max(s,tree_max[R--]);
      L/=2;
      R/=2;
    }
    return s;
  }
};

int N,K;
int arr[200001];
int ans=1;
int Lsort[200001];

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  cin>>N>>K;
  SegmentTree s=SegmentTree(N);
  for (int i=0;i<N;i++){
    cin>>arr[i];
    s.update(i,arr[i]);
  }
  int pre=N-1;
  for (int i=N-1;i>=0;i--){
    for (int j=min(i-1,pre);j>=0;j--){
      if (arr[j]>arr[j+1])
	break;
      pre=j-1;
    }
    Lsort[i]=pre+1;
  }
  if (Lsort[K-1]==0)
    ans=0;
  for (int i=0;i+K<N;i++){
    if (Lsort[i+K]<=i+1)
      continue;
    if (!(s.query_min(i,i+K-1)==arr[i] && s.query_max(i+1,i+K)==arr[i+K])){
      //cout<<i<<endl;
      ans++;
    }
  }
  for (int i=0;i+K-1<N;i++)
    if (Lsort[i+K-1]<=i){
      //if (i!=1)
	ans++;
      break;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10336
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int a, b;
        cin >> a >> b;
        if (a + b > 9) {
            cout << "error" << endl;
            return;
        }
        cout << a + b << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    int N, cnt = 0;
    cin >> N;
    vll A(N);
    REP(i, N) {
        cin >> A[i];
        if (A[i]%2 == 1)
            cnt++;
    }
    if (cnt%2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 1024
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

a,b = map(int, input().split())

if a in g1 and b in g1:
  print('Yes')
elif a in g2 and b in g2:
  print('Yes')
elif a in g3 and b in g3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
double logbase(double a, double base)
{
  return log(a) / log(base);
}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % mod;
      a = a * a % mod;
      n >>= 1;
  }
  return res;
}
ll comb(ll n,ll k,ll p)
{
  ll res = 1;
  REP(i,k){
    res = res * (n - i) % p;
    res = res * modpow(i+1, p-2, p) % p;
  }
  return res;
}




int main()
{
  int n,a,b;
  cin >> n >> a >> b; 
  
  int p = pow(10,9) + 7;
  int A = comb(n, a, p) % p;
  int B = comb(n, b, p) % p;
 
  int MAX = modpow(2, n, p)-1;
 
  int ans = MAX - A - B;
  ans = ans % p;
  
  if(ans>=0){
    cout << ans << endl;
  }else{
    cout << ans+p << endl;
  }
}


Measured memory_bytes: 256
/*#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int S,t;
    cin >> S;
    t = S%3600;
    cout << S/3600 << ":"<<  t/60 << ":" <<S%60 << endl;
    return 0;
}


Measured memory_bytes: 3092
require 'scanf'
require 'pp'

# ????¨?
class Submit
  attr_accessor :time, :judge

  def initialize(time, judge)
    @time = time
    @judge = judge
  end

  def ok?
    @judge == 0
  end
end

# ????????????????????????????¨?????????¨??????
class Problem < Array
  def penalty
    if ok?
      (self.size - 1) * 20
    else
      0
    end
  end

  def ok?
    last.ok?
  end

  def time
    if ok?
      last.time + penalty
    else
      0
    end
  end
end

# ?????????
class Team
  attr_reader :problems, :id

  def initialize(id)
    @id = id
    @problems = {}
  end

  def submit(problem, submit)
    log = @problems[problem] ||= Problem.new
    log << submit
  end

  def n_solved
    @problems
      .select { |id, problem| problem.ok? }
      .count
  end

  def total_time
    @problems
      .map { |id, problem| problem.time }
      .inject(0, :+)
  end

  def <=>(other)
    c = other.n_solved <=> self.n_solved
    unless c == 0
      c
    else
      self.total_time <=> other.total_time
    end
  end
end

while true
  line = gets
  break unless line

  mm, tt, pp, r = line.scanf('%d %d %d %d')
  break if [mm, tt, pp, r].all?(&:zero?)

  teams = Array.new(tt) do |t|
    Team.new(t + 1)
  end
  
  r.times do
    line = gets
    break unless line

    m, t, p, j = line.scanf('%d %d %d %d')
    teams[t - 1].submit(p, Submit.new(m, j))
  end

  sorted_teams = teams.sort

  rank = 1
  ranks = []

  sorted_teams.each_with_index do |t, i|
    prev = i == 0 ? nil : sorted_teams[i - 1]

    if !prev.nil? && t.n_solved == prev.n_solved && t.total_time == prev.total_time
      ranks.last << t.id
    else
      ranks << [t.id]
    end
  end

  puts ranks.map{|sr| sr.sort.reverse.join('=')}.join(',')
end

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, mina = INF, maxa = -1, a;
  cin >> n;
  rep(i, n) {
    cin >> a;
    mina = min(mina, a);
    maxa = max(maxa, a);
  }

  int ans = maxa - mina;
  cout << ans << endl;
  return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

#define ar array<ll, 2>
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define For(i, n) for(ll i = 0; i < n; i++)
#define Rev(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, n) for(ll i = 1; i <= n; i++)
#define REV(i, n) for(ll i = n; i >= 1; i--)
#define Rep(i,a,b) for(ll i = a; i <= b; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

#define CERR cout
// #define CERR cerr

void debug_out() { CERR << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	CERR << " " << to_string(H);
	debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) CERR << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

const ll mod = 1e9L + 7;
const ll INF = 1e18L + 5;
const ll mxN = 2e5 + 1;
ll n;
vt<ll> a;

// remember to read no of test_cases
void solve()
{
	cin >> n;
	ll ans = 0;
	FOR(i, n)
	{
		ans += n / i;
		if (n % i == 0)
			ans--;
	}
	cout << ans;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);  cin.tie(0);
	ll t = 1;
	// cin >> t;
	FOR(tt, t) solve();
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  V<string> s(3); 
  for (auto&& e : s) {
    cin >> e;
    reverse(begin(e), end(e));
  }

  int i = 0;
  while (true) {
    if (s[i].empty()) {
      return cout << (char)('A' + i) << '\n', 0;
    }
    int ni = s[i].back() - 'a';
    s[i].pop_back();
    i = ni;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = sc.next();
        int red =0;
        int blue =0;
        
        for(int i=0; i<s.length() ; i++){
            if(s.charAt(i) == 'R'){
                red++;
            }
            else{
                blue++;
            }
        }

        if(red>blue){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	n=n%k;
	printf("%lld",min(k-n,n));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string Wet;
  cin >> Wet;
  if(Wet == "Sunny")
    cout << "Cloudy" << endl;
  else if(Wet == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
dis = []
for i in range(n):
    l = list(map(int, stdin.readline().rstrip().split()))
    dis.append(l)

def dist(x1,y1,xn,yn):
    di = ((x1-xn)**2 + (y1-yn)**2)**0.5
    return di

total = 0
for i in range(n-1):
    for j in range(i+1,n):
        d = dist(dis[i][0],dis[i][1],dis[j][0],dis[j][1])
        total += d

# nの階乗
ns = 1
for i in range(1,n+1):
    ns *= i

# 辺の数
num = 0
for i in range(n-1):
    num += 1 + i

ans = total * ((n-1)*ns)/num/ns

print(ans)

Measured memory_bytes: 3192
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e4+10;
const int M = 1e3+10;

int n, dp[N][M], h;
vector<vector<int>> v;

int solve(int health, int idx){
   if(health < 0)
      return 0;
   if(idx >= n){
      if(health > 0)
         return inf;
      return 0;
   }
   int &ans = dp[health][idx];
   if(ans != -1)
      return ans;
   ans = inf;
   smin(ans, solve(health, idx+1));
   smin(ans, solve(health - v[idx][0], idx) + v[idx][1]);
   return ans;
}

int32_t main(){_
   
   cin>>h>>n;

   for (int i = 0; i < n; ++i)
   {
      int x, y;
      cin >> x >> y;
      v.push_back({x, y});
   }

   memset(dp, -1, sizeof dp);
   cout<<solve(h, 0);
   

   return 0;
}

Measured memory_bytes: 79616
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


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

    if((a+b)%2==0)ans = (a+b)/2;
    else ans = (a+b)/2 + 1;
    
    //cout << (!flag ? "Yes" : "No") << endl;
    cout << ans << endl;

}


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

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String S = sc.next();
    String T = sc.next();
    Map<Character, Character> alphabetS = new HashMap<Character, Character>();
    Map<Character, Character> alphabetT = new HashMap<Character, Character>();
    boolean check = true;
    for(int i=0; i<S.length(); i++){
      char ss = S.charAt(i);
      char tt = T.charAt(i);   
      if(alphabetS.get(ss) != null){
        if(!alphabetS.get(ss).equals(tt)){
          check = false;
          break;
        }
      }else{
        alphabetS.put(ss, tt);
      }
      if(alphabetT.get(tt) != null){
        if(!alphabetT.get(tt).equals(ss)){
          check = false;
          break;
        }
      }else{
        alphabetT.put(tt, ss);
      }
    }
    if(check == true) out.println("Yes");
    else out.println("No");
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 26344
import heapq

X, Y, Z, K = map(int, input().split(" "))

A = sorted(map(int, input().split(" ")), reverse=True)
B = sorted(map(int, input().split(" ")), reverse=True)
C = sorted(map(int, input().split(" ")), reverse=True)

anslist = []
flag = {}

heapq.heappush(anslist, (-(A[0]+B[0]+C[0]), (0, 0, 0)))


for _ in range(K):
    p = heapq.heappop(anslist)
    while p[1] in flag:
        p = heapq.heappop(anslist)
    print(p[0]*(-1))
    a, b, c = p[1]
    flag[a, b, c] = True
    # push
    for i, j, k in [[1, 0, 0], [0, 1, 0], [0, 0, 1]]:
        if a+i >= X or b+j >= Y or c+k >= Z:
            continue
        tmp = (a+i, b+j, c+k)
        heapq.heappush(anslist, (-(A[a+i]+B[b+j]+C[c+k]), tmp))


Measured memory_bytes: 4724
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll i,j,k,l,m,n;
		cin>>n;
		vi a(n),b(n),c(n);
		vi aa(n,0),bb(n,0),cc(n,0);
		for(i=0;i<n;i++)
		{
			cin>>a[i]>>b[i]>>c[i];
		}
		aa[0]=a[0];bb[0]=b[0];cc[0]=c[0];
		for(i=1;i<n;i++)
		{
			aa[i]=a[i]+max(bb[i-1],cc[i-1]);
			bb[i]=b[i]+max(aa[i-1],cc[i-1]);
			cc[i]=c[i]+max(aa[i-1],bb[i-1]);
		}
		ll ans=max(aa[n-1],bb[n-1]);
		ans=max(ans,cc[n-1]);
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
typedef long long int lli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define ulta(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b
#define pr3(a, b, c) cout << a << " " << b << " " << c
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli fib(lli n){
    if (n == 0 || n == 1)
        return 1;
    else{
        lli arr[n + 1];
        arr[0] = 0;
        arr[1] = 1;
        for (lli i = 2; i <= n; i++){
            arr[i] = arr[i - 1] + arr[i - 2];
        }
        return arr[n];
    }
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
 
lli is_prime(lli a){
    lli i;
    if (a == 2 || a == 3)
        return 1;
    else
        for (i = 2; i * i <= a; i++){
            if (a % i == 0)
                return 0;
        }
    return 1;
}
 
void swap(lli x, lli y){ //using XOR
    x ^= y;
    y ^= x;
    x ^= y;
}
 
lli digsum(lli n){
    return floor(log10(n)) + 1;
}
 
lli binsearch(lli arr[], lli l, lli r, lli no){
    while (l <= r){
        lli mid = (l + r) / 2;
        if (arr[mid] == no)
            return mid;
        else if (arr[mid] < no)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return -1;
}
 
string sortString(string &str){
    lli i = 0, j = 0, k = 0;
    lli charCount[26] = {0};
    loop(i, 0, str.length())
        charCount[str[i] - 'a']++;
    loop(i, 0, 26){
        loop(j, 0, charCount[i]){
            str[k++] = char('a' + i);
        }
    }
    return str;
}

//sort(arr,arr+n,greater<lli>()) :: sorting array in reverse
 
int32_t main(){
    fast_io
    lli i = 0,j = 0;
    lli a,b;
    cin >> a >> b;
    cout << lcm(a,b);
}

Measured memory_bytes: 256
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0015
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#define MAX_DIGITS 80
#define MAX_INPUTS 101

int             add(const char *n1, const char *n2, char **a);
char           *stralloc(const size_t length);

int
main()
{
    int             n, i;
    char            n1[MAX_INPUTS];
    char            n2[MAX_INPUTS];
    char           *r;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", n1);
        scanf("%s", n2);

        errno = 0;
        if (add(n1, n2, &r)) {
            /* fprintf(stderr, "%s\n", strerror(errno)); */
            printf("overflow\n");
            continue;
        }

        printf("%s\n", r);
        free(r);
    }

    return 0;
}

int
add(const char *n1, const char *n2, char **a)
{
    int             l1, l2, lr;
    int             c = 0;
    int             d;
    int             i;
    char           *r;
    char           *n;

    l1 = strlen(n1);
    l2 = strlen(n2);
    if (l1 > MAX_DIGITS || l2 > MAX_DIGITS) {
        errno = EINVAL;
        return -1;
    }
    lr = l1 > l2 ? l1 : l2;

    r = stralloc(lr + 1);
    while (lr >= 0) {
        d = c + (l1 > 0 ? n1[--l1] - '0' : 0) + (l2 > 0 ? n2[--l2] - '0' : 0);
        c = d / 10;
        r[lr--] = d % 10 + '0';
    }
    i = r[0] == '0' ? 1 : 0;
    if (strlen(r + i) > MAX_DIGITS) {
        free(r);
        errno = ERANGE;
        return -1;
    }
    if (i != 0) {
        n = r;
        r = stralloc(strlen(n + i));
        strcpy(r, n + i);
        free(n);
    }
    *a = r;
    return 0;
}

char           *
stralloc(const size_t length)
{
    return (char *)calloc(length + 1, sizeof(char));
}

Measured memory_bytes: 1752
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	double n;
	cin >> n;
	n = sqrt(n);
	n = floor(n);
	print((i64)pow(n, 2));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
/*********************
    メモ化再帰で解いてみた
**********************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/

//DPテーブル(dp[i] := ちょうどi円引き出すのに必要な操作の回数の最小値)
ll dp[100010];

int main(){
    ll n;
    cin >> n;
    rep(i,n+1)dp[i]=INF;

    rep(i,6){
        dp[i]=i;
    }
    
    //ループ
    rep(i,n){
        for(int j=1;i+pow(6,j)<=n;j++){
            chmin(dp[i+(int)(pow(6,j))],dp[i]+1);
            if(i+pow(9,j)<=n)chmin(dp[i+(int)(pow(9,j))],dp[i]+1);
            }
    }
    cout << dp[n] << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

void solve() {
    string ans = "AKIHABARA";
    if (S.length() > ans.length()) {
        cout << "NO" << endl;
        return;
    }
    int i_ans = 0, idx = 0;
    while (i_ans < ans.length()) {
        if (ans[i_ans] == S[idx]) {
            i_ans++, idx++;
            continue;
        }
        if (ans[i_ans] == 'A') {
            i_ans++;
            continue;
        }
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
}

int main() {
    cin >> S;
    solve();
    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/05/20 00:39:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;

  using Bitset = bitset<5000>;
  vector<Bitset> dpl(n+1);
  dpl[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    auto a = A[i-1];
    dpl[i] = dpl[i-1] | dpl[i-1] << a;
  }
  vector<vector<int>> cdpl(n+1, vector<int>(k));
  for (int i = 0; i <= n; i++) {
    cdpl[i][0] = dpl[i][0];
    for (int j = 1; j < k; j++) {
      cdpl[i][j] += cdpl[i][j-1] + dpl[i][j];
    }
  }
  vector<Bitset> dpr(n+1);
  dpr[n][0] = 1;
  for (int i = n-1; i >= 0; i--) {
    auto a = A[i];
    dpr[i] = dpr[i+1] | dpr[i+1] << a;
  }

  int ans = n;
  for (int i = 0; i < n; i++) {
    auto a = A[i];
    for (int j = 0; j < k; j++) {
      if (!dpr[i+1][j]) continue;
      auto min_v = k-a-j;
      auto max_v = k-1-j;
      auto cnt = cdpl[i][max_v];
      if (min_v > 0)
        cnt -= cdpl[i][min_v-1];
      if (cnt > 0) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    
    int n, x, cnt;
    while(cin>>n >>x){
        if(n==0 && x==0)break;
        cnt=0;
        for(int i=1;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)cnt++;
                }
            }
        }
        
        cout<<cnt<<endl;
    }
    return 0;
}



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

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

int main() {
  for (int i=0; i<4; i++) reverse(v[i].begin(), v[i].end());

  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  while (s.size()>0) {
    bool flag = true;
    for (int i=0; i<4; i++) {
      if (v[i] == s.substr(0, v[i].size())) {
        flag = false;
        s = s.substr(v[i].size());
      }
    }
    if (flag) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512