akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    int num=0;
    if(s[0]=='L'){
        for(int i=1;i<n;i++){
            if(s[i]=='R'){
                if(i==n-1){
                    s[i]='L';
                    num++;
                }
                else if(s[i+1]=='R'){
                    s[i]='L';
                }
                else{
                    s[i]='L';
                    num++;
                }
            }
            if(num==k){
                i=n;
            }
        }
    }
    else{
        for(int i=1;i<n;i++){
            if(s[i]=='L'){
                if(i==n-1){
                    s[i]='R';
                    num++;
                }
                else if(s[i+1]=='L'){
                    s[i]='R';
                }
                else{
                    s[i]='R';
                    num++;
                }
            }
            if(num==k){
                i=n;
            }
        }
    }
    num=0;
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            if(i!=0){
                if(s[i-1]=='L')num++;
            }
        }
        else{
            if(i!=n-1){
                if(s[i+1]=='R')num++;
            }
        }
    }
    cout << num<<endl;
    return 0;
}



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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if(b%a == 0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import bisect
N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
dict = {}
for i in range(N):
    if a[i] in dict:
        dict[a[i]] += b[i]
    else:
        dict[a[i]] = b[i]
array = sorted(list(dict.items()))
ruiseki = [0]*len(array)
ruiseki[0] = array[0][1]
for i in range(1, len(array)):
    ruiseki[i] = ruiseki[i-1] + array[i][1]
print(array[bisect.bisect_left(ruiseki, K)][0])

Measured memory_bytes: 22276
#include<stdio.h>

int A[30];
int B[30];

int main(){
	int n,i,j;
	int ans = 0;
	int tmp = 0;
	char str[1000];
	
	scanf("%d",&n);
	scanf("%s",str);
	
	for(i = 0;i < n;i++){
		tmp = 0;
		for(j = 0;j < 30;j++){
			A[j] = 0;
			B[j] = 0;
		}
		for(j = 0;j < i;j++){
			A[str[j]-'a']++;
		}
		for(j = i;j < n;j++){
			B[str[j]-'a']++;
		}
		
		for(j = 0;j < 26;j++){
			if(A[j] > 0&& B[j] > 0)tmp++;
		}
		
		if(ans < tmp)ans = tmp;
	}

	printf("%d\n",ans);	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int m = scan.nextInt();
    int l = scan.nextInt();
    int[][] a = new int[n][m];
    int[][] b = new int[m][l];
    long[][] c = new long[n][l];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        a[i][j] = scan.nextInt();
      }
    }

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < l; j++) {
        b[i][j] = scan.nextInt();
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < l; j++) {
        for (int k = 0; k < m; k++) {
          c[i][j] += a[i][k] * b[k][j];
        }
        System.out.print(c[i][j]);
        if (j < l - 1) {
          System.out.print(" ");
        }
      }
      System.out.println();
    }

  }

}



Measured memory_bytes: 55096
k = gets.to_i
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k.times do
    $n = queue.shift
    queue.push(10 * $n + $n % 10 - 1) if $n % 10 != 0
    queue.push(10 * $n + $n % 10)
    queue.push(10 * $n + $n % 10 + 1) if $n % 10 != 9
end
puts $n


Measured memory_bytes: 3964
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		
		out.close();
	}
	
	static class TaskC
	{
		void solve(int TestCase, InputReader in, PrintWriter out)
		{
			int n = in.nextInt();
			int[] data = new int[n];
			for(int i = 0; i < n; i++)
			{
				data[i] = in.nextInt();
			}
			
			int start = 0;
			int ans = 0;
			for(int i = 1; i < n; i++)
			{
				if(data[i] > data[i - 1]) start = i;
				ans = Math.max(ans, i - start);
			}
			
			out.println(ans);
		}
	}
	
	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 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());
		}
	}
}

Measured memory_bytes: 41056
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <stdexcept>
using namespace std;
long long a, b, n;

int main() {
   cin >> a >> b >> n;
   if ((b-1) <= n)  cout << a * (b-1) / b << endl;
   else cout << a*n/b << endl;
}

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

int main(void)
{
	int a,b,c,t;
	scanf("%d%d%d",&a,&b,&c);
	t=a;
	a=b;
	b=t;
	
	t=a;
	a=c;
	c=t;
	
	printf("%d %d %d",a,b,c);
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 1;
    char pre = S[0];
    rep(i, N) {
        if (pre != S[i]) {
            cnt++;
            pre = S[i];
        }
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 512
n, t = map(int, input().split())
mc = 10 ** 9
for i in range(n):
    c1, t1 = map(int, input().split())
    if t1 <= t:
        mc = min(mc, c1)
if mc == 10 ** 9:
    print("TLE")
else:
    print(mc)


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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int H, W;
    string buf;
    vector<string> s;

    cin >> H >> W;

    string padding = "";
    rep(i, W+2) {
        padding = padding +'.';
    }
    s.push_back(padding);
    rep(i, H) {
        cin >> buf;
        s.push_back('.'+buf+'.');
    }
    s.push_back(padding);

    rep(i, H) {
        rep(j, W) {
            if (s[i+1][j+1] == '#') {
                if ((s[i][j+1] == '#')
                || (s[i+1][j] == '#')
                || (s[i+2][j+1] == '#')
                || (s[i+1][j+2] == '#')) 
                {
                    continue;
                }

                else {cout << "No" << endl; return 0;}
                
            }
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 3640
/***************************************************
 * Problem Name : B - Palindrome-philia .cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-12-08
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    string str;
    cin >> str;
    int cnt = 0;

    for (int i = 0, j = (int) str.size() - 1; i < j; i++, j--) {
        if (str[i] != str[j]) cnt++;
    }
    cout << cnt << "\n";

    return 0;
}


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

int main() {
    ll X,D,K;
    cin>>X>>K>>D;
    X=abs(X);
    ll move=min(K,X/D);
    X-=move*D;
    K-=move;
    if(K%2==0)cout<<X;
    else cout<<D-X<<endl;
}

Measured memory_bytes: 3628
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int h,w;
    cin>>h>>w;
    char grid[h][w];
    rep(i,0,h)
    {
        rep(j,0,w)
        {
            cin>>grid[i][j];
        }
    }
    int dp[h][w];
    dp[0][0] = 1;
    rep(i,1,h)
    {
        if(grid[i][0] != '#')
            dp[i][0] = dp[i-1][0]%mod;
        else
            dp[i][0] = 0;
    }
    rep(i,1,w)
    {
        if(grid[0][i] != '#')
            dp[0][i] = dp[0][i-1]%mod;
        else
            dp[0][i] = 0;
    }
    rep(i,1,h)
    {
        rep(j,1,w)
        {
            if(grid[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = dp[i-1][j]%mod + dp[i][j-1]%mod;
        }
    } 
    cout<<dp[h-1][w-1]%mod<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f;
}
inline void file(){
	freopen(".in","r",stdin);
}
const int maxn = 1e5 + 10;
int x[maxn], c[maxn];
int F[maxn], G[maxn];
int p1[maxn], p2[maxn];
int dp[maxn][5]; 
signed main(){
	int n = read(); int Dis = read();
	for (int i = 1; i <= n; ++i) x[i] = read(), c[i] = read();
	int ans = 0, now = 0;
	for (int i = 1; i <= n; ++i) now = now + c[i], ans = max(ans, now - x[i]);
	now = 0;
	for (int i = n; i >= 1; --i) now = now + c[i], ans = max(ans, now - (Dis - x[i]));
	now = 0;
	for (int i = 1; i <= n; ++i){ now += x[i - 1] - x[i] + c[i]; }
	dp[0][3] = Dis - x[1]; dp[0][2] = now + x[1] - (Dis - x[n]);
	x[n + 1] = Dis;
	for (int i = 1; i <= n; ++i) { 
		dp[i][0] = dp[i - 1][0] - (x[i] - x[i - 1]) + c[i];
		dp[i][1] = dp[i - 1][1] + (x[i] - x[i - 1]);
		dp[i][2] = dp[i - 1][2] + (x[i + 1] - x[i]) - c[i];
		dp[i][3] = dp[i - 1][3] - (x[i + 1] - x[i]);
	}
	int L = 0, R = 0;
	for (int i = 1; i <= n; ++i) 
		p1[i] = max(p1[i - 1], dp[i][0]);
	for (int i = n; i >= 1; --i)
		p2[i] = max(p2[i + 1], dp[i][2]);	
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, p1[i] + p2[i] - dp[i][3]);
		ans = max(ans, p1[i] - dp[i][1] + p2[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int x;
int main(){
    cin>>N;
    int A[100];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }        

    sort(A,A+N,greater<int>());
    for(int i=0;i<N;i++)x+=A[i]*(i%2!=1?1:-1);             
    cout<<x<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#define mem(a,b) memset(a,b,sizeof(a))
 
using namespace std;
const int MOD=1e9+7;
typedef long long ll;
const int MAXN=1e5+15;
const ll INF=0x3f3f3f3f;
 
typedef pair<ll,ll>PA;
 
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x);x=(x*x);}return res;}
pair<ll,ll>P;
vector<PA> V;
multiset<ll>R,B;
int cmp(PA a,PA b)
{
    return a.first<b.first;
}
int main()
{
    int n;
    ll x,y;
    ll res2,ans;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        V.push_back(make_pair(min(x,y),max(x,y)));
        R.insert(min(x,y));
        B.insert(max(x,y));
    }
    ll maR=-INF,maB=-INF;
    ll miR=INF,miB=INF;
    int col_max=0,col_min=0;
    sort(V.begin(),V.end(),cmp);
    for(int i=0;i<V.size();i++)
    {
        maR=max(V[i].first,maR);
        maB=max(V[i].second,maB);
        miR=min(V[i].first,miR);
        miB=min(V[i].second,miB);
    }
 
    ans=(maR-miR)*(maB-miB);
    //cout<<ans<<endl;
    for(int i=0;i<V.size();i++)
    {
        R.erase(R.find(V[i].first));
        B.insert(V[i].first);
        //swap
        B.erase(B.find(V[i].second));
        R.insert(V[i].second);
 
        //cout<<( *R.rbegin()-*R.begin() )<<" "<<( *B.rbegin()-*B.begin())<<endl;
        ans= min (ans,( *R.rbegin()-*R.begin() )*( *B.rbegin()-*B.begin()) );
    }
    cout<<ans<<endl;
    return 0;
}

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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long long ld;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll cnt = 1;
    for (ll i = 1; i < s.size(); i++) {
        if (s[i - 1] != s[i]) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 512
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var y = int.Parse(line[1]) / 1000;
        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; j <= n - i; j++)
            {
                if (i * 10 + j * 5 + (n - i - j) == y) { Console.WriteLine("{0} {1} {2}", i, j, n - i - j); goto end; }
            }
        }
        Console.WriteLine("{0} {1} {2}", -1, -1, -1);
        end:;
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    int ans = 0;
    while(!(A%2) && !(B%2) && !(C%2)){
        if(A == B && B == C){ans = -1;break;}
        ++ans;
        int a = B / 2 + C / 2;
        int b = A / 2 + C / 2;
        int c = A / 2 + B / 2;

        A = a;
        B = b;
        C = c;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ans, cnt;
set<string> S;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        int x; cin >> x;
        string t;
        if (1 <= x && x < 400) t = "ash";
        else if (400 <= x && x < 800) t = "brown";
        else if (800 <= x && x < 1200) t = "green";
        else if (1200 <= x && x < 1600) t = "water";
        else if (1600 <= x && x < 2000) t = "blue";
        else if (2000 <= x && x < 2400) t = "yellow";
        else if (2400 <= x && x < 2800) t = "orange";
        else if (2800 <= x && x < 3200) t = "red";
        else {
            cnt++;
            continue;
        }
        S.insert(t);
    }
    int mn = S.size(), mx = mn + cnt;
    if (mn == 0) mn = 1;
    cout << mn << " " << mx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
typedef struct{
  int n;
  std::string str;
}data;


typedef struct q{
  private:
    static const int max = 100001;/*量に応じて変更*/
    int head,tail;
    data a[max];
  public:
    void initialize(){
      head=0;tail=0;
    }
    bool isEmpty(){
      return head==tail;
    }
    void enqueue(data x){
      if (tail==max)tail=0;
      a[tail]=x;
      tail++;
    }
    data dequeue(){
      if (head==max)head=0;
      head++;
      return a[head-1];
    }
}queue;

int main(){
  queue q;
  int n,k,i,time=0;
  data temp;
  std::cin >> n>>k;
  for (i=0;i<n;i++){
    std::cin >> temp.str>>temp.n;
    q.enqueue(temp);
  }
  while (!(q.isEmpty())){
    temp=q.dequeue();
    if (temp.n<=k){
      time+=temp.n;
      std::cout << temp.str<<' '<<time << '\n';
    }else{
      time+=k;
      temp.n-=k;
      q.enqueue(temp);
    }
  }

}



Measured memory_bytes: 7088
#include <bits/stdc++.h>
#define p first
#define c second
#define inf 999999999
using namespace std;
int main(void){
    int n,i,u=0;
    cin>>n;
    vector<pair<int,int>> p(n,pair<int,int>(0,inf));
    vector<int> used(n,0);
    vector<bool> ok(100000,true);
    for(i=0;i<n;i++)
        cin>>p[i].first;
    deque<pair<int,int>> q;
    q.emplace_front(0,0);
    while(!q.empty()){
        pair<int,int> now=q.front();q.pop_front();
        if(now.p>=n-1){
            cout<<now.c<<endl;
            return 0;
        }
        if(p[now.p].second>now.c){
            p[now.p].second=now.c;
        }else{
            continue;
        }
        if(p[now.p].first!=0){
            if(ok[used[now.p]]){
                u++;
                used[now.p]=u;
            }
            else continue;
            do{
                now.p+=p[now.p].first;
                if(used[now.p]!=u && ok[used[now.p]]) used[now.p]=u;
                else{
                    ok[u]=false;
                    break;
                }
                if(now.p>=n-1){
                    cout<<now.c<<endl;
                    return 0;
                }
                if(p[now.p].first==0){
                    q.push_front(now);
                    break;
                }
            }while(1);
        }
        else{
            for(i=1;i<=6;i++){
                q.emplace_back(now.p+i,now.c+1);
            }
        }
    }
    cout<<"error!"<<endl;
    return 0;
}


Measured memory_bytes: 4104
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    for (int i = 1; i < n; i++) {
      if (h[i - 1] < h[i]) h[i]--;
      if (h[i] < h[i - 1]) {
        os.println("No");
        return;
      }
    }
    os.println("Yes");
  }
}


Measured memory_bytes: 50308
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(C, L, R, up) for (ll C = L; C < R; C += up)
#define rev(C, R, L, down) for (ll C = R - 1; C >= L; C -= down)

ll solve1(ll x)
{
    ll yen500 = x / 500;
    ll yen5 = (x - (yen500 * 500)) / 5;
    ll happy = yen500 * 1000 + yen5 * 5;
    return happy;
}

int main(void)
{
    ll x;
    cin >> x;
    cout << solve1(x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

using namespace std;

int main(){
    io

    int n,t,a;
    cin >> n >> t >> a;
    
    double min(100000);
    int index;
    for(int i(0); i<n; i++){
        double x; cin >> x;
        x = t - (x * 0.006);
        if(abs(a - x) < min){
            min = abs(a - x);
            index = i;
        }
    }
    cout << index + 1 << ENDL;
 
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}else{
		return gcd(b, a % b);
	}
}

vector<ll> getPrime(ll N) {
	vector<ll> ps;
	ll a = 2;
	while(N > a * a) {
		if (N % a == 0) {
			ps.push_back(a);
			N /= a;
		}else{
			a++;
		}
	}
	return ps;
}

ll modpow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    ll res = modpow(x, y / 2);
    return res * res % mod;
}

int main() {
	ll N, K;
	cin >> N >> K;
	// vector<ll> ps = getPrime(N);
	// size = ps.size();
	vector<ll> tmp(K+1, 0);
	for (ll i = K;i > 0;i--) {
		tmp[i] = modpow(K / i, N);
		for (ll j = 2;j < 1e9;j++) {
			if (i * j > K) break;
			tmp[i] += mod - tmp[i * j];
			tmp[i] %= mod;
		}
	}
	ll ans = 0;
	for (ll i = 1;i <= K;i++) {
		ans += i * tmp[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4000
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int[] a,b;
        a = new int[101];
        b = new int[101];
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int i,j,t,now=111,co=0,nowt=-1;
        for(i=0;i<n;i++)a[i] = s.nextInt();
        for(i=0;i<n;i++){
            for(j=i;j<n;j++){
                if(now>a[j]){
                    now=a[j];
                    nowt = j;
                }
            }
            if(a[i]!=now&&nowt>=0){
                t = a[nowt];
                a[nowt] = a[i];
                a[i]=t;
                co++;
            }
            now=111;
        }
        for(i=0;i<n;i++){
            if(i==0)System.out.print(a[i]);
            else System.out.print(" "+a[i]);
        }
        System.out.println();
        System.out.println(co);


    }
}


Measured memory_bytes: 26428
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<int> v(3);
	for (int i=0; i<3; i++)
		cin>>v[i];
	swap (v[0],v[1]);
	swap (v[0],v[2]);
	for (int i=0; i<3; i++)
		cout<<v[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int mod = 1000003;
inline int mul(int x,int y){return 1ll*x*y%mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}

int n,m,a[1000010],inv[1000010],q;

int main() {
	a[0] = a[1] = 1;inv[1] = 1;
	for(int i=2;i<mod;i++){
		a[i] = 1ll*a[i-1]*i%mod;
		inv[i] = ((-1ll*(mod/i)*inv[mod%i])%mod+mod)%mod;
	}
	//cout<<mul(a[221],inv[a[220]])<<endl;
	read(q);
	while(q--){
		int x,d,n;
		read(x);read(d);read(n);
		if(d == 0){
			cout<<pow(x,n)<<endl;
			continue;
		}
		x = 1ll*x*inv[d]%mod;
		//cout<<x<<endl;
		if(x == 0 || x+n-1>=mod){
			cout<<0<<endl;
			continue;
		}
		cout<<mul(mul(a[x+n-1],inv[a[x-1]]),pow(d,n))<<endl;
	}
	return 0;
}


Measured memory_bytes: 8704
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 100000;

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

    vector<vector<int> > v(m, vector<int>(MAX+1, 0));
    for(int i=0; i<n; ++i){
        int s, t, c;
        cin >> s >> t >> c;
        ++ v[c-1][s];
        -- v[c-1][t];
    }

    vector<int> w(MAX+2, 0);
    for(int i=0; i<m; ++i){
        for(int j=0; j<=MAX; ++j){
            if(v[i][j] == 1)
                ++ w[j];
            else if(v[i][j] == -1)
                -- w[j+1];
        }
    }
    for(int i=0; i<=MAX; ++i)
        w[i+1] += w[i];

    int ans = *max_element(w.begin(), w.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  vi cnt(N,0);
  rep(i,N) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  sort(rng(A));
  int r = A.back();
  int l = A[0];
  if(r<2&&N>2) {
    cout << "Impossible" << endl;
    return 0;
  }
  if(l!=(r+1)/2) {
    cout << "Impossible" << endl;
    return 0;
  }
  if(r%2==0&&cnt[l]!=1) {
    cout << "Impossible" << endl;
    return 0;
  }
  if(r%2==1&&cnt[l]!=2) {
    cout << "Impossible" << endl;
    return 0;
  }
  srep(i,l+1,r+1) {
    if(cnt[i]<2) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1L<<61);

int main() {
  int n; cin >> n;
  rep(i,50001) {
    if (floor(1.08*i) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String n = in.readString();

            int digSum = 0;
            for (char c : n.toCharArray()) {
                digSum += c - '0';
            }

            System.out.println(digSum % 9 == 0 ? "Yes" : "No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 34288
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := make([]int, 9)
	for i := 0; i < 9; i++ {
		a[i] = nextInt()
	}
	n := nextInt()
	var b int
	for i := 0; i < n; i++ {
		b = nextInt()
		for j := 0; j < 9; j++ {
			if a[j] == b {
				a[j] = -1
			}
		}
	}

	ans := false
	if a[0] == -1 && a[1] == -1 && a[2] == -1 {
		ans = true
	}
	if a[3] == -1 && a[4] == -1 && a[5] == -1 {
		ans = true
	}
	if a[6] == -1 && a[7] == -1 && a[8] == -1 {
		ans = true
	}
	if a[0] == -1 && a[3] == -1 && a[6] == -1 {
		ans = true
	}
	if a[1] == -1 && a[4] == -1 && a[7] == -1 {
		ans = true
	}
	if a[2] == -1 && a[5] == -1 && a[8] == -1 {
		ans = true
	}
	if a[0] == -1 && a[4] == -1 && a[8] == -1 {
		ans = true
	}
	if a[2] == -1 && a[4] == -1 && a[6] == -1 {
		ans = true
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, a[200000];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];

    int num[200010] = {};
    for (int i = 0; i < n; i++) {
        num[a[i]]++;
    }

    sort(num, num + 200010);

    int cnt = 0;
    for (int i = 0; i < 200010; i++) {
        if (num[i]) cnt++;
    }
    // cout << cnt << endl;

    int ans = 0;
    for (int i = 0; i < 200010 and max(0, cnt - k); i++) {
        if (!num[i]) continue;
        ans += num[i];
        cnt--;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
    #include <math.h>
    using namespace std;
    int main(){
      int N,cnt=0;
      cin>>N;
      int a[N];
      for(int i=0;i<N;i++) cin>>a[i];
      sort(a,a+N);
      for(int i=0;i<N;i++){
        if(a[i]==a[i+1]) continue;
        else cnt++;
      }  
      cout<<cnt<<endl;
    }

Measured memory_bytes: 256
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)


Measured memory_bytes: 9272
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=15;
char mp[N][N];int vis[N][N],n,m;
bool dfs(int x,int y){
	vis[x][y]=1;
	if(x==n&&y==m)return true;
	R int c=0;
	if(x<n&&mp[x+1][y]=='#')++c;
	if(y<m&&mp[x][y+1]=='#')++c;
	if(c!=1)return false;
	if(x<n&&mp[x+1][y]=='#')return dfs(x+1,y);
	if(y<m&&mp[x][y+1]=='#')return dfs(x,y+1);
}
int main(){
	scanf("%d%d",&n,&m);
	fp(i,1,n)scanf("%s",mp[i]+1);
	if(mp[1][1]!='#'||mp[n][m]!='#')return puts("Impossible"),0;
	if(!dfs(1,1))return puts("Impossible"),0;
	fp(i,1,n)fp(j,1,m)if((mp[i][j]=='#')!=vis[i][j])return puts("Impossible"),0;
	return puts("Possible"),0;
}

Measured memory_bytes: 384
void main() {
	auto S = rs;
	'x'.repeat(S.length).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
function main()
  
  N = parse(Int,readline())
  
  S = []
  T = []
  
  for i in 1:N
    (s,t) = split(chomp(readline()), " ")
    t = parse(Int,t)
    push!(S,s)
    push!(T,t)
  end
  
  X = chomp(readline())
  
  check = false
  ans = 0
  
  for i in 1:N
    if S[i] == X
      check = true
      continue
    end
    if check
      ans += T[i]
    end
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 112400
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
// const int INF=4e18+10;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}
void solve()
{
    int a;
    long double b;
    cin>>a>>b;
    cout<<(int)(a*b)<<endl;


}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3816
package main

import (
  "fmt"
)

func rec(s string, ln int, mx byte) {
  if len(s) == ln {
    fmt.Println(s)
  }else{
    for i := byte('a'); i < mx; i++ {
      rec(s + string(i), ln, mx)
    }
    rec(s + string(mx), ln, mx + 1)
  }
}

func main() {
  var N int
  fmt.Scanf("%d\n", &N)
  rec("", N, 'a')
}

Measured memory_bytes: 6016
#include<stdio.h>
#include<iostream>
using namespace std;
int main (){
    int n,d,x;
    cin >> n >> d >> x;
    int total=0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        total += (d - 1) / a + 1;
    }
    cout << total + x << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  fscanf(STDIN,"%d %d",$d,$x);
  $eat = [];
  for($i=0; $i<$n; $i++){
    $a = trim(fgets(STDIN));
    for($j=0; $j<$d; $j++){
      $cal = $j*$a +1;
      if($cal <= $d){
        $eat[] = $cal;
      }
    }
  }
  echo count($eat)+$x."\n";

Measured memory_bytes: 4604
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=305,inf=1e8;
#define pb push_back
struct lines{
    int to,flow,cap;
}l[maxn*maxn*5];
vector<int> g[maxn];
int cur[maxn],d[maxn],t=-1,S,T;
bool v[maxn];
 
inline void add(int from,int to,int cap){
    l[++t]=(lines){to,0,cap},g[from].pb(t);
    l[++t]=(lines){from,0,0},g[to].pb(t);
}
 
inline bool BFS(){
    memset(v,0,sizeof(v)),v[S]=1,d[S]=0;
    queue<int> q; q.push(S);
    int x; lines e;
     
    while(!q.empty()){
        x=q.front(),q.pop();
        for(int i=g[x].size()-1;i>=0;i--){
            e=l[g[x][i]];
            if(e.flow<e.cap&&!v[e.to]) v[e.to]=1,d[e.to]=d[x]+1,q.push(e.to);
        }
    }
     
    return v[T];
}
 
int dfs(int x,int A){
    if(x==T||!A) return A;
    int flow=0,f,sz=g[x].size();
    for(int &i=cur[x];i<sz;i++){
        lines &e=l[g[x][i]];
        if(d[x]+1==d[e.to]&&(f=dfs(e.to,min(e.cap-e.flow,A)))){
            A-=f,flow+=f;
            e.flow+=f,l[g[x][i]^1].flow-=f;
            if(!A) break;
        }
    }
     
    return flow;
}
 
inline int max_flow(){
    int an=0;
    while(BFS()){
        memset(cur,0,sizeof(cur));
        an+=dfs(S,inf);
    }
    return an;
}
 
int n,m;
char ch;
 
int main(){
    scanf("%d%d",&n,&m),S=0,T=n+m+1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            ch=getchar();
            while(ch!='.'&&ch!='o'&&ch!='S'&&ch!='T') ch=getchar();
            if(ch!='.') add(i,j+n,1),add(j+n,i,1);
            if(ch=='S') add(S,i,inf),add(S,j+n,inf);
            else if(ch=='T') add(i,T,inf),add(j+n,T,inf);
        }
     
    int ans=max_flow();
    if(ans>=inf) puts("-1");
    else printf("%d\n",ans);
     
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    int num = 0;
    for(int i = 1; i < s.size(); i++) {if(s[i] == 'W') num++;}
    //cout << num << " ";
    int mx = num;
    int cur = num;
    for(int i = 1; i < s.size(); i++){
        cur += (s[i - 1] == 'E') - (s[i] == 'W');
        mx = max(mx, cur);
    }
    cout << n - mx - 1;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> p[100005];
priority_queue<ll> q;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        p[x].push_back(y);
    }
    for(int i=1;i<=m;i++){
        for(int j=0;j<p[i].size();j++){
            q.push(p[i][j]);
        }
        if(q.size()){
            ans+=q.top();q.pop();
        }
    }
    cout<<ans<<endl;
}


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

int main() {

 int N,K;
  cin >> N >> K;
  
  int x = 0;
  int a;
 for(int i=0;i<N;i++){
   cin >> a;
   if (K-a > a){
     x += a;
   }
   else if(K<a){
     x += a-K;
   }
   else{
     x += K-a;
   }
 }
 cout << 2 * x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define m 1000000007
using namespace std;
/*ll mod(ll x,ll y)
{ ll ans=1;

    while(y>0)
    {
        if(y&1)
            ans=ans*x %m;
        y/=2;
        x=(x*x) %m;

    }
    return ans;
}*/
int main()
{
 /*ll a,b,c,d,m,n,res=0;
 cin>>a>>b>>c>>d;
 cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;*/

 /*ll n;
 cin>>n;
 ll ans= (mod(10,n)-(mod(9,n)*2-mod(8,n)))%m;
 //ll ans=mod(8,n);
 if(ans<0)
    ans+=m;
 cout<<ans<<endl;
 ll s;
 cin>>s;
 vector<ll> v(s+1);
 v[0]=1;
 for(int i=3;i<=s;i++)
 {

     for(int j=0;j<=i-3;j++)
     {
         v[i]+=v[j];
         v[i]%=m;

     }
 }
 cout<<v[s]<<endl;*/
 ll n,x,y;
 cin>>n;
 ll a[n];
 ll b[n];
 for(ll i=0;i<n;i++)
 {
     cin>>x>>y;
     a[i]=x+y;b[i]=x-y;

 }
 sort(a,a+n);
 sort(b,b+n);
 cout<<max(a[n-1]-a[0], b[n-1]-b[0])<<endl;
return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll N, D;
  cin >> N >> D;

  vector<ll> X(N), Y(N);
  for(ll i=0; i<N; i++) cin >> X[i] >> Y[i];

  ll n = 0;
  for(ll i=0; i<N; i++){
    if (X[i]*X[i] + Y[i]*Y[i] <= D * D){
       ++n;
    }
  }

  cout << n << endl;

  return 0;
}

Measured memory_bytes: 6420
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;
const int MAXLG=60;
const int MAXVAL=200000;

int n; ll times;
int a[MAXN];
int ans[MAXN],nans;

pair<int,int> o[MAXN];
ll cnt[MAXN][MAXLG+1];

int pos[MAXVAL+1];

ll safeadd(ll a,ll b) { if(a>LLONG_MAX-b) return LLONG_MAX; return a+b; }

void solve() {
	REP(i,n) o[i]=MP(a[i],i);
	sort(o,o+n);
	for(int l=0,r=l;l<n;l=r) {
		while(r<n&&o[r].first==o[l].first) ++r;
		FOR(i,l,r-1) cnt[o[i].second][0]=o[i+1].second-o[i].second+1;
		cnt[o[r-1].second][0]=o[l].second-o[r-1].second+n+1;
	}
	//printf("cnt:"); REP(i,n) printf(" %lld",cnt[i][0]); puts("");
	REP(k,MAXLG) REP(i,n) cnt[i][k+1]=cnt[i][k]==LLONG_MAX?LLONG_MAX:safeadd(cnt[i][k],cnt[(i+cnt[i][k])%n][k]);

	ll sofar=0; int at=0;
	for(int k=MAXLG;k>=0;--k) if(sofar+cnt[at][k]<=n*times) sofar+=cnt[at][k],at=(at+cnt[at][k])%n;
	//printf("sofar=%lld at=%d\n",sofar,at);

	ll rem=n*times-sofar;
	if(rem==0&&at==0) at=n;
	//printf("rem=%lld at=%d\n",rem,at);
	assert(rem<=n&&rem+at==n);

	memset(pos,-1,sizeof(pos));
	nans=0;
	FOR(i,at,n) {
		int x=a[i],z=pos[x];
		if(z!=-1) {
			//printf("x=%d z=%d nans=%d\n",x,z,nans);
			while(nans>z) --nans,pos[ans[nans]]=-1;
		} else {
			pos[x]=nans,ans[nans++]=x;
		}
	}
}

void run() {
	scanf("%d%lld",&n,&times);
	REP(i,n) scanf("%d",&a[i]);
	solve();
	REP(i,nans) { if(i!=0) printf(" "); printf("%d",ans[i]); } puts("");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 100736