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

using namespace std;

int main(){
  vector<int> N;
  string in;
  cin >> in;
  for(char c : in){
    N.push_back(c - '0');
  }
  
  int K;
  cin >> K;
  
  long long dp[N.size()][K + 1][2];
  for(int k = 0; k <= K; k++){
    dp[0][k][0] = 0;
    dp[0][k][1] = 0;
  }
  
  dp[0][0][0] = 1;
  dp[0][1][1] = 1;
  dp[0][1][0] = N[0] - 1;
  
  for(int i = 1; i < N.size(); i++){
    dp[i][0][0] = 1;
    dp[i][0][1] = 0;
    
    for(int k = 1; k <= K; k++){
      dp[i][k][0] = dp[i - 1][k][0];
      if(N[i]) dp[i][k][0] += dp[i - 1][k][1] + (N[i] - 1) * dp[i - 1][k - 1][1];
      dp[i][k][0] += 9 * dp[i - 1][k - 1][0];
      
      if(N[i]) dp[i][k][1] = dp[i - 1][k - 1][1];
      else dp[i][k][1] = dp[i - 1][k][1];
    }
  }
  
  cout << dp[N.size() - 1][K][0] + dp[N.size() - 1][K][1] << endl;
  
  return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
ans = 0
WH_list = [[0] * W, [0] * H]
for i in range(N):
    x, y, a = map(int, input().split())
    if (a == 1):
        for j in range(x):
            WH_list[0][j] = 1
    elif (a == 2):
        for j in range(x, W):
            WH_list[0][j] = 1
    elif (a == 3):
        for j in range(y):
            WH_list[1][j] = 1
    else:
        for j in range(y, H):
            WH_list[1][j] = 1
ans = WH_list[0].count(0) * WH_list[1].count(0)
print(ans)

Measured memory_bytes: 3064
/*
Author : Hocky Yudhiono
6/27/2020 7:19:54 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

// If the time limit is strict, try not to use long double

// Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    // Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout << fixed << setprecision(10);
}

string s,t;

int main(){
    cin >> s >> t;
    int ans = 0;
    rep(i,0,sz(s)) if(s[i] != t[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;

  vi alphabet(26,0);

  rep(i,s.size()) alphabet[s[i]-'a']++;

  rep(i,26){
    if(!alphabet[i]){
      cout << (char)('a' + i) << endl;
      return 0;
    } 
  }

  cout << "None" << endl;
  return 0;
} 

Measured memory_bytes: 3688
s = input()
if "N" in s and not "S" in s:
  print("No")
  exit()
elif not "N" in s and "S" in s:
  print("No")
  exit()
elif "W" in s and not "E" in s:
  print("No")
  exit()
elif not "W" in s and "E" in s:
  print("No")
  exit()
print("Yes")


Measured memory_bytes: 3060
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
#from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    B=sorted(A,reverse=True)

    for i in range(N):
        if A[i]<B[0]:
            print(B[0])
        else:
            print(B[1])



resolve()

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int l=A, ll=A;
    for(int i=0; i<K; i++) {
        if(l+i <= B) cout << l+i << endl;
        ll = l+i;
    }
    int r=B-(K-1);
    for(int j=0; j<K; j++) {
        if(r+j <= ll) continue;
        else if(r+j <= B) cout << r+j << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 20
#define Q 200
#define TRUE 1
#define FALSE 0

int solve(int,int);

int n,A[N];

int main(){
  int q,hairetu[Q];
  int i,j;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&hairetu[i]);
  }
  for(i=0;i<q;i++){
      
    if(solve(0,hairetu[i]))
      printf("yes\n");
    else
      printf("no\n");
  }

  return 0;
}

int solve(int i, int m){  
  
  if(m==0) return TRUE;
  if(i>=n) return FALSE;
  if( solve(i+1,m) || solve(i+1,m-A[i]) ) return TRUE;
}

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

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


int main(){
  int x;
  cin >> x;
  int ans = 0;
  while(x>0){
    if(x>=500){
      ans+=1000;
      x-=500;
    }else if(x>=5){
      ans+=5;
      x-=5;
    }else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
vector<long long> tree[100005];
long long a[100005];
long long b[100005];
map<pair<long long, long long>, long long> ans;
set<long long> memo;
long long col[100005];

long long dfs(long long pa, long long pacolor, long long cur) {
	long long col = 0;
	for(auto next: tree[cur]) {
		if(next != pa) {
			if(col == pacolor) col++;
			ans[make_pair(min(cur, next), max(cur, next))] = col;
			memo.insert(col);
			dfs(cur, col, next);
			col++;
		}
	}
	return 0;
}

int main(){
	cin >> N;
	rep(i, N - 1) {
		cin >> a[i] >> b[i];
		a[i]--;b[i]--;
		tree[a[i]].push_back(b[i]);
		tree[b[i]].push_back(a[i]);
	}

	dfs(-1, -1, 0);

	cout << memo.size() << endl;
	rep(i, N - 1) {
		cout << ans[make_pair(min(a[i], b[i]), max(a[i], b[i]))] + 1 << endl;
	}

}

Measured memory_bytes: 21448
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;


void remainder_minimization()
{
  long long int l, r;
  cin >> l >> r;

  if (r - l >= 2019)
  {
    cout << 0 << "\n";
    return;
  }

  int v_min = 2019;
  for (long long int i = l; i <= r - 1; ++i)
  {
    for (long long int j = l + 1; j <= r; ++j)
    {
      int tmp = (i * j) % 2019;
      if (v_min > tmp) v_min = tmp;
    }
  }

  cout << v_min << "\n";
}


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

  vector<int> a_copy(a.size());
  for (int i = 0; i < a.size(); ++i) a_copy[i] = a[i];
  sort(a_copy.begin(), a_copy.end(),greater<int>());
  int v_max = a_copy[0], v_max_second = a_copy[1];

  for (int i = 0; i < n; ++i)
  {
    if (a[i] == v_max) cout << v_max_second << "\n";
    else cout << v_max << "\n";
  }
}


//skip
void city_savers()
{
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<int> b(n);
  for (int i = 0; i < n + 1; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];


}


void build_stairs()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  for (int i = n - 1; i > 0; --i)
  {
    if (h[i - 1] - h[i] > 1)
    {
      cout << "No" << "\n";
      return;
    }
    else if (h[i - 1] - h[i] == 1)
    {
      --h[i - 1];
    }
  }
  cout << "Yes" << "\n";
}


void green_bin()
{
  int n;
  cin >> n;
  map<string, int> S;
  for (int i = 0; i < n; ++i) 
  {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[s]++;
  }

  long long int ana_num = 0;
  for (auto value : S)
    for (int cnt = value.second - 1; cnt > 0; --cnt) 
      ana_num += cnt;
 
  cout << ana_num << "\n";
}


void alchemist()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];

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

  double v_sum = v[0];
  for (int i = 1; i < n; ++i) v_sum = (v_sum + v[i]) / 2;

  cout << v_sum << "\n";
}


void lower_atc()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];


  int tmp = 0, v_max = 0;
  for (int i = 0; i < n; ++i)
  {
    if ((i != n - 1) && h[i] >= h[i + 1]) ++tmp;
    else
    {
      v_max = max(v_max, tmp);
      tmp = 0;
    }
  }

  cout << v_max << "\n";
}


void maximal_value()
{
  int n;
  cin >> n;
  vector<int> b(n - 1);
  for (int i = 0; i < n - 1; ++i) cin >> b[i];

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
  {
    if (i == 0)          a[i] = b[i];
    else if (i == n - 1) a[i] = b[i - 1];
    else                 a[i] = min(b[i - 1], b[i]);
  }

  cout << accumulate(a.begin(), a.end(), 0) << "\n";
}


int main()
{
  remainder_minimization();
  //exeption_handling();
  //city_savers();
  //build_stairs();
  //green_bin();
  //alchemist();
  //lower_atc();
  //maximal_value();
}


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

const int inf = 1e9+5;


int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>ara(n);
    for(int& x: ara){
        scanf("%d",&x);
    }
    vector<int>dp(n,inf);

    dp[0] = 0;
    for(int i = 0; i < n;i++){
        for(int xx = 1; xx <= k;xx++){
            int j =  xx+i;
            if(j < n)dp[j] = min(dp[j],dp[i]+abs(ara[i]-ara[j]));
        }
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())

solved = [0]* 10**5
penalty = [0]* 10**5
penalty_sum = 0
for _ in range(m):
    q, result = input().split()
    q = int(q) - 1
    
    if result == 'AC':
        if solved[q] == 0:
            solved[q] = 1
            penalty_sum += penalty[q]
    else:
        if solved[q] == 0:
            penalty[q] += 1

print(str(sum(solved)) + " " + str(penalty_sum))
    

Measured memory_bytes: 4596
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    while(n--){
        string a,b;
        cin >> a >> b;
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        if(b.size() < a.size()) swap(a,b);
        b += "0";
        for(int i=0; i<b.size()-1; i++){
            int aa = i < a.size() ? a[i] - '0' : 0;
            int bb = b[i] - '0';
            int cc = aa + bb;
            b[i] = (cc%10) + '0';
            //cout << aa << "+" << bb << "=" << cc << endl;
            if(cc >= 10){
                b[i+1]++;
            }
        }
        if(b[b.size()-1] == '0')
            b = string(b.begin(), b.end()-1);
        reverse(b.begin(), b.end());
        if(b.size() > 80)
            cout << "overflow" << endl;
        else cout << b << endl;
    }
    return 0;
}
    

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int mx = max({a,b,c});
    int sum = a+b+c;
    sum += mx*((int)pow(2,k)-1);
    cout << sum << endl;
}

Measured memory_bytes: 256
import Control.Applicative

type Data = (Int, Int)

type Problem = [Data]

type Result = [Int]

count :: Data -> Int

count (n, x)
    = length $ filter (\(m, l, o) -> m + l + o == x) sets where
        sets = concat.concat $ [[[(m, l, o) | o <- [(l + 1)..n]] | l <- [(m + 1)..n]] | m <- [1..n]]

solve :: Problem -> Result

solve xs
    = map count xs

output :: Result -> String

output xs
    = concat $ map (\x -> show x ++ "\n") xs
    
input :: IO Problem

input
    = return =<< inputProblem []
    
inputProblem :: Problem -> IO Problem

inputProblem xs
    = do
        [n, x] <- map read.words <$> getLine
        if (n, x) /= (0, 0)
            then inputProblem $ xs ++ [(n, x)]
            else return xs
    
main :: IO ()

main
    = putStr.output =<< solve <$> input

Measured memory_bytes: 5572
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

void cnc(int q[9], int ct[10]){
	rep(i,10) ct[i] = 0;
	rep(i,9) ct[q[i]]++;
}

int main(void){

  int n;
	int st[9][2] ={{0,0},{0,3},{0,6},{3,0},{3,3},{3,6},{6,0},{6,3},{6,6}};
	while(cin >> n){
		bool kg=false;
		if(cin.eof()) break;
		int w[9][9]={0};
		
		rep(i,n){
			if(kg) cout << endl;
			rep(j,9) rep(k,9) cin >> w[j][k];
			int wk[9]={0}, wt[10]={0};
			bool rr[9][9]={false};
			rep(j,9){
				rep(k,9) wk[k] = w[j][k];
				cnc(wk,wt);
				rep(k,9) if(wt[w[j][k]] > 1) rr[j][k]=true;

				rep(k,9) wk[k] = w[k][j];
				cnc(wk,wt);
				rep(k,9) if(wt[w[k][j]] > 1) rr[k][j]=true;

				rep(k,9) wk[k] = w[st[j][0]+k/3][st[j][1]+k%3];
				cnc(wk,wt);
				rep(k,9) if(wt[w[st[j][0]+k/3][st[j][1]+k%3]] > 1) rr[st[j][0]+k/3][st[j][1]+k%3]=true;
			}
			rep(j,9) rep(k,9){
				cout << (rr[j][k]? "*": " ");
				cout << w[j][k];
				cout << (k>7? "\n": "");
			}
			kg=true;
		}
	}
	return 0;
	
}

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

int main()
{
   int N;
   char S[11];
   int K;
   cin >> N >> S >> K;
   for(int i = 0; i < N; i++){
       if(S[i]!=S[K - 1]){
           S[i] = '*';
       }

   }
   cout << S;
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Stack<Character> q;
		String input = "";
		while (scanner.hasNext()) {
			input = scanner.nextLine();
			if (input.equals(".")) {
				break;
			}
			q = new Stack<Character>();
			boolean badFormat = false;
			char[] ch = input.toCharArray();
			int i = 0;
			while (i < ch.length) {
				char c = ch[i];
				switch (c) {
				case '(':
				case '[':
					q.push(c);
					break;
				case ')':
					if (!q.isEmpty()) {
						if (q.peek() == '(') {
							q.pop();
						} else {
							badFormat = true;
						}
					} else {
						badFormat = true;
					}
					break;
				case ']':
					if (!q.isEmpty()) {
						if (q.peek() == '[') {
							q.pop();
						} else {
							badFormat = true;
						}
					} else {
						badFormat = true;
					}
					break;
				default:
					break;
				}
				i++;
			}
			System.out.println((q.isEmpty() && !badFormat) ? "yes" : "no");
		}
	}
}

Measured memory_bytes: 34068
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >>n>>k;
  double a[n];
  for(int i=0; i<n; i++) cin>>a[i];
  double s,t;
  for(int i=0; i<k; i++){
  	s+=a[i];
  }
  t=s;
 
  for(int i=0;i<n-k;i++){
  	s-=a[i];s+=a[i+k];
    if(t<s) t=s;
  }
  
  cout <<setprecision(15)<< t/2+0.5*k << endl;
  
}

Measured memory_bytes: 1792
x, y = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

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

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

if (x + y) % 3 == 0 :
    moves = (x + y) // 3
    tate = (moves + abs(x - y)) // 2

    print(cmb(moves, tate, mod))
else :
    print(0)

Measured memory_bytes: 122040
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}

void dfs(int k,string sub,int n){
  if(sub.length() == n){
    cout << sub << endl;
    return;
  }
  for(int i=0;i<k;i++){
    char temp = 'a'+i;
    if(i != k-1){
      dfs(k,sub+temp,n);
    }
    else{
      dfs(k+1,sub+temp,n);
    }
  }
  return;
}
int main(){
  int k;
  cin >> k;
  vector<ll> a;
  queue<string> q;
  for(int i=0;i<10;i++){
    string temp = "";
    char now = '0'+i;
    temp += now;
    q.push(temp);
  }
  while(true){
    string now = q.front();
    q.pop();
    if(now.length() > 10) break;
    char next;
    q.push(now[0]+now);
    if(now[0] != '9'){
      next = now[0]+1;
      q.push(next+now);
    }
    if(now[0] != '0'){
      next = now[0]-1;
      q.push(next+now);
    }
    if(now[0] == '0') continue;
    ll score = 0;
    for(int i=0;i<now.length();i++){
      int num = now[i]-'0';
      score *= 10;
      score += num;
    }
    a.push_back(score);
  }
  sort(a.begin(),a.end());
  cout << a[k-1] << endl;
  return 0;
}


Measured memory_bytes: 23792
N = int(input())
b_list = list(map(int, input().split()))

generate_seq = []


def is_ok(b):
    len_b = len(b)
    if len_b == 1 and b[0] == 1:
        generate_seq.append(1)
        return True

    for idx, val in enumerate(b):
        if idx + 1 < val:
            return False

    processing = []
    for idx in range(len_b):
        if b[idx] != idx + 1:
            processing.append(False)
        else:
            b_tmp = b[:]
            del b_tmp[idx]
            tmp = is_ok(b_tmp)
            if tmp:
                generate_seq.append(idx + 1)
                return True
    return False


result = is_ok(b_list)
if result:
    print('\n'.join(list(map(str, generate_seq))))
else:
    print(-1)


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, m;
    cin >> n >> m;
    vint p(m), y(m);
    rep(i, m) cin >> p[i] >> y[i], --p[i];

    vector<vector<int>> vals(n);
    rep(i, m) vals[p[i]].push_back(y[i]);

    rep(i, n) {
        sort(ALL(vals[i]));
        UNIQUE(vals[i]);
    }
    rep(i, m) {
        printf("%06d", p[i] + 1);
        printf("%06d\n", lower_bound(ALL(vals[p[i]]), y[i]) - vals[p[i]].begin() + 1);
    }
}

int main() {
    std::cin.tie(nullptr);
    //std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

int main(void){
    ll K;
    string S;
    cin>>S>>K;
    int one = -1;
    for (int i=0;i<S.size();i++){
        if (S[i]!='1') break;
        else one = i;
    }
    char ans;
    if (one == -1){
        ans = S[0];
    }
    else if (one >= K-1){
        ans = '1';
    }
    else {
        ans = S[one+1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main(){
   int n,c_M,c_m,c,h1=0,h2=0;
   cin>>n;
   vector<int> x(n);
   lp(i,n)
    cin>>x[i];
  c_m=accumulate(x.begin(),x.end(),0)/n;
  c_M=accumulate(x.begin(),x.end(),0)/n+1;

  lp(i,n){
      h1+=pow((x[i]-c_m),2);
      h2+=pow((x[i]-c_M),2);
  }
    if(h2>h1)
        cout<<h1<<endl;
    else
        cout<<h2<<endl;
}


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

bool check(int x) {
	set<int> st;
	while (x != 0) {
		st.insert(x % 10);
		x /= 10;
	}
	return st.size() == 1 ? true : false;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	while (not check(n)) {
		n++;
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
n = input().split()
r = int(n[0])
c = int(n[1])

a = []
MOD = 10**9+7

for i in range(r):
    x = input()
    y = []
    for char in x:
        if char == '.':
            y.append(1)
        else:
            y.append(0)
    a.append(y)

if a:
    dp = [[0 for i in range(c)] for j in range(r)]

    dp[0][0] = a[0][0]

    for i in range(1,r):
        dp[i][0] = dp[i-1][0] * a[i-1][0]

    for j in range(1,c):
        dp[0][j] = dp[0][j-1] * a[0][j-1]

    for i in range(1,r):
        for j in range(1,c):
            dp[i][j] = dp[i-1][j] * a[i-1][j] + dp[i][j-1] * a[i][j-1]

print((dp[r-1][c-1] * a[r-1][c-1])%MOD)

Measured memory_bytes: 272436
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!long;
    auto cnt = sort(N.iota.map!(_ => readln.front).array.filter!(c => "MARCH".canFind(c)).array).group.map!(g => cast(long)g[1]).array;
    auto res = 0;
    cnt.length.iota.map!(i =>
        iota(i+1, cnt.length).map!(j => 
            iota(j+1, cnt.length).map!(k => 
                cnt[i] * cnt[j] * cnt[k]
            ).sum
        ).sum
    ).sum.writeln;
}



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };
auto chmax = [](auto&& a, auto b) { return a < b ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = size(s);
  vector<int> h0(n + 1), h1(n + 1);
  for (int i = 0; i < n; ++i) {
    h0[i + 1] = h0[i] + (s[i] != '1' ? 1 : -1);
    h1[i + 1] = h1[i] + (s[i] == '0' ? 1 : -1);
  }
  int mx0 = 0, mxi = 0;
  vector<pair<int, int>> lr0{{0, 0}};
  for (int i = 0; i < n; ++i) {
    if (h0[i + 1] >= h0[mxi]) {
      mxi = i + 1;
    }
    int cur = h0[mxi] - h0[i + 1];
    if (cur < mx0) continue;
    if (cur > mx0) {
      mx0 = cur;
      lr0.clear();
    }
    lr0.emplace_back(mxi, i + 1);
  }
  int mx1 = 0, mni = 0;
  vector<pair<int, int>> lr1{{0, 0}};
  for (int i = 0; i < n; ++i) {
    if (h1[i + 1] <= h1[mni]) {
      mni = i + 1;
    }
    int cur = h1[i + 1] - h1[mni];
    if (cur < mx1) continue;
    if (cur > mx1) {
      mx1 = cur;
      lr1.clear();
    }
    lr1.emplace_back(mni, i + 1);
  }
  for (auto [l, r] : lr0) {
    for (int i = l; i < r; ++i) {
      if (s[i] == '?') {
        s[i] = '0';
      }
    }
  }
  for (auto [l, r] : lr1) {
    for (int i = l; i < r; ++i) {
      if (s[i] == '?') {
        s[i] = '1';
      }
    }
  }
  int m = max(mx0, mx1);
  int t = 0, mnt = 0, mnti = 0, mxt = 0, si = -1;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      ++t;
    } else if (s[i] == '1') {
      --t;
    } else {
      t = mnt = mxt = 0;
      mnti = i + 1;
      continue;
    }
    if (t - mnt == m) {
      si = mnti;
      break;
    }
    if (mxt - t == m) {
      si = i + 1;
      break;
    }
    if (chmin(mnt, t)) {
      mnti = i + 1;
    }
    chmax(mxt, t);
  }
  int l = 0, r = 0;
  bool ok = true;
  for (int i = si; i < n; ++i) {
    if (s[i] == '0') {
      ++l, ++r;
    } else if (s[i] == '1') {
      --l, --r;
    } else {
      --l, ++r;
    }
    while (l < 0) {
      l += 2;
    }
    while (r > m) {
      r -= 2;
    }
    if (l > r) {
      ok = false;
      break;
    }
  }
  l = 0, r = 0;
  for (int i = si; i--; ) {
    if (s[i] == '0') {
      --l, --r;
    } else if (s[i] == '1') {
      ++l, ++r;
    } else {
      --l, ++r;
    }
    while (l < 0) {
      l += 2;
    }
    while (r > m) {
      r -= 2;
    }
    if (l > r) {
      ok = false;
      break;
    }
  }
  cout << (m + not ok) << '\n';
}


Measured memory_bytes: 27796
while 1:
	e = input()
	if e == 0: break
	ans = 3*e
	for z in range(e+1):
		z3 = z**3
		if z3 > e: break
		y = int((e-z3)**0.5)
		x = e - y**2 - z3
		ans = min(ans,x+y+z)
	print ans

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

using namespace std;


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

    int k;
    cin >> k;
    
    int even = k / 2;
    if (k % 2) {
        cout << even * (even + 1) << '\n';
    } else {
        cout << even * even << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

double v[3000];
double dp[3000][3000];
int n;


signed main(){
    FASTER;
    //dp[i][j] prob of exactly i heads with j coins
    cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    dp[0][0]=1;
    for(int coin=1;coin<=n;coin++){
        dp[0][coin]=(1-v[coin-1])*dp[0][coin-1];;
        for(int heads=1;heads<=n && coin!=0;heads++){
            dp[heads][coin]=v[coin-1]*dp[heads-1][coin-1]+(1-v[coin-1])*dp[heads][coin-1];
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)ans+=dp[i][n];
    cout<<fixed<<setprecision(10)<<ans;//sum it
}


Measured memory_bytes: 140928
A,B=gets.split.map(&:to_i)
def dat(n)
    n+=1
    lev=60
    ret=Array.new(lev,0)
    lev.times do |i|
        a = (n / (1<<(i+1)))*(1<<i)
        b=0
        b = (n % (1<<(i+1)))-(1<<i) if (1<<i)<=(n % (1<<(i+1)))
        ret[i]=a+b
    end
    return ret
end
as=dat(A-1)
bs=dat(B)
lev=60
ans=0
lev.times do |i|
    ans+=1<<i if (bs[i]-as[i]).odd?
end
puts ans



Measured memory_bytes: 1788
#include <bits/stdc++.h>
	using namespace std;
	
	typedef long long ll;
	#define pi 3.14159265 
	#define EPS 1e-8
	
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"
 
	const ll INF=(ll)2e18;
	

	
	int main()
	{
		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
			
		 ll a,b,c,d;
		 cin>>a>>b>>c>>d;
		 
		 while(1)
		 {
			 c-=b;
			 if(c<=0)
			 {
				 cout<<"Yes";
				 exit(0);
			 }
			 a-=d;
			 if(a<=0)
			 {
				 cout<<"No";
				 exit(0);
			 }
		 }
		 
	}


Measured memory_bytes: 3592
b = gets

if b == nil then
  exit
else
  b = b.chomp
end

def putOther(arg1, arg2, targetnum)
  if arg1 == targetnum then
    puts arg2
  else
    puts arg1
  end
end

ar1 = ["A", "T"]
ar2 = ["C", "G"]

if ar1.include?(b) then
  putOther(ar1[0], ar1[1], b)
else
  putOther(ar2[0], ar2[1], b)
end


Measured memory_bytes: 1788
N = int(input())
memo = {}
ans = 0
for i in range(N):
  s = list(input())
  s.sort()
  s = str(s)
  if s in memo.keys():
    memo[s] += 1
  else:
    memo[s] = 1
for v in memo.values():
  if v >= 2:
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 21988
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int maxm = 1e5;
typedef long long ll;
const ll mod = 1e9 + 7;
ll fac[maxn];

ll qpow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans % mod;
}

ll C(int n, int m) {
	return fac[n] * qpow(fac[m], mod - 2) % mod * qpow(fac[n - m], mod - 2) % mod;
}

int main() {
	int n, k;
	fac[0] = 1;
	for (int i = 1; i <= maxm; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		if (i > n - k + 1) {
			cout << "0" << endl;
			continue;
		}
		cout << C(n - k + 1, i) * C(k-1,i-1) % mod << endl;
	}
	return 0;
}



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

int main() {
  string s;
  cin >> s;

  int n = 1 << (s.size() - 1);
  long ans = 0;
  rep(i,n){
    string v = "";
    rep(j, s.size()){
      if((i >> j) & 1 == 1) v = "";
      else {
        v += s[j];
        if (v != "") ans += stol(v);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 512);
		int number = Integer.parseInt(br.readLine());//行数
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18504
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 405
using namespace std;
typedef long long ll;
int n,c,a[N],b[N],p[N][N],s[N][N];
unsigned long long f[N][N];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%dalao)if(b&1)r=1ll*r*a%dalao;return r;}
int main(){
	cin>>n>>c;
	for(int i=1;i<=400;i++){
		p[i][0]=1,s[i][0]=i;
		for(int j=1;j<=400;j++)p[i][j]=1ll*p[i][j-1]*i%dalao,s[i][j]=(s[i-1][j]+p[i][j])%dalao;
	}
	for(int i=1;i<=n;i++)cin>>a[i];
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		for(int j=0;j<=c;j++){
			for(int k=0,z=0;k<=j;k++,z++){
				if(z==9)z=0,f[i][j]%=dalao;
				f[i][j]+=1ll*f[i-1][j-k]*(s[b[i]][k]-s[a[i]-1][k]+dalao);
			}
			f[i][j]%=dalao;
		}
	}
	cout<<f[n][c];
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
    double Pi = acos(-1);
    double r;
    cin>>r;
    double area = Pi*r*r;
    double circle = 2*Pi*r;
    cout<<fixed<<setprecision(6)<<area<<' '<<circle<<'\n';
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){

    int k;
    cin >> k;
    
    vector<ll> a(k);
    rep(i, k)cin >> a[i];
    reverse(all(a));

    ll mi = 2, ma = 2;
    rep(i, k){
        mi = (mi + a[i] - 1) / a[i] * a[i];
        ma = (ma / a[i] + 1) * a[i] - 1;
    }

    if(mi > ma)cout << -1 << endl;
    else cout << mi << ' ' << ma << endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{ return firstElof.second < secondElof.second; }
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; 
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D;
//***********//
int main() {
	cin >> N >> M;
	vl A(M);
	vll C(M, vl(N));
	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++) {
			C[i][j] = 0;
		}
	}
	for (i = 0; i < M; i++) {
		ll b;
		cin >> A[i] >> b;
		for (j = 0; j < b; j++) {
			ll c;
			cin >> c;
			C[i][c - 1] = 1;
		}
	}
	ll L = pow(2, N);
	vll dp(M+1, vl(L, 0));
	for (i = 0; i <= M; i++) {
		for (j = 0; j < L; j++) {
			dp[i][j] = INF;
			if (j == 0) dp[i][j] = 0;
		}
	}
	for (i = 0; i < M; i++) {
		for (j = 0; j < L; j++) {
			ll p = j; ll j2 = j;
			for (k = 0; k < N; k++) {
				if (p % 2 == 0 && C[i][k] == 1) j2 += pow(2, k);
				p /= 2;
			}
			dp[i + 1][j] = min(dp[i+1][j],dp[i][j]);
			dp[i + 1][j2] = min(dp[i+1][j2],min(dp[i][j2], dp[i][j] + A[i]));
			//cout << i << " " << j  << " -> " << i+1 << " " << j2 << " " << dp[i + 1][j2] << endl;
		}
	}
	if (dp[M][L - 1] == INF)cout << -1;
	else cout << dp[M][L - 1];
}


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

s = {}
for i in range(n):
	tmp = input()
	if tmp in s:
		s[tmp] += 1
	else:
		s[tmp] = 1

val_max = max(s.values())
keys_val_max = [k for k in s if s[k] == val_max]

keys_val_max.sort()
for k in keys_val_max:
	print(k)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long  A,B,C,K;
    cin >> A >> B >> C >> K ;
    if(A>=K){
        cout << K << endl;
        return 0;
    }
  else if(A<K)  {
    long long s=0;
    
    for (long long i = 0; i < A; i++){
      s++;
    }
    if(K-A-B<=0){
        cout << s << endl;
        return 0;
    }

    else if(K-A-B>0||A+B+C>=K){
        for (long long i = 0; i < K-A-B; i++)  {
        s--;
      }

      cout << s << endl;
    }
}
}
    


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll now=0;
  FOR(i,0,a){
    ll A;
    ci(A);
    now+=A;
    if(b<now){
      co(i+1)
        break;
    }
    if(i==a-1) co(a+1)
  }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        t: f32,
    }
    let ans = ((t + 0.5) as u32) / a * b;
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

char visited[1234567];

int main(void) {
	int K;
	int mofu = 7;
	int count = 1;
	if (scanf("%d", &K) != 1) return 1;
	if (K == 1 || K == 7) {
		puts("1");
		return 0;
	}
	for (;;) {
		if (visited[mofu]) {
			puts("-1");
			return 0;
		}
		visited[mofu] = 1;
		count++;
		mofu = (mofu * 10 + 7) % K;
		if(mofu == 0) {
			printf("%d\n", count);
			return 0;
		}
	}
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int frac[22];
    frac[0] = 1;
    frac[1] = 1;
    for(int i = 2; i <= 20; i++){
        frac[i] = frac[i - 1] * i;
    }
    
    string s; cin >> s;
    int n = (int)s.size();

    int cnt = 0;
    int alpha[26] = {};

    for(int i = 0; i < n; i++){
        alpha[(int)s[i] - 'a']++;  
    }

    for(int i = 0; i < 26; i++){
        if(alpha[i] % 2 == 1) cnt++;
    }

    if(n % 2 == 1) cnt--;
    if(cnt > 0){
        cout << 0 << endl;
        return 0;
    }
    

    for(int i = 0; i < 26; i++) alpha[i] /= 2;
    
    

    int sita = 1;
    int u = n / 2;
    for(int i = 0; i < 26; i++){
        sita *= frac[alpha[i]];
    }

    cout << frac[u] / sita << endl;

    return 0;
}




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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long d = sc.nextLong();
		long a = sc.nextLong();
		Pair[] ps = new Pair[n];
		for(int i = 0; i < n; i++) {
			long x = sc.nextLong();
			long h = sc.nextLong();
			ps[i] = new Pair(x, h);
		}
		Arrays.sort(ps);
		long res = 0;
		long count = 0;
		LinkedList<Pair> pos = new LinkedList<Pair>();
		for(int i = 0; i < n; i++) {
			long x = ps[i].a;
			while(!pos.isEmpty() && pos.peekFirst().a < x) {
				count -= pos.peekFirst().b;
				pos.removeFirst();
			}
			long rem = Math.max(ps[i].b - count * a, 0);
			long dif = (long)Math.ceil(rem*1.0/a);
			res += dif;
			count += dif;
			pos.add(new Pair(x + 2*d, dif));
		}
		System.out.println(res);
	}
	static class Pair implements Comparable<Pair>{
		long a, b;
		public Pair(long a, long b) {
			this.a = a; this.b = b;
		}
		@Override
		public int compareTo(Pair p) {
			return a < p.a ? -1: a == p.a? 0: 1;
		}
	}
	
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 70792
#include <stdio.h>

int main(){
  long a;
  double b;
  scanf("%ld %lf", &a, &b);
  int bup = (int)b;

  int bdown = (int)(b*1000)/10 - bup*100;

  long ans = bup * a + (bdown * a) / 100;

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

  //  printf("%d %d ", bup, bdown);

  return 0;
}


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

int main()
{
    int X;
    std::cin >> X;

    if (X == 1) {
        std::cout << 1 << std::endl;
        return 0;
    }
 
    int ans = 0;
    for (int i = 2; i < X; i++) {
        int x = i * i;
        for (int j = 3; j < X; j++) {
            if (x <= X) {
                ans = std::max(ans, x);
            }
            else {
                break;
            }

            x *= i;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	int n;
	int a[100003],b[100002];
	int i;
	long long kill=0,cout=0;
	scanf("%d",&n);
	for(i=0;i<n+1;i++){
		scanf("%d",a+i);
	}
	for(i=0;i<n;i++){
		scanf("%d",b+i);
	}
	for(i=0;i<n;i++){
		if(a[i]>=(b[i]+cout)){
			kill+=b[i]+cout;
			cout=0;
		}else{
			kill+=a[i];
			if(a[i]<=cout){
				cout=b[i];
			}else{
				cout=b[i]-(a[i]-cout);
			}
		}
		//printf("i=%d kill=%d cout=%d\n",i,kill,cout);
	}
	if(a[i]>=(cout)){
		kill+=cout;
	}else{
		kill+=a[i];
	}
	//printf("i=%d kill=%d cout=%d\n",i,kill,cout);
	printf("%lld\n",kill);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll x;
    std::cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    std::cout << ans << '\n';
    return 0;
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

int main()
{
  IOS;

  int N;
  cin >> N;
  VLL A(N);
  forn(i, 0, N) cin >> A[i];

  VVLL dp(N, VLL(N));
  for (int i = N - 1; i >= 0; i--)
  {
    for (int j = i + 1; j < N; j++)
    {
      LL sum = A[j], p = LONG_MAX;
      for (int k = i; k < j; k++)
      {
        sum += A[k];
        p = min(p, dp[i][k] + dp[k + 1][j]);
      }
      dp[i][j] = sum + p;
    }
  }
  cout << dp[0][N - 1] << endl;

  return 0;
}


Measured memory_bytes: 4520