akhauriyash/Code-Regression huggingface dataset:
#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>
     ordered_set s;
     s.insert(1);
     cout<<*s.find_by_order(1); //print kth smallest element
     cout<<s.order_of_key(3);  //print number of strictly smaller element of 3;
*/
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pi acos(-1)
#define bp __builtin_popcount
#define ll long long int
#define ld long double
#define endl '\n'
#define pii pair<ll , ll>
#define tii tuple<ll,ll,ll>
//aaaccess element of tuple ex. 3rd element(index 2) cout<< get<2>(tuppleName);

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define minq priority_queue <int, vector<int>, greater<int> >
#define maxQueue priority_queue<ll>
#define pb push_back
#define mx3(a,b,c) max(a,max(b,c))
#define pf push_front
#define ff first
#define ss second
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
const ll N = 1000005;
const ll M = 1e6 + 10;
const ll mod = 998244353;

// ll power(ll x, ll y, ll p)
// {
// 	ll res = 1;
// 	x = x % p;
// 	while (y > 0)
// 	{
// 		if (y & 1)
// 			res = (res * x) % p;
// 		y = y >> 1;
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// ll modinv(ll n, ll p)
// {
// 	return power(n, p - 2, p);
// }
// ll ncr(ll n, ll r, ll p)
// {
// 	if (r == 0)
// 		return 1;
// 	int n1 = n;
// 	ll fac[n1 + 1];
// 	fac[0] = 1;
// 	for (int i = 1 ; i <= n; i++)
// 		fac[i] = fac[i - 1] * i % p;

// 	return (fac[n] * modinv(fac[r], p) % p *
// 	        modinv(fac[n - r], p) % p) % p;
// }
/*vector<bool> prime(N, true);
void sieve()
{
	for (int i = 2; i <= sqrt(N); ++i) {
		if (prime[i]) {
			for (int j = i * i; j <= N; j += i) {
				prime[j] = false;
			}
		}
	}
}/*

/*int Prime[M];
void MinPrimeFactor()
{
	for (ll i = 1; i < M; i++) Prime[i] = i;
	for (int p = 2; p * p <= M; p++)
	{
		if (Prime[p] == p)
		{
			for (int i = 2 * p; i <= M; i += p)
			{
				Prime[i] = min(p, Prime[i]);
			}
		}
	}
}*/

/*vector<int> getFactorization(int x)
{
	vector<int> ret;
	while (x != 1)
	{
		ret.push_back(Prime[x]);
		x = x / Prime[x];
	}
	return ret;
}
*/
bool isPowerOfTwo(int x)
{
	return (x && !(x & (x - 1)));
}
int main()
{
	FAST;
	int i, j, k, n, t, sum = 0;
	cin >> n;
	map<int, int>mp;
	for (i = 1; i <= sqrt(n); i++)
	{
		for (j = 1; j <= sqrt(n); j++)
		{
			for (k = 1; k <= sqrt(n); k++)
			{
				sum = i * i + j * j + k * k + i * j + k * j + i * k;
				mp[sum]++;
			}
		}
	}
	for (i = 1; i <= n; i++)
		cout << mp[i] << endl;
	return 0;
}

Measured memory_bytes: 5332
using System;

namespace ITP1_5_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for(int i = 1; i <= n; i++)
            {
                if (CheckNum(i))
                    continue;
                Include3(i);
            }
            Console.WriteLine();
        }

        static bool CheckNum(int i)
        {
            if (i % 3 == 0)
            {
                Console.Write(" {0}", i);
                return true;
            }
            return false;
        }

        static void Include3(int i)
        {
            var x = i;
            while (x > 0)
            {
                if (x % 10 == 3)
                {
                    Console.Write(" {0}", i);
                    return;
                }
                x /= 10;
            }
        }
    }
}

Measured memory_bytes: 9288
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    lint n=input;
    std::vector<lint>a(n);
    for(lint&x:a)x=input;

    lint ans=0;
    std::map<lint,lint>map;
    for(lint i=0;i<n;i++){
        ans+=map[i-a.at(i)];
        map[i+a.at(i)]++;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 27452
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++){
    	cin>>p[i];
    }
    double _dp[2*(n+5)+1]={0};
    double* dp=_dp+(n+5);
    dp[0]=1;
    for(int i=0;i<n;i++){
        //if(i==1)dp[0]=0;
    	double _dp1[2*n+1]={0};
    	double* dp1=_dp1+n;
    	for(int j=-i;j<=i;j++){
    		dp1[j-1]+=(1-p[i])*(dp[j]);
    		dp1[j+1]+=(p[i])*(dp[j]);
    	}
    	for(int j=-n;j<=n;j++){
    		dp[j]=dp1[j];
    	}
    }
    double ans=0;
    for(int i=1;i<=n;i++){
    	ans+=dp[i];
    }
    cout<<fixed<<setprecision(15)<<ans;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.start();
		

	}
	private void start(){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		System.out.printf("%d %d\n", a * b, (a + b) * 2);
	}

}

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

int main() {
    int ans = 0;
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int A_MAX = *max_element(A.begin(), A.end());
    vector<int> Num(A_MAX + 1, 1);
    sort(A.begin(), A.end());
    int Now_num = 0;
    for(int i = 0; i < N; i++) {
        int a = A.at(i);
        if(Now_num == a) {
            continue;
        }
        Now_num = a;
        if(Num.at(a) == 1) {
            if(i == N - 1 || A.at(i + 1) != a) {
                ans++;
            }
            int x = a;
            while(x <= A_MAX) {
                Num.at(x) = 0;
                x += a;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 8008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll mod = 1e9 + 7;
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    REP(i, N) cin >> T[i];
    REP(i, N) cin >> A[i];

    vector<bool> Tupdate(N, false), Aupdate(N, false);
    Tupdate[0] = true; Aupdate[N-1] = true;

    if(N==1) {
        if(T[0] == A[0]) {
            cout << 1 << endl;
            return 0;
        } else {
            cout << 0 << endl;
            return 0;
        }
    }
    
    FOR(i, 1, N-1) {
        if(T[i] > T[i-1]) Tupdate[i] = true;
    }

    FOR(i, 0, N-2) {
        if(A[i] > A[i+1]) Aupdate[i] = true;
    }

    REP(i, N) {
        if(Tupdate[i] && Aupdate[i] && T[i] != A[i]) {
            cout << 0 << endl;
            return 0;
        }
    }

    REP(i, N) {
        if( (!Tupdate[i] && Aupdate[i] && T[i] < A[i]) || (Tupdate[i] && !Aupdate[i] && T[i] > A[i])) {
            cout << 0 << endl;
            return 0;
        }
    }

    // if(Tmax != Amax) {
    //     cout << 0 << endl;
    //     return 0;
    // }

    ll ans = 1;
    REP(i, N) {
        if(!Tupdate[i] && !Aupdate[i]) {
            ans *= min(T[i], A[i]);
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
priority_queue<int,vector<int>,greater<int> >q;
vector<int>vec[maxn];
int a[maxn],fa[maxn];
int Find(int x){return fa[x]==x?fa[x]:fa[x]=Find(fa[x]);}
void Union(int x,int y){
    int xx=Find(x),yy=Find(y);
    if(xx!=yy) fa[xx]=yy;
}
void read(int &ret){
    ret=0;
    char ch=getchar();
    while(ch>'9'||ch<'0') ch=getchar();
    while(ch>='0'&&ch<='9'){
        ret=ret*10+ch-'0';
        ch=getchar();
    }
}
int main(){
    int n,m;
    read(n),read(m);
    for(int i=0;i<=n;i++) fa[i]=i;
    for(int i=0;i<n;i++){read(a[i]);}
    int u,v;
    for(int i=1;i<=m;i++){
        read(u),read(v);
        Union(u,v);
    }
    if(n==m+1){puts("0");return 0;}
    for(int i=0;i<n;i++){vec[Find(i)].push_back(a[i]);}
    long long ans=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(vec[i].size()){
            sort(vec[i].begin(),vec[i].end());
            ans+=vec[i][0];
            cnt++;
            for(int j=1;j<vec[i].size();j++) q.push(vec[i][j]);
        }
    }
    if((n-m-1)*2>n){puts("Impossible");return 0;}
    while(!q.empty()){
        if(cnt>=(n-m-1)*2) break;
        ans+=q.top();q.pop();
        cnt+=1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi square; for(int i = 40000; i > 0; i--) square.push_back(i*i);
  for (int i = N; i > 0; i--) {
    if (count(all(square),i)) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

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

	string s;
	cin >> s;

	sort(all(s));

	if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
 
template<class T>
inline bool read(T &num)  
{
       char in;bool IsN=false;
       while(in=getchar(),in!='-'&&(in<'0'||in>'9'))if(in==EOF)return false;
       in=='-'?(IsN=true,num=0):num=in-'0';
       while(in=getchar(),in>='0'&&in<='9')num=num*10+in-'0';
       return IsN?num=-num:num,true;
}
 
 
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define __m  int mid=l+(r-l)/1
 
const int maxn   = 2e6 + 7;
const LL  inf_LL = 9e18   ;
const int inf    = 2e9 + 7;
const int mod    = 1e9 + 7;

set<int>have;
int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    int n;
    read(n);
    while(n--)
    {
        int k;
        read(k);
        if(have.count(k)==1)
            have.erase(k);
        else 
            have.insert(k);
    }
    printf("%d\n",have.size());
    return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();

		if(3200 <= a) {
			System.out.print(s);
		}else {
			System.out.print("red");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    stack<ll> st;
    REP(i, n){
        ll x;
        cin >> x;
        st.push(x);
        if(st.top() < 2 * (st.size() - 1) + 1){
            ans *= st.size();
            ans %= MOD;
            st.pop();
        }
    }
    for(ll i = st.size(); i >= 1; i--){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  v1i v(n-1), a(n, 0);
  rep(i, n-1) cin >> v[i];
  rrep(i, n-1) a[v[i]-1]++;
  rep(i, n) cout << a[i] << endl;
  return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll k;
    cin >> k;
    for (ll i = 0; i < k; i++)
    {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string text, res;
	cin >> text;
	string const sorted_aidunyan = "AADINNUY";
	string const aizunyan = "AIZUNYAN";

	int length = text.length();
	if(length < 8) res = text;
	for(int i = 0; length > i; i++){
		string part = text.substr(i, 8);
		SORT(part);
		if(part == sorted_aidunyan){
			text.replace(i, 8, aizunyan);
			i += 7;
		}
	}
	cout << text << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int b[n];
    int count = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
        {
            a[i + 1] = 100001;
            count += 1;
            i += 1;
        }
    }
    cout << count;

    return 0;
}


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

using namespace std;

struct edge {
    int to;
    int cost;
};

struct status {
    int cost;
    int v;

    bool operator<(const status &another) const { return cost < another.cost; };

    bool operator>(const status &another) const { return cost > another.cost; };
};

const int INF = 1145141919;

int dijkstra(int s, int n, vector<vector<edge>> &graph) {
    priority_queue<status, vector<status>, greater<>> que;
    vector<int> dis(n, INF);
    dis[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v] < now.cost)continue;

        for (auto next:graph[now.v]) {
            if (dis[next.to] > dis[now.v] + next.cost) {
                dis[next.to] = dis[now.v] + next.cost;
                que.push({dis[next.to], next.to});
            }
        }
    }

    return dis[0];
}

int main() {
    int k;
    cin >> k;
    vector<vector<edge>> graph(k + 1);
    for (int i = 1; i <= k; i++) {
        graph[i].push_back({(i + 1) % k, 1});
        if (i < k)graph[i].push_back({(i * 10) % k, 0});
    }

    cout << dijkstra(k, k + 1, graph);
    return 0;
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> a;
  rep(i,n){
    ll x; cin >> x;
    a.emplace_back(x,1);
  }
  rep(T,m){
    ll b,c; cin >> b >> c;
    a.emplace_back(c,b);
  }

  sort(a.rbegin(),a.rend());
  int cnt = n;
  ll ans = 0;
  rep(i,n+m){
    if(a[i].S<cnt){
      ans += a[i].F*a[i].S;
      cnt -= a[i].S;
    } else {
      ans += a[i].F*cnt;
      break;
    }
  }
  cout << ans << ln;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> L.at(i);
    }
    sort(L.begin(),L.end());
    for(int i=0;i<N-1;i++){
        sum+=L.at(i);
    }
    if(sum>L.at(N-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n;cin>>n;
    ll r=0,g=0,b=0,ans=1;
    string s;cin>>s;
    rep(i,n*3){
        ll k;
        if(s[i]=='R')k=r;
        if(s[i]=='G')k=g;
        if(s[i]=='B')k=b;
        ll mi=inf;
        if(k<r)chmin(mi,r);
        if(k<g)chmin(mi,g);
        if(k<b)chmin(mi,b);
        //cout<<k<<' '<<r<<' '<<g<<' '<<b<<endl;
        //out(ans);
        if(mi!=inf)ans=ans*(mi-k)%998244353;
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    REP(i,1,n+1)ans=ans*i%998244353;
    out(ans);
}

Measured memory_bytes: 900
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

n,m = gsmi # 10**5, 10**9
as = gsmi # [10**9] * 10**9

sumn = 0
sums = Array.new(n+1) do |i|
  sumn+=(i==0 ? 0 : as[i-1])
end

sumh = Hash.new(0)
sums.each{|sum| sumh[sum%m]+=1 }

ans = 0
sumh.each do |key1,v1|
  key2 = key1%m
  if key1==key2
    ans += v1*(v1-1)/2
  else
    v2 = sumh[key2]
    ans += v1*v2
    sumh[key1], sumh[key2] = 0,0
  end
end

puts ans


Measured memory_bytes: 23996
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 30 20:19:25 2020

@author: black
"""


K, N = map(int, input().split())
li = list(map(int, input().split()))
li.append(K + li[0])
sub = [li[i+1]-li[i] for i in range(N)]
MAX = max(sub)
total = sum(sub)
print(total - MAX)

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	const int dr[] = { 0, -1, 0, 1, 0 };
	int h, w;
	cin >>h >>w;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	
	
	rep(i,h) rep(j,w) if(ba[i][j]=='#'){
		rep(k ,4){
			int ny=i+dr[k], nx=j+dr[k+1];
			if(ny<0 ||ny>=h ||nx<0 ||nx>=w) continue;
			if(ba[ny][nx] !='.') ba[ny][nx] = ba[i][j] = '@';
		}
	}
	
	rep(i,h) rep(j,w) if(ba[i][j]=='#'){
		puts("No"); return 0;
	}
	puts("Yes");
	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C ;
  
  int i;
  for( i=0; B>=A;i++)
    B=B-A;
  if(i>C)
    cout << C <<endl;
  else
    cout << i <<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
 
public class Main{
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	while(true){
    		final int N = sc.nextInt();
    		final int A = sc.nextInt();
    		final int B = sc.nextInt();
    		final int C = sc.nextInt();
    		final int X = sc.nextInt();
 
    		if(N == 0 && A == 0 && B == 0 && C == 0 && X == 0){
    			break;
    		}
    		
    		int count = 0;
    		
    		int cur_x = X;
    		
    		for(int i = 0; i < N; i++){
    			final int Y = sc.nextInt();
    			
    			if(count > 10000){
    				continue;
    			}
    			
    			while(Y != cur_x && count <= 10000){
    				cur_x = (A * cur_x + B) % C;
    				count++;
    			}
    			
    			if(count > 10000){
    				continue;
    			}
    			
    			if(i != N - 1){
    				cur_x = (A * cur_x + B) % C;
    				count++;
    			}
    		}
    		
    		if(count > 10000){
    			System.out.println(-1);
    		}else{
    			System.out.println(count);
    		}
    	}
    	
    	
    	
    }
     
}

Measured memory_bytes: 12000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class B0Or1Swap {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> p(N), q(N);
        REP(i, N) {
            cin >> p[i];
            q[i] = p[i];
        }
        sort(q.begin(), q.end());

        int num = 0;
        REP(i, N) {
            if (p[i] != q[i]) num++;
        }
        cout << (num <= 2 ? "YES" : "NO") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    B0Or1Swap solver;
    solver.solve(in, out);
    return 0;
}


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

zoro = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    zoro += 1
  else:
    zoro = 0
  if zoro == 3:
    print("Yes")
    exit()
else:
  print("No")

Measured memory_bytes: 9108
#include<stdio.h>
int main(){
  int a,b,x,y,r;
  scanf("%d%d",&a,&b);
  if(a>=b){
    x=a;
    y=b;
  }
  if(b>a){
    x=b;
    y=a;
  }
  while((r=x%y)!=0){
    x=y;
    y=r;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif

        ll x = inl(), y = inl(), z = inl(), k = inl();
        vl a(x), b(y), c(z);
        rep(i, x) a[i] = inl();
        rep(i, y) b[i] = inl();
        rep(i, z) c[i] = inl();

        sort(all(a), greater<>());
        sort(all(b), greater<>());
        sort(all(c), greater<>());

        vl ans;
        rep(i, x) {
            rep(j, y) {
                rep(l, z) {
                    if ((i + 1) * (j + 1) * (l + 1) > k) break;
                    ans.eb(a[i] + b[j] + c[l]);
                }
            }
        }
        sort(all(ans), greater<>());
        rep(i, k) cout << ans[i] << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1404
package main

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

func main() {
  var N int
  fmt.Scan(&N)
  
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)
  
  ws := make(Ws, N)
  for i := 0; i < N; i++ {
    sc.Scan()
    ws[i].A, _ = strconv.Atoi(sc.Text())
    sc.Scan()
    ws[i].B, _ = strconv.Atoi(sc.Text())
  }
  sort.Sort(ws)
  s := 0
  for _,w := range ws {
    s += w.A
    if s > w.B {
      fmt.Println("No")
      return
    }
  }
  fmt.Println("Yes")
}

type Work struct { A, B int }

type Ws []Work
func (a Ws) Len() int { return len(a) }
func (a Ws) Less(i, j int) bool { return a[i].B < a[j].B }
func (a Ws) Swap(i, j int) { a[i], a[j] = a[j], a[i] }



Measured memory_bytes: 6272
n = int(input())
s = input()

Rs = {}
Gs = {}
Bs = {}

ans = 0
minus = 0

for i in range(n):
    if s[i] == "R":
        Rs[i] = 1
    elif s[i] == "G":
        Gs[i] = 1
    elif s[i] == "B":
        Bs[i] = 1

for rk in Rs:
    for gk in Gs:
        dist = gk - rk
        if Bs.get(gk + dist) is not None:
            minus += 1
        if Bs.get(rk - dist) is not None:
            minus += 1
        if abs(dist) % 2 == 0:
            if Bs.get(rk + dist//2) is not None:
                minus += 1

ans = len(Rs) * len(Gs) * len(Bs) - minus

print(ans)



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

int main() {
	int n,w,l;
	vector<pair< int, pair<int,int> > > a; 
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w;
		a.push_back(make_pair(w,make_pair(i,0)));
	}
	sort(a.begin(), a.end());
	for(int i=0;i<n;i++){
		(a[i].second).second=i;
		l=a[i].first;
		a[i].first=(a[i].second).first;
		(a[i].second).first=l;
//	cout<<"a[i]"<<a[i].first<<" "<<(a[i].second).first<<endl;
	}
	int mi=(a[0].second).first;
	sort(a.begin(),a.end());
//for(int i=0;i<n;i++) cout<<"a[i]"<<a[i].first<<" "<<(a[i].second).first<<" "<<(a[i].second).second<<endl;
	
	bool b[1010]={0};
	int ans=0;
	for(int i=0;i<n;i++){
		if (b[i]!=0) continue;
	//	cout<<i<<" "<<b[i]<<endl;
		b[i]=1;
		int j=i,k=1,sum=(a[i].second).first,mini=(a[i].second).first;
		while(1){
			if(i==(a[j].second).second) break;
			j=(a[j].second).second;
			b[j]=1;
			sum=sum+(a[j].second).first;
			k++;
			if(mini>(a[j].second).first) mini=(a[j].second).first;
		}
//		cout<<k<<" "<<mini <<" "<<sum<<" "<<mi<<endl;
		if(k>1) ans=ans+min(sum+(k-2)*mini,sum+(k+1)*mi+mini); 
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1224
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<ll> p, q, r;

	rep(i,a){
		int t;cin >> t;
		p.push(t);
	}
	rep(i,b){
		int t;cin >> t;
		q.push(t);
	}
	rep(i,c){
		int t;cin >> t;
		r.push(t);
	}

	ll ans = 0;
	rep(i,x){
		ll t = p.top();p.pop();
		r.push(t);
	}
	rep(i,y){
		ll t = q.top();q.pop(); 
		r.push(t);
	}
	rep(i,x+y){
		ans += r.top();r.pop();
	}

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


Measured memory_bytes: 7920
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

using namespace std;

const int MOD = 1000000007;

int main(){

    string s;
    cin >> s;
    vector <int> a(26, 0);
    string res = "yes";

    REP(i,s.size())
    {
        int n = s[i]-'0';
        a[n]++;
        if(a[n] > 1)
        {
            res = "no";
            break;
        }
    }
    cout << res << endl;
    
    return 0;     
}



Measured memory_bytes: 256
"""ABC091 2D Plane 2N Points diff:
"""

N = int(input())

ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(N)]

ans_x = 0
cd.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_x += 1
            break

# ans_y = 0
# cd.sort(key=lambda x: x[1])
# ab.sort(key=lambda x: x[0], reverse=True)
# ab_used = [0]*N
# for i, (c, d) in enumerate(cd):
#     for j, (a, b) in enumerate(ab):
#         if not ab_used[j] and a < c and b < d:
#             ab_used[j] = 1
#             ans_y += 1
#             break

print(ans_x)

Measured memory_bytes: 67664
import java.util.Scanner;

class Main {

    static intStack stack;
    static Scanner scan;
    
    public static void main(String[] args) {
	// get from Std in
	scan  = new Scanner(System.in);
        String input = scan.nextLine();

	// scan: input string
	scan = new Scanner(input);

	// create: stack
	intStack s = new intStack(100);

	// start: calc.
	String c; // token
	int a, b; // number: use in calc
	for(int i = 0; scan.hasNext(); i += 2) {
	    c = scan.next();
	    switch (c) {
	    case "+":
		a = s.pop();
		b = s.pop();
	        s.push(b + a);
		break;
	    case "-":
		a = s.pop();
		b = s.pop();
		s.push(b - a);
		break;
	    case "*":
		a = s.pop();
		b = s.pop();
		s.push(b * a);
		break;
	    default:
		int n = Integer.parseInt(c);
		s.push(n);
	    }
	}
	System.out.println(s.pop());
	
    }
}

class intStack {
    private static int length;
    private static int[] Stack;
    private static int current;

    public intStack(int length) {
	this.length = length;
	this.Stack = new int[length];
	this.current = 0;
    }

    public void push(int data) {
	this.Stack[current] = data;
	current++;
    }

    public int pop() {
	if (current == 0) return 0;
	current--;
	return this.Stack[current];
    }
}



Measured memory_bytes: 26272
N, M = map(int, input().split())

broken = []
for _ in range(M):
  broken.append(int(input()))
broken = set(broken)

mod = 10 ** 9 + 7
f2, f1 = 0, 1
for i in range(1, N + 1):
  if i in broken:
    if i - 1 in broken:
      print(0)
      exit()
    f2 = f1
    f1 = 0
    continue
  f = (f2 + f1) % mod
  f2 = f1
  f1 = f
print(f)


Measured memory_bytes: 13216
#include<stdio.h>

#define free 0
#define not 1
#define N 8
#define Q 999

void putqueen(int);
void printboard(void);

int c[N],r[N],dp[N*2-1],dn[N*2-1],queen[N][N];

int main()
{
  int i,j,k,row,col;
  
  for(i=0; i<N; i++)
    {
      c[i]=free;
      for(j=0; j<N; j++)
	{
	  queen[i][j]=free;
	}
    }
   for(i=0; i<2*N; i++) dp[i] = dn[i] = free;
  
  scanf("%d",&k);
  for(i=0; i<k; i++)
    {
      scanf("%d%d",&row,&col);
      queen[row][col] =Q;
    }

  putqueen(0);
  

  return 0;
}

void putqueen(int x)
{
  int j;
  
  if(x == N)
    {
      printboard();
      return;
    }
  
  
 
  for(j=0; j<N; j++)
    {
      if(c[j]==not || dp[x+j]==not || dn[x-j+N-1]==not) continue;
	  
      r[x]=j;
      c[j]=dp[x+j]=dn[x-j+N-1]=not;
	  
      putqueen(x+1);
      c[j]=dp[x+j]=dn[x-j+N-1]=free;
	      
	      
    }
    
 
}
	  
	  
void printboard(void)
{
  int i,j;
  
  for(i = 0; i < N; i++)
    for(j = 0; j < N; j++)
      if(queen[i][j]==Q && r[i] != j) return;
      
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(r[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2112
N=int(input())

l = 0
r = N-1
print(l)
t = input()
if t=='Vacant': exit()
for i in range(20-1):
    q = (l+r)//2
    if l==q:
        print(l+1)
        exit()
    print(q)
    s = input()
    if s=='Vacant': exit()
    if ((q-l)&1==0 and s==t) or ((q-l)&1==1 and s!=t):
        l=q
        t=s
    else:
        r=q-1


Measured memory_bytes: 3660
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define LL long long
#define int LL
#define P pair<int, int>
const LL N = 2e3 + 10;
const LL mod = 1e9 + 7;
const LL inf = 0x3f3f3f3f;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
    x = 0;char c = getchar();bool f = 0;
    for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
int n, k, f[N][N], fac[N * N + N * 2], inv[N * N + N * 2];
void updata(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }
int C(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
signed main()
{
    read(n),read(k); k--;
    if (!k) return 0*puts("1");
    fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for (int i = 2; i <= n * k + n + k; i++) fac[i] = (LL)fac[i - 1] * i % mod, inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
    for (int i = 2; i <= n * k + n + k; i++) inv[i] = (LL)inv[i - 1] * inv[i] % mod;
    f[0][0] = 1;
    for (int i = 0; i <= n; i++)
        for (int j = i; j <= n; j++)
        {
            if (i) updata(f[i][j], f[i - 1][j]);
            if (j) updata(f[i][j], (LL)f[i][j - 1] * C(i + (j - 1) * k + k - 1, k - 1) % mod);
        }
    printf("%lld\n", f[n][n] * fac[n] % mod);
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n, m; cin >> n >> m;
    vvll ypi(m, vll(3));
    rep(i, m){
        cin >> ypi[i][1] >> ypi[i][0];
        ypi[i][2] = i;
    }
    sort(all(ypi));

    vll cityIndex(n, 1);
    vvll ipn(m, vll(3));
    rep(i, m){
        ipn[i][0] = ypi[i][2];
        ipn[i][1] = ypi[i][1];
        ipn[i][2] = cityIndex[ypi[i][1]-1];
        cityIndex[ypi[i][1]-1]++;
    }

    sort(all(ipn));

    rep(i, m){
        rep(j, 6-to_string(ipn[i][1]).size()) cout << 0;
        cout << ipn[i][1];
        rep(j, 6-to_string(ipn[i][2]).size()) cout << 0;
        cout << ipn[i][2];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 14864
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, M, K;
	cin >> N >> M >> K;

	vll a(N + 1, 0);
	vll b(M + 1, 0);
	repn(i, N) {
		ll x;
		cin >> x;
		a[i] = a[i - 1] + x;
	}

	repn(i, M) {
		ll y;
		cin >> y;
		b[i] = b[i - 1] + y;
	}

	ll ans = 0;
	rep(i, N + 1) {
		auto itr = upper_bound(b.begin(), b.end(), K - a[i]);
		ll j = distance(b.begin(), itr) - 1;
		if (j < 0) { continue; }

		ans = max(ans, i + j);
	}

	cout << ans << endl;
}

Measured memory_bytes: 6424