akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, t: "List[int]", v: "List[int]"):
    bounds = [[] for _ in range(N)]
    gb0 = (1, 0)
    tend = sum(t)
    gb1 = (-1, tend)
    for i in range(N):
        bounds[i].append(gb0)
        bounds[i].append(gb1)
    stt = 0
    for i in range(N):
        ti = t[i]
        vi = v[i]
        end = stt + ti
        b0 = (-1, stt + vi)
        b1 = (0, vi)
        b2 = (1, -end + vi)
        for j in range(i):
            bounds[j].append(b0)
        bounds[i].append(b1)
        for j in range(i + 1, N):
            bounds[j].append(b2)
        stt = end
    stt = 0
    vms = [0] * (tend * 2 + 1)
    for i in range(N):
        end = stt + t[i]
        bi = bounds[i]
        inf = float("inf")
        mins = {-1: inf, 0: inf, 1: inf}
        for a, b in bi:
            mins[a] = min(mins[a], b)
        for tm in range(stt * 2, end * 2):
            vms[tm] = min(a * tm + b * 2 for a, b in mins.items())
        stt = end
    print(sum(vms) / 4)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, t, v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f([], S, S).
f([X|Xs], S, Z) :- S2 is S + 1.0 / X, f(Xs, S2, Z).

main :-
    get_number(N),
    get_numbers(N, Xs),
    f(Xs, 0, S),
    Z is 1.0 / S,
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8200
n = int(input())
ary = [0]+list(map(int,input().split()))+[0]
total = 0
for i in range(1,n+2):
    total += abs(ary[i] - ary[i-1])
for i in range(1,n+1):
    print(total-abs(ary[i]-(ary[i-1])) -abs(ary[i]-(ary[i+1])) +abs((ary[i-1])-(ary[i+1])))


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int K;
  cin >> K;
  vector<int> A(K);
  REP(i, K){
    cin >> A[i];
  }
  vector<ll> maxc(K+1), minc(K+1);
  maxc[K] = minc[K] =2;

  REPR(i, K-1){
    maxc[i] = A[i] * (maxc[i+1] / A[i]) + A[i]-1;
    minc[i] = A[i] * (minc[i+1] / A[i]);
    if(minc[i+1] % A[i] != 0){
      minc[i] += A[i];
    }
    ll maxn = A[i] *(maxc[i] / A[i]);
    ll minn = A[i] *(minc[i]/ A[i]);
    if(maxn < minc[i+1] || maxc[i+1] < maxn || minn < minc[i+1] || maxc[i+1] < minn){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << minc[0] << " " << maxc[0] << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  set<char> S;
  char c;
  for (int i = 0; i < N; i++) {
    cin >> c;
    S.insert(c);
  }
  if (S.size() == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}P;

void koch(int,P,P);

int main(){
  int n;
  P cd,cd2;
  scanf("%d",&n);
  cd.x = 0;
  cd2.x = 100;
  cd.y = 0;
  cd2.y = 0;
  printf("%.10f %.10f\n",cd.x,cd.y);
  koch(n,cd,cd2);
  printf("%.10f %.10f\n",cd2.x,cd2.y);

  return 0;
}

void koch(int n,P p1,P p2){
  P s,t,u;
  if(n==0){
    return;
  }
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * 0.5 - (t.y - s.y) * (sqrt(3.0)/2.0) + s.x;
  u.y = (t.x - s.x) * (sqrt(3.0)/2.0) + (t.y - s.y) * 0.5 + s.y;
  koch(n-1,p1,s);
  printf("%.10f %.10f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.10f %.10f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.10f %.10f\n",t.x,t.y);
  koch(n-1,t,p2);
}
  



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
struct UnionFind{
    vector<ll> par;
    
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
    
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[root(x)];
    }
};

int main(){
  ll n,m;cin>>n>>m;
  vector<ll> x(m),y(m),z(m);
  rep(i,m) cin>>x[i]>>y[i]>>z[i],x[i]--,y[i]--;
  UnionFind uf(n);
  rep(i,m) uf.merge(x[i],y[i]);
  set<ll> st;
  rep(i,n) st.insert(uf.root(i));
  cout<<st.size()<<endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int n;
    cin >> n;
    int a[3 * n];

    REP(i, 3 * n) {
        scanf("%d", &a[i]);
    }

    sort(a, a + (3 * n), greater< int >());

    ll cnt = 0;

    for (int i = 0, j = 1; i < n; ++i,j += 2) {
        cnt += a[j];
    }

    OUT(cnt);

    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n+1);
    REP(i, n) cin >> a[i+1];

    vector<ll> ret;
    vector<ll> b(n+1);
    for(ll i=n; i>=1; --i) {
        ll sum = a[i];
        for(ll j=2*i; j<=n; j+=i) {
            sum += b[j];
        }
        b[i] = sum % 2;
        if(b[i] == 1) {
            ret.push_back(i);
        }
    }

    cout << ret.size() << endl;
    REP(i, ret.size()) cout << ret[i] << (i+1==(ll)ret.size()?'\n':' ');

    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
ll MOD = 1000000007ll;
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];
    map<int, ll> mp, mp2;
    rep(i, n) rep(j, i + 1, n)
    {
        if (a[i] > a[j])
        {
            mp[i]++;
        }
        if (a[j] > a[i])
            mp2[j]++;
    }
    ll ans = 0;
    ll kk = k * (k + 1) / 2;
    kk %= MOD;
    rep(i, n)
    {
        // cerr << mp[i] << endl;
        ans += mp[i] * kk;
        ans %= MOD;
        ans += mp2[i] *(((k - 1) * k / 2) %MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

typedef long long ll;

const int MOD = 1000000007;
const int N_MAX = 1000000;

ll n;
int dp[N_MAX];
int acc[N_MAX + 1];

void solve() {
  dp[0] = 1; acc[0] = 1;
  dp[1] = n; acc[1] = n + 1;

  FOR(i, 2, n) {
    dp[i] = (dp[i- 1] + (n - 1) * n % MOD) % MOD;
    if (i >= 3) {
      dp[i] = (dp[i] - (i - 2) + acc[i - 3]) % MOD;
    }
    acc[i] = (acc[i - 1] + dp[i]) % MOD;
  }
  printf("%d\n", dp[n]);
}

void input() {
  scanf("%lld", &n);
}

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


Measured memory_bytes: 7936
#include <stdio.h>
int main(void){
int a,b,c,count=3;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b){count--;}
    if(a==c){count--;}
    if(b==c){count--;}
  if(count==0){count++;}
  printf("%d",count);
return 0;
}

Measured memory_bytes: 128
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, p[55];
int main() {
	cin >> n;
	for (LL i = 1; i <= n; ++i) cin >> p[i];
	LL ans = 0;
	for (LL i = 1; i <= n; ++i) if (p[i] != i) ++ans;
	if (ans > 2) ptn; else pty;
	return 0;
}

Measured memory_bytes: 256
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }

vector<ll> f;
void set_f(int n) { f.resize(n+1); f[0] = 1; for (int i=1; i<= n; i++) { f[i] = (f[i-1] * i) % MOD;} }
ll nod(ll a, ll b) { if (b == 0) { return a; } else { return nod(b, a % b); } }
ll pw(ll x, ll n, ll m=MOD) { if (n == 0) { return 1;} if (n%2 == 0) { return pw((x*x) % m, n/2, m); } return (pw(x, n-1, m) * x) % m; }
ll dv(ll a, ll b) { return (a * pw(b, MOD - 2)) % MOD; }
ll c_n_k(int n, int k) { if (k > n) { return 0; } if (k < 0) { return 0; } return dv(dv(f[n], f[k]), f[n-k]); }


void solve() {
    ll a, b, n;
    cin >> a >> b >> n;

    ll x = min(n, b - 1);

    cout << (a * x) / b;
}


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

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            //cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

bool includesATCG(char c) {
	if (c=='A')return true;
	if (c=='T')return true;
	if (c=='C')return true;
	if (c=='G')return true;
	return false;
}
int main() {
	std::string S;
	int r{},b{};
	std::cin >> S;
	for (int i = 0; i < S.length(); ++i) {
		if (includesATCG(S.at(i))){
			++b;
		}else{
			if ((b != 0)&&(r < b))  r = b;
			b = 0;
		}
	}
	if (r < b) r = b;
	std::cout << r << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin>>s;
int ans=0;
for(int i=1;i<=3;i++){
if(s[i]==s[i-1])ans++;
}
if(ans>0){
cout<<"Bad"<<endl;
}
else{
cout<<"Good"<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int main(){
	int n;
	vector<int> v;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int t;
		scanf("%d", &t);
		v.push_back(t);
	}
	int ans;
	for(int i=0; i<n; i++){
		if(i == v[v[i] - 1] - 1) ans++;
	}
	ans /= 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,c,d int
    fmt.Scan(&a,&b,&c,&d)
    m := make([]int, 101)
    for i:=a;i<b;i++{
        m[i]++
    }
    for i:=c;i<d;i++{
        m[i]++
    }
    ans := 0
    for i:=0;i<=100;i++{
        if m[i]==2{
            ans++
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int A,B,C,D,x=0,y=0;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	while(C>0){
		C=C-B;
		x=x+1;
	}
	while(A>0){
		A=A-D;
		y=y+1;
	}
	if(x>y){
		printf("No\n");
	}
	if(x<=y){
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int A, B, T;
  cin >> A >> B >> T;

  int bis = B * (T / A);
  cout << bis << endl;
  return 0;
}


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

int main() {
  int64_t n, x, y;
  std::cin >> n >> x >> y;
  std::vector<int64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  if (n == 1) {
    std::cout << std::abs(a[0] - y) << std::endl;
  } else {
    std::vector<int64_t> x_e(n), y_e(n);
    x_e[n - 2] = y_e[n - 2] = std::abs(a[n - 2] - a[n - 1]);
    auto x_max = x_e[n - 2];
    auto y_min = y_e[n - 2];
    for (int i = n - 3; 0 <= i; i--) {
      x_e[i] = std::max(std::abs(a.back() - a[i]), x_max);
      y_e[i] = std::min(std::abs(a.back() - a[i]), y_min);
      x_max = std::max(y_e[i], x_max);
      y_min = std::min(x_e[i], y_min);
    }
    std::cout << std::max(x_max, std::abs(y - a.back())) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = [0] + A
N = len(A)

def cost_delta(A, index):
    size = len(A)
    d = abs(A[index-1] - A[(index+1)%size])
    d -= abs(A[index] - A[(index+1)%size])
    d -= abs(A[index-1] - A[index])
    return d


total_cost = sum([abs(A[i]-A[i+1]) for i in range(N-1)]) + abs(A[0]-A[N-1])
#print(total_cost)
for i in range(1,N):
    delta = cost_delta(A, i)
    print(total_cost + delta )

Measured memory_bytes: 14048
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc121_a(vector<vector<int>> v) {

    int h1=v[0][0];
    int w1=v[0][1];
    int h2=v[1][0];
    int w2=v[1][1];
    
    cout <<(h1-h2)*(w1-w2)<<endl;
    
    
}

int main() {

//    vector<vector < string>> vec_arr_result;
        vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    abc121_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
int t[17][17];
int dp[64 * 1024];
int main() {
	int w, d;
	while (cin >> w >> d, w) {
		vector<int> hd(d), hw(w),fd(d,0),fw(w,0);
		for (auto &a : hw)cin >> a;
		for (auto &a : hd)cin >> a;
		int sum = 0;
		int m = 0;
		do {
			m = 0;
			for (int i = 0; i < w; i++) {
				if (fw[i] == 0)m = max(m, hw[i]);
			}
			for (int j = 0; j < d; j++) {
				if (fd[j] == 0)m = max(m, hd[j]);
			}
			for (int i = 0,j=-1; i < w&&j<d; i++) {
				if (fw[i] || hw[i] != m)continue;
				sum += m;
				fw[i] = 1;
				for (j++; j < d; j++) {
					if (fd[j] == 0&&hd[j]==m) {
						fd[j] = 1;
						break;
					}
				}
			}
			for (int j = 0; j < d; j++) {
				if (fd[j] == 0 && hd[j] == m) {
					fd[j] = 1;
					sum += m;
				}
			}
		} while (m);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 301;

double dp[MAX_N][MAX_N][MAX_N];

double dfs(int i, int j, int k, int n) {
  if (dp[i][j][k] >= 0) {
    return dp[i][j][k];
  }
  if (i == 0 && j == 0 && k == 0) return 0.0;
  double res = 0.0;

  if (i > 0) {
    res += dfs(i - 1, j, k, n) * i;
  }

  if (j > 0) {
    res += dfs(i + 1, j - 1, k, n) * j;
  }

  if (k > 0) {
    res += dfs(i, j + 1, k - 1, n) * k;
  }

  res += n;
  res *= 1.0 / (i + j + k);

  return dp[i][j][k] = res;
}

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

  memset(dp, -1, sizeof(dp));

  int sushi_cnt[4] = {0, 0, 0, 0};
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;

    sushi_cnt[a]++;
  }

  double ans = dfs(sushi_cnt[1], sushi_cnt[2], sushi_cnt[3], n);

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
vector<int> x[200000];
int n,m,pos[200000];
map<pair<int,int>, bool> ma;
int idi(int i){
	pos[i]=1;
	int r=1;
	for(int j=0;j<x[i].size();j++)
		if(!pos[x[i][j]])
			r+=idi(x[i][j]);
	return r;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)pos[i]=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;--a;--b;
		if(ma[mp(a,b)]||ma[mp(b,a)])
			continue;
		ma[mp(a,b)]=1;
		x[a].pb(b);
		x[b].pb(a);
	}
	int res=1;
	for(int i=0;i<n;i++)
		if(!pos[i])
			res=max(res,idi(i));
	cout<<res;
	return 0;
}

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

using namespace std;

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    priority_queue<int,vector<int>,greater<int> > pq;
    for(int i=0;i<n;i++) {
        int temp;
        cin >> temp;
        pq.push(temp);
    }       
    int cost = 0;
    for(int i=0;i<k;i++) {
        cost += pq.top();
        pq.pop();
    }
    cout << cost << "\n";
}

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

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

int main() {
    // input, ready
    int N;
    string S,T;
    cin >> N >> S >> T;

    //resolve
    for(int i=0; i< N; i++)
    {
        printf("%c%c",S[i],T[i]);
    }

    // output
   printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<stack>
using namespace std;

string int_to_string(int& n){
  stringstream ss;
  ss<<n;
  return ss.str();
}

int string_to_int(const string& s){
  int n;
  istringstream iss(s);
  iss >> n;
  return n;
}

int main(){

  string num;
  stack<int> st;
  int ope1,ope2;

  while(cin>>num){
    if(num=="+"){
      ope1=st.top();
      st.pop();
      ope2=st.top();
      st.pop();
      st.push(ope2+ope1);
    }else if(num=="-"){
      ope1=st.top();
      st.pop();
      ope2=st.top();
      st.pop();
      st.push(ope2-ope1);
    }else if(num=="*"){
      ope1=st.top();
      st.pop();
      ope2=st.top();
      st.pop();
      st.push(ope2*ope1);
    }else st.push( string_to_int(num) );
  }
  ope1=st.top();
  cout<<ope1<<endl;
  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
vector<vector<bool>> Grid;
int H, W;

void Show(vector<vector<bool>> S) {
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < S[i].size(); j++) {
			if ((S[i][j])) {
				cout << '.';
			} else {
				cout << '#';
			}
		}
		cout << endl;
	}
}

bool check(int i, int j) {
	bool OK = true;
	if (i != 0 && !Grid[i - 1][j])return true;
	if (i != H - 1 && !Grid[i + 1][j])return true;
	if (j != 0 && !Grid[i][j - 1])return true;
	if (j != W - 1 && !Grid[i][j + 1])return true;
	return false;
}

int main() {
	cin >> H >> W;
	Grid.resize(H);
	string S;
	for (int i = 0; i < H; i++) {
		Grid[i].resize(W);
		cin >> S;
		for (int j = 0; j < W; j++) {
			//白をtrueに。
			Grid[i][j] = (S[j] == '.');
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (!Grid[i][j] && !check(i, j)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  char N;
  cin >> N;
  if(N == 'A'){
    cout << 'T';
  } else if(N == 'T'){
    cout << 'A';
  } else if(N == 'C'){
    cout << 'G';
  } else {
    cout << 'C';
  }
}

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

using namespace std;

int n,s;
int mem[100][100][100];
int f(int deps,int cnt,int sum)
{
    if(mem[deps][cnt][sum])return mem[deps][cnt][sum];
    if(cnt == n && sum == s)return 1;
    if(deps == 10) return 0;
    return mem[deps][cnt][sum]=f(deps + 1,cnt + 1,sum + deps)+f(deps + 1,cnt,sum);
}

int main()
{
    while(1){
    memset(mem,0,sizeof(mem));
    cin >> n >> s;
    if(n == 0 && s == 0)break;
    printf("%d\n",f(0,0,0));
    }
    return 0;
}

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

const int INF = 40;
int sx, sy;
int gx, gy;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h, w, ans = 0;
typedef pair<int, int> P;

int main() {
  cin >> h >> w;
  char maze[w][h];
  int d[w][h];
  string S;

  for (int i = 0; i < h; i++) {
    cin >> S;
    for (int j = 0; j < w; j++) {
      maze[j][i] = S[j];
    }
  }

  queue<P> que;

  for (int sy = 0; sy < h; ++sy) {
    for (int sx = 0; sx < w; ++sx) {
      // for (int gy = 0; gy < h; ++gy) {
      //   for (int gx = 0; gx < w; ++gx) {
      // if (sy == gy && sx == gx) continue;
      // if (maze[sx][sy] == '#' || maze[gx][gy] == '#') continue;
       if (maze[sx][sy] == '#') continue;

      for (int initi = 0; initi < h; initi++)
        for (int initj = 0; initj < w; initj++) d[initj][initi] = INF;

      que.push(P(sx, sy));
      d[sx][sy] = 0;

      while (que.size()) {
        P p = que.front();
        que.pop();

        for (int i = 0; i < 4; i++) {
          int nx = p.first + dx[i], ny = p.second + dy[i];

          if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' &&
              d[nx][ny] == INF) {
            que.push(P(nx, ny));
            d[nx][ny] = d[p.first][p.second] + 1;
          }
        }
      }

      rep(i, w) rep(j, h) if(maze[i][j]!='#') ans = max(ans, d[i][j]);
      // ans = max(ans, d[gx][gy]);
      //          cout << ans << endl;
      //   }
      // }
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#define max(a,b) a>b ? a : b
#define min(a,b) a<b ? a : b
using namespace std;

typedef long long ll;

ll LCM(ll a, ll b)
{
	ll result;
	ll n1 = max(a, b);
	ll n2 = min(a, b);
	for (int i = 1;; i++)
	{
		result = n1*i;
		if (result%n2 == 0)
			return result;
	}
}

ll GCD(ll a, ll b)
{
	while (true)
	{
		int ma = max(a, b), mi = min(a, b);
		if (ma%mi == 0)
			return mi;
		else
		{
			ma -= mi;
			return GCD(ma, mi);
		}
	}
}

int main()
{
	ll n1, n2;
	while (cin >> n1 >> n2)
		cout << GCD(n1, n2) << ' ' << LCM(n1, n2) << endl;
	return 0;
}

Measured memory_bytes: 1156
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 100005;
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int,int>>v(n+1);
  for (int i = 1; i <= n; ++i)
  {
    int a;
    cin >> a;
    v[i].ff = a;
    v[i].ss = i;
  }
  sort(all(v));
  for (int i = 1; i <= n; ++i)
  {
    cout << v[v[i].ff].ss << " ";
  }
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
	int H[1024],W[1024],i,j,k,l;
	for(k=0;k<1024;k++){
		scanf("%d %d",&H[k],&W[k]);
		if(H[k]==0&&W[k]==0) break;
	}
	for(l=0;l<1024;l++){
		if(H[l]==0&&W[l]==0) break;
		for(i=0;i<H[l];i++){
			for(j=0;j<W[l];j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=2e5+10;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()


#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int binomialCoeff(int n, int k)  
{
    if (k == 0 || k == n)  
        return 1;  

    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
long long power(ll a, ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a);
        b/=2;
        a=(a*a);
    }
    return ans;
}

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

 vector<ll>v[N];
int main()
{
    IOS;
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]>a[i+1]) --a[i];
    }

    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 5760
import bisect

N, C, K = map(int,input().split())

T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()


#print(T)

ans = 0
left = 0
while True:
    if left >= N:
        break
    #print("T[left]",T[left])
    ind = bisect.bisect_right(T, T[left]+K)
    #print("ind",ind)
    left = min(ind, left+C)
    ans += 1
    #print("left",left)
    #print('&&&&&&&&&&&&&&&&&&')
    
print(ans)

Measured memory_bytes: 72140
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(ll imid,ll N){
	return 2 * N <= imid * (imid + 1);
}

void print(ll MAX,ll N){
	if(MAX < N){
		cout << MAX << endl;
		N -= MAX;
		print(MAX-1,N);
	}
	else{
		cout << N << endl;
		N -= N;
	}
}

signed main(){
	ll N;
	cin >> N;
	ll imin = 0;
	ll imax = INF;
	while(imax - imin > 1){
		ll imid = (imax+imin)/2;
		if(check(imid,N))imax = imid;
		else imin = imid;
	}
	print(imax,N);
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main ( ) {
	int n,i,ans=0;
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	for (i=1;i<=n;i++) {
		if (a[i]==i) {
			if (a[i+1]!=i && i!=n) {
				swap(a[i],a[i+1]);ans++;
			}
			else if (i==n) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*
Sample Input 1
5
1 4 3 5 2
Sample Output 1
2
Sample Input 2
2
1 2
Sample Output 2
1

Sample Input 3
2
2 1
Sample Output 3
0
Sample Input 4
9
1 2 4 9 5 8 7 3 6
Sample Output 4
3
*/

Measured memory_bytes: 768
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


x, a = map(int, input().split())
if a>x:
    print(0)
else:
    print(x-a)

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int solve(int r, int g, int b, int** a, int i, int j);

int n;
string s;

int main(){
    cin >> n;
    cin >> s;
    int **a = new int*[3];
    rep(i, 3){
        a[i] = new int[n+1];
        a[i][0] = 0;
    }
    int r=0, g=0, b=0;
    rep(i, n){
        if(s[i]=='R'){
            r++;
        }else{
            if(s[i]=='G'){
                g++;
            }else{
                b++;
            }
        }
        a[0][i+1] = r;
        a[1][i+1] = g;
        a[2][i+1] = b;
    }

    int rf=0, gf=0, bf=0;
    long ans=0;
    rep(i, n-1){
        //cout << i << endl;
        if(s[i]=='R'){
            rf++;
        }else{
            if(s[i]=='G'){
                gf++;
            }else{
                bf++;
            }
        }
        rep2(j, i+1, n){
            if(s[j]=='R'){
                if(rf==0){
                    rf++;
                    ans += solve(rf, gf, bf, a, i+1, j+1);
                    rf--;
                }else{
                    continue;
                }
            }else{
                if(s[j]=='G'){
                    if(gf==0){
                        gf++;
                        ans += solve(rf, gf, bf, a, i+1, j+1);
                        gf--;
                    }else{
                        continue;
                    }
                }else{
                    if(s[j]=='B'){
                        if(bf==0){
                            bf++;
                            ans += solve(rf, gf, bf, a, i+1, j+1);
                            bf--;
                        }else{
                            continue;
                        }
                    }
                }
            }
        }
        rf=0;gf=0;bf=0;
    }

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

int solve(int r, int g, int b, int **a, int i, int j){
    //cout << r << g << b << endl;
    int dis = j - i;
    if(r==0){
        if(j+dis<=n && s[j+dis-1]=='R'){
            return a[0][n] - a[0][j] - 1;
        }else{
            return a[0][n] - a[0][j];
        }
    }else{
        if(g==0){
            if(j+dis<=n && s[j+dis-1]=='G'){
                return a[1][n] - a[1][j] - 1;
            }else{
                return a[1][n] - a[1][j];
            }
        }else{
            if(j+dis<=n && s[j+dis-1]=='B'){
                return a[2][n] - a[2][j] - 1;
            }else{
                return a[2][n] - a[2][j];
            }
        }
    }
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ld double
#define pb push_back
const int MAXN = 65;
const ld EPS = 1e-6, DOIS = 2;
int cnt = 0;
ld x[MAXN], y[MAXN], c[MAXN];
ld modulo(ld g){return (g<0) ? -g : g;}
int main(){
    fastio;
    int n,k; cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>x[i]>>y[i]>>c[i];
    }
    if(k==1){cout<<"0"<<endl; return 0;}
    ld l = 0;
    ld r = 1e6;
    while(r - l > EPS){
        ld t = (l + r)/DOIS;
        bool achei = false;

        for(int i=1; i<=n; i++){//testando centros
            int discos = 0;
            for(int j=1; j<=n; j++){
                ld dist = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
                if(dist <= t/c[j] + EPS)discos++;
            }
            if(discos >= k)achei = true;
        }

        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){

                ld raio_i = t/c[i];
                ld raio_j = t/c[j];

                ld x_medio = (x[i] + x[j])/DOIS;
                ld y_medio = (y[i] + y[j])/DOIS;

                ld dist_centros = sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
                if(modulo(dist_centros) > raio_i + raio_j)continue;//nao intersectam

                ld d1 = (dist_centros*dist_centros + raio_i*raio_i - raio_j*raio_j)/(DOIS*dist_centros);

                ld x_P = x[i] + (x[j]-x[i])*d1/dist_centros;
                ld y_P = y[i] + (y[j]-y[i])*d1/dist_centros;

                ld x_perp = y[j] - y[i];
                ld y_perp = x[i] - x[j];

                ld norma_perpSQ = x_perp*x_perp + y_perp*y_perp;
                ld normaSQ = (x_P-x[i])*(x_P-x[i]) + (y_P-y[i])*(y_P-y[i]);
                ld k2 = sqrt((raio_i*raio_i - normaSQ)/norma_perpSQ);

                // INTERSECCOES
                int discos1 = 0;
                ld x1 = x_P + k2*x_perp;
                ld y1 = y_P + k2*y_perp;
                for(int g=1; g<=n; g++){
                    ld dist = sqrt((x1-x[g])*(x1-x[g]) + (y1-y[g])*(y1-y[g]));
                    if(dist <= t/c[g] + EPS)discos1++;
                }
                if(discos1 >= k)achei = true;
                
                int discos2 = 0;
                ld x2 = x_P - k2*x_perp;
                ld y2 = y_P - k2*y_perp;
                for(int g=1; g<=n; g++){
                    ld dist = sqrt((x2-x[g])*(x2-x[g]) + (y2-y[g])*(y2-y[g]));
                    if(dist <= t/c[g] + EPS)discos2++;
                }
                if(discos2 >= k)achei = true;
            }
        }
        if(achei)r = t;
        else l = t;
    }
    cout<<setprecision(7)<<l<<endl;
}

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

int main() {
  vector<int>a(1000);
  vector<int>b(3);
  int n ,ans=0;
  string s;
  cin >> n >> s;
  rep(i,1000){
  	int ind=0;
  	b.at(0)=i/100;
  	b.at(1)=i/10-b.at(0)*10;
  	b.at(2)=i-b.at(0)*100-b.at(1)*10;
  	rep(j,n){
  		if(s.at(j)-'0'==b.at(ind)) ind++;
  		if(ind>=3) break;
  	}
  	if(ind>=3) a.at(i)=1;
  }
  rep(i,1000) ans+=a.at(i);
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<b&&a<c){
  if(b<c)
     printf("%d %d %d\n",a,b,c);
   else
      printf("%d %d %d\n",a,c,b);

}else if(b<a&&b<c){
  if(a<c)
     printf("%d %d %d\n",b,a,c);
   else
      printf("%d %d %d\n",b,c,a);
}else{
  if(a<b)
     printf("%d %d %d\n",c,a,b);
   else
      printf("%d %d %d\n",c,b,a);
}

return 0;
}



Measured memory_bytes: 2060
require 'set'

n=gets.to_i
a=n.times.map{gets.chomp}
s=Set[*a]

flag=s.size==n
for i in 0...(n-1)
  if a[i][-1]!=a[i+1][0]
    flag=false
  end
end
  
puts flag ? "Yes" : "No"

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

int ft_isprime(int n){
    
    if (n == 2) {
        return 1;
    }
    if (n <= 1 || n % 2 == 0) {
        return 0;
    }
    for (int i = 3; i <= (n / 2); i += 2) {
        if (n % i == 0) {
            return 0;
        }
    }
    return 1;
}

int main(void) {
    int x;
    cin >> x;
    
    if (ft_isprime(x) == 1) {
        cout << x << endl;
        return 0;
    }
    
    while(1){
        x++;
        if (ft_isprime(x) == 1) {
            cout << x << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256