akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K;
	
	cin >> N >> K;

	cout << N - K + 1 << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c) cout<<1<<endl;
    else cout<<0<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1024;

int main() {
	int n;
	scanf("%d", &n);
	forr(i, 1, 10){
		forr(j, 1, 10){
			if (i*j == n) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	
	return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);

#define LL long long

const int mxn = 1e7 + 5;
int minPrime[mxn];
void aux_func()
{
	for (int i = 2; i * i <= mxn; i++) 
	{
		//if i is prime
		if (minPrime[i] == 0) 
		{ 
			for (int j = i * i; j <= mxn; j += i)
			{
				// not yet found
				if(minPrime[j] == 0)
					minPrime[j] = i;
			}
		}
	}
	for (int i = 2; i <= mxn; ++i) 
	{
		if (minPrime[i] == 0) 
			minPrime[i] = i;
	}
}

LL nod[mxn];

int main() {
	FI;
	aux_func();

	int n;
	cin >> n;

	if(n == 1) {
		cout << 1 << endl;
		return 0;
	}

	LL ans = 1;
	nod[1] = 1;
	for(int i=2;i<=n;i++) {
		int num = i;
		int cnt = 0;
		int div = minPrime[num];
		while(num % div == 0)
		{
			num /= div;
			cnt++;
		}

		nod[i] = (cnt + 1LL) * nod[num];

		ans += i * nod[i];  
	}

	cout << ans << endl;

	return 0;
}


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


int main() {
  int N;
  cin >> N;
  vector<int> P(N), M(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  
  M.at(0) = P.at(0);
  for (int i = 1; i < N; i++) {
    M.at(i) = min(M.at(i-1), P.at(i));
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    if (M.at(i)==P.at(i)) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long H,W;
  cin >> H >> W;
  if (H >= 2 && W >= 2) {
      cout << ((H * W) + 1) / 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
taro = hanako = 0
n.times {
  a, b = gets.chomp.split
  if a == b
    taro += 1
    hanako += 1
  elsif a > b
    taro += 3
  else
    hanako += 3
  end
}

puts "#{taro} #{hanako}"

Measured memory_bytes: 8772
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 x = A*B;
      if(x%2 == 0){
    System.out.println("No");
       }else{
	System.out.println("Yes");
      }
      }
}

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

int N=0;
int main(){

    cin>>N;
    vector<int> L(N);
    for(int i=0;i<N;i ++){
        cin>>L[i];
    }
    int M = L[0];
    int sum =0;
    for(int i;i<N;i ++){
        sum = sum + L[i];
    }
    
    for (int i; i<N; i ++){
        if(M < L[i]){
            M = L[i];
        }
    } 
    if(M < sum - M){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    
    return 0;

}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();

        for (int i = 0 ; i < s.length() ; i++) {
            boolean f = true;
            for (int j = 0 ; j < s.length() ; j++) {
                int k = j+i >= s.length() ? j+i - s.length() : j+i;
                if (s.charAt(j) != t.charAt(k)) {
                    f = false;
                    break;
                }
            }
            if (f) {
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int f6(int n){
	int i=1;
	while(i*6<=n) i*=6;
	return i;
}

int f9(int n){
	int i=1;
	while(i*9<=n) i*=9;
	return i;
}
int *dp;
int solve(int n){

	if(n<=5) return (dp[n]=n);
	else{
		int x=f9(n);
		int y=f6(n);
	return (dp[n]=1+min(solve(n-x),solve(n-y))); 
	} 
}

int main(){
	startTime=clock();
	int n;
	cin >> n;
	dp=new int[n+1];

	cout << solve(n);

	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 998244353;
int n, s;
int a[3000];
int dp[3001][3001];

signed main() {
	int i, j;
	
	cin >> n >> s;
	rep(i, n) cin >> a[i];
	
	rep(i, n) dp[i][0] = 1;
	rep(i, n) {
		rep(j, s + 1) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			
			if (j + a[i] <= s) {
				dp[i + 1][j + a[i]] += dp[i][j];
				dp[i + 1][j + a[i]] %= mod;
			}
		}
	}
	
	int ans = 0;
	rep(i, n + 1) {
		ans += dp[i][s];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n, k, ans = 1123456789, ar[123456];
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> ar[i];

	sort(ar, ar+n);
	for(int i = 0 ; i <= n-k ; i++)
		ans = min(ar[i+(k-1)] - ar[i], ans);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  /*int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  for (int i = n - 1; i > 0; i--) {
    int a = arr[i], b = arr[i - 1];
    if (a + b == 5) {
      cout << "Infinite" << endl;
      return 0;
    } else ans += a + b;
  }
  cout << "Finite" << endl;
  cout << ans << endl;*/
  int n = 5;
  int arr[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i] + (arr[i] % 10 ? 10 - (arr[i] % 10) : 0);
  }
  int ma = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] % 10 == 0) continue;
    ma = max(ma, 10 - arr[i] % 10);
  }
  cout << sum - ma << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long power(long long a,long long now) {
	long long ans = 1;
	while (now != 0) {
		if (now % 2 == 1) {
			ans *= a;
			ans %= MAX_MOD;
		}
		now /= 2;
		a *= a;
		a %= MAX_MOD;
	}
	return ans;
}
long long inv(long long a) {
	return power(a, MAX_MOD - 2);
}
long long permutation(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
	}
	return ans;
}
long long combination(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
		ans *= inv(i + 1);
		ans %= MAX_MOD;
	}
	return ans;
}
int main() {
	long long n, k;
	cin >> n >> k;
	cout << combination(n - 1, k - 1) << endl;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<limits.h>
#define M 2000000

int n;
int S[M];

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void heapIncreaseKey(int i,int k){
  int tmp;
  if(k < S[i]) {
    printf("error");
    return;
  }
  S[i] = k;
  while(i > 1 && S[parent(i)] < S[i]){
    tmp=S[i];
    S[i]=S[parent(i)];
    S[parent(i)]=tmp;
    i = parent(i);
  }
}

void insert(int k){
  
  n++;
  S[n] = INT_MIN;
  heapIncreaseKey(n, k);
}

void maxHeapify(int i){
  int largest;
  int l,r;
  int tmp;
  l = left(i);
  r = right(i);
  
    if(l<=n && S[l] > S[i])largest=l;
    else largest=i;
    
    if(r<=n && S[r]>S[largest])largest=r;
    
    if(largest != i){
      tmp=S[i];
      S[i]=S[largest];
      S[largest]=tmp;
      maxHeapify(largest);
    }
}

int exstractMax(){
  int mm;
  if(n < 1){
    return 0;
  }
  mm = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(1);
  return mm;
}

int main(void){
  int i, k;
  char in[20];
  while(1){
    scanf("%s", in);
    if(in[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else if(in[1] == 'x') printf("%d\n", exstractMax());
    else break;
  }
  
  return 0;
}

Measured memory_bytes: 4696
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val x = (1..m).map { sc.nextInt() }.sorted()


  if (n >= m) {
    println(0)
    return
  }

  val length = x[m-1] - x[0]

  val l = (1..m-1).map { x[it] - x[it-1] }.sorted().reversed()
  val last = l.subList(0, n-1).sum()

  println(length - last)

}

Measured memory_bytes: 63692
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

char x[4] = { 'A', 'C', 'G', 'T' };

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    int t = 0;
    rep(i, n) {
        int flag = 0;
        rep(j, 4) {
            if(s[i] == x[j]) {
                t++;
                flag = 1;
            }
        }
        if(!flag) {
            ans = max(ans, t);
            t = 0;
        }
    }
    ans = max(ans, t);

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

Measured memory_bytes: 256
n, q = tuple(int(i) for i  in input().split(' '))
s = input()

c = [0] * (n + 1)

for i in range(n):
    c[i + 1] = c[i] + (1 if s[i:i + 2] == 'AC' else 0)

for i in range(q):
    l, r = tuple(int(i) for i  in input().split(' '))
    print(c[r - 1] - c[l - 1])


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> C(N);
  for (int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    C.at(a-1)++;
    C.at(b-1)++;
  }
  for (int j=0; j<N; j++) {
    cout << C.at(j) << endl;
  }
}


Measured memory_bytes: 256
import numpy as np
import math

N, K= map(int, input().split())

if N > K: 
    prob_base = (N-K) / N
    prob = 0
    
    for i in range(1, K+1):
        x = math.ceil(np.log2(K/i))
        prob += (1/N) * (1/2)**x
        
    print(prob_base + prob)
    
else:
    prob = 0
    for i in range(1, N+1):
        x = math.ceil(np.log2(K/i))
        prob += (1/N) * (1/2)**x
        
    print(prob)

Measured memory_bytes: 22296
def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0

  #DP
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #入る可能性はない
        dp[i+1][w]=dp[i][w]
  return dp[N][W]

N,W = map(int,input().split())
lstw = [0 for i in range(N)]
lstv = [0 for i in range(N)]

for i in range(N):
  w,v = map(int, input().split() ) 
  lstw[i] = w
  lstv[i] = v
  
ret = knapsack(N,W,lstw,lstv)
  
print(ret)

Measured memory_bytes: 300856
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i=0; i<=a; i++) {
        for (int j=0; j<=b; j++) {
            for (int k=0; k<=c; k++) {
                int num = 500*i + 100*j + 50*k;
                if (num == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3204
#include <stdio.h>

int main() {

    int n;
    int a[100000];

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int ans;
    int max;
    ans = 0;
    max = 0;
    for(int i = 0; i < n - 1; i++) {
        if(a[i] >= a[i + 1]) {
            ans = ans + 1;
        } else {
            if (max < ans) {
                max = ans;
            }
            ans = 0;
        }
    }
    if (max < ans) {
        max = ans;
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 512
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define mii             map<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define mod             998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n,k; cin>>n>>k;
    vector<ld> v(n), pref(n+1,0);
    rep(i,0,n)
    {
        cin>>v[i];
        v[i]++;
        v[i]/=2.0;
    }
    ld ans = 0;
    rep(i,1,n+1)
    {
        pref[i] = pref[i-1] + v[i-1];
        if(i>=k)
        {
            ans = max(ans,pref[i]-pref[i-k]);
        }
    }
    deci(15)<<ans; 
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

int cDiv(int x, int y) { return y == 0 ? INF : (x+y-1)/y; }


int main() {
  ll n, m; cin >> n >> m;

  V ans(m+2);
  rep(i, n) {
    int l, r; cin >> l >> r;
    int d = 1;
    while (d <= l) {
      int a = cDiv(l, d);
      int x = cDiv(l, a);
      int y = r/a+1;
      if (a > 1) chmin(y, cDiv(l, a-1));
      ++ans[x];
      --ans[y];
      d = cDiv(l, a-1);
    }
  }

  rep(i, m) ans[i+1] += ans[i];
  rep(i, m) cout << ans[i+1] << '\n';
  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string S;
    cin >> S;
    string ans = "";
    bool all = true;
    
    for ( char c = 'a'; c <= 'z'; c++ ) {
        bool exist = false;
        for ( int i = 0; i < S.length(); i++ ) {
            if ( S[i] == c ) { exist = true; }
        }
        if ( !exist ) {
            all = false;
            if ( ans == "" ) { ans += c; }
        } 
    }
    
    if ( all ) { cout << "None" << endl; }
    else { cout << ans << endl;}
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  double R;
  cin >> R;

  printf("%.12lf\n", 2*R*3.1415926535897932384626);
  
  return 0;
}


Measured memory_bytes: 3788
//msolutions2019_d.cpp
//Sun Jun 28 12:39:28 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	vector<int> G[n];
	for (int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int c[n];
	for (int i=0;i<n;i++){
		cin >> c[i];
	}
	sort(c,c+n,greater<int>());

	queue<int> q;
	q.push(0);
	int visited[n];
	fill(visited,visited+n,-1);
	visited[0] = c[0];
	int ans = 0;
	int ccount = 1;
	while(!q.empty()){
		int tmp = q.front();q.pop();
		for (int i=0;i<G[tmp].size();i++){
			int next = G[tmp][i];
			if (visited[next]==-1){
				ans += c[ccount];
				q.push(next);
				visited[next] = c[ccount];
				ccount++;
			}
		}
	}

	cout << ans << endl;
	for (int i=0;i<n;i++){
		cout << visited[i] << " ";
	}
	printf("\n");
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4340
#include <iostream>
#include <cstring>
using namespace std;
#define ll long long
ll a[300];
int main()
{
    int n;
    cin>>n;
    bool k=false;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    while(k==false)
    {
        for(int i=1;i<=n;i++)
        {
            if(a[i]%2!=0)
            {
                k=true;
            }
            a[i]/=2;
        }
        ans++;
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 256
<?PHP
fscanf(STDIN, "%d", $d);
$list = explode(' ', trim(fgets(STDIN)));

$ans=0;
for($i=1; $i<count($list)-1; $i++){
  if($list[$i-1]<=$list[$i] && $list[$i]<$list[$i+1]){
    $ans++;
  }elseif($list[$i-1]>$list[$i] && $list[$i]>=$list[$i+1]){
    $ans++;
  }
}
echo $ans;

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n,m; cin >> n >> m;
    vector<pii> demand(m);
    rep(i,m){
        cin >> demand[i].second >> demand[i].first;
    }
    sort(demand.begin(),demand.end());
    int res=0,end = 0;
    rep(i,m){
        if(demand[i].second>=end){
            res++;
            end=demand[i].first;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>

int F(int A,long long int B);



int main(){
	
	int i,ans=11;
	long long int N;
	
	
	scanf("%lld",&N);
	
	
	for(i=1;i<=sqrt(N);i++){
	
	if(N%i==0){
		if(F(i,N/i)<ans){
		ans=F(i,N/i);
		
		}
	}
	}
	
	
	printf("\n%d\n\n",ans);
	
	
	return 0;
}



int F(int A,long long int B){
	
	int keta,a=1,b=1;
	
	while(A/10!=0){
		A=A/10;
		a++;
	}
	while(B/10!=0){
		B=B/10;
		b++;
	}
	
	if(a>b){
		keta=a;
	}else {
		keta=b;
	}
	
	return keta;
}

Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <iostream>
// #include <cmath>
// #include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
 

void print(int h, int w) {
    char x[h][w];

    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (i==0 || i == h-1 || j==0 || j == w-1) {
                x[i][j] = '#';
            } else {
                x[i][j] = '.';
            }
        }
    }

    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            cout << x[i][j];
        }
        cout << endl;
    }
}


int main() {
    int h,w;
    while (true) {
        cin >> h >> w;
        if ( h== 0 && w == 0) {
            break;
        }
        print(h, w);
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner stdinScanner = new Scanner(System.in);
        int K = stdinScanner.nextInt();
        int count = 1;
        int current = 7;
        while (count <= K) {
            if (current % K == 0) {
                System.out.println(count);
                return;
            }
            count++;
            current = (current * 10 + 7) % K;
        }
        System.out.println("-1");
    }
}

Measured memory_bytes: 35628
<?php
  
  fscanf(STDIN,"%d %d",$K,$N);
$a_list = explode(" ",trim(fgets(STDIN)));


$sum1=0;
$max=0;
$m=array();




for($i=0;$i<$N;$i++){
  if($i == $N-1){
    $diff = abs($K-$a_list[$i])+$a_list[0];
  }else{
   $diff=$a_list[$i+1]-$a_list[$i];
  }
  if($max<$diff){
    $max=$diff;
    $max_i = $i;
  }
  
}


echo $K-$max."\n";



 





Measured memory_bytes: 18932
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <=0){
                return false;
            }
        }
        return true;
    }

    private int readByte(){
        if(hasNextByte())return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}
public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int k = fs.nextInt();
        char[] c = ('R'+fs.next()+'L').toCharArray();

        boolean flag = true;//R出現後
        int fortune = n;
        int count = 0;
        int end = 0;
        for(int i=0;i<n+2;i++){
            if(c[i] == 'L' && flag){
                flag = false;
                fortune-=2;
                count++;
            }else if(c[i] == 'R' && !flag){
                flag = true;
            }
        }
        if(c[1]=='L'){
            fortune++;
            count--;
        }
        if(c[n] == 'R'){
            fortune++;
            count--;
            end++;
        }
        fortune = fortune + 2*Math.min(count,k);
        k-=count;
        if(k>0){
            fortune = Math.min(n-1,fortune + Math.min(k,end));
        }
        System.out.println(fortune);

    }
}

Measured memory_bytes: 25812
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, u, v;
    cin >> n >> m;
    unordered_map<int, vector<int>> out_deg;
    unordered_map<int, int> in_deg;
    vector<int> ans(n+1, 0);
    for(int i = 0; i < n-1+m; i++) {
        cin >> u >> v;
        in_deg[v] += 1;
        out_deg[u].push_back(v);
    }
    vector<int> dq;
    for(int i = 1; i <= n; i++) {
        if (in_deg[i] == 0)
            dq.push_back(i);
    }
    while(!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            for(int neibor: out_deg[node]) {
                if (--in_deg[neibor] == 0) {
                    ans[neibor] = node;
                    new_dq.push_back(neibor);
                }
            }
        }
        dq.swap(new_dq);
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 14152
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, C = map(int, input().split())
CM = [list(map(int, input().split())) for _ in range(C)]
NM = [list(map(int, input().split())) for _ in range(N)]

cnt = [[0] * (C + 1) for _ in range(3)]

for i in range(N):
    for j in range(N):
        cnt[(i + j + 2) % 3][NM[i][j]] += 1

ans = 1 << 28
for i in range(1, C + 1):
    for j in range(1, C + 1):
        for k in range(1, C + 1):
            if i == j or j == k or i == k:
                continue
            c = 0
            for l in range(1, C + 1):
                c += cnt[0][l] * CM[l - 1][i - 1]
                c += cnt[1][l] * CM[l - 1][j - 1]
                c += cnt[2][l] * CM[l - 1][k - 1]
            ans = min(ans, c)

print(ans)

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b)     for(int i=a;i>=b;--i)
#define init(a, x) memset(a,x,sizeof(a))
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>a>>b>>c>>d;
    	ll ans = max(a*d, b*d);
    	ll ans1 = max(a*c, b*c);
    	cout<<max(ans, ans1)<<endl;
    }
    return 0;
}

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

long long N, A, B, C, D;

int main(){
	cin >> N >> A >> B >> C >> D;

	for(long long S = 0; S < N; S++){
		if(S % 2 == 0){
			long long top = A + (S/2) * (D - C);
			long long bottom = A -1 * (S/2) * (D - C);
			long long len = N - 1 - S;
			long long maxtop;
			long long maxbottom;
			long long mintop;
			long long minbottom;

			maxtop = top + D * len;
			maxbottom = bottom + C * len;

			mintop = top - C * len;
			minbottom = bottom - D * len;
			
			if(maxtop >= B && B >= maxbottom){
				cout << "YES" << endl;
				return 0;
			}

			if(mintop >= B && B >= minbottom){
				cout << "YES" << endl;
				return 0;
			}
		}
	}

	cout << "NO" << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	list<int>v;
	int a,b,n;cin>>n;
	auto c=v.end();
	while(n--){
		cin>>a;
		if(a==0){
			cin>>b;
			c=v.insert(c,b);
		}else if(a==1){
			cin>>b;
			if(b>0)while(b--)c++;
			else while(b++)c--;
		}else c=v.erase(c);
	}
	for(auto e:v)cout<<e<<"\n";
	return 0;
}



Measured memory_bytes: 18620
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n,l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  rep(i,n){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
/*input
4
1 2 3 4
3
1 2
3 4
2 4

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec;
  int v;
  ll s = 0;
  map<ll, ll> mp;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
    mp[v]++;
    s += v;
  }  
  int q;
  cin >> q;
  while (q--) {
    ll b, c;
    cin >> b >> c;
    s -= mp[b] * b;
    mp[c] += mp[b];
    s += c * mp[b];
    mp[b] = 0;
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};



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

  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(10,-1));
  vector<int> p(m);
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]) cin >> s[i][j];
  }
  rep(i,m) cin >> p[i];
  int ans = 0;
  for(int i = 0; i < (1<<n); i++){
    bitset<10> bit(i);
    bool ok = true;
    rep(j,m){
      int cnt = 0;
      rep(l,k[j]){
        if(bit[s[j][l]-1]) cnt++;
      }
      if(cnt%2 != p[j]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i,0,N){cin >> S[i];}
  
  sort(S.begin(),S.end());
  rep(i,0,N){cout << S[i];}
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    println(
        when (s) {
            "SUN" -> 7
            "MON" -> 6
            "TUE" -> 5
            "WED" -> 4
            "THU" -> 3
            "FRI" -> 2
            "SAT" -> 1
            else -> throw Exception()
        }
    )
}

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

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	if((x-a)*(x-a) < (x-b)*(x-b)){
		cout << "A" << endl;
	}else{
		cout << "B" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,m;cin>>n>>m;
  int a[m];
  rep(i,m){
    cin>>a[i];
    --a[i];
  }
  int mc[9]={2,5,5,4,5,6,3,7,6};
  int dp[n+1000];
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  rep(i,n){
    rep(j,m){
      if(dp[i]!=-1){
        dp[i+mc[a[j]]]=max(dp[i]+1,dp[i+mc[a[j]]]);
      }
    }
  }
  sort(a,a+m,greater<int>());
  int cur=n;
  while(cur){
    rep(i,m){
      if(cur>=mc[a[i]]&&dp[cur-mc[a[i]]]==dp[cur]-1){
        cout<<a[i]+1;
        cur-=mc[a[i]];break;
      }
    }
  }
  cout<<endl;
}





Measured memory_bytes: 256
n = int(input())
L = [list(map(int,input().split())) for _ in range(n)]
L.sort(key=lambda x:x[0]+x[1])
seen=-10**10
cnt=0
for i in range(n):
    if seen<=L[i][0]-L[i][1]:
        seen=L[i][0]+L[i][1]
        cnt+=1
print(cnt)

Measured memory_bytes: 32296
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

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

    bitset<100> hit;
    for (int n = 0; n < N; n++) {
        int p;
        cin >> p;
        hit[p - 1] = true;
    }

    int Y, Z;
    for (int y = X; ; y--) {
        if (y == 0 || !hit[y - 1]) {
            Y = y;
            break;
        }
    }

    for (int z = X; ; z++) {
        if (z == 101 || !hit[z - 1]) {
            Z = z;
            break;
        }
    }

    if (X - Y <= Z - X)
        cout << Y << endl;
    else
        cout << Z << endl;


    return 0;
}


Measured memory_bytes: 3604
S = input()
L = len(S)
dp = [[False] * (L + 1) for _ in range(L + 1)]

# [left, right)
for i in range(L + 1):
    dp[i][i] = True

for w in range(3, L + 1):
    for left in range(L - w + 1):
        right = left + w
        if S[left] != 'm' or S[right - 1] != 'w':
            continue
        for mid in range(left + 1, right):
            if S[mid] == 'e' and dp[left + 1][mid] and dp[mid + 1][right - 1]:
                dp[left][right] = True
                break
print("Cat" if dp[0][L] else "Rabbit")

Measured memory_bytes: 9368
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(c) c.begin(),c.end()

using namespace std;
typedef long long ll;

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  string S; cin >> S;
  int passed = 0, foreign = 0;
  REP(i, S.size()) {
    if (S[i] == 'a' && passed < A + B) {
      cout << "Yes" << endl;
      passed++;
    } else if (S[i] == 'b' && passed < A + B && foreign + 1 <= B) {
      cout << "Yes" << endl;
      passed++;
      foreign++;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;


int main(){
  
  int m,d; cin >> m >> d;
  int ans=0;
  
  for (int i=1; i<=m; i++){
    for (int j=1; j<=d; j++){
      int d10=(int)j/10;
      int d1=j%10;
      if (i==d10*d1 && d1>=2 && d10>=2){
        ans++;
      }
    }
  }

  cout << ans;
 
  return 0;
}


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


#define int                long long int
#define jaldichal          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                 push_back
#define mk                 make_pair
#define R                  return
#define C                  continue
#define line               "\n"
#define space              " "
#define sizee(v)           ((int)((v).size()))
#define arrsize            200005
#define odd(x)             ((int)(x&1))
#define fi                 first
#define se                 second
#define all(x)             x.begin(),x.end()
#define w(x)               int x;cin>>x;for(int i=1;i<=x;i++)

#define vi                 vector<int>
#define vii                vector<pair < int , int > > 
#define setbits(x)         __builtin_popcountll(x)
#define pii                pair<int, int>
#define inp(v)             for(auto &x : v)cin>>x
int n,m;

void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*c,max(b*c,max(b*d,a*d)));
}
signed main()
{    
    jaldichal
    solve();



return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n, k,sum = 0;

	cin >> n >> k;
	rep(i, n) {
		int x; 
		cin >> x;

		sum += (min(k - x, x)) * 2;
	}
	cout << sum << endl;

	return	0;
}


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

int main() {
  int n;
  cin >> n;
  int c[26], s[n][26];
  vector<int> last(26, -1);
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  for (int i = 0; i < n; ++i) {
    int neg(0), score(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      if (last[j] >= 0) neg -= c[j];
    }
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + (last[j] >= 0 ? c[j] : 0);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    cout << test + 1 << endl;
    last[test] = i;
  }
  return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>

int main(void){

  int A , B;
  scanf("%d %d" , &A , &B);

  //余ったスペースがさの二倍より大きいか
  int sum = A + B;
  int sa = (A < B) ? B - A : A - B;

  if((2 * sa) <= (16 - sum)){
    puts("Yay!");
  }else{
    puts(":(");
  }

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624