akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define int long long

signed main(){

  int H, W;
  int N;
  vector<int> A;
  vector<vector<int>> ans;

  cin>>H>>W;

  cin>>N;

  A.resize(N);

  ans.resize(H+1);
  
  for(int i = 0, j = 0; i < N; i++){
    
    cin>>A[i];
    
    while(A[i]){
      
      if(ans[j].size() == W) j++;
      
      ans[j].push_back(i+1);
      
      A[i]--;
    }
  }

  for(int i = 0; i < H; i+=2){ //cout<<"A"<<endl;
    for(int j = 0; j < W; j++){
      if(j) cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
    
    //cout<<i+1<<" H = "<<H<<endl;
    
    if(i+1 >= H) break;
    // cout<<"B"<<endl;
    for(int j = 0; j < W; j++){
      if(j) cout<<" ";
      cout<<ans[i+1][W-j-1];
    }
    cout<<endl;
  }

  return 0;
}

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

int main (){
    int w,h;
    cin >> w >> h;
    vector< pair<ll,int> > vp;
    for(int i=0;i<w;i++){
        ll p;
        cin >> p;
        vp.push_back(make_pair(p,0));
    }
    for(int i=0;i<h;i++){
        ll q;
        cin >> q;
        vp.push_back(make_pair(q,1));
    }
    sort(vp.begin(),vp.end());
    int pos = 0;
    ll ans = 0;
    while(1){
        if(w==0&&h==0)
            break;
        if(vp.size()<=pos) break;
        if(vp[pos].second == 0&&w>=1){
            w--;
            ans += vp[pos].first*(h+1);
        }
        if(vp[pos].second == 1&&h>=1){
            h--;
            ans += vp[pos].first*(w+1);
        }
        pos++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6512
N = int(input())
x = 0
result = False
while x < 100:
    d = 0
    sum = 0
    while sum <= N:
        sum = 4*x + 7*d
        if sum == N:
            result = True
            break
        d += 1
    if result == True:
        break
    x += 1

if result == True:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <istream>
#include <sstream>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	cout << N-K+1 << endl;
}


Measured memory_bytes: 256
S = str(input())
S = list(S)
# print(S)
memory = [S[0]]
now=[]
count = 1
for i in S[1:]:
    now+=i
#     print("memory:{}, now:{}".format(memory, now),end="")
    if now==memory:
        print()
    else:
#         print("count")
        memory=[]
        memory+=now
        count+=1
        now=[]

        
print(count)

Measured memory_bytes: 6948
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%2==0 || b%2==0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
		return;
	}
}

Measured memory_bytes: 22228
n,l = map(int, input().split())
#味はl ~ l+n-1
#全部で作った味は n*(l + (n-1)/2) 
res=n*l + n*(n-1)//2
if 0 < l:
    res-=l
elif l+n-1<0:
    res-=(l+n-1)
print(res)

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

int main() {
  int N; cin>>N;
  vector<int>L(N*2);
  for (int i=0; i<N*2;++i) cin>>L[i];
  sort (L.begin(),L.end());
  int ans =0;
  for(int i=0; i<N*2;i +=2) ans +=L[i];
  cout<<ans<<endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
    int n;
    cin>>n;
    int sum=0;

    FOR(i,1,n+1){
        if(i<10){
            sum++;
        }
        if(i<1000 && i>=100){
            sum++;
        }
        if(i<100000 && i>=10000){
            sum++;
        }
    }
    cout << sum << endl;
    
}
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int,input().split())
P = list(map(int,input().split()))

ex = [0]*N

for i,p in enumerate(P):
    ex[i] = (p+1)*(1/2)

ex = [0] + ex
cumsum = np.cumsum(ex)

B = cumsum[K:] - cumsum[:-K]

print(np.max(B))

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

using namespace std;

int main() {
	string str;
	while (cin >> str, str != "#") {
		vector<string> ans;

		int n = str.size();
		for (int i = 0; i < (1 << n); ++i) {
			string s = str;
			bool f = true;
			for (int j = 0; j < n; ++j) {
				if (i & (1 << j)) {
					if (s[j] == 'z') {
						f = false;
					}
					else {
						++s[j];
					}
				}
			}
			if (!f) continue;

			bool ff = true;
			bool isUsed[26] = {0};
			for (int j = 0; j < n; ++j) {
				if ( !isUsed[(int)(s[j]-'a')] && s[j] != 'a' ) {
					isUsed[(int)(s[j]-'a')] = true;
					if (s[j]-1 != str[j]) {
						ff = false;
						break;
					}
				}
				else {
					if (s[j] != str[j]) {
						ff = false;
						break;
					}
				}
			}

			if (ff) ans.push_back(s);
		}

		sort(ans.begin(), ans.end());

		cout << ans.size() << endl;
		if (ans.size() > 10) {
			for (int i = 0; i < 5; ++i) {
				cout << ans[i] << endl;
			}
			for (int i = ans.size()-5; i < ans.size(); ++i) {
				cout << ans[i] << endl;
			}
		}
		else {
			for (int i = 0; i < ans.size(); ++i) {
				cout << ans[i] << endl;
			}
		}
	}
}

Measured memory_bytes: 2352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1e9+7;

int main() {
    ll N,r=1;
    cin >> N;

    rep(i,N) {
        r *= i+1;
        r %= MOD;
    }

    cout << r << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    Vec v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(ALL(v));
    Yes((v[0]==v[1]&&v[1]!=v[2] )|| (v[0]!=v[1]&&v[1]==v[2] ));
    return  0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int a,b,c,d; cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b; if(c<=0) {puts("Yes"); return 0;}
		a-=d; if(a<=0) {puts("No"); return 0;}
		
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int A,B,x;
int main(){
	cin>>x>>A>>B;
	if(abs(x-A)<abs(x-B)){
		cout<<"A"<<endl;
	}else if(abs(x-B)<abs(x-A)){
		cout<<"B"<<endl;
	}
	return 0;
		
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846

int main() {FIN
    
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << (PI * r * r) << " " << (2 * PI * r) << "\n";
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, T;
  cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> ind(N);
  iota(ind.begin(), ind.end(), 0);
  sort(ind.begin(), ind.end(), [&](int a, int b) { return A[a] < A[b]; });
  vector<int> dp(T + 1, 0);
  for (int i : ind) {
    for (int t = T - 1; t > -1; t--) {
      dp[min(T, t + A[i])] = max(dp[min(T, t + A[i])], dp[t] + B[i]);
    }
  }
  cout << dp[T] << '\n';
  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, W;
char s[100][100];

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

    cin >> H >> W;
    FOR(i, 1, H + 1) FOR(j, 1, W + 1) cin >> s[i][j];
    FOR(i, 1, H + 1) FOR(j, 1, W + 1) {
        if(s[i][j] == '#') {
            if(s[i][j + 1] == '.' && s[i][j - 1] == '.' && s[i + 1][j] == '.' && s[i - 1][j] == '.') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = n;
    if(n >= b-1) x = b-1;
    ll ans = a*(x%b)/b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
<?php
fscanf(STDIN, "%d", $N);
$Sn = trim(fgets(STDIN));
$Snary = explode(" ", $Sn);

$temp = [];
foreach ($Snary as $colore) {
  if (! in_array($colore, $temp, true)) {
    $temp[] = $colore;
  }
}

echo count($temp) === 4 ? 'Four' : 'Three';
?>

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> 
#define pal pair < ll, ll> 
#define vi vector <int> 
#define vl vector < ll > 
#define vpai vector < pii > 

const ll mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 556239;

ll fact[sze];
ll inv[sze];

ll fermat(ll x,ll y,ll p){
    // if(b==0) return 1;
    // if(b%2==0) return fermat(a*a%mod,b/2,mod)%mod;
    // return (a%mod*fermat(a*a%mod,b/2,mod)%mod)%mod;
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
}

void init(){
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<sze;i++){
        fact[i]=(fact[i-1]*i)%mod;
        inv[i]=(mod+fermat(fact[i],mod-2,mod))%mod;
    }
}

ll choose(int n,int r){
    if(n<r||n<0||r<0) return 0;
    if(r==0) return 1;
    return (fact[n]*(inv[r]*inv[n-r]%mod))%mod;
}

void solve() {
    int n,m;
    cin>>n>>m;
    ll ans=0;
    ll curr=1;
    for(int i=0;i<=n;i++){
        ans=(ans+curr*(choose(n,i)%mod*choose(m-i,n-i)%mod*fact[n-i])%mod+mod)%mod;
        ans=(ans+mod)%mod;
        curr=curr*(-1);
    }
    cout<<(ans*choose(m,n)%mod*fact[n]%mod+mod)%mod<<endl;
    //cout<<choose(5,2)<<endl;
}

int main() {
    IOS;
    init();
    int t = 1;
    // cin >> t;
    while (t--) {
       solve();
    }

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<char> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }
    string answer = "Three";
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == 'Y')
        {
            answer = "Four";
            break;
        }
    }
    cout << answer << endl;
}

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

using namespace std;

template<typename T = int>
vector<T> dijkstra(const vector<vector<pair<int, T>>> &G, int st, const T inf) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
    pq.push({0, st});
    vector<T> dist(G.size(), inf);
    dist[st] = 0;
    while (!pq.empty()) {
        const auto now = pq.top();
        pq.pop();
        for (auto nxt : G[now.second]) {
            const T nextCost = now.first + nxt.second;
            if (dist[nxt.first] <= nextCost) {
                continue;
            }
            dist[nxt.first] = nextCost;
            pq.push(make_pair(nextCost, nxt.first));
        }
    }
    return dist;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, long long>>> Graph(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--;
        b--;
        Graph[a].emplace_back(make_pair(b, c));
        Graph[b].emplace_back(make_pair(a, c));
    }
    int q, k;
    cin >> q >> k;
    k--;
    const auto dist = dijkstra(Graph, k, (long long) 1e18);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--;y--;
        cout << dist[x] + dist[y] << endl;
    }
}


Measured memory_bytes: 11120
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    bool ans = false;
    for (int c = 0; c <= 50; c++) {
        for (int t = 0; t <= 25; t++) {
            if (c + t == X && 2 * c + 4 * t == Y) {
                ans = true;
            }
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3636
n = int(input())
aa = list(map(int, input().split()))
total_odd = sum(aa[1::2])
total_eve = sum(aa[0::2])
tmp = total_eve - total_odd
outs = [tmp]
for i in range(1,n):
    tmp = 2*aa[i-1] - tmp
    outs.append(tmp)
print(' '.join(list(map(str,outs))))

Measured memory_bytes: 19144
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define int long long
using namespace std;

double n,a;
signed main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        a+=1.0/t;
    }
    printf("%6lf\n",1/a);
    
}





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

long long calc_target(long long x)
{
    long long target = 1;
    long long exp = 0;
    while (x > 0)
    {
        if (~x & 1)
        {
            target += (1 << exp);
        }
        exp++;
        x >>= 1;
    }
    return target;
}

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

    long long A;
    map<long long, int> m;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        m[A]++;
    }

    long long ans = 0;
    for (auto itr = m.rbegin(); itr != m.rend(); itr++)
    {
        long long target = calc_target(itr->first);
        while (itr->second > 0)
        {
            itr->second--;
            if (m[target] > 0)
            {
                m[target]--;
                ans++;
            }
            else
            {
                itr->second++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 25216
// clang-format off
#include <cassert>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <queue>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
constexpr ll MOD = 1000000007;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
int N, A, B;
constexpr int  MAX = 50;
cpp_int comb(int a, int b)
{
    cpp_int bunsi = 1;
    cpp_int bunbo = 1;
    int n = min(b, a-b);
    if(n == 0){
        return 1;
    }
    rep1(i, n){
        bunbo *= i;
        bunsi *= a-i+1;
    }
    return (bunsi/bunbo);
}

int main()
{
    cin >> N >> A>> B;
    vector<ll> v(N);
    rep(i, N){
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll sum = 0;
    ll mini = v[A-1];
    int num = 0;
    rep(i, A){
        sum += v[i];
        if(v[i] == mini){
            num++;
        }
    }
    cout << fixed << setprecision(7) << ((long double)(sum) / A) << endl;
    int cnt = count(v.begin(), v.end(), mini);
    if(mini == v[0]){
        cpp_int ans = 0;
        for(int i = A; i <= B and i <= cnt; i++){
            ans += comb(cnt, i);
        }
        cout << ans << endl;
    } else {
        cout << comb(cnt, num) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int H1 = inputintArray[0];
            int M1 = inputintArray[1];
            int H2 = inputintArray[2];
            int M2 = inputintArray[3];
            int K  = inputintArray[4];

            int time;

            time = (H2 - H1) * 60 + (M2 - M1);
            int result;
            result = time - K;


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<int>> adj;
const int N = 100001;
int depth[N];
int par[N];
int sz[N];
void dfs(int u, int p = -1){
  depth[u] = p == -1 ? 0 : depth[p] + 1;
  par[u] = p;
  sz[u] = 1;
  for(auto el : adj[u]){
    if(el != p){
      dfs(el, u);
      sz[u] += sz[el];
    }
  }

}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  adj.resize(n);
  for(int i = 0;i < n - 1;i++){
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
//  return 0;
  int d = depth[n - 1];
  int v = n - 1;
  for(int i = 0;i < (d - 1) / 2;i++)
    v = par[v];
  if(sz[v] >= sz[0] - sz[v]){
    cout << "Snuke";
  }else{
    cout << "Fennec";
  }
}


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

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		boolean[] primes = new boolean[10001];
		primes[0] = primes[1] = true;
		for (int i = 2; i <= 10000; i++) {
			if (primes[i]) continue;
			for (int j = i+i; j <= 10000; j += i)
				primes[j] = true;
		}
		while (sc.hasNext()) {
			int n = sc.nextInt();
			int res = 0;
			for (int i = 1; i <= n; i++) {
				if (!primes[i] && !primes[n-i+1]) res++;
			}
			out.println(res);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 23816
n,w=map(int, input().split())
x=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if x[i][0]<=j:
            dp[i+1][j]=max(dp[i][j],dp[i][j-x[i][0]]+x[i][1])
        else:
          	dp[i+1][j]=dp[i][j]
print(dp[-1][-1])

Measured memory_bytes: 120044
#include <bits/stdc++.h>
#define mod (1000000007)
using namespace std;

#define endl ("\n")
typedef long long ll;

const ll upper = 2001;
ll C[upper][upper];
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invaraibly fail
    
    C[0][0] = 1;
    for(int n = 1;n < upper;n++)
    {
        for(int r = 0; r <= n;r++)
        {
            if(r == n) 
            {
                C[n][r] = 1;
            }
            else if(r == 0)
            {
                C[n][r] = 1;
            }
            else
            {
                C[n][r] = (C[n-1][r-1] + C[n-1][r])%mod;
            }
        }
    }

    ll n, k;
    cin >> n >> k;
    ll b = n - k + 1;
    ll sol = 0ll;
    for(ll i = 1;i <= k;i++)
    {
        if(i > b)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << (C[b][i]*C[k-1][i-1])%mod << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 30080
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, h, w = list(map(int, readline().split()))
    cnt = 0
    for i in range(n):
        a, b = list(map(int, readline().split()))
        if a >= h and b >= w:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


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

int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<" "<<(a+b)*2<<endl;
}
/*for(初期化式;条件式;終了のときの式)
  for(int i=a;i<=b;i++){
     cout<<i<<endl;
  }*/



Measured memory_bytes: 3092
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        char c=(char)bu.read();
        if(c>='A' && c<='Z') System.out.print("A");
        else System.out.print('a');
    }
}


Measured memory_bytes: 32464
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int numberOfData = Integer.parseInt(in.readLine());
		String[] strData = in.readLine().split(" ");
		TrampCard[] trampCards = new TrampCard[numberOfData], bubbleSorts = new TrampCard[numberOfData], selectionSorts = new TrampCard[numberOfData];
		for (int i = 0; i < numberOfData; i++) {
			trampCards[i] = new TrampCard(strData[i]);
		}
		System.arraycopy(trampCards, 0, bubbleSorts, 0, numberOfData);
		System.arraycopy(trampCards, 0, selectionSorts, 0, numberOfData);
		bubbleSort(numberOfData, bubbleSorts);
		sortResult(numberOfData, bubbleSorts);
		stableCheck(numberOfData, trampCards, bubbleSorts);
		selectionSort(numberOfData, selectionSorts);
		sortResult(numberOfData, selectionSorts);
		stableCheck(numberOfData, trampCards, selectionSorts);
	}

	public static void selectionSort(int numberOfData, TrampCard[] cards) {
		int min;
		for (byte x = 0; x < numberOfData; x++) {
			min = x;
			for (int y = x + 1; y < numberOfData; y++) {
				if (cards[min].readNum() > cards[y].readNum()) {
					min = y;
				}
			}
			if (cards[x].readNum() > cards[min].readNum()) {
				TrampCard temp = cards[x];
				cards[x] = cards[min];
				cards[min] = temp;
			}
		}
	}

	public static void bubbleSort(int numberOfData, TrampCard[] cards) {
		for (int x = 0; x < numberOfData; x++) {
			for (int y = numberOfData - 1; y > x; y--) {
				if (cards[y].readNum() < cards[y - 1].readNum()) {
					TrampCard temp = cards[y];
					cards[y] = cards[y - 1];
					cards[y - 1] = temp;
				}
			}
		}
	}

	public static void sortResult(int numberOfData, TrampCard[] sorts) {
		for (int z = 0; z < numberOfData; z++) {
			if (z == numberOfData - 1) {
				System.out.println(sorts[z].readData());
			} else {
				System.out.print(sorts[z].readData() + " ");
			}
		}
	}

	public static void stableCheck(int numberOfData, TrampCard[] inputCards,
			TrampCard[] outputCards) {
		boolean check = true;
		for (int n = 0; n < numberOfData; n++) {
			for (int m = n + 1; m < numberOfData; m++) {
				for (int x = 0; x < numberOfData; x++) {
					for (int y = x + 1; y < numberOfData; y++) {
						if (inputCards[n].num == inputCards[m].num
								&& inputCards[n].card == outputCards[y].card
								&& inputCards[m].card == outputCards[x].card) {
							check = false;
							break;
						}
					}
					if (!check) {
						break;
					}
				}
				if (!check) {
					break;
				}
			}
			if (!check) {
				break;
			}
		}
		if (check) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}
}

class TrampCard {
	String card;
	char mark;
	int num;

	public TrampCard() {
	}

	public TrampCard(String card) {
		this.card = card;
		this.mark = card.charAt(0);
		this.num = Integer.parseInt(card.substring(1));
	}

	public String readData() {
		return String.valueOf(mark) + String.valueOf(num);
	}

	public char readMark() {
		return mark;
	}

	public int readNum() {
		return num;
	}
}

Measured memory_bytes: 19236
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int n;
ll ans;
vi p;
bool is_prime(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0)
		re false;
	}
	re true;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	forn(i,2,1001)
	if(is_prime(i))
	p.pb(i);;
	forn(i,1,n){
		int now=n-i,nn=0;
		vector<ll> e;
		e.clear();
		while(now>1){
			if(is_prime(now)){
				e.pb(1);
				break;
			}
			while(nn<sz(p)&&now%p[nn])
			nn++;
			int res=0;
			while(now%p[nn]==0){
				now/=p[nn];
				res++;
			}
			e.pb(res);
		}
		ll y=1;
		rep(i,sz(e))
		y*=(e[i]+1);
		ans+=y;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;
#define NIL -INF

typedef struct Node_t {
  ll key;
  Node_t *parent;
  Node_t *left;
  Node_t *right;
} Node;

Node *root = NULL;

void insert(ll key) {
  Node *y = NULL;
  Node *x = root;

  Node *z = (Node*)malloc(sizeof(Node));
  z->key = key;
  z->parent = NULL;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NULL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

int find(Node *r, ll key) {
  if (r == NULL) return 0;
  if (r->key == key) return 1;

  if (key < r->key) {
    return find(r->left, key);
  } else {
    return find(r->right, key);
  }
}

void inorder(Node *n) {
  if (n == NULL) return;

  inorder(n->left);
  cout << " " << n->key;
  inorder(n->right);
}

void preorder(Node *n) {
  if (n == NULL) return;

  cout << " " << n->key;
  preorder(n->left);
  preorder(n->right);
}

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

  // REP(i, 500500) {
  //   Node n = {NIL, NIL, NIL, NIL};
  //   T[i] = n;
  // }

  REP(i, n) {
    string cmd;
    cin >> cmd;

    if (cmd == "insert") {
      ll key;
      cin >> key;
      insert(key);
    } else if (cmd == "find") {
      ll key;
      cin >> key;
      if (find(root, key)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    bool flag = true;  // 点数が全て10の倍数ならtrue
    vector<int> s(N);
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        sum += s[i];
        flag &= (s[i]%10 == 0);
    }

    if(flag){
        cout << 0 << endl;
        return 0;
    }
    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }

    sort(s.begin(), s.end());

    for(auto i : s){
        if(i%10 == 0) continue;
        sum -= i;
        if(sum % 10 != 0){
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

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

  // 変数の取込
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];

  // 配列のためインデックスを0からスタートさせる
  rep(i,n) a[i]--;
 
  // bを全て足しこむ
  int ans = 0;
  rep(i,n) {
    ans += b[a[i]];
  }
 
  // 条件が一致したcを全て足しこむ
  rep(i,n-1) {
    if (a[i]+1 == a[i+1]) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
}


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


int main()
{
	int x,nB =0;
	cin >> x;
	if (x%10 >= 1)nB++;
	if (x%100 >= 10)nB++;
	if (x%1000 >= 100)nB++;
	cout << nB  << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	for (int i = min(a, b); i > 0; --i) {
		if (a % i != 0 || b % i != 0)
			continue;
		--k;
		if (k <= 0) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
a,b,c=map(int,input().split())
k=int(input())
if b<=a:
    while b<=a:
        b*=2
        k-=1
if c<=b:
    while c<=b:
        c*=2
        k-=1
if k<0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
def solve(way, height, n):
  ss = []
  for a,b in way:
    if height[a-1] <= height[b-1]:
      ss.append(a)
    if height[a-1] >= height[b-1]:
      ss.append(b)
  return n - len(set(ss))


if __name__ == "__main__":
  n,m = map(int, input().split())
  height = [int(i) for i in input().split()]
  way = [tuple(map(int, input().split())) for i in range(m)]
  print(solve(way, height, n))


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int v = 0;
    int pv = 0;
    rep(i, n){
        if(a[i] != pv){
            v++;
            pv = a[i];
        }
    }
    if(v % 2 == 0){
        cout << v-1 << endl;
    }else{
        cout << v << endl;
    }
}




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

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l;i <= r;i++) if(i % d == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>
#define MAX 200

typedef struct{
  int top;
  int number[MAX];
} STACK;

void initialize(STACK *);
void push(STACK *, int);
int pop(STACK *);
int isFull(STACK *);
int isEmpty(STACK *);

int main(){
  STACK stack, *s;
  char str[200];
  int x, y;
  s = &stack;
  initialize(s);

  while(scanf("%s",str) != EOF){
    if(str[0] == '+'){
      x = pop(s) + pop(s);
      push(s,x);
    }
    else if(str[0] == '-'){
      x = pop(s);
      y = pop(s);
      x = y - x;
      push(s,x);
    }
    else if(str[0] == '*'){
      x = pop(s) * pop(s);
      push(s,x);
    }
    else if(str[0] <= '9' && str[0] >= '0'){
      x = atoi(str);
      push(s,x);
    }
    else break;
  }
  x = pop(s);
  printf("%d\n",x);
  return 0;
}

void initialize(STACK *s){
  s->top = 0;
}
void push(STACK *s, int x){
  if(isFull(s) == 1) exit(1);
  else{
    s->top += 1;
    s->number[s->top] = x;
  }
}

int pop(STACK *s){
  if(isEmpty(s) == 1) exit(2);
  else{
    s->top -= 1;
    return s->number[s->top+1];
  }
}

int isEmpty(STACK *s){
  if(s->top == 0) return 1;
  else return 0;
}

int isFull(STACK *s){
  if(s->top >= MAX-1) return 1;
  else return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int main()
{
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//	#endif
    cin.sync_with_stdio(0);
    cin.tie(0); cin.exceptions(cin.failbit);
	ll n,k;
	cin>>n>>k;
	ll a[n+1],vis[n+1];
	memset(vis,-1,sizeof(vis));
	rep(i,1,n+1)
	cin>>a[i];
	ll ch=1,nx=1,cys;
	while(1)
	{
		if(vis[nx]==-1)
		vis[nx]=ch;
		else{
			cys=ch-vis[nx];
			break;
		}
		nx=a[nx];
		ch++;
	}
	//cout<<cys<<"*"<<vis[nx]<<endl;
	if(k<vis[nx]+cys)
	{
		nx=1;
		while(k--)
		{
			nx=a[nx];
		}
		cout<<nx;
		return 0;
	}
	k=k-vis[nx]+1;
	k=k%(cys);
	while(k--)
		{
			nx=a[nx];
		}
		cout<<nx;
		return 0;
}


Measured memory_bytes: 6764
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    long double A, B;

    cin >> A >> B;

    int64_t C = A*B;

    cout << C << endl;

    return 0;
    
}

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

int main(){
  int i,N,X,m[120];
  cin >>N>>X;
  for(i=0;i<N;i++) cin >> m[i];

  int sum=0;
  for(i=0;i<N;i++) sum=sum+m[i];

  int min=1000;
  for(i=0;i<N;i++) if(m[i]<=min) min=m[i];
  cout <<N+(X-sum)/min;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

char q[10][10];
int book[10],b,a,c,l[20],m[20],n[10];

void abc(int);

int main()
{
  int i,j;
    
  scanf("%d",&b);
  for(i=0;i<8;i++)
    for(j=0;j<8;j++)
      q[i][j]='.';
  for(i=0;i<b;i++)
    {
      scanf("%d%d",&a,&c);
      q[a][c]='Q';
      book[c]=1;
      l[a+c]=1;
      m[a-c+8]=1;
      n[a]=1;
    }
  
  abc(0);
  
  return 0;
}


void abc(int p)  
{
  int i;
  
  if(n[p]==1)
    abc(p+1);
  if(p==8)
    {
      for(i=0;i<8;i++)
	printf("%s\n",q[i]);
      return;
    }
  
  for(i=0;i<8;i++)
    {
      if(book[i]==0&&l[p+i]==0&&m[p-i+8]==0)
	{
	  book[i]=1;
	  l[p+i]=1;
	  m[p-i+8]=1;
	  q[p][i]='Q';
	  abc(p+1);
	  book[i]=0;
	  l[p+i]=0;
	  m[p-i+8]=0;
	  q[p][i]='.';
	}
    }
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	vector<int> num = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int K;
	cin >> K;

	cout << num[K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
use std::cmp::min;

fn main()
{
    input! {
    s:Chars,
    }

    let a = s.iter().enumerate()
        .filter(|(i, &c)| (c as i32) % 2 == (*i as i32) % 2)
        .count();
    let b = s.iter().enumerate()
        .filter(|(i, &c)| (c as i32) % 2 != (*i as i32) % 2)
        .count();
    println!("{}", min(a, b));
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int g[15][15];

int main(){
    int n;
    cin >> n;
    rep(i,n)rep(j,n)g[i][j] =-1;
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }
    int ans = 0;
    
    rep(i,1<<n){
        vector<int> d(n);
        // (i>>j) &1 judges jth element of i bits is one
        rep(j,n)if ((i>>j) &1)d[j] =1;
        bool ok = true;
        rep(i,n){
            if(d[i]){
                rep(j,n){
                    if(g[i][j] ==-1)continue;
                    if(g[i][j] != d[j])ok=false;
                }
            }
        }
        if(ok) ans = max(ans,__builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << 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 P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>

string s;
bool f1, f2;
void solve()
{
}

signed main()
{
    cin >> s;
    int n;
    n = '0';
    if ((s[0] - n) * 10 + s[1] - n <= 12 && (s[0] - n) * 10 + s[1] - n)
        f1 = true;
    if ((s[2] - n) * 10 + s[3] - n <= 12 && (s[2] - n) * 10 + s[3] - n)
        f2 = true;
    if (f1 && f2) {
        cout << "AMBIGUOUS" << endl;
    } else if (f1) {
        cout << "MMYY" << endl;
    } else if (f2) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    solve();
    return 0;
}


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

int N;
string sl;

int main(){
    char buf = '0';
    int ans = 0;
    cin >> N;
    cin >> sl;
    for(char s : sl){
        if(buf != s){
            ans +=1;
            buf = s;
        }
    }

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

Measured memory_bytes: 512
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
int n;
bool memo[400000]={0};

int main(void){
  int i,j=2,co=0;
  for(i=2;i<sqrt(246913);i++){
    if(memo[i]==0){
      j=2;
      while(i*j<=246913){
	memo[i*j]=1;
	j++;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    if(n==1)co=1;
    else {
      co=0;
      for(i=n+1;i<=2*n;i++)if(memo[i]==0)co++;
    }
    printf("%d\n",co);
  }
  return 0;
}


Measured memory_bytes: 2124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length = scanner.nextInt();
        String first = scanner.next();
      	String second = scanner.next();
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < length; i++){
        	builder.append(first.charAt(i));
            builder.append(second.charAt(i));
        }
        System.out.println(builder.toString());
    }
}

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

using namespace std;

int main() {

    long long n, m;
    cin >> n >> m;

    vector <pair <long long, long long> > p(n);
    for(long long i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());

    long long ans = 0;
    long long cnt = 0;
    for(auto t: p) {
        long long limit = t.second;
        long long cost = t.first;
        if(cnt < m) {
            long long taken = min(limit, m - cnt);
            ans += taken * cost;
            cnt += taken;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    while (a >= b) {
      b = b * 2;
      count++;
    }
    while (b >= c) {
      c = c * 2;
      count++;
    }
    System.out.println((count <= k ? "Yes" : "No"));
  }
}


Measured memory_bytes: 35572
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  const Int k=38;
  const Int n=k*k-k+1;
  cout<<n<<" "<<k<<endl;
  for(Int i=0;i<k;i++){
    cout<<n;
    for(Int j=1;j<k;j++) cout<<" "<<i*(k-1)+j;
    cout<<endl;
  }
  for(Int i=0;i<k-1;i++){
    for(Int a=0;a<k-1;a++){
      cout<<i+1;
      for(Int j=1;j<k;j++)
	cout<<" "<<j*(k-1)+(a+i*j)%(k-1)+1;
      cout<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 512