akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s;
  int K;
  cin>>s>>K;
  int n = s.size();
  map<string, int> cand;
  REP(i, K){
    REP(j, n-i){
      ++cand[s.substr(j, i+1)];
      //cout<<s.substr(j, i+1)<<endl;
    }
  }
  //for(auto itr = cand.begin(); itr!=cand.end(); ++itr){
  //  string temp = itr->second;
  //  cout<<temp<<endl;
  //}
  auto itr = cand.begin();
  REP(i, K-1)++itr;
  string ans = itr->first;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
const LL MAX_N=2e5 + 10;
const LL mod=1e9+7;
const double PI=acos(-1);

int num[MAX_N];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", &num[i]);
    if(n & 1){
        for(int i = n; i > 0; i -= 2)   printf("%d ", num[i]);
        for(int i = 2; i <= n; i += 2)  printf("%d%c", num[i], " \n"[i == n - 1]);
    }
    else{
        for(int i = n; i > 0; i -= 2)   printf("%d ", num[i]);
        for(int i = 1; i <= n; i += 2)  printf("%d%c", num[i], " \n"[i == n - 1]);
    }
    return 0;
}


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

int solve(int a,int b,int c,int d,int e){
  if ((a%10)+(b%10)+(c%10)+(d%10)+(e%10)==0){
    return a+b+c+d+e;
  }
  vector<int> t = {a,b,c,d,e};
  int min1=9;
  int minin;
  for (int i=0; i<5; i++){
    int buf = t.at(i)%10;
    if (buf!=0 && buf<min1){
      min1 = buf;
      minin = i;
    }
  }
  int ans=0;
  for (int i=0; i<5; i++){
    if (i==minin) ans += t.at(i);
    else ans += ((t.at(i)+9)/10)*10;
  }
  return ans;
  
}

int main() {
  int a,b,c,d,e; cin >>a >>b >>c >>d >>e;
  int ans=0;
  ans = solve(a,b,c,d,e);
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int c= a/b;
    int d=a%b;
    double e = (double)a/b;
    printf("%d %d %f ",c,d,e);
    return 0;

}


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

using namespace std;

#define roop(i, n) for(int i = 0;i < n;i++)

int dp[3][3][9];



int main(void){

    int w, h, n;
    cin >> w >> h >> n;

    vector<vector<int>> area(h, vector<int>(w));

    roop(i, n){
        int x, y, s;
        cin >> x >> y >> s;
        if(s == 1){
            for(int j = 0;j < h;j++){
                for(int k = 0;k < x;k++){
                    area[j][k] = 1;
                }
            }
        }else if(s == 2){
            for(int j = 0;j < h;j++){
                for(int k = x;k < w;k++){
                    area[j][k] = 1;
                }
            }
        }else if(s == 3){
            for(int j = 0;j < y;j++){
                for(int k = 0;k < w;k++){
                    area[j][k] = 1;
                }
            }
        }else {
            for(int j = y;j < h;j++){
                for(int k = 0;k < w;k++){
                    area[j][k] = 1;
                }
            }
        }
    }


    int ans = 0;
    roop(i, h){
        roop(j, w){
            if(area[i][j] == 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] arsg) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		int add = A+B;
		int sub = A-B;
		int mul = A*B;

		int res = Math.max(Math.max(add, sub), mul);

		System.out.println(res);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin>>n>>s>>k;
  for(int i=0;i<n;i++){
    if(s[i]!=s[k-1])s[i]='*';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;
int n;
ll k;
ll x[N];
ll c[60][2], myn[60];

int main() {

  scanf("%d%lld", &n, &k);
  for (int i = 1; i <= n; ++i)
    scanf("%lld", &x[i]);
  for (int i = 0; i < 60; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int l = 1; l <= n; ++l)
        c[i][j] += (((x[l] >> i) & 1) ^ j) << i;
    }
  }
  ll ans = 0;
  for (int i = 0; i < 60; ++i) {
    if (i)
      myn[i] += myn[i - 1];
    myn[i] += max(c[i][0], c[i][1]);
  }
  ll sum = 0;
  for (int i = 59; i > 0; --i) {
    if ((k >> i) & 1)
      ans = max(ans, sum - c[i][1] + c[i][0] + myn[i - 1]);
    sum += c[i - 1][k >> (i - 1) & 1];
  }
  ans = max(ans, sum);
  printf("%lld\n", ans);

  return 0;
}


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

int main() {
    ll N,M,V,P;
    cin >> N >> M >>V >> P;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.rbegin(),A.rend());
    ll sum[N+1] = {};
    for(int i=0;i<N;i++){
        sum[i+1] += sum[i];
        sum[i+1] += A[i];
        if(i < P){
            continue;
        }
        if((i-P+1)*(A[i]+M) < (sum[i]-sum[P-1])+M*max(V-(P-1)-(N-1-i)-1,0LL) || A[i] +M < A[P-1]){
            cerr << "sum=" <<sum[i] -sum[P-1] << endl;
            // cerr <<"i=" <<i <<"A[i]=" << A[i]<< "canNot" << endl;
            cout << i<<endl;
            return 0;
        }

        
    }
    cout << N <<endl;
    return 0;
}

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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int n;
ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

//check T
void solve()
{

	cin >> n;
	cout << a[n-1] << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[5003][5003];
int N, L;

constexpr int MAX_N = 1003;
ll fact[MAX_N], inv[MAX_N];

ll powm(ll x, ll p) {
	if (p == 0) return 1;
	ll res = powm(x, p / 2);
	res *= res;
	res %= mod;
	if (p % 2LL == 1) {
		res *= x;
		res %= mod;
	}
	return res;
}

int main() {
	string s; cin >> N >> s;
	L = s.length();
	dp[0][L] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < 5002; ++j) {
			dp[i][j] += j == 0 ? dp[i - 1][j] : dp[i - 1][j - 1];
			dp[i][j] %= mod;
			dp[i][j] += 2 * dp[i - 1][j + 1];
			dp[i][j] %= mod;
		}
	}
	ll t = 1;
	for (int i = 0; i < L; ++i) {
		t *= 2;
		t %= mod;
	}
	ll ans = dp[N][0]*powm(t, mod - 2) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 195712
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N;
	set<int> v[100005];
	bool ans = false;

	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a].insert(b);
		v[b].insert(a);
	}

	queue<int> que;
	rep(i,N) if( v[i].size() == 1 ) que.push(i);

	while( !que.empty() ){
		int n = que.front();
		que.pop();
		if( v[n].empty() ){
			ans = true;
			break;
		}
		int p = *(v[n].begin());
		for(auto t: v[p]){
			v[t].erase(p);
			if( v[t].size() == 1 ) que.push(t);
		}
	}

	cout << (ans ? "First" : "Second") << endl;

	return 0;
}


Measured memory_bytes: 14464
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

L = gets.chomp
MOD = 10 ** 9 + 7

ans = 0
LS = L.size
count_one = 1
(0...L.size).each{|i|
  if L[i] == '1' then
    ans += ((pow(3, LS - i - 1, MOD) + 1) * count_one) % MOD
    count_one = (2 * count_one) % MOD
  end
}

puts (ans + 1) % MOD


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


//#define int long long 

const int inf = 0x3f3f3f3f, N = 3e5;

struct RMQ {
        vector <int> t;
        int n;
        RMQ(int n) : n(n) {
                t.resize(n << 1, 0);
        }
        void modify(int p, int v) {
        		v = max(v, t[p + n]);
                for(t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = max(t[p], t[p ^ 1]);
        }
        int query(int l, int r) { int res = 0;
                for(l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
                        if(l & 1) res = max(res, t[l++]);
                        if(r & 1) res = max(res, t[--r]);
                }
                return res;
        }
}t(2 * N);

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k, ans = 0; cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		int x; cin >> x; ++x;
		int l = max(1, x - k), r = min(N + 1, x + k);
		int y = t.query(l, r) + 1;
		t.modify(x, y);
		ans = max(ans, y);
	}

	cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

struct edge{
	ll to, idx;
};

using Graph = vector<vector<edge>>;
vector<bool> visited(101010, false);
vector<ll> res;
vector<ll> K;

ll dfs(ll now, ll par, const Graph &G){
	if(visited[now]) return -1;
	visited[now] = true;

	ll tot = K[now];
	for(auto e: G[now]){
		if(e.to == par) continue;
		ll val = dfs(e.to, now, G);
		if(val>=0){
			tot += val;
			if(val%2==1){
				res.push_back(e.idx);
			}
		}
	}

	return tot;
}

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

    ll N, M;
    cin >> N >> M;

    vector<pll> C(N);
    REP(i, N){
    	cin >> C[i].first >> C[i].second;
    }
    sort(C.begin(), C.end());
    vector<ll> X, Y;
    Y.push_back(0);
    REP(i, N) X.push_back(C[i].first);
    REP(i, N) Y.push_back(C[i].second);
    Y.push_back(0);

    Graph G(N+1);

    REP(i, M){
    	ll L, R;
    	cin >> L >> R;
    	ll ldx = lower_bound(X.begin(), X.end(), L) - X.begin();
    	ll rdx = upper_bound(X.begin(), X.end(), R) - X.begin();
    	rdx--;
		if(ldx==N) continue;
		if(rdx==-1) continue;
		if(ldx==rdx+1) continue;

		edge e = {rdx+1, i};
		edge f = {ldx, i};
		G[ldx].push_back(e);
		G[rdx+1].push_back(f);
    }

    REP(i, N+1) K.push_back(Y[i]^Y[i+1]);

    REP(i, N+1){
    	ll tmp = dfs(i, -1, G);
    	if(tmp>=0){
    		if(tmp%2==1){
    			cout << -1 << endl;
    			return 0;
    		}
    	}
    }

    sort(res.begin(), res.end());
    cout << res.size() << endl;
    REP(i, res.size()) cout << res[i]+1 << " ";
    cout << endl;

    /*
    REP(i, N+1){
    	cout << "from: " << i << endl;
    	REP(j, G[i].size()){
    		cout << G[i][j].to << " " << G[i][j].idx << endl;
    	}
    }
    */

    //cout << K << endl;
    return 0;
}

Measured memory_bytes: 23796
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
#define DI pair<double, int>
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

double a, b, p, q, r;
int main() {
	cin >> a >> b >> p >> q >> r;
	printf("%.10lf\n", b + (b * p - (b - a) * q) / (q + r));
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] ch = sc.next().toCharArray();
        char ans = 97; // 97 == 'a'
        
        Arrays.sort(ch);
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] == ans) {
                ++ans;
            } else if (ch[i] > ans) {
                break;
            }
        }
        out.println(ans < 123 ? ans : "None"); // 122 == 'z'

        out.flush();
    }
}

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

vector<string> BubbleSort(vector<string> C, int N) {
  rep (i, N) {
    for (int j = N - 1; j > i; j--) {
      string v = C.at(j);
      if (C.at(j).at(1) < C.at(j - 1).at(1)) {
        C.at(j) = C.at(j - 1);
        C.at(j - 1) = v;
      }
    }
  }

  return C;
}

vector<string> SelectionSort(vector<string> C, int N) {
  rep (i, N) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (C.at(j).at(1) < C.at(minj).at(1)) minj = j;
    }
    string v = C.at(i);
    C.at(i) = C.at(minj);
    C.at(minj) = v;
  }

  return C;
}

bool isStable(vector<string> c1, vector<string> c2, int N) {
  rep (i, N) {
    if (c1.at(i) != c2.at(i)) return false;
  }

  return true;
}

void Print(vector<string> cards, int N) {
  rep (i, N) {
    if (i > 0) cout << " ";
    cout << cards.at(i);
  }
  cout << endl;
}

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

  vector<string> cards(n);
  rep (i, n) cin >> cards.at(i);

  vector<string> bubble = BubbleSort(cards, n);
  vector<string> select = SelectionSort(cards, n);

  // Bubble Sort
  Print(bubble, n);
  cout << "Stable" << endl;

  // Select Sort
  Print(select, n);
  if (isStable(bubble, select, n) == true) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,x,c[13]={},a[13][13]={};

ll d(ll number,ll ans,ll ab[]){
	//cout<<ans<<endl;
	//for(ll i=0;i<m;i++){
	//	cout<<ab[i]<<" ";
	//}
	//cout<<endl;
	if(number==n){
		for(ll i=0;i<m;i++){
			if(ab[i]<x){
				return 1<<30;
			}
		}
		return ans;
	}else{
		ll dab[m]={};
		ll left=d(number+1,ans,ab);
		
		
		for(ll i=0;i<m;i++){
			dab[i]=ab[i]+a[number][i];
		}
		ll right=d(number+1,ans+c[number],dab);
		
		
		return min(left,right);
	}
}
	



int main(){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
		cin>>a[i][j];
		}
	}
	ll ab[m]={};
	ll ans=d(0,0,ab);
	if(ans >= 1<<30){
		cout<<"-1"<<endl;
	}else{
		cout<<ans<<endl;
	}
}
	

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

using namespace std;

#define fastio ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;

void multof3(int n)
{

}

int main()
{
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout); 
	#endif	
	
	fastio;

	string s;
	cin >> s;
	if(s[s.size() - 1] != 's')
		cout << s + 's';
	else
		cout << s << "es";

	return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = 1e9+7;
const int N = 101;
using ll = long long;
int n, K,dp[100001];
void add_self(int &a, int b) {
    a = (a + b) % mod;
    if(a < 0) a += mod;
}
int main()
{
    scanf("%d %d", &n, &K);
    dp[0]=1;
    for(int i = 1; i <= n; i++) {
        vector<int> fake(K+1, 0);
        int x;
        scanf("%d", &x);
        for(int k = K; k >= 0; k--) {
            int L = k+1, R = k+min(x, K-k);
            if(L <= K)add_self(fake[L], dp[k]);
            if(R+1 <= K) add_self(fake[R+1], -dp[k]);
        }
        int now = 0;
        for(int k = 1; k <= K; k++) {
            add_self(now, fake[k]);
            add_self(dp[k], now);
        }
    }
    printf("%d\n", dp[K]%mod);
    return 0;
}

//dp[2][1] += (dp[1][2])

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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a) {return a;}

template<typename T, typename... Args>
T Max(T a, Args... args){ return a > Max(args...)? a : Max(args...);}

template<typename T>
T Min(T a) {return a;}

template<typename T, typename... Args>
T Min(T a, Args... args){ return a < Min(args...)? a : Min(args...);}


//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a; n/=2;
    }
    return result;
}

ll mod_expo(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;
}

int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int n,k; cin >> n >> k;
    vector< int > v(n);
    for(int i=0;i<n;i++) cin >> v[i];

    int pointer = 0;

    for(int i=k;i<n;i++)
    {
        if(v[i]>v[pointer++])
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    cerr << "time = " << clock() << " ms" << '\n';
    return 0;
}



Measured memory_bytes: 3968
import java.util.Scanner;


public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        String s = next();
        if(Character.isUpperCase(s.charAt(0))){
            print('A');
        }
        else print('a');
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

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

typedef struct node{
  node *p,*l,*r;
  int key;
} Node;

typedef Node* Nodepointer;

Nodepointer T;

void insert(int z){
  Nodepointer t=(Node*)malloc(sizeof(Node));
  t->l=NULL;
  t->r=NULL;
  t->key=z;
  if(!f){
    T->key=z;
    f=1;
    return;
  }
  Nodepointer y=NULL,x=T;
  while(x!=NULL){
    y=x;
    if(t->key<x->key)x=x->l;
    else x=x->r;
  }
  t->p=y;
  if(y==NULL)T=t;
  else if(t->key<y->key)y->l=t;
  else y->r=t;
}

void print(Nodepointer x,int y){
  if(y)cout<<' '<<x->key;
  if(x->l!=NULL)print(x->l,y);
  if(!y)cout<<' '<<x->key;
  if(x->r!=NULL)print(x->r,y);
}

int main(){
  string s;
  int n,z;
  cin>>n;
  T=(Node*)malloc(sizeof(Node));
  T->p=NULL;
  T->l=NULL;
  T->r=NULL;
  while(n--){
    cin>>s;
    if(s=="insert")cin>>z,insert(z);
    else if(f){
      print(T,0);
      cout<<endl;
      print(T,1);
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24648
from math import ceil

#n=10
#X=[123,123,123,123,123]

#n=5
#X=[ 3 ,2 ,4 ,3 ,5 ]

#n=10000000007
#X=[2,3,5,7,11]

n=int(input())
X=[]
for _ in range(5):
    X.append(int(input()))

print(5 + ceil(n / min(X)) - 1)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if (a == b){
        cout << 'a' << " == " << 'b'<< endl;
        return 0;
    }
    else if (a > b){
        cout << 'a' << " > " << 'b' << endl;
        return 0;
    }
    else if (a < b){
        cout << 'a' << " < " << 'b' << endl;
        return 0;
    }
}


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

using namespace std;

bool binsearch(vector<int>,int,int,int);

int main(){
	int x,n;cin>>x>>n;
	vector<int> v(n);
	
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int i=0;
	while(1){
		if(binsearch(v,0,n-1,x-i)){
		cout<<x-i;break;
		}
		if(binsearch(v,0,n-1,x+i)){
		cout<<x+i;break;
		}
		i++;
	}
	return 0;
}

bool binsearch(vector<int> v,int p,int q,int x){
	
	if(q>=p){
		int mid = (p+q)/2;
		if(v[mid]==x)
		return 0;
		
		if(v[mid]>x)
		return binsearch(v,p,mid-1,x);
		
		if(v[mid]<x)
		return binsearch(v,mid+1,q,x);
		
		return 1;
	}
	else
	return 1;
	
	}



Measured memory_bytes: 3584
#include<iostream>
#include<vector>

using namespace std;



int main(void)
{
	vector<int> x(11);
	int r,D;
	cin >> r >> D >> x[0] ;

	for (int i = 1; i <= 10; i++)
	{
		x[i] = r * x[i - 1] - D;
		cout << x[i]<<endl;
	}

	return 0;
}

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

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N;
	vector<int>v(N + 1);
	for (int i = 1; i < N; i++) {
		cin >> L;
		v[L]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << v[i] << endl;
	}
}

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

int n;

int main(){
  string s1, s2;
  cin >> n >> s1 >> s2;

  long long count = 1;

  for(long i=0;i<n;i++){
    if(s1[i] == s2[i]){ // (1)
      if(i == 0){ // (1-1)
	count *= 3;
	count %= 1000000000+7;
      }else{ // (1-2)
	if(s1[i-1] == s2[i-1]){ // (1-2-1)
	  count *= 2;
	  count %= 1000000000+7;
	}
      }
    }else{ // (2)
      if(i == 0){ // (2-1)
	count *= 6;
	count %= 1000000000+7;
      }else{
	if(s1[i-1] == s2[i-1]){
	  count *= 2;
	  count %= 1000000000+7;
	}else{
	  count *= 3;
	  count %= 1000000000+7;
	}
      }
      i++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
// O(n^2m)
// bipartite graph O(\sqrt{n}m)
// capacityが同じ O(min{m^1/2,n^2/3}*m)
#include <cstring>  //for memset
#define MAX_V 100000
#define INF 10000000
struct edge {
    int to, cap, rev;
};
vector<edge> G[MAX_V];
int level[MAX_V];  // sからの距離
int iter[MAX_V];   //どこまで調べ終わったか

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, static_cast<int>(G[to].size())});
    G[to].push_back((edge){from, 0, static_cast<int>(G[from].size() - 1)});
}

void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); ++i) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < G[v].size(); ++i) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}
int main(){
    string s;
    cin >> s;
    string a = "2018";
    rep(i,s.size()){
        if(i <=3){
            cout << a[i];
        }else{
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3192
#include <iostream>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<=b;i++)
    char s[200010]={'\0'};
    int n;
    int cnt=0;
    ll ans=0;

int main()
{
    cin>>s;
    n=strlen(s);
    for(int i=n-1;i>=0;i--){
        if(s[i]=='W')cnt++;
        else    ans+=cnt;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

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


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

ll repeatSquaring(ll n, ll p, ll mod) {
  if(p == 0) return 1;
  if(p % 2 == 0) {
    ll t = repeatSquaring(n, p / 2, mod);
    return t * t % mod;
  } else {
    return (n * repeatSquaring(n, p - 1, mod)) % mod;
  }
}

ll comb(ll n, ll k, ll mod) {
  //分子
  ll res = 1;
  rep(i, k) res = res * (n - i) % mod;
  
  //分母（逆数にする前）
  ll bunbo = 1;
  rep(i, k) bunbo = bunbo * (k - i) % mod;
  
  res = (res * repeatSquaring(bunbo, mod - 2, mod)) % mod;
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll all = repeatSquaring(2, n, MOD) - 1;
  
  ll anum = comb(n, a, MOD);
  ll bnum = comb(n, b, MOD);
  
  cout << (all - anum - bnum + MOD + MOD) % MOD << endl;
  
}

/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, k, s;
  scanf("%d%d%d", &n, &k, &s);
  if (s != 1e9) {
    for (int i = 0; i < n; i++) {
      if (i < k) {
        printf("%d ", s);
      } else {
        printf("%d ", s + 1);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i < k) {
        printf("%d ", s);
      } else {
        printf("%d ", s - 1);
      }
    }
  }
  printf("\n");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  map<string, i64> c;
  for (i64 i = 0; i < N; i++)
  {
    string S;
    cin >> S;
    c[S]++;
  }
  cout << "AC x " << c["AC"] << endl
       << "WA x " << c["WA"] << endl
       << "TLE x " << c["TLE"] << endl
       << "RE x " << c["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
const int N=200005;
using namespace std;
int ar[N],n;
int mx_e,mx_v;
int pev=0;
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>ar[i];
        if(ar[i]>=mx_e){
            pev=mx_e;
            mx_e=ar[i];
            mx_v=i;
        }
    }
    sort(ar+1,ar+n+1);
    reverse(ar+1,ar+n+1);
    for(int i=1;i<=n;i++){
        if(i!=mx_v)cout<<mx_e<<'\n';
        else cout<<ar[2]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double x; cin >> x;
    double now=100;
    int cnt=0;
    while(now<x){
        now*=1.01;
        ll p=now;
        now=p;
        cnt++;
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 3824
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<set>
#include<queue>
#define M 1000020
#define inf 0x3f3f3f3f
#define LL long long
#define int long long
const int mod=998244353;
using namespace std;
inline int read(){
	int f=1,x=0;char s=getchar();
	while (!isdigit(s)){if(s=='-')f=-1;s=getchar();}
	while (isdigit(s)){x=(x<<1)+(x<<3)+(s^48),s=getchar();}
	return x*f;
}
int n,a[M],f[M],cnt[M],prime[M],tot,mu[M],is[M],g[M],ans,maxx,inv[M];
inline void init(void){
	mu[1]=1,inv[1]=1;
	for (int i=2;i<=M-10;i++){
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		if (!is[i]) prime[++tot]=i,mu[i]=mod-1;
		for (int j=1;j<=tot&&prime[j]*i<=M-10;j++){
			is[i*prime[j]]=1;
			if (i%prime[j]) mu[i*prime[j]]=mod-mu[i];
			else break;
		}
	}
}
signed main(void){
	n=read();init();
	for (int i=1;i<=n;i++) a[i]=read(),cnt[a[i]]++,maxx=max(maxx,a[i]);
	for (int i=1;i<=maxx;i++){
		for (int j=i;j<=maxx;j+=i) f[i]=(f[i]+cnt[j]*j%mod)%mod;
		f[i]=f[i]*f[i]%mod;
	}
	for (int i=1;i<=maxx;i++){
		for (int j=i;j<=maxx;j+=i)
			g[i]=(g[i]+mu[j/i]*f[j]%mod)%mod;
		ans=(ans+g[i]*inv[i]%mod)%mod;
	}
	for (int i=1;i<=n;i++) ans=(ans-a[i]+mod)%mod;
	printf("%lld",ans*inv[2]%mod);
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    int k, q;
    cin >> k >> q;
    Vl d(k);
    for (int i = 0; i < k; i++) {
        cin >> d[i];
    }

    Vl m(q), x(q), n(q);
    for (int i = 0; i < q; i++) {
        cin >> n[i] >> x[i] >> m[i];
    }

    Vl dm(k);
    for (int i = 0; i < q; i++) {
        ll out = 0;
        ll a_last = x[i] % m[i];
        for (int j = 0; j < k; j++) {
            dm[j] = d[j] % m[i];
            ll tmp;
            if (j <= (n[i] - 1) % k - 1) {
                tmp = (n[i] - 1) / k + 1;
            }
            else {
                tmp = (n[i] - 1) / k;
            }
            a_last += dm[j] * tmp;
            if (dm[j] == 0) out += tmp;
        }
        out += a_last / m[i];
        cout << n[i] - 1 - out << "\n";
    }

    return 0;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
   input! {
      n: usize,
      k: usize,
      mut a: [usize; n],
   }
   if n <= k {
      for _ in 0..n {
         print!("{} ", n);
      }
      println!("");
      return;
   }

   for _ in 0..k {
      let mut s = vec![0i64; n + 1];
      for i in 0..n {
         let l = if i > a[i] { i - a[i] } else { 0 };
         let r = if i + a[i] < n { i + a[i] + 1 } else { n };
         s[l] += 1;
         s[r] -= 1;
      }
      let mut flag = true;
      for i in 0..n {
         if i != 0 {
            s[i] += s[i - 1];
         }
         a[i] = s[i] as usize;
         if a[i] != n {
            flag = false;
         }
      }
      if flag {
         break;
      }
   }
   for i in 0..n {
      print!("{} ", a[i]);
   }
   println!("");
}


Measured memory_bytes: 6332
/*input
41 59 31
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c;

    return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll a,b;
    cin >> a>>b;
    ll t=1;
    for(i=0;i<50;i++){
        if(t<b)t+=a-1;
        else break;
    }
    cout << i<< endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
res = 1
cur = None
np = None
for a in list(map(int, input().split())):
    # print(res,cur,np,a)
    if cur is None:
        pass
    elif np is None:
        if a==cur:
            np = 0
        elif a>cur:
            np = 1
        else:
            np = -1
    else:
        if np==0:
            if a==cur:
                pass
            elif a>cur:
                np = 1
            else:
                np = -1
        elif np>0:
            if a>=cur:
                pass
            else:
                res += 1
                np = None
        else:
            if a<=cur:
                pass
            else:
                res += 1
                np = None
    cur = a

print(res)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
lli dep[200009];
vector<lli> adj[200007];
lli nod, cd;

lli vis[200008];
lli cnt, var;
void dfs1(lli node, lli k)
{
    vis[node] = 1;
    fw(i, 0, adj[node].size())
    {
        if (vis[adj[node][i]] == 0)
        {
            cnt++;
            if (cnt == k)
            {
                var = adj[node][i];
            }
            dfs1(adj[node][i], k);
        }
    }
}

void dfs(lli node, lli par)
{
    dep[node] = 1 + dep[par];
    fw(i, 0, adj[node].size())
    {
        if (dep[adj[node][i]] == -1)
        {
            dfs(adj[node][i], node);
        }
        if ((dep[adj[node][i]] != -1))
        {
            if (nod == 0)
            {
                nod = adj[node][i];
            }
            if (cd == 0)
                cd = 1 + dep[node] - dep[nod];
            return;
        }
    }
}

int main()
{

    memset(dep, -1, sizeof(dep));
    dep[1] = 0;
    FASTIO
    // L(T)
    {
        lli n, k;
        cin >> n >> k;
        fe(i, 1, n)
        {
            lli alpha;
            cin >> alpha;
            adj[i].push_back(alpha);
        }
        dfs(1, 0);
        if (k >= dep[nod])
        {
            k = k - dep[nod];
            k = k % cd;
        }
        else
        {
            nod = 1;
        }

        if (k == 0)
        {
            cout << nod << endl;
            return 0;
        }

        dfs1(nod, k);
        cout << var << endl;
    }
    return 0;
}

Measured memory_bytes: 26768
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <utility>
const int maxn = 22;
using ll = long long;
const ll ha = 1000000007LL;
ll pow_mod(ll a, ll b) {
  ll ans = 1, res = a;
  while(b) {
    if(1LL & b) ans = ans * res % ha;
    res = res * res % ha; b >>= 1;
  }
  return ans;
}
ll inv(ll x) {
  return pow_mod(x, ha - 2LL);
}

ll fac[1 << 20], ifac[1 << 20];
void process() {
  fac[0] = 1;
  const int n = (1 << 20) - 1;
  for(int i = 1; i <= n; i ++) {
    fac[i] = fac[i - 1] * (ll)i % ha;
  }
  ifac[n] = inv(fac[n]);
  for(int i = n - 1; i >= 0; i --) {
    ifac[i] = ifac[i + 1] * (ll(i + 1)) % ha;
  }
}
ll C(int n, int m) {
  if(n < m) return 0;
  ll ret = fac[n] * ifac[n - m] % ha;
  ret = ret * ifac[m] % ha;
  return ret;
}

int A[maxn]; ll f[1 << 20];
int main() {
  process();
  int n, m; scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; i ++) {
    scanf("%d", &A[i]);
  }
  std::sort(A + 1, A + 1 + m); f[0] = 1;
  for(int i = m; i >= 1; i --) {
    for(int s = (1 << n) - 1; s >= 0; s --) {
      int sum = 0;
      for(int j = 0; j < n; j ++) {
        if((1 << j) & s) sum += (1 << j);
      }
      ll res = (1 << n) - sum - A[i];
      for(int j = 0; j < n; j ++) {
        if(((1 << j) & s) == 0) {
          ll delta = f[s] * C(res, (1 << j) - 1) % ha;
          delta = delta * fac[1 << j] % ha;
          int v = s | (1 << j);
          f[v] += delta;
          if(f[v] >= ha) f[v] -= ha;
        }
      }
    }
  }
  ll ans = 0;
  for(int s = 0; s < (1 << n); s ++) {
    int cnt = 0, sum = 0;
    for(int i = 0; i < n; i ++) {
      if((1 << i) & s) {
        cnt ++; sum += (1 << i);
      }
    }
    ll delta = f[s] * fac[(1 << n) - sum - 1] % ha;
    if(1 & cnt) delta = (ha - delta) % ha;
    ans = (ans + delta) % ha;
  }
  ans = ans * (ll(1LL << n)) % ha;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 17024
#include <iostream>
using namespace std;
int main(){

  int w,h,x,y,r;
  cin >>w>>h>>x>>y>>r;

  if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
  
  return 0;
}

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

struct cood
{
    int x, y;
} A[205];

bool myComp(cood a, cood b)
{
    return atan2(a.y, a.x) < atan2(b.y, b.x);
}

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i].x >> A[i].y;
    sort(A, A + N, myComp);
    for(int i = 0; i < N; i++)
        A[N + i] = A[i];
    double ans = 0;
    for(int i = 0; i < N; i++)
    {
        long long x = 0, y = 0;
        for(int j = i; j < i + N; j++)
        {
            x += A[j].x;
            y += A[j].y;
            ans = max(ans, sqrt(pow(x, 2) + pow(y, 2)));
        }
    }
    printf("%.15f\n", ans);
}

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

const int N = 13;

int n, m, c[N], p[N], q[N];
char b[N][N];

void Y(){ puts("YES"); exit(0); }

int g(string &s, string &t){
    string u = t;
    reverse(u.begin(), u.end());
    return (s == u);
}

void f(int x, int y){
    if(count(c, c + n, 1) == n){
        string s[N];
        map<string, int> mp;        
        for(int i = x - 1; i >= 0; i--){
            for(int j = 0; j < m; j++) s[j] += b[q[i]][j];
        }
        for(int i = (n & 1); i < x; i++){
            for(int j = 0; j < m; j++) s[j] += b[p[i]][j];
        }
        for(int i = 0; i < m; i++) mp[s[i]]++;
        for(int i = m * !(m & 1); i < m + !(m & 1); i++){
            if(i < m && !g(s[i], s[i])) continue;
            if(i < m) mp[s[i]]--;
            int t = 1;
            for(int j = 0; j < m; j++){
                if(i == j) continue;
                string u = s[j];
                reverse(u.begin(), u.end());
                if(s[j] == u) if(mp[u] & 1){ t = 0; break; }
                if(mp[u] != mp[s[j]]){ t = 0; break; }
            }
            if(i < m) mp[s[i]]++;
            if(t) Y();
        }
        return;
    }
    for(; y >= 0 && c[y]; y++);
    if(y >= 0) c[y] = 1;
    p[x] = y;
    for(int i = y + 1; i < n; i++){
        if(c[i]) continue;
        c[i] = 1; q[x] = i;
        f(x + 1, y + 1);
        c[i] = 0;
    }
    if(y >= 0) c[y] = 0;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%s", b[i]);
    f(0, -(n & 1));
    puts("NO");
}

Measured memory_bytes: 384