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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    using P = pair<i64, i64>;
    vector<i64> m(N), M(N);
    REP(i, N) cin >> m[i] >> M[i];

    sort(m.begin(), m.end());
    sort(M.begin(), M.end());

    i64 cnt;
    if (N % 2 == 0) {
        cnt = (M[N / 2] + M[(N - 1) / 2]) - (m[N / 2] + m[(N - 1) / 2]) + 1;
    } else {
        cnt = M[N / 2] - m[N / 2] + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

int main() {
    long long x;
    cin >> x;

    for(int a=-120; a<=120; a++) {
        for(int b=-120; b<=120; b++) {
            if(pow(a, 5) - pow(b, 5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#ifdef _debug
#define out(i) cout << #i << ' ' << i << ' '
#else 
#define out(i) //
#endif
using ll = long long;
using ull = unsigned long long;
const int maxn = 51;
ll dp[maxn][maxn][3000];
int n, K;
const int tomod = 1000000007;
ll form(ll a){return a % tomod;}
void add(ll &a, ll v){a = form(a + v);}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> K;
	if(K&1)return cout << 0 << '\n', 0;
	dp[0][0][0] = 1;
	for(int i = 0;i < n;++i)
		for(int j = 0;j <= i;++j)
			for(int k = 0;k <= K;++k){
				ll v = dp[i][j][k];
				// ._.
				add(dp[i+1][j][k + j + j], v);
				// . .
				add(dp[i+1][j+1][k + j + j + 2], v);
				// ./.
				add(dp[i+1][j][k + j + j], v * (j + j));
				// ./\.
				add(dp[i+1][j-1][k + j + j - 2], v * j * j);
			}
	cout << dp[n][0][K] << '\n';
}

Measured memory_bytes: 59264
N,A,B=map(int,input().split());M=998244353;P=N+1;f=1;F=[1]*P;I=[1]*P;z=0;R=range
if B==0:print(1);exit()
for n in R(1,P):F[n]=f=f*n%M
I[N]=i=pow(f,M-2,M)
for n in R(N,1,-1):I[n-1]=i=i*n%M
for k in R(min(A+1,N-B)if N-B-A else A+1):Q=N-B-k-1;z=(z+(B-k)*F[B+k-1]*I[B]*I[k]*F[Q+A-k]*I[Q]*I[A-k])%M
print(z)

Measured memory_bytes: 190680
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
using namespace std;

int main()
{
    //freopen("frog.inp","r",stdin);
    //freopen("frog.out","w",stdout);
    int n;
    cin>>n;
    vector <long long> res(n);
    vector <long long> h(n);
    for (int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    res[1]=0;
    res[2]=abs(h[1]-h[2]);
    for (int i=3;i<=n;i++)
    {
        res[i]=min(res[i-1]+abs(h[i-1]-h[i]),res[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<res[n];
    return 0;
}


Measured memory_bytes: 1792
//Problem B
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> strList = new ArrayList<>();
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		for(int i = 0; i < n; i++) {
			strList.add(sc.next());
		}
		strList.sort(Comparator.naturalOrder());
		
		StringBuilder ret = new StringBuilder();
		for(String s : strList) {
			ret.append(s);
		}
		System.out.println(ret.toString());
	}
}


Measured memory_bytes: 10060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[,] map = new int[11, 7];

            for (int i = 1; i <= 9; i++)
            {
                string input = Console.ReadLine();

                if (i % 2 == 1) input = "00" + input;
                else input = "0" + input;

                for (int j = 0; j < input.Length; j++)
                {
                    map[i, j] = int.Parse(input[j].ToString());
                }
            }

            int posX = 1, posY = 1;
            char dir = 'R';

            while (true)
            {
                switch (dir)
                {
                    case 'R':
                        if (map[posY - 1, posX] == 1) { posY--; dir = 'U'; }
                        else if (map[posY, posX + 1] == 1) posX++;
                        else if (map[posY + 1, posX] == 1) { posY++; dir = 'D'; }
                        else dir = 'L';
                        break;
                    case 'L':
                        if (map[posY + 1, posX - 1] == 1) { posY++; posX--; dir = 'D'; }
                        else if (map[posY, posX - 1] == 1) posX--;
                        else if (map[posY - 1, posX - 1] == 1) { posY--; posX--; dir = 'U'; }
                        else dir = 'R';
                        break;
                    case 'D':
                        if (map[posY + 1, posX + 1] == 1) { posY++; posX++; dir = 'R'; }
                        else if (map[posY + 2, posX] == 1) posY += 2;
                        else if (map[posY + 1, posX] == 1) { posY++; dir = 'L'; }
                        else dir = 'U';
                        break;
                    case 'U':
                        if (map[posY - 1, posX] == 1) { posY--; dir = 'L'; }
                        else if (map[posY - 2, posX] == 1) posY -= 2;
                        else if (map[posY - 1, posX + 1] == 1) { posY--; posX++; dir = 'R'; }
                        else dir = 'D';
                        break;
                }
                sb.Append(dir);

                if (dir == 'L' && posX == 2 && posY == 1) break;
                if (dir == 'U' && posX == 1 && posY == 2) break;
            }
            Console.WriteLine(sb);
        }
    }
}

Measured memory_bytes: 8752
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

int main() {
	cout.precision(20);
	string S;
	ll N;
	cin >> N;
	if (N % 10 == 3)
		cout << "bon";
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
		cout << "pon";
	else
		cout << "hon";
}




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

using namespace std;

const int nax=3333;
double dp[nax][nax];

int main()
{
    int n; cin>>n;
    double a[nax];
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-a[i]);
            if(j>0) dp[i][j]+=dp[i-1][j-1]*a[i];
        }
    }
    double res=0;
    for(int i=0;i<=n;i++)
    {
        if(i*2>n) res+=dp[n][i];
    }
    cout<<setprecision(50)<<res;
    return 0;
}


Measured memory_bytes: 80128
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int d=sc.nextInt();
		if(d==25)System.out.println("Christmas");
		if(d==24)System.out.println("Christmas Eve");
		if(d==23)System.out.println("Christmas Eve Eve");
		if(d==22)System.out.println("Christmas Eve Eve Eve");
	}
}


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

void main() {
  int N = readln.chomp.to!int;
  int[] L = readln.split.to!(int[]);

  L.sort!"a<b";

  ulong ans = 0;
  foreach(i; 0..(N-2)) {
    int a = L[i];
    foreach(j; (1+i)..(N-1)) {
      int b = L[j];
      int lower = abs(a-b);
      int upper = a+b;

      auto sorted = assumeSorted(L[(1+j)..N]);
      int lidx = cast(int)(sorted.lowerBound(lower).length);
      int uidx = cast(int)(sorted.lowerBound(upper).length)-1;

      ans += uidx - lidx + 1;
    }
  }
  ans.writeln;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	int e = 1;
	for (int i = 0; i < m; i++)e *= 2;
	int ans = 0;
	ans += (1900 * m + 100 * (n - m))*e;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, ll> P;
typedef pair<ll, P> Pa;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<Pa> PQ;

ll l[100010];
int n, L;
ll ans = 0;

int main(){
	PQ que;
	cin >> n >> L;
	for(int i = 1; i <= n; i++) cin >> l[i];
	for(int i = 1; i <= n; i++){
		if(l[i] > l[i-1] && l[i] > l[i+1]){
			que.push(Pa(l[i],P(i,0)));
		}
	}
	while(true){
		if(que.size() == 0) break;
		Pa p = que.top(); que.pop();
		ans += L-(p.fi+ans);
		l[p.sec.fi] = 0;
		if(l[p.sec.fi+1] != 0 && l[p.sec.fi+1] > l[p.sec.fi+2]) que.push(Pa(l[p.sec.fi+1]-ans,P(p.sec.fi+1,ans)));
		if(l[p.sec.fi-1] != 0 && l[p.sec.fi-1] > l[p.sec.fi-2]) que.push(Pa(l[p.sec.fi-1]-ans,P(p.sec.fi-1,ans)));
	}
	cout << ans << endl;
}

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

int main(){ 
    int n;
    string s;
    cin >> n;
    cin >> s;
    bool frag = false;
    int count=0;
    
    for(int i=0;i<n/2;i++){
        if(s[n/2+i] == s[i]){
            count++;
        }
    }
    if(count==n/2) frag = true;
    
    if(frag && n%2==0){
        cout << "Yes" << endl;
    } else if(n%2 ==1){ 
        cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }


    
    return 0;
} 


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    ll now_K=K;
    vl A(N);
    ll sum=0,MX=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
        MX=max(MX,A[i]);
    }
    ll dp0[50],dp1[50];//越える可能性があるかの情報をdp0,dp1に持たせて、桁数をdp[]に持たせる
    rep(i,50){
        dp0[i]=dp1[i]=0;
    }
    rep(i,50){
        ll X=pow(2,49-i);
        if(X>K&&X>MX){
            continue;
        }
        //cout << X << endl;
        ll cnt=0;
        rep(i,N){
            if((A[i]/X)%2==0){
                cnt++;//桁で0の数
            }
        }
        //cout << cnt << endl;
        if(dp0[i-1]!=0||dp1[i-1]!=0){
        	dp0[i]=dp0[i-1]+X*max(N-cnt,cnt);//0,0
        }
        if(now_K>=X){
            dp1[i]=dp1[i-1]+(cnt)*X;
            now_K-=X;
            dp0[i]=max(dp0[i],dp1[i-1]+(N-cnt)*X);
        }
        else{
            dp1[i]=dp1[i-1]+X*(N-cnt);
        }
    }
    rep(i,50){
        //cout << dp0[i] << " " << dp1[i] << endl;
    }
    cout << max(sum,max(dp0[49],dp1[49])) << '\n';
}


Measured memory_bytes: 4316
#include <stdio.h>

int		main(void)
{
	int		x, y;
	int		a, b;
	//long		tmp;
	int		rmd;
	int		i;
	int		rst;

	scanf("%d %d",&a, &b);
	if( a >= b )
	{
		x = a;
		y = b;
	}else
	{
		x = b;
		y = a;
	}

	rmd = x % y;
	if( rmd == 0 )
	{
		printf("%d\n",y);
	}
	else
	{
		//printf("rmd=%ld\n",rmd);
		for(i=1; i<=rmd; i++)
		{
			if((( y % i) == 0) && (( rmd % i) == 0))
			{
				rst = i;
			}
		}
		printf("%d\n",rst);
	}
	return 0;
}

Measured memory_bytes: 592
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

const int MX=1e7+1;
vi spf(MX,-1);

void sieve(){
   for(int i=2; i<MX; i++) if(spf[i]==-1){
      for(int j=i; j<MX; j+=i) spf[j]=i;
   }
}

int f(int N){
   if(N==1) return 1;
   vi vec;
   while(N>1){
      vec.pb(spf[N]);
      N/=spf[N];
   }
   int res=1;
   for(int i=0; i<sz(vec); i++){
      int cnt=0;
      int x=vec[i];
      while(i<sz(vec) && vec[i]==x){
         cnt++; i++;
      }
      i--;
      res*=cnt+1;
   }
   return res;
}

int32_t main(){
   boost;
   //memset(spf,-1,MX);
   sieve();
	int N; cin>>N;
	int res=0;
	for(int i=1; i<=N; i++){
      res+=i*f(i);
	}
   cout << res << endl;
   return 0;
}



Measured memory_bytes: 81212
N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(M)]
 
dp=[True]*N

 
for i in A:
  if H[i[0]-1]<H[i[1]-1]:
    dp[i[0]-1]=False
    
  elif H[i[0]-1]>H[i[1]-1]:
    dp[i[1]-1]=False
  
  elif H[i[0]-1]==H[i[1]-1]:
    dp[i[1]-1]=False
    dp[i[0]-1]=False
  
 
print(dp.count(True))

Measured memory_bytes: 31900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))



int main(){
	ll N;
	cin >> N;
	vector<ll> A(N),ans(N,0);
	FOR(i,0,N)cin>>A[i];
	FOR(i,0,N){
		ans[0] += TO(i%2,1,-1)*A[i]*2;
	}
	ans[0] /= 2;
	if(ans[0]<0)ans[0]*=-1;
	cout << ans[0];
	ans[N-1] = A[N-1]*2-ans[0];
	FOR(i,1,N-1){
		ans[i] = 2*A[i-1]-ans[i-1];
		cout << " " << ans[i];
	}
	cout << " " << ans[N-1];
	cout << endl;
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int T;
int ex_gcd(int a,int b,int &x,int &y)
{
	if(b==0)
	{
		x=1,y=0;
		return a;
	}
	int d=ex_gcd(b,a%b,x,y);
	int tmp=x;
	x=y,y=tmp-a/b*y;
	return d;
}
int getinv(int A,int MOD)
{
	int x,y;
	int d=ex_gcd(A,MOD,x,y);
	if(d!=1) return -1;
	return (x+MOD)%MOD;
}
int a,x,b,y,c;
int d;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
vector<pair<int,int> >pos;
vector<int>cnt;
void getpos()
{
	pos.clear(),cnt.clear();
	int W=c,H=d;
	int now=0;
	while(true)
	{
		int r=W/H;
		pos.push_back(make_pair(1LL*now*getinv(d,c)%c,now%c==0?c:(c-now+c)%c)),cnt.push_back(r); 
		now+=r*H;
		W%=H;
		if(W==0) break;
		H%=W;
		if(H==0) H=W;
	}
	pos.push_back(make_pair(c,0));
	return;
}
void solve()
{
	scanf("%d%d%d%d%d",&a,&x,&b,&y,&c);
	int G;
	G=gcd(a,b),a/=G,b/=G,c/=gcd(G,c);
	G=gcd(a,c),a/=G,c/=G,y/=G;
	G=gcd(b,c),b/=G,c/=G,x/=G;
	a%=c,b%=c;
	if(c==1)
	{
		printf("%d\n",x+y);
		return;
	}
	d=1LL*a*getinv(b,c)%c;
	getpos();
	int ans=0;
	for(size_t i=0;i<cnt.size();i++)
	{
		int xl=pos[i].first,yl=pos[i].second,xr=pos[i+1].first,yr=pos[i+1].second;
		int dx=(xr-xl)/cnt[i],dy=(yl-yr)/cnt[i];
		int l=0,r=x+y,res=0;
		while(l<=r)
		{
			int mid=((long long)l+r)/2;
			long long p=(x-1LL*xl*mid)/dx,q=(y-1LL*yr*mid)/dy;
			if((x-1LL*xl*mid)>=0&&(y-1LL*yr*mid)>=0&&p+q>=1LL*cnt[i]*mid) res=mid,l=mid+1;
			else r=mid-1;
		}
		ans=max(ans,res);
	}
	printf("%d\n",ans);
	return;
}
int main()
{
	scanf("%d",&T);
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin >> n;
#define in2(n, k) cin >> n >> k;
#define in3(n, k, s) cin >> n >> k >> s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (i = j; i < k; i += in)
#define rloop(i, j, k, in) for (i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)      \
            cin >> \
        a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int64 x;
    cin >> x;
    int64 i, j, i1, j1;
    nloop(i, -120, 120, 1)
    {
        nloop(j, -120, 120, 1)
        {
            if (pow(i, 5) - pow(j, 5) == x)
            {
                i1 = i;
                j1 = j;
            }
        }
    }
    cout << i1 << " " << j1;
    return 0;
}


Measured memory_bytes: 4120
// AUTHOR:: MOHAMMAD FAISAL
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
    cin >> s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3] || s[3] ==s[4])
      cout<<"Bad";
    else
      cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();

		if (0 <= a && a <= 100 && 0 <= b && b <= 100 && 0 <= c && c <= 100) {
			if (a < b && b < c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}

Measured memory_bytes: 25976
N = int(input())
M = 10**9 + 7

dp = [
    [[[1 if i==0 else 0 for i in range(N-2)] for j in range(4)]
    for k in range(4)] for j in range(4)
    ]

dp[0][1][2][0] = 0
dp[0][2][1][0] = 0
dp[1][0][2][0] = 0

for m in range(N-3):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    dp[j][k][l][m+1] += dp[i][j][k][m]
                    dp[j][k][l][m+1] %= M
                    dp[0][1][2][m+1] = 0
                    dp[0][2][1][m+1] = 0
                    dp[1][0][2][m+1] = 0

                    if (i==0):
                        for o in range(4):
                            dp[o][1][2][m+1] = 0
                            dp[1][o][2][m+1] = 0

total = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            total += dp[i][j][k][N-3]
            total %= M
print(total)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
LL n,array1[2*N],i,T,counter=0,flag=0;
cin>>n>>T;
for(i=0;i<n;++i){
    cin>>array1[i];
}
LL works=array1[0]+T,begininig=0;
for(i=1;i<n;++i){
    if(array1[i]<=works){
        works=array1[i]+T;
    }
    else{
        counter+=works-begininig;
        works=array1[i]+T;
        begininig=array1[i];
    }
}
printf("%lld",counter+works-begininig);



    return 0;
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second

typedef long long int ll;

const ll INF = 1e10;
ll p[200];


main(){
	IOS;
	ll n;
	cin>>n;
	if(n >= 195){
		cout<<"5"<<endl;
	}
	else if(n < 195 and n >=189){
		cout<<"4"<<endl;
	}
	else if(n < 189 and n >= 165){
		cout<<"3"<<endl;
	}
	else if(n < 165 and n >=135){
		cout<<"2"<<endl;
	}
	else if(n < 135 and n >=105){
		cout<<"1"<<endl;
	}
	else {
		cout<<0<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 101;

int n,m,q,ans,l[N],r[N],w[N],v[N],c[N];

inline int cal(){
	int ans = 0;
	for(int i=1;i <= q;i++)
		if(c[r[i]]-c[l[i]] == w[i]) ans += v[i];
	return ans;
}

void dfs(int x,int k){
	if(x == n+1){
		ans = max(ans,cal());
		return;
	}
	for(int i=k;i <= m;i++)
		c[x] = i , dfs(x+1,i);
}

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i <= q;i++) scanf("%d%d%d%d",&l[i],&r[i],&w[i],&v[i]);
	dfs(1,1);
	cout<<ans<<endl;
} 

Measured memory_bytes: 3760
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = [Intl() for _ in range(n)]
    dp = [[0,0,0] for _ in range(n+1)]
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j == k:pass
                else:
                    dp[i+1][k] = max(dp[i+1][k],dp[i][j] + a[i][k])
    print(max(dp[-1]))

Measured memory_bytes: 44112
*r;main(p,q,l){for(;~scanf("%d%d",&p,&q);){for(r=calloc(q*4,l=1);*r=!r[p%=q];putchar(p/q+48))r[p]=l++,p*=10;for(puts("");p*l;)putchar(--l?--r[p]>0?32:94:10);}}

Measured memory_bytes: 0
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([usize]);
    v.sort_by(|a, b| b.cmp(a));
    //eprintln!("{:?}", v);
    let mut i = 0;
    let mut p: (usize, usize) = (0, 0);
    while i < n - 1 {
        if v[i] == v[i + 1] {
            //eprintln!("i: {}", i);
            if p.0 < p.1 {
                p.0 = v[i];
            } else {
                p.1 = v[i];
            }
            i += 2;
        } else {
            i += 1;
        }
        if p.0 != 0 && p.1 != 0 {
            break;
        }
    }
    println!("{}", p.0 * p.1);
}


Measured memory_bytes: 8444
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    let (n, m): (usize, usize) = read();

    if max(n, m) - min(n, m) >= 2 {
        println!("0")
    } else {
        let mut ans = 1;
        for i in 1..n+1 {
            ans *= i as i64;
            ans %= MOD;
        }
        for i in 1..m+1 {
            ans *= i as i64;
            ans %= MOD;
        }
        if n == m {
            ans *= 2;
            ans %= MOD;
        }
        println!("{}", ans);
    }

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main (){
  int s;
  cin >> s;
  int x = s/3;
  if(x<1){
    cout << 0 << endl;
  } else {
    ll ans=0;
    COMinit();
    for(int i=1;i<=x;i++){
      ans += COM(s-2*i-1, i-1);
      ans %= MOD;
    }
    cout << ans << endl;
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans = 0;
  FOR(x,1,n+1){
    int t = x;
    int s = 0;
    while(t){
      s += t%10; t/=10;
    }
    if(a<=s && s<=b)ans+=x;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b) ; }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}

void read(vt<int> &a) {
    rep(i,0,a.size()) 
        cin >> a[i] ; 
}
void read(vt<ld> &a) {
    rep(i,0,a.size()) 
    cin >> a[i] ; 
}

bool prime(ll t) {
    for(ll i  =2 ; i*i <= t ; ++i) {
        if(t%i==0) 
            return 0 ; 
    }
    return 1 ; 
}
bool cmp(pii &a , pii &b) {
    if(a.ss == b.ss) 
        return a.ff > b.ff ; 
    return a.ss < b.ss ; 
}

// ==========Start Here==============
const int N = 1e6 + 1 ; 




int main() 
{ 
    int n ; 
    cin >> n ; 
    vt<int> a(n) ; 
    vt<int> cnt(N+1) ; 
    int x ; 
    rep(i,0,n)  {
        cin >> a[i] ;  
        ++cnt[a[i]] ; 

    }

    int g = 0 ; 
    rep(i,0,n) {
        g = gcd(g,a[i]) ; 
    }
    if(g>1) {
      cout << "not coprime"; 
      return 0 ; 
    }

    for(int i = 2 ; i < N ; ++i) {
        int tmp =0 ; 
        for(int j = i ; j < N ; j += i ) 
            tmp += cnt[j] ; 
        if(tmp > 1) {
            cout << "setwise coprime" ; 
            return 0 ; 
        }
    }
    cout << "pairwise coprime" ; 
    

    return 0; 
} 


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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	int n,i;
	ll x;
	ll s[105];
	cin>>n>>x;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	
	ll sum=0;
	for(i=0;i<n;i++){
		sum+=s[i];
		if(sum>x){
			cout << i << endl;
			return 0;
		}
	}
	if(sum==x)
	cout << n << endl;
	else cout << n-1 << endl;	
	
		
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = sorted([I() for _ in range(n)])
    s = sum(a)
    if s % 10 != 0:
        return s
    for c in a:
        if c % 10 != 0:
            return s - c

    return 0



print(main())


Measured memory_bytes: 6552
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####

def f(x, A, B):
    return (A * x // B) - A * (x // B)

def solve(A, B, N):
    # 0 <= x <= N  integer
    # max value Ax//B - A (x//B)
    q,r = divmod(N, B)
    ans = 0
    if q:
        ans = max(ans, f(q*B-1, A,B))
    ans = max(ans, f(N, A, B))
    return ans

def brute(A, B, N):
    ans = -1e9
    for x in range(0, N+1):
        ans = max(ans, f(x, A, B))
    return ans


    
print solve(*rrm())


Measured memory_bytes: 64276
import numpy as np
from scipy import signal
import pprint

n = input()
a = np.array(list(map(int, input().split())), dtype=np.int64)

p = 200003
g = 2

c = np.zeros(p, dtype=np.int64)
d = np.zeros(p, dtype=np.int64)

k = 1
for i in range(p-1):
  c[k] = i
  d[i] = k
  k = k*g%p

b = np.zeros(p, dtype=np.float64)

for x in a:
  if x > 0:
    w = int(c[x])
    b[w] += 1

res = signal.fftconvolve(b, b, mode='full')


ans = 0

for i in range(len(res)):
  if res[i] > 0.5:
    w = int(round(res[i]))
    ans += w * d[i % (p-1)]

for x in a:
  ans -= x*x%p

ans = ans//2

print(ans)


Measured memory_bytes: 90524
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void) {
  int a, b;
  char s[11], t[11], u[11];
  char str_a[3], str_b[3];
  
  //printf("%d", (int)log10(9));
  scanf("%s", s);
  scanf("%s", t);
  scanf("%s", str_a);
  scanf("%s", str_b);
  scanf("%s", u);
  
  a = atoi(str_a);
  b = atoi(str_b);

  if(strcmp(s, u) == 0) {
    a -= 1;
  } else {
    b -= 1;
  }

  printf("%d %d\n", a, b);

  return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int mod=pow(10,9)+7;
int main(){
  ll n,k;
  cin>>n>>k;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n+1][k+1];
  for(int i=0;i<=k;i++)dp[0][i]=1;
  for(int i=0;i<=n;i++)dp[i][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      int diff=(j-arr[i-1]);
      if(diff<=0)
        dp[i][j]=(dp[i][j-1] %mod +dp[i-1][j]%mod)%mod;
      else if(diff>0){
        int val=(dp[i-1][j] -dp[i-1][diff-1]);
        if(val<0)val=(val+mod)%mod;
        dp[i][j]=(val%mod +dp[i][j-1]%mod)%mod;
      }
    }
  }
  if(k==0)
    cout<<dp[n][k]<<endl;
  else{
    int val=dp[n][k]-dp[n][k-1];
    if(val<0)val=(val+mod)%mod;
    cout<<val<<endl;
  }
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e5;
const ll inf = 1e12;
const ll mod = 1e9+7;


int main(){
	fastio;
	ll x;
	cin >> x;
	if ( x <600) cout << "8\n";
	else if ( x <800) cout << "7\n";
	else if ( x <1000) cout << "6\n";
	else if ( x <1200) cout << "5\n";
	else if ( x <1400) cout << "4\n";
	else if ( x <1600) cout << "3\n";	
	else if ( x <1800) cout << "2\n";
	else if ( x <2000) cout << "1\n";

}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, n, h;std::cin >> n >> h;
  vvl d = vv(n*2, 2, 0, ll);
  re(i, n){
    std::cin >> a >> b;
    d[i][0] = a, d[i+n][0] = b, d[i+n][1] = 1;
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  ll ans = 0;
  ll now = 0;
  while(h>0){
    if(d[now][1]==1){
      h-=d[now][0];
      ans++;
    }else{
      ll t = h/d[now][0] + (h%d[now][0]==0?0:1);
      ans += t, h = 0;
    }
    now++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<pair<string, int>> pairs(n);
    vector<pair<string, int>> memo(n);
    for(int i=0; i<n; i++){
        string name;
        int score;
        cin >> name >> score;
        pairs[i] = make_pair(name, -score);
    }
    for(int i=0; i<n; i++){
        memo[i] = make_pair(pairs[i].first, pairs[i].second);
    }

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

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(pairs[i].first == memo[j].first  &&  pairs[i].second == memo[j].second){
                cout << j+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val d = readLine()!!.split(" ")

    for (i in n..100000) {
        var f = true
        for (x in d) {
            f = f && !(x in i.toString())
        }
        if (f) {
            println(i)
            return
        }
    }
}


Measured memory_bytes: 42420
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

//????????????
class Dice {
private:
	map<char, string> mp;
public:
	//string d = "UFRLBD";
	string d = "RENSWL";
	vector<int> v; //UFRLBD:123456
	Dice(vector<int> v) :v(v) {
		mp[d[0]] = "2354";
		mp[d[1]] = "1463";
		mp[d[2]] = "1265";
		mp[d[3]] = "1562";
		mp[d[4]] = "1364";
		mp[d[5]] = "2453";
	};
	void roll(char c) {
		roll(mp[c]);
	}
	void roll(string s) {
		int tmp = v[s[0] - '1'];
		rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
		v[s[s.size() - 1] - '1'] = tmp;
	}
};

signed main() {
	vector<int> v(6); rep(i, 0, 6) { cin >> v[i]; }
	Dice D(v);
	int q; cin >> q;
	rep(i, 0, q) {
		int u, f; cin >> u >> f;
		while (!(D.v[0] == u&&D.v[1] == f))D.roll(D.d[rand() % 6]);
		cout << D.v[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int K;
  string S;
  cin >> S >> K;
  long int ans=0;
  
  if(S[0] != S[S.size()-1]){ //最初と最後の文字が一致してないなら
    for(int i=0; i<S.size()-1 ; i++){
      if(S[i] == S[i+1]){
        ans++;
        S[i+1] = ' ';
      }
    }
    ans *= K;
    cout << ans << endl;
    return 0;
  }
  
  //最初と最後の文字が一致してるなら
  long int start_size = 1;
  long int end_size = 1;
  for(int i=0; i<S.size()-1; i++){
    if(S[i] == S[i+1]) start_size++;
    else break;
  }
  for(int i=S.size()-1; i>=0; i--){
    if(S[i] == S[i-1]) end_size++;
    else break;
  }
  
  if(start_size == S.size()){//全部同じ文字なら
    ans = S.size()*K/2;
    cout << ans << endl;
    return 0;
  }
  
  //まず最初と最後の文字の部分を数える(i)
  const long int len = start_size + end_size; 
  ans = start_size/2  +  (len/2) *(K-1)  + end_size/2;  
  
  //最後に真ん中の文字の部分の連続部分を数える(ii)
  long int count = 0;
  for(int i=start_size; i<S.size()-1 -end_size; i++){
    if(S[i]==S[i+1]){
      count++;
      S[i+1] = ' ';
    }
  }
  count *= K;
  
  //(i) + (ii)
  ans = ans + count;
  
  cout << ans << endl;
  
  return 0;
}
 
  
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    ll b,c,d,x,y,z,n,m,l,w,sum=100000,sum2=0,ans=0;
    string s,t;
    bool ok=true;
    cin >> n >> x;
    VI a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    rep(i,n){
        if(a[i] <= x){
            x -= a[i];
            ans++;
        }
        else{
            ok = false;
            break;
        }
    }
    if(ans==0){
        cout << ans << endl;
        return 0;
    }
    if(x>0 && ok){
        ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        int N = sc.nextInt();	
	        long ans=0;
	        long sum=0;
	        for (int i=1 ; i<N; i++) {
	        	long a = sc.nextInt();
	        	long b = sc.nextInt();
	        	if(a>b) {
	        		long t = b;
	        		b=a;a=t;
	        	}
	        	sum=sum+i;
	        	ans=ans+sum;
	        	ans=ans-a*(N-b+1);
	        }
	        sum=sum+N;
	        ans=ans+sum;

	        
	        System.out.println(ans);

		 }
	}

Measured memory_bytes: 59600