akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INFL = 1e18;
const int MOD = 1000000007;

const int MAX_V = MAX;

struct edge{int to; ll cost;};

//V := number of nodes
//G := adj
//rest := number of nodes which are not determined yet
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];
int rest = V-1;
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INFL);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep((int)G[v].size(), i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


void solve(void){
    cin >> V;
    rep(V-1, meaningless_) {
        int a, b, c;
        scanf("%d %d %d\n", &a, &b, &c);
        a--; b--;
        edge e1 = {b, c};
        G[a].pb(e1);
        edge e2 = {a, c};
        G[b].pb(e2);
    }
    int Q, K;
    scanf("%d %d\n", &Q, &K);
    dijkstra(K-1);
    rep(Q, meaningless_) {
        int x, y;
        scanf("%d %d\n", &x, &y);
        printf("%lld\n", d[x-1]+d[y-1]);
    }
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int m;

vector<deque<int>> create(int length, int limit) {
    vector<deque<int>> ret;
    if (length == 0) {
        ret.emplace_back();
        return ret;
    }
    for (int i = limit; i <= m; i++) {
        auto v = create(length - 1, i);
        for (auto &x:v) {
            x.push_front(i);
            ret.push_back(x);
        }
    }
    return ret;
}

int main() {
    int n, q;
    cin >> n >> m >> q;
    vector<vector<int>> request(q);
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        request[i] = {a - 1, b - 1, c, d};
    }

    vector<deque<int>> sequences = create(n, 1);
    int ret = 0;
    for (auto v:sequences) {
        int sum = 0;
        for (auto now:request) {
            if (v[now[1]] - v[now[0]] == now[2])sum += now[3];
        }
        ret = max(ret, sum);
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 103056
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, k;
long long ans = 0;

int main() { 

  cin >> n >> k;

  for (int b = k + 1; b <= n; b++) {
    ans += 1ll * (b - k) * (n / b);
    int cur = n % b;
    if (cur >= k) {
      ans += cur - k + 1;
    }
    if (k == 0) {
      ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <functional>
#include <iomanip>
#include <math.h>
using namespace std;
using LL = long long;

LL binary(LL n) {
	LL ans = 0;
	for (LL i = 0; n>0; i++)
	{
		ans = ans + (n % 2)*pow(10, i);
		n = n / 2;
	}
	return ans;
}

LL Do_Cal(string s) {
	LL n = s.size();
	LL result = 0; LL now = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '+') {
			result += now;
			now = 0;
		}
		else {
			now *= 10;
			now += (int)s[i] - (int)'0';
			//cout << now << endl;
		}

		if (i == n - 1) {
			result += now;
		}

	}

	return result;

}

int main(void) {

	string S;

	cin >> S;
	int N = S.size();
	LL OnOff = 0;
	LL result = 0;

	while (true) {
		LL OnOff_binary = binary(OnOff);
		LL bias = 0;
		ostringstream sout;
		sout << setfill('0') << setw(N - 1) << OnOff_binary;
		string str = sout.str();
		//cout << str << endl;
		string S_inserted = S;

		for (int i = 0; i < N-1; i++) {

			if (str[i] == '1') {
				S_inserted.insert(i + 1 + bias, "+");
				bias++;
			 }

		}

		//cout << S_inserted << endl;
		//getchar();

		result += Do_Cal(S_inserted);
		
		OnOff++;
		if (OnOff >= pow(2, N - 1)) break;

	}

	cout << result << endl;
	return 0;
}

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

int main() {

  int N,K,D;D=1;
  cin >> N >> K ;

   for (int i = 0 ; i < N ; i++){
     if ( D * 2 <= D + K ){
       D = D * 2;
     }
     else{
       D = D + K ;
     }
   }
  cout << D << endl;
}

Measured memory_bytes: 3636
while True:
  n, m = map(int, input().split())
  if n == 0:
    break
  a = [int(input()) for _ in range(n)]
  b = [int(input()) for _ in range(m)]
  a.sort
  b.sort
  suma = sum(a)
  sumb = sum(b)
 
  def change():
    for i in a:
      for j in b:
        if(i-j) * 2 == suma - sumb:
          print(i, j)
          return
    print(-1)
  
  change()


Measured memory_bytes: 5604
nums = [int(e) for e in input().split()]

T = nums[0]
t = nums[1]
A = nums[2]
a = nums[3]
while T > 0 and A > 0:
    A = A - t
    T = T - a

if A <= 0:
    print('Yes')
else:
    print('No')

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

int main()
{
	int n, p;
	cin >> n;
	int max = -100000000000, min;
	cin >> min;
	for (int i = 1; i < n; i++)
	{
		cin >> p;
		if (p - min > max) max = p - min;
		if (p < min) min = p;
	}
	cout << max << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a[300000],n,q,box,b=1,c=0,x,y;
vector<int> vec;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
b=a[i];
vec.push_back(b);
}
sort(vec.begin(),vec.end());
for(int i=0;i<n;i++){
if(vec[i]==a[i])
c++;
else
break;
}
if(n==c){
cout<<"0"<<endl;
return(0);
}
c=0;
cin>>q;
for(int i=0;i<q;i++){
cin>>x>>y;
box=a[x-1];
a[x-1]=a[y-1];
a[y-1]=box;
for(int j=0;j<n;j++){
if(vec[j]==a[j])
c++;
else
break;
if(vec[n-j-1]==a[n-j-1])
c++;
else
break;
}
if(2*n==c){
cout<<i+1<<endl;
return(0);
}
c=0;
}
cout<<"-1"<<endl;
return(0);
}


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


int main(){
    int N,tmp,ans = 0;
    int minv = INT_MAX;
    cin >> N;
    for(int i = 0; i < N;i++){
        cin >> tmp;
        if(minv >= tmp){
            ans++;
            minv = tmp;
        }else{

        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A, B, C, X, Y = gets.split.map(&:to_i)

candidates = []

candidates.push(
  A * X + B * Y
)

candidates.push(
  [X, Y].max * 2 * C
)

candidates.push(
  if X > Y
    Y * 2 * C + (X - Y) * A
  else
    X * 2 * C + (Y - X) * B
  end
)

puts candidates.min


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 2e9;



int main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << "L" << string(dy + 1, 'U') << string(dx + 1, 'R') << "D";
	cout << "R" << string(dy + 1, 'D') << string(dx + 1, 'L') << "U" << endl;
	return 0;
}

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

ll t,n,m;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(ll x)
{
	static char s[233];
	if (!x) { putchar('0');putchar('\n');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar('\n');
}

inline ll gcd(ll x,ll y) { return (!y)?x:gcd(y,x%y); }

inline void ex_gcd(ll a,ll b,ll &x,ll &y)
{
	if (!b) { x=1;y=0;return; }
	ex_gcd(b,a%b,x,y);
	ll hh=x;x=y;y=hh-(a/b)*y;
}

inline ll ksm(ll x,ll y,const ll &mod) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline ll calc(ll n)
{
	ll res=1;
	for (ll i=2;i*i<=n;i++) if (n%i==0)
	{
		res*=(i-1);n/=i;
		while (n%i==0) n/=i,res*=i;
	}
	if (n>1) res*=(n-1);
	return res;
}

inline ll gao(ll n,ll m,ll lim)
{
	if (m==1) return lim;
	ll phi=calc(m),d=gcd(m,phi),hh=gao(n%d,d,phi);
	ll x,y;
	ex_gcd(phi,m,x,y);
	x=(x%m+m)%m;
	ll hhh=ksm(n,hh,m)-hh,res;
	ll now=m*phi/d;
	if (hhh==0) res=hh;
	else res=(hh+(__int128)x*phi*(hhh/d))%now;
	res+=(lim-res)/now*now;
	while (res<lim) res+=now;
	while (res-now>=lim) res-=now;
	return res;
}

int main()
{
	t=rd();
	while (t--)
	{
		n=rd();m=rd();n%=m;
		ll ans=gao(n,m,calc(m));
		print(ans);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int N,T;
int ans=10000;

signed main(){
    cin>>N>>T;
    rep(i,N){
        int c,t;
        cin>>c>>t;
        if(t<=T)ans=min(ans,c);
    }
    if(ans==10000)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string a,b;
  cin>>a>>b;
  string s = a+b;
  int c = stoi(s);
  DUMP(c);
  int lim =1010;
  for(int i=1;i*i<lim*lim;++i){
    if(i*i==c){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
dog = 1
monkey = 1
for i in range(1, N+1):
    dog *= i
    dog %= 10**9 + 7

for i in range(1, M+1) :
    monkey *= i
    monkey %= 10**9 + 7

if N == M:
    print((2 * monkey * dog) % (10 ** 9 + 7))
elif abs(N - M) == 1:
    print((monkey * dog) % (10 ** 9 + 7))
else:
    print(0)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
inline int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
int ans= 0;
int divisors[1000005]={0};
void div(int x){
  if(divisors[x] > 1){ ans++;return;}
  if(x!=1 && divisors[1] > 0) {
    ans++;
    return;
  }
  int k = sqrt(x);
  for(int i = 2 ; i <=k ; i++){
    if(x%i == 0) {
      if(divisors[x/i] > 0  || divisors[i] > 0 ){ ans++;break;}

    }
  }
}
int32_t main() 
{ 
  fast;
  int n;
  cin >> n;
  vector <int > a(n);
  for(int i = 0 ; i< n ; i++){ cin >> a[i];divisors[a[i]]++;}
  for(int i = 0 ; i < n ;i++){
    div(a[i]);
  }
  cout << n-ans << "\n";
  return 0; 
}

Measured memory_bytes: 12680
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   P 2
#define   S 3
#define   R 4
using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string a;
    cin>>a;
    int last[n+2];
    memset(last,-1,sizeof last);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(i-k>=0)
        {
             if(a[i]=='r')
             {
                 if(last[i-k]==P)
                 {
                     last[i]=-1;
                 }
                 else
                 {
                     sum+=p;
                     last[i]=P;
                 }
             }
             else if(a[i]=='p')
             {
                   if(last[i-k]==S)
                 {
                     last[i]=-1;
                 }
                 else
                 {
                     sum+=s;
                     last[i]=S;
                 }
             }
             else
             {
                  if(last[i-k]==R)
                 {
                     last[i]=-1;
                 }
                 else
                 {
                     sum+=r;
                     last[i]=R;
                 }
             }
        }
        else
        {
            if(a[i]=='r')sum+=p,last[i]=P;
            else if(a[i]=='p')sum+=s,last[i]=S;
            else sum+=r,last[i]=R;
        }
    }
    cout<<sum<<endl;
    return 0;

}





































Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1000000;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
vector< pair<int, ll> >  G[N];
vi pro(N);
vector<ll> dis(N);
int P[N][20];
void dfs(int u, int parent, int prof){
    P[u][0] = parent;
    pro[u] = prof;
    fore(i, 1, 20)
        P[u][i] = P[P[u][i - 1]][i - 1];
    for(auto v : G[u]){
        if(v.F != parent){
            dis[v.F] = dis[u] + v.S;
            dfs(v.F, u, prof + 1);
        }
    }
}
int main(){
    fin;
    int n;
    cin >> n;
    fore(i, 1, n){
        int u, v; 
        ll w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].pb({v, w});
        G[v].pb({u, w});
    }
    int q, k;
    cin >> q >> k;
    k--;
    dfs(k, k, 0);
    w(q){
        int u, v;
        cin >> u >> v;
        u--;v--;
        cout << dis[u] + dis[v] << '\n';
    }
    return 0;
}   

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

using namespace std;

#define int long long
#define fi first
#define se second
#define inf 1e9
const int mod=(int)1e9+7;


void test_case(){
	int n;
	cin>>n;
	vector<int> bit(61);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		for(int b=0;b<60;b++){
			if(x&((int)1<<b))bit[b]++;
		}
	}
	int ans=0;
	for(int i=0;i<60;i++){
		ans=(ans+(((int)1<<i)%mod*bit[i])%mod*(n-bit[i]))%mod;
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


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

long dfs_calc(string &s) {
  int len = s.length();
  long sum = stol(s);

  for (int i = 1; i < len; i++) {
    string left = s.substr(0, i);
    sum += stol(left) * pow(2, len - i - 1);
    string right = s.substr(i, len - i);
    sum += dfs_calc(right);
  }

  return sum;
}

int main() {
  string s;
  cin >> s;
  // s = "9999999999";

  long sum = dfs_calc(s);
  cout << sum << endl;
  return 0;
}


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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  ll l = a[0];
  for (int i = 1; i < n; i++) {
    l = lcm(l, a[i]);
    if (l / 2 > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  if (l % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> d(n);
  for(int i = 0; i < n; i++)
    d[i] = l / a[i];
  
  for(int i = 0; i < n; i++) {
   if (d[i] % 2 == 0) {
     cout << 0 << endl;
     return 0;
   }
  }
  
  int count = 0;
  for (int i = l / 2; i <= m; i += l)
    count++;
  
  cout << count << endl;
  return 0;
}

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

using namespace std;
#define int long long

signed main(){

   int N;
   cin>> N;

   int m=0;
   for(int i=1; i<=N; i++){
      int s=i*(i+1)/2;
      if(s>=N){
         m=i;
         break;
      }
   }
   int s=m*(m+1)/2;
   vector<int> ans;
   for(int i=m; i>=1; i--){
      int S=i*(i-1)/2;
      if(N>S){
         ans.push_back(i);
         N-=i;
      }
      if(N==0) break;
   }

   for(int a: ans){
      cout<< a<< endl;
   }
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int>> program(C, vector<int>(200000 + 2));

  int s, t, c;
  rep(i, N) {
    cin >> s >> t >> c;
    c--;
    s = s * 2 - 1;
    t = t * 2 - 1;
    repp(j, s, t) {
      program[c][j] = 1;
    }
  }

  int ans = 0;
  repp(i, 1, 200000) {
    int temp = 0;
    rep(j, C) {
      temp += program[j][i];
    }
    chmax(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    long double a, b;
    cin >> a >> b;
    cout << (ll)(a * b) << endl;
}


Measured memory_bytes: 3712
#include <iostream>

using namespace std;

struct state{
	int x, y, p, q, dir;
	state(int a, int b, int c, int d, int e){
		x = a, y = b, p = c, q = d, dir = e;
	}
};

int N, M, A;
char map[105][105];
int sx, sy, gx, gy;
bool used[105][105][15][15][4];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void dfs(int x, int y, int p, int q, int dir)
{
	used[x][y][p][q][dir] = true;
	if(map[x][y] == 'G') return;
	
	int np, nq, nx, ny;
	for(int nd = 0; nd < 4; nd++){
		np = p, nq = q;
		nx = x + dx[nd], ny = y + dy[nd];
		if(nx < 0 || nx >= M || ny < 0 || ny >= N) continue;
		if(map[nx][ny] == '#') continue;
		if(nd == 1 && map[nx][ny] == 'S') continue;
		if((dir+4-nd) % 4 == 2) continue;
		if(dir != nd){
			if(map[x][y] == 'S') continue;
			if(dir/2 == nd/2) np++;
			else nq++;
		}
		if(np > A || nq > A) continue;
		if(used[nx][ny][np][nq][nd]) continue;
		dfs(nx, ny, np, nq, nd);
	}
}

int main(void)
{
	cin >> N >> M >> A;
	for(int y = 0; y < N; y++){
		for(int x = 0; x < M; x++){
			cin >> map[x][y];
			if(map[x][y] == 'S') sx = x, sy = y;
			if(map[x][y] == 'G') gx = x, gy = y;
		}
	}
	
	if(sy == N-1 || map[sx][sy+1] == '#'){
		cout << -1 << endl;
		return 0;
	}
	sy++;
	
	for(int x = 0; x < M; x++){
		for(int y = 0; y < N; y++){
			for(int p = 0; p <= A; p++){
				for(int q = 0; q <= A; q++){
					for(int d = 0; d < 4; d++){
						used[x][y][p][q][d] = false;
					}
				}
			}
		}
	}
	
	dfs(sx, sy, 0, 0, 3);
	
	int ans = 1000;
	for(int p = 0; p <= A; p++){
		for(int q = 0; q <= A; q++){
			for(int d = 0; d < 4; d++){
				if(used[gx][gy][p][q][d]){
					ans = min(ans, p+q);
				}
			}
		}
	}
	if(ans == 1000) ans = -1;
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(all(b));
  rep(i, n) {
    if (a[i] != b[n - 1]) {
      cout << b[n - 1] << endl;
    } else {
      cout << b[n - 2] << endl;
    }
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(2);
    int ans_c = 0;
    for(int i=0; i<n; i++){
        cin >> d.at(0) >> d.at(1);
        if(d.at(0) == d.at(1)){
            ans_c += 1;
        }
        else{
            ans_c = 0;
        }
        if(ans_c == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for cnt_500 in range(a + 1):
    for cnt_100 in range(b + 1):
        for cnt_50 in range(c + 1):
            price = 500 * cnt_500 + 100 * cnt_100 + 50 * cnt_50
            if price == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

ll solve1(ll perimeter, int n, vector<ll> const & x) {
    ll dist = 0;
    {  // compute the dist when start = 0
        const int start = 0;
        int l = start + 1;
        int r = n;
        dist += x[start];
        while (l != r) {
            dist += x[l - 1] + perimeter - x[r - 1];
            -- r;
            if (l == r) break;
            dist += x[l] + perimeter - x[r];
            ++ l;
        }
    }

    // compute the dist when start = n + 1
    ll answer = dist;
    REP (start, n - 1) {
        int last = start + (n - start) / 2;
        dist -= x[start];
        dist += x[last] - x[start];
        if ((n - start) % 2 == 0) {
            dist -= perimeter - x[last];
        } else {
            if (last != n - 1) {
                dist -= perimeter - x[last + 1];
            }
        }
        chmax(answer, dist);
    }
    return answer;
}

ll solve(ll perimeter, int n, vector<ll> const & x) {
    vector<ll> y(n);
    REP (i, n) y[i] = perimeter - x[n - i - 1];
    return max(solve1(perimeter, n, x), solve1(perimeter, n, y));
}

int main() {
    int l, n; cin >> l >> n;
    vector<ll> x(n);
    REP (i, n) cin >> x[i];
    cout << solve(l, n, x) << endl;
    return 0;
}


Measured memory_bytes: 3328
n=int(input())
m=100003
L=[1]*(m+1)
L[0]=L[1]=0
for i in range(2,int(m**0.5)+1):
    if L[i]:
        for j in range(i*i,m+1,i):
            L[j]=0
for i in range(n,m+1):
    if L[i]==1:
        print(i)
        exit()

Measured memory_bytes: 39408
#include <stdio.h>
#include <iostream>

using namespace std;

bool check (int a)
{
	while (a % 2 == 0) {
		a /= 2;
	}

	while (a % 3 == 0) {
		a /= 3;
	}

	while (a % 5 == 0) {
		a /= 5;
	}

	if (a == 1) {
		return true;
	} else {
		return false;
	}

}

int main() {
	int m,n;
	int counter;

	while (cin >> m) {
		if (m == 0) {
			break;
		}
		else {
			cin >> n;
			counter = 0;
			for (int i = m; i <= n; i++) {
				if (check(i)) {
					counter++;
				}
			}
			cout << counter << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}

int f(map<char,int> mp){
    int ret=0;
    for(auto x:mp){
        ret=max(ret,x.second);
    }
    return ret;
}

signed main (){
    int n;cin>>n;
    string s[3];
    rep(i,0,3)cin>>s[i];
    map<char,int> mp[n];
    rep(i,0,n){
        rep(j,0,3){
            mp[i][s[j][i]]++;        }
    }
    int ans=0;
    rep(i,0,n){
        ans+=(3-f(mp[i]));
    }
    cout<<ans<<endl;
}
/*
*/


Measured memory_bytes: 256
fun main(arg: Array<String>) {

    val n = readLine()!!.toInt()

    val p = Array(n) { i ->
        readLine()!!.split(" ").map { it.toInt() }.let { intArrayOf(i, it[0], it[1]) }
    }

    val edge = ArrayList<IntArray>()

    p.sortBy { it[1] }
    for (i in 0..n - 2) {
        val d = Math.abs(p[i][1] - p[i + 1][1])
        edge.add(intArrayOf(p[i][0], p[i + 1][0], d))
    }

    p.sortBy { it[2] }
    for (i in 0..n - 2) {
        val d = Math.abs(p[i][2] - p[i + 1][2])
        edge.add(intArrayOf(p[i][0], p[i + 1][0], d))
    }

    edge.sortBy { it[2] }

    val uf = UnionFind(n)
    var ret = 0L

    edge.forEach {
        if (!uf.hasSameRoot(it[0], it[1])) {
            uf.unite(it[0], it[1])
            ret += it[2]
        }
    }
    println(ret)
}

class UnionFind(size: Int) {
    private val data: Array<Int> = Array(size) { -1 }

    fun unite(x: Int, y: Int) {
        val x = find(x)
        val y = find(y)
        if (data[x] > data[y]) {
            val temp = data[x]
            data[x] = data[y]
            data[y] = temp
        }
        data[x] += data[y]
        data[y] = x
    }

    fun find(k: Int): Int {
        if (this.data[k] < 0) return k
        data[k] = find(data[k])
        return data[k]
    }

    fun hasSameRoot(x: Int, y: Int) = find(x) == find(y)

    fun size(k: Int) = -data[find(k)]
}


Measured memory_bytes: 76708
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{

public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
        int n=s.nextInt(),b=s.nextInt();

        out.write(6-n-b+"\n");
        out.flush();
  }
}


Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,shu=0,g=0,j=0;
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++)
	{
		j=i;
		shu=0;
		shu+=j%10;
		shu+=j/10%10;
		shu+=j/100%10;
		shu+=j/1000%10;
		shu+=j/10000%10;
		if(shu>=b&&shu<=c)
		{
			g+=i;
		}
	}
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};const int MAX = 510000;
const int MOD = 1000000007;
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 N,P;  cin>>N>>P;
  map<int, int> ma;
  rep(i,0,N){
    int x;  cin>>x; x%=2;
    ma[x]++;
  }
  ll ans = 1;
  if(ma[0]==N){
    if(P == 0){
      rep(i,0,N) ans *= 2;
    }else{
      ans = 0;
    }
    cout<<ans<<endl;
    return 0;
  }
  /*if(N==1){
    if(ma[0]==1 && P==1){
      cout<<0<<endl;
      return 0;
    }
  }*/
  rep(i,0,N-1){
    ans *= 2;
  }
  cout<< ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <math.h>
#include <cctype>
#include <algorithm>
#include <sstream>
using namespace std;

const float PI = 3.14;


int main()
{
	long long n, k;
	cin >> n >> k;

	cout << min(k - n % k, n % k) << endl;

	
	return 0;
}


Measured memory_bytes: 3636
h, w = map(int, input().split())
cells = []
for hh in range(h):
    row = list(input())
    cells.append(row)
#print(cells)

dp = [[0 for c in range(w)] for r in range(h)]

if cells[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

r = 0
for c in range(1,w):
    if cells[r][c] != cells[r][c-1] and cells[r][c] == "#":
        dp[r][c] = dp[r][c-1] + 1
    else:
        dp[r][c] = dp[r][c-1]
c = 0        
for r in range(1,h):
    if cells[r][c] != cells[r-1][c] and cells[r][c] == "#":
        dp[r][c] = dp[r-1][c] + 1
    else:
        dp[r][c] = dp[r-1][c]

for r in range(1,h):
    for c in range(1,w):
        upper = dp[r-1][c]
        if cells[r][c] != cells[r-1][c] and cells[r][c] == '#':
            upper += 1
        left = dp[r][c-1]
        if cells[r][c] != cells[r][c-1] and cells[r][c] == '#':
            left += 1
        dp[r][c] = min(left, upper)
print(dp[-1][-1])

Measured memory_bytes: 3316
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  n++;
  vector<ll> a(n);
  vector<ll> maxl(n);
  vector<ll> minl(n);
  REP(i,n) cin >> a[i];
  ll maxV = 1;
  ll ans = 0;
  REP(i,n){
    ll j = n-i-1;
    ll t=0;
    if(j==n-1){
      maxl[j] = a[j];
      minl[j] = a[j];
    }else{
      maxl[j] = maxl[j+1]+a[j];
      minl[j] = (minl[j+1]+1)/2+a[j];
    }
    if(j<=55){
      t = 1;
      REP(k,j) t*=2;
      maxl[j] = min(t,maxl[j]);
      if(minl[j]>t){
        cout << -1 << endl;
        return 0;
      }
    }
    //DEBUG(maxl[j]);
    //DEBUG(minl[j]);
  }
  vector<ll> l(n);
  REP(i,n){
    if(i==0){
      l[i] = 1-a[i];
    }else{
      l[i] = l[i-1]*2;
      l[i] = min(maxl[i],l[i]);
      l[i] -= a[i];
    }
    ans += l[i]+a[i];
  }
  //ll smax = 0;
  //ll smin = 0;
  //REP(i,n) smax += maxl[i];
  //REP(i,n) smin += minl[i];
  //DEBUG(smax);
  //DEBUG(smin);
  cout << ans << endl;
  return 0;
}


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

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

    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            long long num = 0;
            if(i==j){
                if (i <= N)num++;
                if (10 * i + i <= N)num++;
                for (int k = 0; k < 10; k++) {
                    if ((100 * i + 10 * k + i) <= N)num++;
                    else break;
                }
                for (int k = 0; k < 100; k++) {
                    if ((1000 * i + 10 * k + i) <= N)num++;
                    else break;
                }
                for (int k = 0; k < 1000; k++) {
                    if ((10000 * i + 10 * k + i) <= N)num++;
                    else break;
                }
                for (int k = 0; k < 10000; k++) {
                    if ((100000 * i + 10 * k + i) <= N)num++;
                    else break;
                }
                ans += num * num;
            }
            else {
                long long num1 = 0;
                long long num2 = 0;
                if (10 * i + j <= N)num1++;
                for (int k = 0; k < 10; k++) {
                    if ((100 * i + 10 * k + j) <= N)num1++;
                    else break;
                }
                for (int k = 0; k < 100; k++) {
                    if ((1000 * i + 10 * k + j) <= N)num1++;
                    else break;
                }
                for (int k = 0; k < 1000; k++) {
                    if ((10000 * i + 10 * k + j) <= N)num1++;
                    else break;
                }
                for (int k = 0; k < 10000; k++) {
                    if ((100000 * i + 10 * k + j) <= N)num1++;
                    else break;
                }

                if (10 * j + i <= N)num2++;
                for (int k = 0; k < 10; k++) {
                    if ((100 * j + 10 * k + i) <= N)num2++;
                    else break;
                }
                for (int k = 0; k < 100; k++) {
                    if ((1000 * j + 10 * k + i) <= N)num2++;
                    else break;
                }
                for (int k = 0; k < 1000; k++) {
                    if ((10000 * j + 10 * k + i) <= N)num2++;
                    else break;
                }
                for (int k = 0; k < 10000; k++) {
                    if ((100000 * j + 10 * k + i) <= N)num2++;
                    else break;
                }
                ans += num1 * num2;
                
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  combination comb(100010);
  int red = n - k;
  vector<mint> d(k + 1);
  mint sum = 0;
  for (int i = 1; i <= k; ++i) {
    mint ans = comb(red + 1, i) * comb(k - 1, i - 1);
    cout << ans << endl;
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ; 
  vector<int> v(n+1) ;
  
  rep(i,105){
    rep(j,105){
      rep(k,105){
        int now = i*i + j*j + k*k + i*j + j*k + k*i ;
        if( now <= n ) v.at(now) ++  ;
      }
    }
  }
  
  rep(i,n+1) cout << v.at(i) <<endl ;


}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int n,m;
	int ir[10000],de[10000];
	int max;
	int i;
	int flg;
	max=0;
	flg=0;
	scanf("%d",&n);
	scanf("%d",&m);
	max+=m;
	for(i=0;i<n;i++){
		scanf("%d %d",&ir[i],&de[i]);
		m+=ir[i];
		m-=de[i];
		if(m<0){
			flg=1;
		}
		if(max<m){
			max=m;
		}
	}
	if(flg==1){
		printf("0\n");
	}
	if(flg==0){
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 1096
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t A, B;
    int64_t ans = 0;

    scanf("%"PRId64"%"PRId64, &A, &B);

    if (A > B) {
        ans = A + (A - 1);
    } else if (A < B) {
        ans = B + (B - 1);
    } else {
        ans = A + B;
    }

    printf("%"PRId64"\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      if((n-1)%(k-1)==0)System.out.println((n-1)/(k-1));
      else System.out.println((n-1)/(k-1)+1);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}


Measured memory_bytes: 50456
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N;
    cin >> N;
    vector<pair<string,int>> book;
    map<pair<string,int>,int> mp;
    REP(i,N){
        string s;
        int p;
        cin >> s >> p;
        mp[make_pair(s,p)] = i+1;
        book.pb(make_pair(s,abs(p-100)));
    }
    sort(book.begin(),book.end());
    for(auto b : book){
        cout << mp[make_pair(b.first,100-b.second)] << endl;
    }
}

Measured memory_bytes: 3568
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan_ = new Scanner(System.in);
        int a_ = scan_.nextInt();
        int b_ = scan_.nextInt();
        System.out.println( a_ == b_ ? "a == b" : a_ > b_ ? "a > b" : "a < b");
        
    }
}


Measured memory_bytes: 26212
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
map<string,bool> mp;
int main(){
int n;
cin>>n;
bool ok=true;
char memo;
for(int i=0;i<n;i++){
  string s={};
  cin>>s;
  if(i!=0&&memo!=s[0])ok=false;
  if(mp[s]){ok=false;}
   mp[s]=true;
   memo=s[s.size()-1];
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
bool comp(pair<int,string> a,pair<int,string> b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}
signed main(){
    gok
    int n;
    cin>>n;
    map<string,int> mp;
    vector<pair<int,string>> vv;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    for(auto ii:mp)
    {
        vv.push_back({ii.second,ii.first});
    }
    sort(vv.begin(),vv.end(),comp);
    int ma=vv[0].first;
    int id=0;
    while(ma==vv[id].first)
    {
        cout<<vv[id].second<<endl;
        id++;
    }
    return 0;
}


Measured memory_bytes: 28144
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int min = 1000;
    for(int i=0;i<(int)S.length()-(int)T.length()+1;i++){
        int change = 0;
        for(int j=0;j<(int)T.length();j++){
            if(S[i+j]!=T[j]){
                change++;
            }
        }
        if(change<min) min = change;
    }

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

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  
  int cnt1=0,cnt2=0;
  
  for(int i=0;i<str.size();i++)
  {
    
    if(str[i]=='A')
      cnt1++;
    else
      cnt2++;
  }
  
  if(cnt1==3 || cnt2==3)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256