akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Main main = new Main();
        main.solve();
    }
    
    private void solve(){
        
        Scanner sc = new Scanner (System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        boolean Takahashi = true;
        for (int index=0; index<K; index++){
            if (Takahashi){
                if (A%2==1){
                  A-=1;  
                } 
                B=B+(A/2);
                A/=2;
                Takahashi=false;
            } else {
                if (B%2==1){
                  B-=1;  
                } 
                A=A+(B/2);
                B/=2;
                Takahashi=true;
            }
        }
        
        System.out.print(A);
        System.out.print(" ");
        System.out.println(B);
    }
}

Measured memory_bytes: 22608
import math
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
A,B,C,D = map(int, input().split())
#A = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
if math.ceil(C/B) <= math.ceil(A/D):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9164
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n)]
#print(dp)
dp[0]=l[0]
#print(dp)
for i in range(1,n):
    for j in range(3):
        for k in range(3):
            if j!=k:
                dp[i][j]=max(dp[i][j],dp[i-1][k]+l[i][j])
print(max(dp[-1]))


Measured memory_bytes: 77912
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String lines = sc.nextLine();
		String[] line = lines.split(" ");
		int K = Integer.parseInt(line[0]);
		int N = Integer.parseInt(line[1]);

		lines = sc.nextLine();
		line = lines.split(" ");
		int[] A = new int[N];
		int distance = -1;

		for(int i = 0; i < A.length; i++) {
			A[i] = Integer.parseInt(line[i]);
		}

		int sum = 0;
		int Max = -1;
		for(int i = 0; i < N-1; i++) {
			distance = A[i+1] - A[i];
			if(Max < distance) {
				Max = distance;
			}else {

			}
		}
		distance = K - (A[N-1] - A[0]);
		if(Max < distance) {
			Max = distance;
		}

		System.out.println(K - Max);

	}
}


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

int main()
{
	int a,b;
	int i;	
	
	while(cin >> a >> b)
	{
		
		int n = 10;
		int i = 1;
		
		int s = a + b;
		
		while(1){
			double q = s / n;
			if (q == 0){
				cout << i << endl;
				break;
			}
			i++; n*=10;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void) {
	int x[10010], y[10010], i=0, tmp, a;
	while (1) {
		i++;
		cin >> x[i] >> y[i];
		if (x[i] > y[i]) {
			tmp = x[i];
			x[i] = y[i];
			y[i] = tmp;
		}
		if (x[i] == 0 && y[i] == 0) {
			break;
		}
	}
	a = i;
	for (a = 1; a <= i - 1; a++) {
		cout << x[a] << " " << y[a] << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
class RollingHash:
    def __init__(self, s, base, MOD):
        self.s = s
        self.l = l = len(s)
        self.base = base
        self.MOD = MOD
        self.h = h = [0]*(l + 1)
        for i in xrange(l):
            h[i+1] = (h[i] * base + ord(s[i])) % MOD
    def get(self, l, r):
        MOD = self.MOD
        return ((self.h[r] - self.h[l]*pow(self.base, r-l, MOD) + MOD)) % MOD
n, m = map(int, raw_input().split())
s = raw_input()
h1 = RollingHash(s, 13, 10**9+7)
h2 = RollingHash(s, 17, 10**9+7)
l = 0; r = 1
vs = set()
ans = 0
for i in xrange(m):
    q = raw_input()
    if q == "R++":
        r += 1
    elif q == "R--":
        r -= 1
    elif q == "L++":
        l += 1
    else:
        l -= 1
    v = (h1.get(l, r), h2.get(l, r))
    if v not in vs:
        ans += 1
        vs.add(v)
print ans

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

int main() {
  
 int N;
  cin >> N;
  
  int sum = 0;
  
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    
    sum += (r - l + 1);
  }
    
    cout << sum << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<unordered_map>

#define inf 0x3f3f3f3f
#define ii pair<int,int>
#define iii pair<int, ii>
#define ic pair<int, char>
#define icii pair<ic,ii>

#define pb push_back

using namespace std;
const int maxn = 5e3 + 10;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long i64;
 
int n;
int v[maxn]; 
using namespace std;

int mat[3][3];

bool check(int i, int j, int k ){
	bool a=  ((mat[0][1] - k) == (mat[0][2] -j)   && (mat[0][2]- j) == (mat[0][0] - i) );
	bool b= ((mat[1][1] - k) == (mat[1][2] -j) && (mat[1][2] -j) == (mat[1][0] - i) );
	bool c= ((mat[2][1]- k) == (mat[2][2] - j) && (mat[2][2] - j) == (mat[2][0] - i ));
	return ( a && b && c) ;
}

int main(){
	
 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
 for(int i= 0 ;i < 3;i++)
	for(int j= 0 ;j<3;j++)
		cin >> mat[i][j];
	
	for(int i = 0;i <=100 ;i++){
		for(int j= 0;j<=100;j++){
			for(int k =0 ;k<=100;k++){
				if ( check (i, j, k ) ){
					cout << "Yes\n";
					return 0;	
				}
			}
		}
	}
	cout<< "No\n";
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 q;
    cin >> q;
    REP(_,q){
        int64 a,b;
        cin >> a >> b;
        if(a > b)swap(a,b);
        if(a == b || a + 1 == b){
            ANS(2 * a - 2);
        }else{
            int64 c = sqrt(a*b) + 2;
            while(c * c >= a * b)c--;
            if(c * (c+1) >= a * b){
                ANS(2 * c - 2);
            }else{
                ANS(2 * c - 1);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    while(1) {
        int h;
        cin >> h;
        if(!h) break;
        vector<queue<int> > qq(5);
        vector<stack<int> > qqq(5);
        rep(i, h) {
            int a, s, d, f, g;
            cin >> a >> s >> d >> f >> g;
            qqq[0].push(a);
            qqq[1].push(s);
            qqq[2].push(d);
            qqq[3].push(f);
            qqq[4].push(g);
        }
        rep(j, h) {
            rep(i, 5) {
                qq[i].push(qqq[i].top());
                qqq[i].pop();
            }
        }

        int ans = 0;

        while(1) {
            int ssi = qq.size();
            bool hantei = true;
            bool up = false;
            
            vi ssum(5);
            rep(i, h) {
                vi num(10);
                rep(j, ssi) {
                    if(qq[j].front() == 1000) continue;
                    num[qq[j].front()]++;
                }
                int gg = -1;
                rep(j, 10) {
                    if(num[j] > 2) {
                        gg = j;
                        break;
                    }
                }
                if(!((qq[0].front() == qq[1].front() && qq[2].front() == qq[1].front()) || (qq[2].front() == qq[1].front() && qq[2].front() == qq[3].front()) || (qq[4].front() == qq[3].front() && qq[2].front() == qq[4].front()))) {
                    gg = -1;
                }
                if(gg != -1) {
                    ans += gg * num[gg];
                    if(num[gg] == 4 && (qq[1].front() != gg)) {
                        ans -= gg;
                        qq[0].push(qq[0].front());
                    }
                    if(num[gg] == 4 && (qq[3].front() != gg)) {
                        ans -= gg;
                        qq[4].push(qq[4].front());
                    }
                }
                rep(j, ssi) {
                    int bb = qq[j].front();
                    qq[j].pop();
                    if(gg != bb) {
                        qq[j].push(bb);
                    } else {
                        if(qq[j].size() == h) continue;
                        ssum[j]++;
                        up = true;
                    }
                }
            }
            rep(i, 5) {
                rep(j, ssum[i]) {
                    qq[i].push(1000);
                }
            }
            if(!up) hantei = false;
            if(!hantei) break;
        }

        
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t n; cin >> n;
	int64_t a, b; cin >> a >> b;
	int64_t ans = n / (a + b) * a;
	int64_t mod = n / (a + b) * (a + b);
	cout << ans + min(a, (n - mod)) << '\n';
	return 0;
}


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

int main(){
    int n, i, j, c = 0, a = 0, b = 0, d = 0;
    string s;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> s;
        for(j=0; j<s.length()-1; j++){
            if(s[j] == 'A' && s[j+1] == 'B'){
                c++;
            }
        }
        if(s[0] == 'B') b++;
        if(s[s.length()-1] == 'A') a++;
        if(s[0] == 'B' && s[s.length()-1] == 'A') d++;
    }
    if(d == a && d == b && d != 0){
        cout << c + d - 1;
    }else{    
        cout << c + min(a,b);
    }
    return 0;
}

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

int main(){
    ll k;
    cin>>k;
    ll a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

using namespace std;

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int n = sz(s);
    int k;
    cin >> k;
    for (int i = 0; i < n - 1; ++i) {
        if ((int)'z' - (int)s[i] + 1 <= k && s[i] != 'a') {
            k -= (int)('z') - (int)(s[i]) + 1;
            s[i] = 'a';
        }
    }
    s[n - 1] = ((int)(s[n - 1]) - (int)('a') + k) % 26 + 'a';
    cout << s << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100010;
int ans=1,sum=1,n,a[maxn];
void read(int &k){
	k=0; int f=1; char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while ('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]);
    for (int i=1;i<=n;i++) ans*=3;
    for (int i=1;i<=n;i++) if (!(a[i]&1)) sum*=2;
    printf("%d",ans-sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i) >> y.at(i);
  }
  
  vector<int> city(0);
  for(int i = 0; i < N; i++){
    city.push_back(i);
  }

  double sum = 0;
  int counter = 0;
  do{
    counter++;
    for(int i = 0; i < N - 1; i++){
      //city.at(i)番目の町とcity.at(i+1)番目の町の距離
      double dx = (double)x.at(city.at(i)) - (double)x.at(city.at(i + 1));
      double dy = (double)y.at(city.at(i)) - (double)y.at(city.at(i + 1));
      sum += sqrt(dx * dx + dy * dy);
    }
  }while(next_permutation(ALL(city)));
  cout << fixed << setprecision(10);
  cout << sum / (double)counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n;
    cin >> n;
    map<ll, ll> cnt;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll ans = 0;
    for (auto e: cnt) {
        if (e.first != e.second) {
            if (e.second > e.first) ans += e.second - e.first;
            else ans += e.second;
        }
    }

    cout << (ans) << endl;
}


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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin (),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;
	if(s == "AAA" || s == "BBB"){
		cout << "No";
	} else{
		cout  << "Yes";
	}
}








Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  int n;
  cin>>n;
  char s[n+2],t[n+2];
  cin>>s>>t;
  for(int i=0;i<n;i++)
  {
    cout<<s[i]<<t[i];
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[200000]={0};
    for(int i(0);i<n;i++){
        cin>>a[i];
    }
    long long araiguma(0);
    for(int i(1);i<n;i++){
        araiguma += a[i];
    }
    long long sunuke(a[0]);
    long long min_diff(abs(araiguma-sunuke));
    long long diff;
    for(int i(1);i<n-1;i++){
        araiguma -= a[i];
        sunuke += a[i];
        diff = abs(araiguma - sunuke);
        if(diff<min_diff)min_diff = diff;
    }
    cout<<min_diff<<endl;
    return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll h,w;
    cin >> h >> w;
    vector<string> s(h);
    rp(i,h) cin >> s[i];
    rp(i,h){
        rp(j,w){
            if(s[i][j]=='.'){
                int ctr=0;
                if(i-1>=0){
                    if(j-1>=0&&s[i-1][j-1]=='#') ctr++;
                    if(s[i-1][j]=='#') ctr++;
                    if(j+1<w&&s[i-1][j+1]=='#') ctr++;
                }
                if(i+1<h){
                    if(j-1>=0&&s[i+1][j-1]=='#') ctr++;
                    if(s[i+1][j]=='#') ctr++;
                    if(j+1<w&&s[i+1][j+1]=='#') ctr++;
                }
                if(j-1>=0&&s[i][j-1]=='#') ctr++;
                if(j+1<w&&s[i][j+1]=='#') ctr++;
                s[i][j]=(char)('0'+ctr);
            }
            
        }
    }
    rp(i,h){
        print(s[i]);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int mod = 1000000007;

inline LL qpow(LL a, LL b)
{
	LL res = 1;
	while (b)
	{
		if (b & 1) res = (res * a) % mod;
		a = a * a % mod, b >>= 1;
	}
	return res % mod;
}

const int M=1e9+7;
int n,m;
LL ans=1,f[1000005]={1},g[1000005]={1};
LL ksm(LL x,LL y)
{
    LL s=1;
    while(y)
	{
        if(y&1)s=(s*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return s;
}
LL work(int x,int y)
{
    return f[x]%M*g[y]%M*g[x-y]%M;
}
int main(){
	cin >> n >> m;
    for(int i=1;i<=n;i++)
{
        f[i]=f[i-1]*i%M;
        g[i]=ksm(f[i],M-2);
    }
    int k=min(n-1,m);
    for(int i=1;i<=k;i++)
{
        LL x=work(n,i);
        LL y=work(n-1,i);
        ans=(ans+x*y%M)%M;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        string[] ss = Console.ReadLine().Split().ToArray();
        int n = int.Parse(ss[0]);
        int m = int.Parse(ss[1]);

        int[,] A = new int[n, m];
        int[] b = new int[m];

        for (int i = 0; i < n; i++)
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 0; j < array.Length; j++)
            {
                A[i, j] = array[j];
            }
        }

        for (int i = 0; i < m; i++)
        {
            b[i] = int.Parse(Console.ReadLine());
        }

        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
               sum += A[i, j] * b[j];
            }
            Console.WriteLine(sum);
            sum = 0;
        }
    }
}


Measured memory_bytes: 18376
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll x,c=0,ans=0;
    cin>>x;
    c=x/500;
    ans+=(c*1000);
    x-=(c*500);
    c=x/5;
    ans+=(c*5);
    cout<<ans<<endl;


}
return 0;
}

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

using Weight = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, int weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool operator < (const Edge &e, const Edge &f){ return e.weight > f.weight; }
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
    Edges T; Weight total = 0; vector<int> vis(g.size());
    priority_queue<Edge> q;
    q.emplace(-1, r, 0);
    while (!q.empty()) {
        Edge e = q.top(); q.pop();
        if (vis[e.dst]) continue;
        vis[e.dst] = true;
        total += e.weight; if(e.src != -1) T.push_back(e);
        for(auto& f : g[e.dst]) if (!vis[f.dst]) q.push(f);
    }
    return make_pair(total, T);
}

int main(){
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int x;
            cin >> x;
            if(x != -1) g[i].emplace_back(i,j,x);
        }
    }
    cout << prim(g).first << endl;
}

Measured memory_bytes: 3208
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

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

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

    int N = 100000;
    char *S = new char[N];
    cin >> S;
    for (N = 0; S[N] && N < 100000; ++N);

    char *s0 = new char[N];
    char *s1 = new char[N];

    s0[0] = '0';
    s1[0] = '1';
    for (int i = 1; i < N; ++i)
    {
        s0[i] = (s0[i - 1] == '0') ? '1' : '0';
        s1[i] = (s1[i - 1] == '0') ? '1' : '0';
    }

    int ret0 = 0; int ret1 = 0;
    for (int i = 0; i < N; ++i)
    {
        ret0 += (S[i] != s0[i]) ? 1 : 0;
        ret1 += (S[i] != s1[i]) ? 1 : 0;
    }

    cout << MIN(ret0, ret1) << "\n";

    return 0;
}



Measured memory_bytes: 512
n = int(input().strip())
A = list(map(int, input().strip().split(" ")))

def solver(_sign):
    s = A[0]
    count = 0

    if _sign:
        if s <= 0: # head is positive
            count += abs(s) + 1
            s = 1
    else:
        if s >= 0: # head is negative
            count += abs(s) + 1
            s = -1

    for a in A[1:]:
        prev = s
        sign = prev > 0
        s += a
        if s == 0:
            count += 1
            if sign: # previous is positive
                s = -1
            else: # prev is negative
                s = 1
        elif sign == (s > 0): # previous and current have the same sign
            count += abs(s)+1
            if s > 0:
                s = -1
            else:
                s = 1
        else:
            pass
    return count

print(min(solver(True), solver(False)))

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

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for(int r = 0; r * R <= N; r++){
    for(int g = 0; r * R + g * G <= N; g++){
      int resid = N - (r * R + g * G);
      if(resid % B == 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << v.back() - v[0] << endl;
}




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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int fast_exp(int b,int e)
{
    int ans = 1;
    while(e)
    {
        if(e&1) ans = ans * b;
        b = b * b;
        e>>=1;
    }
    return ans;
}

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int ans = k*fast_exp(k-1,n-1);
    cout<<ans<<"\n";
    return 0;
}

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

int main()
{
    int N, a, b, c, d;

    cin >> N;

    a = N / 1000;
    b = (N - 1000 * a) / 100;
    c = (N - 1000 * a - 100 * b) / 10;
    d = N - 1000 * a - 100 * b - 10 * c;

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


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    LL x;
    cin >> x;
    vector<LL> a(N);
    LL ans = 0;

    cin >> a[0];
    LL eat = max(a[0] - x, 0ll);
    a[0] -= eat;
    ans += eat;

    REP1(i, N - 1)
    {
        cin >> a[i];
        eat = max(a[i] + a[i - 1] - x, 0ll);
        a[i] -= eat;
        ans += eat;
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, r[200000];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> r[i];
	int maxv = r[1] - r[0], minv = r[0];
	for (int j = 1; j < n; j++) {
		maxv = max(maxv, r[j] - minv);
		minv = min(minv, r[j]);
	}
	cout << maxv << endl;
}


Measured memory_bytes: 3872
import java.util.*;

// ABC 32-C
// http://abc032.contest.atcoder.jp/tasks/abc032_c
 
public class Main {

	static int n;
	static ArrayList[] map;
	static boolean answerFound = false;
	static ArrayList<Integer> answer;

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		int m = in.nextInt();
		
		map = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			map[i] = new ArrayList<Integer>();
		}
		
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			
			map[a].add(b);
			map[b].add(a);
		}

		int index = 0;
		while (map[index].size() == 0) {
			index++;
		}
		int node1 = index;
		int node2 = (int) map[index].get(0);
//		System.out.printf("node1: %d, node2: %d\n", node1 + 1, node2 + 1);
		
		int[] visited = new int[n];
		ArrayList<Integer> path = new ArrayList<Integer>();
		visited[node1] = 1;
		visited[node2] = 1;
		path.add(node1);
		dfs(node1, path, visited, true);
		path.add(node2);
//		for (int i = 0; i < path.size(); i++) {
//			System.out.printf("%d ", path.get(i) + 1);
//		}
//		System.out.println();
		dfs(node2, path, visited, false);
		
		System.out.println(path.size());
		for (int i = 0; i < path.size(); i++) {
			System.out.printf("%d ", path.get(i) + 1);
		}
		System.out.println();
	}
	
	public static void dfs(int node, ArrayList<Integer> path, int[] visited, boolean insertFront) {
		for (int i = 0; i < map[node].size(); i++) {
			int next = (int) map[node].get(i);
			
			if (visited[next] == 0) {
				visited[next] = 1;
				if (insertFront) {
					path.add(0, next);
				} else {
					path.add(next);
				}
				dfs(next, path, visited, insertFront);
				break;
			}
		}
	}
}

Measured memory_bytes: 119956
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
  int n;
	cin>>n;
  vector<int> a(n); rep(i, n) cin>>a[i], a[i]--;
  for(int i = 0, j = 0; i < 2*n; i++,j=a[j]){
    if(j==1){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
	return 0;
}


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

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

  long long n, ans = 1;
  cin >> n;
  for(int i = 1; i <= n; i++)
    ans = ans * i % 1000000007;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(x: int, y: int):
    a = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]
    print(YES if a[x] == a[y] else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//
// Created by 李青坪 on 2018/10/23.
//

#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

struct Node{
    int value;
    Node *parent, *left, *right;
};
Node *head, *NIL;

void insertNode(int value){
    Node *x = head;
    Node *y = NIL;  //表示父节点
    while (x != NIL){
        y = x;
        if (value < x->value){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    Node *z = new(Node);
    z->value = value;
    z->left = NIL;
    z->right = NIL;
    if (y != NIL){
        if (z->value < y->value){
            y->left = z;
        }
        else{
            y->right = z;
        }
        z->parent = y;
    } else{
        head = z;
    }
}

void inOrder(Node *x){
    if (x != NIL){
        inOrder(x->left);
        printf(" %d", x->value);
        inOrder(x->right);
    }
}

void preOrder(Node *x){
    if (x != NIL){
        printf(" %d", x->value);
        preOrder(x->left);
        preOrder(x->right);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    head = NIL;
    char command[10];
    int value;
    for (int i = 0; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i'){
            scanf("%d", &value);
            insertNode(value);
        } else{
            inOrder(head);
            printf("\n");
            preOrder(head);
            printf("\n");
        }
    }
    return 0;
}
/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
 */


Measured memory_bytes: 26612
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
LL n;
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	bool bk = true;
	LL zx = 0x7fffffff, ans = 0;
	for(i = 1; i <= n; i++){
		LL x, y;
		scanf("%lld%lld", &x, &y);
		ans += x;
		if(x > y && y < zx) zx = y;
		if(x != y) bk = false;
	}
	if(bk == true) printf("0\n");
	else printf("%lld\n", ans-zx);
	return 0;
}

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

int main(){
    int N, ans = 0, find_num=1000, num;
    cin >> N;
    
    for (int i = N; (N+1) / 2 <= i; i--){
        num = i;
        int cnt = 0;
        while (num % 2 == 0) {
            num /= 2;
            cnt++;
        }
        if (ans <= cnt) {
            ans = cnt;
            find_num = i;
        }
    }
    cout << find_num << endl;
}


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

int main() {

  int N = 0, ans = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    ans = ans + r + 1 - l; // ansに差分を足していく
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
 int N,x=0,y=0;
 cin>>N;
 char S[N];
 
 for(int k=0;k<N;++k)
 {cin>>S[k];
 }
 
 for(int i=0;i<N;++i)
  {
      if(S[i]=='I')
       x++;
       if(S[i]=='D')
       x--;
       
       if(x>=y)
       y=x;
       
  }
  cout<<y;
    
    
}

Measured memory_bytes: 256
from math import floor, ceil
a, b = map(int, input().split())

x = ceil(a / 0.08)
y = ceil(b / 0.1)

x, y = min(x, y), max(x, y)
for i in range(x, y + 1):
    if floor(i * 0.08) == a and floor(i * 0.1) == b:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
int A,B,C,K;
  cin>>A>>B>>C;
  cin>>K;
int ans=0;
int flag=0;
while(flag==0){
if(A>=B){
  B=B*2;
  ans++;
  }
else {
  if(B>=C){
  C=C*2;
    ans++;
    }
  else {flag=1;}
  }
  
}
  if(ans<=K){
     cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct compare{
    bool operator()(pair<pair<int,int>,ll> a,pair<pair<int,int>,ll> b)
    {
        int x = a.first.first+a.first.second;
        int y = b.first.first+b.first.second;
        return (x)<(y);
    }
};
int n;
int main() {
    priority_queue<pair<pair<int,int>,ll>,vector<pair<pair<int,int>,ll>>,compare> pq;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a,b;
        ll c;
        cin>>a>>b>>c;
        pq.push({{a,b},c});
    }
    ll dp[n+1][20005];
    memset(dp,0,sizeof dp);
    int i=1;
    while(!pq.empty())
    {
        pair<pair<int,int>,ll> x = pq.top();
        int w,s;
        ll val;
        w = x.first.first;
        s = x.first.second;
        val = x.second;
        for(int j=w;j<20005;j++)
        {
            int fs = min(s,j-w);
            dp[i][fs] = max(dp[i][fs],dp[i-1][j]+val);
        }
        for(int j=0;j<20005;j++)
        dp[i][j] = max(dp[i][j],dp[i-1][j]);
        pq.pop();
        i++;
    }
    ll ans=0;
    for(int i=0;i<20005;i++)
    ans = max(ans,dp[n][i]);
    cout<<ans;
}

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

int main()
{
    string a, b;
    cin >> a >> b;
    string c;
    if(a.length() + 1 == b.length())
    {
        for(int i = 0; i < a.length(); i++){c += b.at(i);}
        //cout << c;
        if(a == c)
        {
            cout << "Yes";
        }
        else {cout << "No";}
    }
    else{cout << "No";}
    //cout << c;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int N, M;
int X, Y;
int x[105], y[105];

int main(void)
{
	cin>> N >> M;
	cin >> X >> Y;
	for(int i = 0; i < N; i++) cin >> x[i];
	for(int i = 0; i < M; i++) cin >> y[i];
	x[N] = X, y[M] = Y;
	sort(x, x+N+1);
	sort(y, y+M+1);
	
	if(x[N] < y[0]) cout << "No War" << endl;
	else cout << "War" << endl;
	
	return 0;
}

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

using namespace std;

int main(){
 int n;
  cin >> n;
  vector<long> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  
  sort(a.begin(),a.end());
  
  int res=0;
  for(int i=0;i<n;){
   int  cnt=0;
   while(i<n&&a[i+cnt]==a[i]) cnt++; 
    res+=(cnt%2);
    i+=cnt;
  } 
   cout << res << endl; 
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    class P
    {
        public int index;
        public List<int> adj;
        public Dictionary<int, long> weights;
        public long Weight;
        public P(int index)
        {
            this.index = index;
            adj = new List<int>();
            weights = new Dictionary<int, long>();
            Weight = long.MaxValue;
        }
    }
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ps = Enumerable.Range(0, nm[0]).Select(v => new P(v)).ToArray();
        for(var i = 0; i < nm[1]; i++)
        {
            var inp = Input.ar;
            ps[inp[0] - 1].adj.Add(inp[1] - 1);
            ps[inp[0] - 1].weights[inp[1] - 1] = -inp[2];
        }
        var bo = new bool[nm[0]];
        ps[0].Weight = 0;
        for (var i = 0; i < nm[0]; i++)
            foreach (var p in ps)
                foreach (var ad in p.adj)
                    if(p.Weight!=long.MaxValue)
                    ps[ad].Weight = Min(ps[ad].Weight, p.Weight + p.weights[ad]);
        var ans = -ps[nm[0] - 1].Weight;
        foreach (var p in ps)
            foreach (var ad in p.adj)
            {
                if (p.Weight == long.MaxValue) continue;
                if (!bo[ad])
                    bo[ad] = bo[p.index];
                if (ps[ad].Weight > p.Weight + p.weights[ad])
                {
                    ps[ad].Weight = p.Weight + p.weights[ad];
                    bo[ad] = true;
                }
            }
        WriteLine(bo[nm[0] - 1] ? "inf" : ans.ToString());
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

int main() {
	long long int n,x,ans=0,a,b,c;
	cin>>n>>x;
	ans=n;
	a=x;
	b=n-x;
	

	while((a>0)&&(b>0)){
			if(a>b){
				swap(a,b);
			}
			ans+=b/a*a*2;
			c=b%a;
			b=a;
			a=c;
	}
	ans-=b;
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i,j,k,a,f[33]={},ans=0;
  
  cin >> n >> m;
  for (i=0;i<n;i++){
    cin >> k;
    for (j=0;j<k;j++){
      cin >> a;
      f[a-1]++;
    }
  }
  
  for (i=0;i<m;i++){
    if (f[i]==n) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(void){
  string s;
  cin >> s;
  char alphabet[26] = {};
  int i;
  for(i = 0; i < (int)s.length(); i++){
    alphabet[s[i] - 'a'] = 1;
  }
  for(i = 0; i < 26; i++){
    if(!alphabet[i]){
      printf("%c\n", 'a'+i);
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        x: usize
    };
    let div: usize = x / 11;
    let diff: usize = x % 11;
    if diff == 0 {
        println!("{}", div * 2);
    } else if diff <= 6 {
        println!("{}", div * 2 + 1);
    } else {
        println!("{}", div * 2 + 2);
    }
}


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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

vector<vector<vector<double>>> dp;
int N;

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) return 0;

	double res = 0.0;
	if (i > 0) res += rec(i-1, j, k) * i;
	if (j > 0) res += rec(i+1, j-1, k) * j;
	if (k > 0) res += rec(i, j+1, k-1) * k;
	res += N;
	res /= (i + j + k);

	return dp[i][j][k] = res;
}


int main(void) {

	cin >> N;

	vector<int> state(3);
	
	int num;
	REP(i, N) {
		cin >> num;
		state[num - 1]++;
	}

	int I, J, K;
	I = state[0];
	J = state[1];
	K = state[2];

	dp.assign(N+1, vector<vector<double>>(N+1, vector<double>(N+1, -1)));
	dp[1][0][0] = N;

	cout << setprecision(10) <<rec(I, J, K) << endl;

	return 0;
}

Measured memory_bytes: 219008
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    string s;
    s = input();
    // writeln(s);
    string key;
    key = "keyence";
    // riteln(s[0 .. 7]);
    // if (s[0 .. 7] == key)
    // {
    //     writeln("YES");
    //     return;
    // }
    // writeln(s[$ - 7 .. $]);
    // if (s[$ - 7 .. $] == key)
    // {
    //     writeln("YES");
    //     return;
    foreach (i; 0 .. key.length)
    {
        string tmp = s[0 .. i] ~ s[$ - (7 - i) .. $];
        if (tmp == key)
        {
            writeln("YES");
            return;
        }

    }
    writeln("NO");

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


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

struct node {
	int id = 0;
	int l = -1;
	int r = -1;
	int parent = -1;
	int name = 0;
	int degree = 0;
	int depth = 0;
	int height = 0;
	int sibling = -1;
};

node a[25];

void soya(node b, int zero) {
	a[b.id].depth = zero;
	if (b.l != -1) {
		soya(a[b.l], zero + 1);
	}
	if (b.r != -1) {
		soya(a[b.r], zero + 1);
	}
}

int niri(node d) {
	int h1 = 0;
	int h2 = 0;
	if (d.l != -1) {
		h1 = niri(a[a[d.id].l]) + 1;
	}
	if (d.r != -1) {
		h2 = niri(a[a[d.id].r]) + 1;
	}
	a[d.id].height = d.height + max(h1,h2);
	return max(h1,h2);
}

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

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		a[num].id = num;
		cin >> a[num].l;
		cin >> a[num].r;
		if (a[num].l != -1) {
			a[num].degree++;
			a[a[num].l].parent = num;
			a[a[num].l].sibling = a[num].r;
		}
		if (a[num].r != -1) {
			a[num].degree++;
			a[a[num].r].parent = num;
			a[a[num].r].sibling = a[num].l;
		}
		if (a[num].l == -1 && a[num].r == -1) {
			a[num].name = 1;
		}
	}
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (a[i].parent == -1) {
			x = i;
			a[i].name = -1;
		}
	}

	soya(a[x], 0);
	int t = niri(a[x]);

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << a[i].parent << ", sibling = " << a[i].sibling << ", degree = " << a[i].degree << ", depth = " << a[i].depth << ", height = " << a[i].height << ", ";
		if (a[i].name == -1) cout << "root" << endl;
		else if (a[i].name == 1) cout << "leaf" << endl;
		else cout << "internal node" << endl;
	}

	return 0;
}




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

ll check(int x){
  ll num=x,cnt=0;
  while(x)x/=10,cnt++;
  ll sum=0,a=9,add=1,b=0;
  while(--cnt>0){
    sum+=a*add;
    a*=10;
    add++;
    b=b*10+9;
  }
  sum+=(num-b)*add;
  return sum;
}

ll bynary_search(){
  ll l=0,r=(1e9);
  while(l<r){
    ll m=(l+r)/2;
    if(check(m)>=n)r=m;
    else l=m+1;
  }
  return l-1;
}

string itos(ll x){
  string res;
  while(x)res+=(x%10+'0'),x/=10;
  reverse(res.begin(),res.end());
  return res;
}

void solve(){
  ll r=bynary_search(),x=r+1;
  string s;
  rep(i,k)s+=itos(x++);
  cout<<s.substr(n-check(r)-1,k)<<endl;
}

int main(){
  while(1){
    cin>>n>>k;
    if(!n&&!k)break;
    solve();
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(auto iter=begin(p);iter!=end(p);iter++){
    cin >> *iter;
  }
  
  auto min = 530000;
  auto count =0;
  for(auto i=0;i<n;i++){
    if(p.at(i)<min){
      count++;
      min = p.at(i);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 202020
int comp(const void *a,const void *b){
    int c = *(int *)a;
    int d = *(int *)b;
    return c - d;
}
int rcomp(const void *a,const void *b){
    int c = *(int *)a;
    int d = *(int *)b;
    return d - c;
}
int main(void){
    int n; ll k;
    cin >> n >> k;
    //int a[MAX],f[MAX];
    vector <ll> a(n),f(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l=-1,r=1000000000000,mid;
    while(l+1<r){
        mid = (l+r)/2;
        ll sum = 0;
        for(int i=0;i<n;i++){
            if(a[i]*f[i]>mid){
                sum += (a[i]*f[i]+f[i]-1-mid)/f[i];
            }
        }
        if(sum <= k) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 3328