akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector<long> a;
    long tmp;
    for(int i=0;i<n;++i){
        cin>>tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    long ans1, ans2;
    ans1 = a[a.size()-1];
    ans2 = a[0];
    long mean1, mean2;
    if(ans1 % 2 == 0){
        mean1 = ans1/2;
        mean2 = ans1/2;
    }
    else {
        mean1 = ans1/2;
        mean2 = ans1/2+1;
    }
    long tmpmin = min(abs(mean1 - ans2), abs(mean2 - ans2));
    for(int i=1;i<n;++i){
        if(tmpmin > min(abs(mean1 - a[i]), abs(mean2 - a[i]))){
            tmpmin = min(abs(mean1 - a[i]), abs(mean2 - a[i]));
            ans2 = a[i];
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int N, A, B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> A >> B;
	if((B - A) % 2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;

}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int N;

void dfs(string s, char mx){
	if(s.length() == N){
		printf("%s\n", s.c_str());
	}
	else{
		for(char c = 'a'; c <= mx; c++){
			dfs(s+c, ((c == mx)? (char)(mx + 1) : mx));
		}
	}
}

int main(void){
	cin >> N;

	dfs("",'a');

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<set>
#include<utility>
#include<algorithm>
using namespace std;
#define MP(a,b) make_pair(a,b)
int main(){
	int dp[16][16];
	int w,h,n;
	set<pair<int,int> > s;
	while(cin>>w>>h,w||h){
		cin>>n;
		s.clear();
		fill_n((int*)dp,16*16,0);
		dp[0][0]=1;
		while(n--){
			int x,y;
			cin>>x>>y;
			s.insert(MP(x-1,y-1));
		}
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(x+1<w && s.find(MP(x+1,y))==s.end())
					dp[y][x+1] += dp[y][x];
				if(y+1<h && s.find(MP(x,y+1))==s.end())
					dp[y+1][x] += dp[y][x];
			}
		}
		cout<<dp[h-1][w-1]<<endl;
	}
	return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll num;

    cin >>num;

    ll ans = (num*(num+1))/2;



    ll sum = 0;

    for(ll i=3; i<=num; i+=3)
    {
        if(i%3==0)
            sum += i;
    }

    ll sum1 = 0;

    for(ll i=5; i<=num; i++)
    {
        if(i%5==0 && i%3==0)
            continue;
        else if(i%5==0)
            sum1 += i;
    }

    //cout << sum << " " << sum1 << endl;

    cout << ans - (sum + sum1) << endl;





    return 0;
}



Measured memory_bytes: 3636
n, tl = gets.split.map(&:to_i)
min_c_init = 10000
min_c = min_c_init
for i in 0...n do
  c, t = gets.split.map(&:to_i)
  if t <= tl && min_c > c
    min_c = c
  end
end
puts (min_c < min_c_init) ? min_c : "TLE"


Measured memory_bytes: 1788
import numpy as np


def calc(n):
    #     lim = int((n - 2) ** 0.5 - 1) + 1
    lim = 130

    result = np.zeros(n + 1, dtype=int)
    for x in range(1, lim):
        for y in range(1, lim):
            if x > y:
                continue
            for z in range(1, lim):
                if y > z:
                    continue
                index = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if index > n:
                    continue
                s = set([x, y, z])
                if len(s) == 1:
                    result[index] += 1
                elif len(s) == 2:
                    result[index] += 3
                else:
                    result[index] += 6

    return result[1:]


for i in calc(int(input())):
    print(i)

Measured memory_bytes: 27244
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
typedef long long LL;
//typedef long double LD;
using namespace std;

#define MOD 1000000007

int main() {
    LL n;
    LL tmp_a;
    LL ans=0;
    vector<LL> a;
    LL a_bin;
    vector<LL> a_bin_all(62, 0);

    cin >> n;
    for(LL i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

    for(LL i=0; i<n; i++){
        tmp_a=a[i];
        for(LL j=0; j<62; j++){
            if((tmp_a&1)==1){
                a_bin_all[j]++;
            }
            tmp_a>>=1;
        }
    }
    for(LL i=0; i<n-1; i++){
        tmp_a=a[i];
        LL keta=1;
        for(LL j=0; j<62; j++){
            a_bin=0;
            if((tmp_a&1)==1){
                a_bin++;
                a_bin_all[j]--;
            }
            if(a_bin==1){
                ans+=(n-1-i-a_bin_all[j])*keta;
            }else{
                ans+=(a_bin_all[j])*keta;
            }
            ans%=MOD;
            tmp_a>>=1;
            keta=(keta*2)%MOD;
        }
        //cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  string N;
  cin >> N;
  for(int i=0;i<3;i++){
    if(N.at(i)=='1'){
      N.at(i)='9';
    }
    else if(N.at(i)=='9'){
      N.at(i)='1';
    }
  }
  cout << N << endl;
}

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

int main(){
	string s; cin >> s;
	cout << (s[0] == s[s.size() - 1] ? (s.size() & 1 ?  "Second\n" : "First\n") : (s.size() & 1 ? "First\n" : "Second\n"));
	return 0;
}

Measured memory_bytes: 512
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  VC1(n,a);
  V rui(1,0);
  REP(i,n)
    rui.pb(a[i]+rui.back());
  
  // 番兵とゼロの扱い！！！
  /*
  if(a[0]==0)
    rui.erase(rui.begin());
  */
  //VECCOUT(rui);
  
  map<ll, V> m;
  REP(i,rui.size())
    m[rui[i]].pb(i);
  ll cou = 0;
  FOREACH(xx,m){
    REPR(i,xx.second.size()-1)
      cou+=i;
  }
  COUT(cou);




  return 0;
}

Measured memory_bytes: 25200
n = int(input())
L = list(map(int, input().split()))

if n == 1:
    print(1)
    exit()

d = [0] * (n - 1)
if (L[0] > L[1]):
    d[0] = -1
elif (L[0] < L[1]):
    d[0] = 1

for i in range(n):
    if (i == 0):
        continue
    elif (i == n - 1):
        break
    else:
        if (L[i] < L[i + 1]):
            d[i] = 1
        elif (L[i] > L[i + 1]):
            d[i] = -1

prev = 0
count = 0
for i in range(len(d)):
    if (i == 0):
        prev = d[i]
        continue
    if (prev == 1):
        if (d[i] == 1):
            continue
        elif (d[i] == 0):
            continue
        else:
            count += 1
            prev = 0
    elif (prev == -1):
        if (d[i] == -1):
            continue
        elif (d[i] == 0):
            continue
        else:
            count += 1
            prev = 0
    elif (prev == 0):
        if (d[i] == 1):
            prev = 1
        elif (d[i] == -1):
            prev = -1

print(count + 1)


Measured memory_bytes: 14252
#if 1

#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int d[3005][3005],n;
char a[3005];

int main()
{
    cin >> n >> a;
	d[0][0] = 1;
	for(int i = 1;i < n;i++)
	{
		for(int j = 0;j <= i;j++)
		{
			if(a[i-1] == '<') d[i][j] = (d[i-1][0]-d[i-1][j]+mod)%mod;
			else d[i][j] = d[i-1][j];
		}
		for(int j = i;j >= 0;j--) 
        {
            d[i][j] = (d[i][j]+d[i][j+1])%mod;
        }
    }
	cout << d[n-1][0];
}

#endif // 1

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

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}



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

	scanf("%d %d %d", &a, &b, &c);

	if(a==b&&b==c){
		printf("1\n");
	}else if(a==b||b==c||a==c){
		printf("2\n");
	}else{
		printf("3\n");
	}

	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 128
N = int(input())

if 0<= N <=999:
  Nn = str(N)
  if Nn[-1] == '3':
    print('bon')
  elif Nn[-1] == '0' or Nn[-1] == '1' or Nn[-1] == '6' or Nn[-1] == '8':
    print('pon')
  else:
    print('hon')

Measured memory_bytes: 9184
#include <iostream>

using namespace std;

typedef long long ll;
ll gcd(ll a, ll b){
  return (b > 0)? gcd(b, a %b):a ;
}
int main(){
  ll a, b;
  while(cin >> a >> b){
    ll _gcd = gcd(a, b);
    cout << _gcd << " " << a*b/_gcd << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
# include <bits/stdc++.h>
using namespace std;
# define eps 1e-6
# define LL long long
# define INF 1e20
# define MX 100005

int n;
int a[MX], b[MX], c[MX];
LL bc[MX];
LL pre[MX];

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for (int i=1;i<=n;i++)
        scanf("%d",&c[i]);
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    sort(c+1,c+1+n);
    for (int i=1;i<=n;i++)
    {
        int dex = n+1;
        int l=1, r=n;
        while (l<=r)
        {
            int mid = (l+r)>>1;
            if (c[mid]>b[i])
            {
                dex = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        bc[i] = n - dex +1;
    }
    for (int i=n;i>=1;i--)
        pre[i] = pre[i+1] + bc[i];

    LL ans = 0;
    for (int i=1;i<=n;i++)
    {
        int dex = n+1;
        int l=1, r=n;
        while (l<=r)
        {
            int mid = (l+r)>>1;
            if (b[mid]>a[i])
            {
                dex = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        ans += (LL)pre[dex];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e9;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    cin >> A >> B >> C;
    vector<ll> AB;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.rbegin(), AB.rend());
    multiset<ll> ans;
    for (int i = 0; i < Z; i++) {
        for (int j = 0; j < min(K, (int) AB.size()); j++) {
            ans.insert(C[i] + AB[j]);
        }
    }
    int count = 0;
    for (auto itr = ans.rbegin(); count < K; itr++) {
        cout << *itr << endl;
        count++;
    }
}


Measured memory_bytes: 149100
div = 10 ** 9 + 7
N, M = map(int, input().split())
h = [1] * (N + 1)
for _ in range(M):
    index = int(input())
    h[index] = 0

a = 1
b = h[1]
for i in range(2, N + 1):
    a, b = b, (a + b) * h[i] % div

print(b)


Measured memory_bytes: 3828
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	X := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		X[i] = nextInt(sc)
	}
	ans := 0
	for i := 0; i+1 < N; i++ {
		ans += min(A*(X[i+1]-X[i]), B)
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}


Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222







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


  ll r = 0, b = 0;
  cin >> n;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == 'R') r++;
    else b++;
  }
  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;



  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

v = []

for c in s:
    for i in range(26):
        if t[i] == c:
            v.append(t[i + n])

print(''.join(v))
exit(0)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	bool ans = false;
	if (A + B >= C) ans = true;
	string S = "Yes";
	if (ans == false) S = "No";
	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N, C;
	cin >> N >> C;
	vector<ll> s(N), t(N), c(N);
	vector<vector<bool> > time(C, vector<bool>(200000, 0));
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
		for (int j = s[i]*2-1; j < t[i]*2; j++) {
			time[c[i]][j] = true;
		}
	}

	int ans = 0;

	for (int i = 0; i < 200000; i++) {
		int tmp = 0;
		for (int j = 0; j < C; j++) {
			if (time[j][i])tmp++;
		}
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int N = 1010, W = 2e4+10;

int n;
struct blk {
  int w, s, v;
  bool operator<(const blk& o) {
    return w+s > o.w + o.s;
  }
};

blk bs[N];
// dp[j] = max value for available wgt w
ll dp[2][W];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> bs[i].w >> bs[i].s >> bs[i].v;
  }
  sort(bs, bs + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < W; j++) {
      dp[1][j] = dp[0][j];
    }
    for (int j = 0; j <= bs[i].s && j+bs[i].w < W; j++) {
      dp[1][j] = max(dp[0][j], dp[0][j+bs[i].w] + bs[i].v);
    }
    swap(dp[0], dp[1]);
  }
  cout << *max_element(dp[0], dp[0] + W) << nl;
  return 0;
}


Measured memory_bytes: 640
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

s = ns()
n = len(s)
t = s[:n//2]
u = s[n//2+1:]
if s == s[::-1] and t == t[::-1] and u == u[::-1]:
    print('Yes')
else:
    print('No')


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

using namespace std;

#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 rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vector<double> p(n);
	rep (i, n) {
	  int a;
	  cin >> a;
	  p[i] = (double)(a + 1) * a / 2 / a;
	}
	double res = 0, tmp;
	rep (i, k) res += p[i];
	tmp = res;
	FOR (i, k, n) {
	  tmp = tmp - p[i - k] + p[i];
	  res = max(res, tmp);
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4784
// http://www.igaris.com/math/c.pdf

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define NEXTP(x) next_permutation(x.begin(),x.end())
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

class comb{
	public:
	vector<ll> f,fr;
	ll MOD;
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin >> n >> k;
	if(n<k){
		cout << 0 << endl;
		return 0;
	}
	comb co;
	co.init(n+k,MOD);
	cout << co.nCr(n-1,k-1) << endl;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int a[N][N], b[N][N];
bool check(int x, int n)
{
    memset(b, -1, sizeof b);
    for (int i = 0; i < n; i++)
    {
        int msk = 1 << i;
        if (x & msk)
        {
            for (int j = 0; j < n; j++)
            {
                b[i][j] = a[i][j];
            }
        }
    }
    for (int j = 0; j < n; j++)
    {
        int p = 0, q = 0;
        for (int i = 0; i < n; i++)
        {
            if (b[i][j] == -1) continue;
            else if (b[i][j] == 0) p++;
            else q++;
        }
        if (p > 0 && q > 0) return false;
        int g = 1 << j & x;
        if (p && g) return false;
        else if (q && !g) return false;
    }
    return true;
}
int main()
{
    // freopen("in.txt", "r", stdin);
    int n, t, p, x;
    while (cin >> n)
    {
        memset(a, -1, sizeof a);
        for (int i = 0; i < n; i++)
        {
            cin >> t;
            for (int j = 0; j < t; j++)
            {
                cin >> p >> x; p--;
                a[i][p] = x;
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            if (check(i, n)) ans = max(ans, __builtin_popcount(i));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
M=int(temp[1])
ab=[[int(j)-1 for j in input().split()] for i in range(M)]

place=[[] for i in range(N)]

for i in range(M):
	place[ab[i][0]].append(ab[i][1])
	place[ab[i][1]].append(ab[i][0])

for i in range(N):
	print(len(place[i]))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

string rev(const string &s, int i, int j){
  string ret = s;
  for(int k = i; k <= j; ++k) ret[k] = s[j-k+i];
  return ret;
}

int main(){
  int N;
  cin >> N;
  string A(N,'0');
  for(int i = 0; i < N; ++i){
    int t;
    cin >> t;
    A[i] = '0' + t - 1;
  }
  string C(N, '0');
  for(int i = 0; i < N; ++i) C[i] = '0' + i;
  if(A == C){
    cout << 0 << endl;
    return 0;
  }
  queue<string> que;
  que.push(A);
  map<string, int> M;
  M[A] = 1;
  while(!que.empty()){
    string s = que.front();
    que.pop();
    for(int i = 0; i < N; ++i){
      for(int j = i+1; j < N; ++j){
        string t = rev(s, i, j);
        if(M[t] > 0) continue;
        M[t] = M[s] + 1;
        if(t == C){
          cout << M[t]-1 << endl;
          return 0;
        }
        if(M[t] < N/2){
          que.push(t);
        }
      }
    }
  }
  map<string, int> M_;
  M_[C] = 1;
  que.push(C);
  while(!que.empty()){
    string s = que.front();
    que.pop();
    for(int i = 0; i < N; ++i){
      for(int j = i+1; j < N; ++j){
        string t = rev(s, i, j);
        if(M_[t] > 0) continue;
        M_[t] = M_[s] + 1;
        if(M[t] > 0){
          cout << M[t] + M_[t] - 2 << endl;
          return 0;
        }
        if(M_[t] <= N/2) que.push(t);
      }
    }
  }
  cout << N-1 << endl;
  return 0;
}



Measured memory_bytes: 112948
#include <stdio.h>
int main(void){
    int H,W,h,w;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)
	break;
    for(h=0; h<H; h++){
    	for(w=0; w<W; w++)
    		putchar('#');
	putchar('\n');
    }
    putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
//#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;


int main(){
    ll n;
    cin>>n;
    ll maxz = -inf;
    ll minz = inf;
    ll maxw = -inf;
    ll minw = inf;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        maxz = max(maxz,x+y);
        minz = min(minz,x+y);
        maxw = max(maxw,x-y);
        minw = min(minw,x-y);
    }
    cout<<max(maxz-minz,maxw-minw)<<endl;
    return 0;
}

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

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

    while(a >= b && k > 0){
        b *= 2;
        k--;
    }
    while(b >= c && k > 0){
        c *= 2;
        k--;
    }
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll labs(ll x){
	if(x>=0)return x;
	else return -x;
}
int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x-i-1);
	}
	sort(a.begin(),a.end());
	ll mid = a[(n-1)/2];
	ll ans = 0;
	for(int i=0;i<n;i++){
		ans += labs(a[i]-mid);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    string s;int k;cin >> s >> k;
    set<string> v;
    rep(i, s.size()) rep(j, k+1) v.insert(s.substr(i,j));
    int count = 0;
    for(auto p:v) {
        if(k==count) {
            cout << p << endl;
            break;
        }
        count++;
    }
    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='B' && i!=0)
		{
			s.erase(s.begin()+i-1);
			i--;
		}
		if(s[i]=='B')
		{
			s.erase(s.begin()+i);
			i--;
		}
	}
	cout << s;
	return 0;
}

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

int main(){
  int N, K, X, Y, price = 0;
  cin >> N >> K >> X >> Y;
  if(K < N){
    price = X * K + Y * (N - K);
  }
  else{
    price = X * N;
  }
  cout << price << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int result = 1;
		
		int nVal = sc.nextInt();
		
		int kVal = sc.nextInt();
		
		for (int i = 0; i < nVal; i++) {
			if (result < kVal) {
				result *= 2;
			} else {
				result += kVal;
			}
		}
		System.out.println(result);
	}
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  while(n>=k){
    n/=k;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n= int(input())


def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
  
if digitSum(n) % 9 == 0:
  print('Yes')
  
else:
  print('No')

Measured memory_bytes: 11044
import fractions

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

if a % b == 0 or b <= c:
    print('NO')
else:
    r = a % b
    d = fractions.gcd(r, b)
    if d == 1:
        print('YES')
    elif c % d == 0:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5048
def main():
    import numpy as np
    from itertools import combinations
    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    ans = 10 ** 15
    for i in range(1, n + 1):
        for comb in combinations(l, i):
            y = np.array([x for _ in range(m)])
            tmp = 0
            for p in comb:
                tmp += p[0]
                y -= np.array(p[1:])
            s = sum([j <= 0 for j in y])
            if s == m:
                ans = min(ans, tmp)

    if ans == 10 ** 15:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
from copy import deepcopy
mod = 10**9 + 7

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a, key=lambda x: abs(x))[::-1]
a_plus = [int(x) for x in a if x > 0]
a_minus = [int(x) for x in a if x < 0]
a_abs = [abs(x) for x in a]

def calc(x):
    res = 1
    for i in x:
        res*=abs(i)
        res %= mod 
    return res

max_a = a[:k]
max_a_minus = []
max_a_plus = []
minus_cnt = 0

for i in max_a:
    if i == 0:
        print(0)
        sys.exit()
    if i < 0:
        minus_cnt += 1
        max_a_minus.append(i)
    else:
        max_a_plus.append(i)

if minus_cnt % 2 == 0:
    print(calc(max_a))
    sys.exit()

plus_cnt = k - minus_cnt

if len(a_minus) <= minus_cnt and len(a_plus) <= plus_cnt:
    ans = -float('inf')
elif len(a_minus) <= minus_cnt:
    if len(max_a_minus) == 0:
        ans = -float("inf")
    else:
        max_a_minus.pop()
        max_a_plus.append(a_plus[plus_cnt])
        ans = calc(max_a_plus + max_a_minus)
elif len(a_plus) <= plus_cnt:
    if len(max_a_plus) == 0:
        ans = -float("inf")
    else:
        max_a_plus.pop()
        max_a_minus.append(a_minus[minus_cnt])
        ans = calc(max_a_minus + max_a_plus)
else:
    flag1 = 1
    flag2 = 1
    if len(max_a_minus) == 0:
        ans1 = -float("inf")
        flag1 = 0
    if len(max_a_plus) == 0:
        ans2 = -float("inf")
        flag2 = 0
    if flag1:
        c1 = deepcopy(max_a_minus)
        c2 = deepcopy(max_a_plus)
        d1 = abs(c1.pop()); d2 = abs(a_plus[plus_cnt])
        c2.append(a_plus[plus_cnt])
        ans1 = calc(c1 + c2)
    if flag2:
        c3 = deepcopy(max_a_minus)
        c4 = deepcopy(max_a_plus)
        d3 = abs(c4.pop()); d4 = abs(a_minus[minus_cnt])
        c3.append(a_minus[minus_cnt])
        ans2 = calc(c3 + c4)
    if flag1 and flag2:
        ans = ans1 if d2*d3 > d1*d4 else ans2
    else:
        ans = max(ans1, ans2)

a_abs = a_abs[::-1]
ans2 = -calc(a_abs[:k])
if ans != -float("inf"):
    print(ans%mod)
else:
    print(ans2%mod)







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

int main() {
	string a; cin >> a;
	for (int i=0; i<a.length(); i++ ){
		if (i%2){
			if (a[i]=='R'){
				cout << "No"; exit(0);
			}
		}
		else {
			if (a[i]=='L'){
				cout << "No"; exit(0);
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int sum[108000];
Int n;
Int fact[108000];
Int a[108000];
Int res;

Int mod_pow(Int x, Int a, Int m = MOD){
  if(a == 0)return 1;
  Int res = mod_pow(x, a / 2, m);
  res = res * res % m;
  if(a % 2)res *= x;
  return res % m;
}

void init(){
  fact[0] = 1;
  for(int i = 1;i < 108000;i++)fact[i] = fact[i-1] * i % MOD;
}

Int inv(Int x){
  return mod_pow(x, MOD-2);
}

Int nCk(Int n, Int k){
  if(n < k)return 0;
  return fact[n] * inv(fact[k]) % MOD * inv(fact[n-k]) % MOD;
}
int main(){
  init();
  
  cin >> n;
  
  for(int i = 1;i < n;i++){
    sum[i] = nCk(n, i+1) % MOD * fact[i] %MOD * fact[n-i-1] % MOD;
    sum[i] += sum[i-1];
  }
  
  for(int i = 0;i < n;i++){
    cin >> a[i];
    res += (fact[n] + sum[i] + sum[n-i-1]) % MOD * a[i] %MOD;
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            int N = int.Parse(Console.ReadLine());
            int o = (N + 1) / 2;
            Console.WriteLine((double)o / N);

            
            
            //Console.Out.Flush();
        }

        struct Edge
        {
            public int _to;
            public long _distance;

            public Edge(int t, long d)
            {
                _to = t;
                _distance = d;
            }
        }


    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 13140
s = 0


def main():
    import sys
    from copy import copy
    input = sys.stdin.readline

    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for i in range(Q)]

    def dfs(num_list):
        if len(num_list) == N:
            global s
            tmp_s = 0
            for a, b, c, d in ABCD:
                if num_list[b-1] - num_list[a-1] == c:
                    tmp_s += d
            s = max(tmp_s, s)

            return
        else:
            for i in range(num_list[-1], M+1):
                dfs(num_list+[i])

    for i in range(1, M+1):
        dfs([i])
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9344
#include <stdio.h>
int main(void){
	
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if((i+j)%2==0)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
		
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
    return 0;
}

Measured memory_bytes: 3628
X,Y = map(int,input().split())

if (X+Y)%3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    ab = (X+Y)//3
    a = X - ab
    b = ab - a
    mod = 10**9+7
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 10**6+1
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ans = cmb(ab,b,mod)
    print(ans)

Measured memory_bytes: 123816
#include<bits/stdc++.h>
using namespace std;
int dp[1000000],l[111];
int main(){
	int n,k;
	cin>>n>>k;
	for (int i =1;i<=n;i++)
		cin>>l[i];
	for (int i = 1;i<=k;i++){
		for (int j =1;j<=n;j++){
			if (l[j]<=i)
				if (!dp[i-l[j]])
					dp[i]=1;
		}
	}
	if (dp[k])
		cout<<"First";
	else
		cout<<"Second";
}

Measured memory_bytes: 640
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    int m = 1e9;
    while (t--) {
        int n;
        cin >> n;
        int x = 100;
        int ans = 0;
        while (true) {
            x = x + x * 0.01;
            ans++;
            if (x >= n) {
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

const int B = 2500;

mint dp[55][55][2800];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= K; k++) {
        if (dp[i][j][k] == 0) continue;
        dp[i+1][j][k+j*2] += dp[i][j][k];
        if (j>0) dp[i+1][j-1][k+(j-1)*2] += j*j*dp[i][j][k];
        dp[i+1][j][k+j*2] += j*dp[i][j][k];
        dp[i+1][j][k+j*2] += j*dp[i][j][k];
        dp[i+1][j+1][k+(j+1)*2] += dp[i][j][k];
      }
    }
  }
  cout << dp[N][0][K] << endl;
}


Measured memory_bytes: 33408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main()
{
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
                ans += __gcd(i, __gcd(j, k));
        }
    }
    cout << ans << "\n";



}


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

int main() {
  long long h,w,x,y;
  cin>>h>>w>>x>>y;
  cout << h*w/2;
  cout << (h%2!=0&&w%2!=0? ".5":"")<<endl;
  cout << (h==x*2&&w==y*2?1:0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define NUM 200000
using namespace std;

int main(){
  int n,k;
  int a[NUM],b,max = 0;
  cin >> k >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    if(i > 0){
      b = a[i] - a[i - 1];
      if(max < b){
	max = b;
      }
    }
  }
  cout << min(k - max,a[n - 1] - a[0]) << endl;

  return 0;
}
      


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

using namespace std; 
 
#define int long long
#define M 1000000007 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin >> s;
	cout << s;
	if(s[s.length()-1]=='s'){
		cout << "es";
	}
	else{
		cout << "s";
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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 che(a,string) cout<<"("<<string <<")"<<"="<<(a)<<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi
文字列からllに変換　stoll(number)*/
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	//最大を取得するのと、最大が何番目かも取得
	int max1 = 0;
	int cmax1 = -1;
	int cmax2 = -1;
	rep(i,n){
		if(chmax(max1,a[i])) cmax1 = i;//これいけんのかな？
	}
	//2番目を取得する
	int max2 =0;
	rep(i,n){
		if(i!=cmax1){
			if(chmax(max2,a[i])) cmax2= i;
		}
	}
	rep(i,n){
		if(i!=cmax1) cout<< max1 <<endl;
		else cout<< max2 <<endl;
	}

}



Measured memory_bytes: 2432
N, M, C = map(int, input().split())
counter = 0
ans = 0
B = list(map(int, input().split()))

for k in range(N):
    A= list(map(int, input().split()))
    for i in range(M):
        ans = ans + A[i] * B[i]
    ans = ans + C
    if ans > 0:
        counter += 1
    ans = 0

print(counter)


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

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(in);
	
	void run() {
		int n = sc.nextInt();
		int y, m, d;
		int ans;
		int count;
		for (int i = 0; i < n; i++) {
			y = sc.nextInt();
			m = sc.nextInt();
			d = sc.nextInt();
			count = 0;
			for (int j = y+1; j < 1000; j++)
				if (j % 3 == 0)
					count++;
			ans = 195*(1000-y-1) + 5*count;
			
			if (y % 3 == 0){
				ans += 20*(10-m)+20-d;
			} else {
				count = 0;
				for (int j = m; j <= 10; j++)
					if (j % 2 == 0)
						count++;
				ans += 20*(10-m+1)-count;
				
				ans -= d;
				
			}
			
			out.println(ans+1);
			
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

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

struct Cake {
    int width, high, area, turn;
    Cake(int w, int h, int t) : width(w), high(h), area(w * h), turn(t) {}
    bool operator<(const Cake &a) const {
        if (turn != a.turn) return turn < a.turn;
        return area < a.area;
    }
};

bool cmp(const Cake &a, const Cake &b) { return a.area < b.area; }

int main() {
    int n, w, h;
    while (cin >> n >> w >> h) {
        if (n + w + h == 0) break;
        vector<Cake> v;
        v.push_back(Cake(w, h, 0));
        for (int i = 0; i < n; i++) {
            int p, s;
            cin >> p >> s;
            p--;
            sort(v.begin(), v.end());
            s = s % (v[p].width + v[p].high);
            if (s < v[p].width) {
                v.push_back(Cake(v[p].width - s, v[p].high, i + 1));
                v[p] = Cake(s, v[p].high, i + 1);
            } else {
                s -= v[p].width;
                v.push_back(Cake(v[p].width, v[p].high - s, i + 1));
                v[p] = Cake(v[p].width, s, i + 1);
            }
        }
        sort(v.begin(), v.end(), cmp);
        for (int i = 0; i <= n; i++){
            cout << v[i].area << " \n"[i == n];
        }
    }
    return 0;
}



Measured memory_bytes: 3088