akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,a[200005],p[200005],q[200005],ans;
ll co(ll x,ll y){
    ll res=0;
    if(x<y){
        while(x*4<y){
            x*=4LL;
            res--;
        }
        return res;
    }
    while(x>y){
        y*=(4LL);
        res++;
    }
    return res;
}
int main(void){
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i];
    stack<P>w;
    w.push(P(INF,n-1));
    for(ll i=n-2;i>=0;i--){
        p[i]+=p[i+1];
        ll k=co(a[i],a[i+1]);
        if(k>0){
            while(k){
                w.top().F++;
                k--;
                p[i]+=(w.top().S-i);
                if(w.top().F==0)w.pop();
            }
        }
        if(k<0){
            w.push(P(k,i));
        }
    }
    w.push(P(INF,0));
    for(ll i=1;i<n;i++){
        ll k=co(a[i]*2,a[i-1]*2);
        q[i]+=q[i-1];
        if(k>0){
            while(k){
                w.top().F++;
                k--;
                q[i]+=(i-w.top().S);
                if(w.top().F==0)w.pop();
            }
        }
        if(k<0){
            w.push(P(k,i));
        }
    }
    ans=min(p[0]*2,q[n-1]*2+n);
    for(ll i=0;i<n-1;i++){
        ans=min(ans,q[i]*2+i+1+p[i+1]*2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

using namespace std;



int main()
{
	int n, m;
	int kouho[101];
	int input;
	bool first_flg;
	
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0) break;
		
		for (int i=1; i<=m; i++) kouho[i] = 0;
		
		for (int i=0; i<n; i++)
		{
			for (int j=1; j<=m; j++)
			{
				cin >> input;
				if (input == 1)
				{
					kouho[j]++;
				}
			}
		}
		
		first_flg = true;
		for (int i=n; i>=0; i--)
		{
			for (int j=1; j<=m; j++)
			{
				if (kouho[j] == i)
				{
					if (first_flg)
					{
						cout << j;
						first_flg = false;
					} else {
						cout << " " << j;
					}
				}
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

typedef long long ll;

int ans, n;

bool judge(ll x) {
    bool flag[3] = {false, false, false};
    while (x) {
        if (x % 10 == 7) {
            flag[0] = true;
        } else if (x % 10 == 5) {
            flag[1] = true;
        } else {
            flag [2] = true;
        }
        x /= 10;
    }
    if (flag[0] && flag[1] && flag[2]) { return true; }
    else { return false; }
}

void dfs(ll x) {
    if (x > n) { return; }
    else if (judge(x)) {
        ans++;
    }
    dfs(x * 10 + 7);
    dfs(x * 10 + 5);
    dfs(x * 10 + 3);
}

int main() {
    cin >> n;

	dfs(0);
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)

set<ll>::iterator it;
ll mod = 1000000007;
ll power(ll a,ll b)
{
	ll p = 1;
	a = a%mod;
	while(b>0)
	{
		if(b%2==1)
			p=((p%mod)*(a%mod))%mod;
		b=b>>1;
		a=((a%mod)*(a%mod))%mod;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n;
	cin>>n;
	string s;
	ll ac,wa,tle,re;
	ac=wa=tle=re=0;
	for(i=0;i<n;i++)
	{
		cin>>s;
		if(s == "AC")
			ac++;
		if(s == "WA")
			wa++;
		if(s == "TLE")
			tle++;
		if(s == "RE")
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;

	return 0;
}

Measured memory_bytes: 3644
main(n,h,m){double H,M;
for(scanf("%d",&n);n--;puts(M<30?"alert":M<90?"warning":"safe")){
scanf("%02d:%02d",&h,&m);
M=m*6;H=h*30+m/2.0;M-=H;
if(M<0)M=-M;if(M>180)M=360-M;
}exit(0);}

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

using namespace std;
#define ll long long

void print(ll n) 
{ 
    string str;
    int i = 0; 
  
    while (n > 0) { 
        ll tmp = n % 26; 
  
        if (tmp == 0) { 
            str.push_back('z'); 
            n = (n / 26) - 1; 
        } 
        else
        { 
            str.push_back( (tmp - 1) + 'a'); 
            n = n / 26; 
        } 
    } 

    reverse(str.begin(), str.end()); 
    cout << str << endl; 
    return; 
} 


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

    ll n;
    cin>>n;

    print(n);

    return 0;
}


Measured memory_bytes: 3648
#include <stdlib.h>
#include<string.h>
#include <stdio.h>
int MAX(int a,int b){
    return a>b?a:b;
}
int main()
{   
    int n;
    scanf("%d",&n);
    int i,sum=0,max=0,l[n];
    for(i=0;i<n;i++){
        scanf("%d",&l[i]);
        sum+=l[i];
        max=MAX(max,l[i]);
    }
    if(max<sum-max)
    printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
                int H,W,i,j;
                while(1){

                                scanf("%d %d",&H,&W);
                                if(H==0 && W==0)
                                                break;



                for(i=1;i<=H;i++){
                                for(j=1;j<=W;j++)
                {
                                printf("#");

                }

                printf("\n");
                }
                printf("\n");}
                return 0;

}


Measured memory_bytes: 2056
/*input
8
WRWWRWRR
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 2e5+1;
int white[N];
int red[N];
int tr = 0;
int tw = 0;
int n;

void solve(){
  	cin >> n;
  	RE(i,n){
  		char o;cin >> o;
  		white[i] = white[i-1]+(o=='R');
  		red[i] = red[i-1]+(o=='W');
  	}
  	tw = white[n];
  	tr = red[n];
  	int ans = INF;
  	REP(i,n+1){
  		int whiteonleft = white[i];
  		int whiteonright = tw-whiteonleft;
  		int redonleft = red[i];
  		int redonright = tr-redonleft;
  		int whAt = min(redonleft,whiteonright);
  		redonleft -= whAt;
  		whiteonright -= whAt;
  		ans = min(ans,whAt+max(redonleft,whiteonright));
  	}
  	cout << ans;
}


signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 6716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
clock_t st = clock();
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1,0));
  for(int i=0;i<n;i++){
    for(int j=n-2;j>=0;j--){
      int z;
      cin>>z;
      a[i][j]=z-1;
    }
  }
  int c=0;
  while(true){
   clock_t ed = clock();
    if((double)(ed-st)/CLOCKS_PER_SEC * 1000.0>1900){
      cout<<n*(n-1)/2;
      return 0;
    }
    vector<bool> b(n,false);
    bool f=false,ff=false;
    for(int i=0;i<n;i++){
      if(!a[i].empty())f=true;
      if(!a[i].empty()&&!b[i]){
        if(!a[a[i].back()].empty()&&a[a[i].back()].back()==i&&!b[a[i].back()]){
          b[i]=b[a[i].back()]=true;
          a[a[i].back()].pop_back();
          a[i].pop_back();
          ff=true;
        }
      }
    }
    if(!f){
      cout<<c;
      return 0;
    }
    if(!ff){
      cout<<-1;
      return 0;
    }
    c++;
  }
}

Measured memory_bytes: 4224
import numpy as np

k,n = map(int,input().split())
A = list(map(int, input().split()))
A = np.array(A)
B = np.diff(A, n=1)

B_ = (A[0])+(k-A[n-1])
B_ans = np.append(B,B_)
ans = np.argmax(B_ans)

print(k - B_ans[ans])

Measured memory_bytes: 34168
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll x;
    cin >> x;
    
    For(i, -1000, 1000){
        ll ii = i*i*i*i*i;
        For(j, -1000, 1000){
            ll ans = ii - j*j*j*j*j;
            if(ans == x){
                cout << i << " " << j << endl;
                return 0;
            } else if(ans < x){
                break;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 510
#define MAX_E 50010
 
int par[MAX],rnk[MAX];
void init(int N){
    for(int i = 0 ; i < N ; i++){
	par[i] = i;
	rnk[i] = 0;
    }
}
 
int find(int x){
    if(par[x] == x){
	return x;
    }
    return par[x] = find(par[x]);
}
 
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]){
	par[x] = y;
    }else{
	par[y] = x;
	if(rnk[x] == rnk[y]){
	    rnk[x]++;
	}
    }
}
 
bool same(int x,int y){
    return (find(x) == find(y));
}
 
struct Edge{ int u,v,cost; };
 
bool comp(const Edge &e1,const Edge &e2){
    return e1.cost < e2.cost;
}
 
int V,E;
Edge es[MAX_E];
 
bool equals(const Edge &e1,const Edge &e2){
    return (e1.u == e2.u && e1.v == e2.v);
}
 
vector<Edge> vec;
 
int kruskal(int ne){
    init(V);
    int res = 0;
    for(int i = 0 ; i < E ; i++){
	Edge e = es[i];
	if(ne != -1 && equals(e,vec[ne])){
	    continue;
	}
	if(!same(e.u,e.v)){
	    unite(e.u,e.v);
	    res += e.cost;
	}
    }
    return res;
}
 
int kruskal(){
    sort(es,es+E,comp);
    init(V);
    int res = 0;
    for(int i = 0 ; i < E ; i++){
	Edge e = es[i];
	if(!same(e.u,e.v)){
	    unite(e.u,e.v);
	    res += e.cost;
	    vec.push_back(e);
	}
    }
    return res;
}
 
int main(){
    int a,b,c;
    cin >> V >> E;
    for(int i = 0 ; i < E ; i++){
	cin >> a >> b >> c; a--; b--;
	es[i] = (Edge){a,b,c};
    }
    vec.clear();
    int cnt = 0, sum = 0;
    int res = kruskal();
    for(int i = 0 ; i < (int)vec.size() ; i++){
	int r = kruskal(i);
	bool check = true;
	for(int j = 0 ; j < V ; j++){
	    if(!same(0,j)){
		check = false;
		break;
	    }
	}
	if((check && r > res) || !check){
	    cnt++;
	    sum += vec[i].cost;
	}
    }
    cout << cnt << " " << sum << endl;
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int n,l;
string s;
vector <string> v;

int main(){

  cin >> n >> l;
  REP (i, n) {
    cin >> s;
    v.push_back(s);
  }

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

  string ans;

  REP (i, n) ans += v.at(i);

  cout << ans << "\n";
}


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

int main(void)
{
    int S[11] = {0};
    int l = 0;
    while (char c = getchar())
    {
        if (!('0' <= c && c <= '9'))
        {
            break;
        }
        S[l++] = c - '0';
    }

    long long a = 0;
    for (int b = 0; b < 1 << (l - 1); b++)
    {
        long long s = 0;
        for (int i = 0; i < l; i++)
        {
            s = s * 10 + (long long)S[i];
            if (b & 1 << i)
            {
                a += s;
                s = 0;
            }
        }
        a += s;
    }
    std::cout << a << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String ticket, result;
        while(sc.hasNext()){
            ticket = sc.nextLine();

            switch(ticket) {
                case "1 1 0":
                case "0 0 1":
                    result = "Open";
                    break;
                default:
                    result = "Close";
                    break;
            }

            System.out.println(result);
        }
    }
}

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


ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

class BIT{
    public:
    int size;
    vector<ll> tree;
    
    void set(int n){
        size = n;
        tree = vector<ll>(n+1, 0);
        return;
    }
    
    void add(int n, ll a) {
        int x = n;
        while (x <= size){
            tree[x] += a;
            x += (x & -x);
        }
        return;
    }
    
    ll getsum(int n) {
        int x = n;
        ll sum = 0;
        while (x > 0) {
            sum += tree[x];
            x -= (x & -x);
        }
        return sum;
    }
    
};

int main() {
    ll N, K;
    cin >> N >> K;
    ll mod = 998244353;
    vector<ll> p(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> p[i];
    
    vector<ll> pow(N+1, 1);
    pow[1] = K*modinv(K-1, mod) % mod;
    for (int i = 2; i <= N; i++) {
        pow[i] = pow[i-1]*pow[1]%mod;
    }
    
    ll inv2 = modinv(2, mod);
    
    BIT bit1, bit2;
    bit1.set(N+1);
    bit2.set(N+1);
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i <= K) {
            ans += (i-1)*inv2%mod;
            bit1.add(p[i], 1);
            bit2.add(p[i], 1);
            continue;
        }
        
        ans += bit2.getsum(p[i]) % mod * modinv(pow[i-K], mod) % mod * inv2 % mod;
        
        ans += i-1-bit1.getsum(p[i]);
        ans += mod-(bit2.getsum(N)-bit2.getsum(p[i])) % mod * modinv(pow[i-K], mod) % mod * inv2 % mod;
        ans %= mod;
        
        bit1.add(p[i], 1);
        bit2.add(p[i], pow[i-K]);
    }
    
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな　オーバーフローする
//開区間と閉区間どうにかしろ
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグりがち
//切り上げ：(a + (b - 1)) / b
const ll MOD = 1000000007;
const ll MAX = 10010010010;

int main(){
    int n; cin >> n;
    int a[n];
    int x[n][n];
    int y[n][n];
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans=0;
    rep(bit,(1<<n)){
        bool res[n];
        int cnt=0;
        rep(i,n){
            //i := honest
            if(bit&(1<<i)){
                res[i]=1; cnt++;
            }
            else res[i]=0;
        }
        bool c=1;
        rep(i,n){
            if(res[i]){
                rep(j,a[i]){
                    if(res[x[i][j]]!=y[i][j]) c=0;
                }
            }
        }
        if(c) chmax(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>l>>n>>m;
    r=ceil(n*1.0/l);
    if(r*l<=m)
    {
        cout<<"OK\n";
    }
    else
    {
        cout<<"NG\n";
    }
    return 0;
}



Measured memory_bytes: 3756
use std::collections::*;
use std::io::*;
struct StdinReader<R: BufRead> {
    pub reader: R,
    pub buf: String,
}
impl<R: BufRead> StdinReader<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf: String::new(),
        }
    }
}
macro_rules! get {
    ($r:expr, $t:ty) => {
        {
            let mut line = &mut $r.buf;
            line.clear();
            $r.reader.read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($r:expr, $($t:ty),*) => {
        {
            let mut line = &mut $r.buf;
            line.clear();
            $r.reader.read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($r:expr, $t:ty; $n:expr) => {
        // items in n lines
        (0..$n).map(|_|
                    get!($r, $t)
                   ).collect::<Vec<_>>()
    };
    ($r:expr, $($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($r, $($t),*)
                   ).collect::<Vec<_>>()
    };
    ($r:expr, $t:ty ;;) => {
        // items in a line
        {
            let mut line = &mut $r.buf;
            line.clear();
            $r.reader.read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($r:expr, $t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($r, $t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let reader = stdin();
    let mut reader = StdinReader::new(reader.lock());
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let a = get!(reader, i32);
    writeln!(out, "{}", a + a * a + a * a * a);
}


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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    rep(i, h) {                                                                \
        rep(j, w) cerr << a[i][j] << space;                                    \
        cerr << endl;                                                          \
    }
#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    ll N, M;
    cin >> N >> M;
    if (N == 1 && M == 1)
        cout << 1 << endl;
    else if (N == 1 || M == 1)
        cout << N * M - 2 << endl;
    else
        cout << (N - 2) * (M - 2) << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10**18

N = int(input())
xmax = -inf
xmin = inf
ymax = -inf
ymin = inf
for _ in range(N):
    a, b = map(int, input().split())
    x = a + b
    y = a - b
    xmax = max(xmax, x)
    xmin = min(xmin, x)
    ymax = max(ymax, y)
    ymin = min(ymin, y)

print(max(xmax-xmin, ymax-ymin))

Measured memory_bytes: 9044
using System;

public class Test
{
	static public void Main( )
	{
		String[] line = Console.ReadLine().Split( ' ' );
		int[] arr = new int[3];
		for( int i=0; i<3; i++ ) {
			arr[i] = int.Parse( line[i] );
		}
		Array.Sort( arr );
		Console.WriteLine( "{0} {1} {2}", arr[0], arr[1], arr[2] );
	}
}

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

int main(){
	int a, b, s;
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		if(a > b){
			s = a;
			a = b;
			b = s;
		}
		cout << a << " " << b << endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int z,x,y;
    cin>>x>>y>>z;
    if(x==y&&y==z)
        cout<<1<<endl;
    else if(x==y&&(y!=z||x!=z))
        cout<<2<<endl;
    else if((x!=y||z!=x)&&y==z)
        cout<<2<<endl;
    else if((x!=y||y!=z)&&x==z)
        cout<<2<<endl;
    else
        cout<<3<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int w,h;
  int x,y,r;

  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  
  if(x>=-100 && y<=100) {
     if(w>=x+r && 0<=x-r && h>=y+r && 0<=y-r)
       puts("Yes");

     else
       puts("No");
  }
  else
    puts("No");
  
  return(0);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long n, k, ans = 0;
	cin >> n >> k;

	vector<long long> h(n);
	for(long long i=0;i<n;i++)
		cin >> h.at(i);

	sort(h.begin(), h.end());
	if(n<=k){
		cout << 0 << endl;
		return 0;
	}
	else{
		for(long long i=0;i<n-k;i++)
			ans += h.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N; cin >> N;
    map<int, int> res;
    REP(i,N){
        int a; cin >> a;
        res[a]++;
    }
    int M; cin >> M;
    REP(i,M){
        int b; cin >> b;
        res[b]--;
        if(res[b]<0){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int n, s, count = 0, digits[10]; // n 個の整数の和がsになる

void dfs(int cur, int start) {              // cur = 0   {}
if(cur == n) {               // cur = 1   {a}
int sum = 0;             // cur = 2   {a, b}

    for(int i = 0; i < n; i++) {
        sum += digits[i];
    }
    
    if(sum == s) { count++; }
        return;
    }
    
    for(int i = start; i < 10; i++) {
        digits[cur] = i; // FIXME: 重複を避ける
        dfs(cur+1, i+1);
    }
    
}

int main(void){
    
    while(scanf("%d %d",&n,&s)!= EOF){
        if(n == 0 && s == 0){
            
            break;
        }
        
        count = 0;
        dfs(0, 0);
        printf("%d\n", count);
    }
    
    return 0;
    
}


Measured memory_bytes: 2024
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    string c[H]; for (int i = 0; i < H; i++) cin >> c[i];
    int ans = 0;
    for (int i = 0; i < W-1; i++) {
        int cost[H][H];
        for (int s = 0; s < H; s++)
            for (int t = 0; t < H; t++)
                cost[s][t] = ((s > 0 && t > 0 ? cost[s-1][t-1] : 0) +
                              (c[s][i] == c[t][i+1] ? 1 : 0));
        int dp[H+1][H+1];
        for (int j = 0; j <= H; j++) dp[0][j] = dp[j][0] = 0;
        for (int s = 1; s <= H; s++)
            for (int t = 1; t <= H; t++)
                dp[s][t] = min(dp[s-1][t], dp[s][t-1]) + cost[s-1][t-1];
        ans += dp[H][H];
    }
    cout << ans << endl;
}


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

using ll=long long;
const ll INF=1e9;
void cmax(ll &lhs,ll rhs){
    lhs=max(lhs,rhs);
}
void cmin(ll &lhs,ll rhs){
    lhs=min(lhs,rhs);
}
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<vector<ll>> dpmax(n,vector<ll>(n+1,-INF));
    vector<vector<ll>> dpmin(n,vector<ll>(n+1,INF));
    for(int k=1;k<=n;k++){
        for(int l=0;l+k<=n;l++){
            int r=l+k;
            if(k==1){
                if(isdigit(s[l])){
                    dpmax[l][r]=s[l]-'0';
                    dpmin[l][r]=s[l]-'0';
                }
            }
            else if(s[l]=='(' || s[r-1]==')'){
                int cnt=0;
                for(int i=l;i<r;i++){
                    cnt+=(int)(isdigit(s[i]));
                }
                if(cnt>=2){
                    if(s[l]=='('){
                        dpmax[l][r]=dpmax[l+1][r];
                        dpmin[l][r]=dpmin[l+1][r];
                    }
                    else{
                        dpmax[l][r]=dpmax[l][r-1];
                        dpmin[l][r]=dpmin[l][r-1];
                    }
                }
            }
            else{
                for(int i=l;i<r;i++){
                    if(s[i]=='+'){
                        cmax(dpmax[l][r],dpmax[l][i]+dpmax[i+1][r]);
                        cmin(dpmin[l][r],dpmin[l][i]+dpmin[i+1][r]);
                    }
                    if(s[i]=='-'){
                        cmax(dpmax[l][r],dpmax[l][i]-dpmin[i+1][r]);
                        cmin(dpmin[l][r],dpmin[l][i]-dpmax[i+1][r]);
                    }
                }

            }
        }
    }
    cout<<dpmax[0][n]<<endl;

    return 0;
}


Measured memory_bytes: 3436
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 100 + 10;
const int MAXM = 6000 + 10;
const double eps = 1e-8;

int n, m, l, tot;
double org[MAXN];
double p[MAXN], t[MAXN], v[MAXN];
double b[MAXM], c[MAXM], tp1[MAXM], tp2[MAXM];
double C[MAXN][MAXN];

int Find(double x) {
        for (int i = 1; i <= tot; ++i)
		if (fabs(x - c[i]) < eps)
			return i;
}

double co[MAXN][MAXM];

inline int lowbit(int x) {
	return x & (-x);
}

double Pow(double a, int b) {
	double ret = 1.0;
	while (b) {
		if (b & 1)
			ret = ret * a;
		b >>= 1;
		a = a * a;
	}
	return ret;
}

inline void Add(int i, int x, double v) {
	if (x == 0)
		return;
	for (; x <= tot; x += lowbit(x))
		co[i][x] += v;
}

inline double Query(int i, int x) {
	double ret = 0;
	for (; x > 0; x -= lowbit(x))
		ret += co[i][x];
	return ret;
}
int main() {
	C[0][0] = 1;
	for (int i = 1; i <= 50; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	scanf("%d%d%d", &n, &m, &l);
	for (int i = 1; i <= n; ++i) {
		scanf("%lf%lf%lf", &p[i], &t[i], &v[i]);
		org[i] = 1.0 * l / v[i];
		p[i] = p[i] / 100;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= m; ++j) {
			b[++tot] = -(org[i] + j * t[i]);
		}
	sort(b + 1, b + 1 + tot);
	int tmp = 0;
	for (int i = 1; i <= tot; ++i) {
		if (i == 1 || fabs(b[i] - b[i - 1]) > eps) {
			c[++tmp] = b[i];
		}
	}
	tot = tmp;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			double curs = -(org[i] + j * t[i]);
			double curp = Pow(p[i], j) * Pow(1 - p[i], m - j) * C[m][j];
			int cur = Find(curs);
			Add(i, cur, curp);
			/*
			double curs = -(org[i] + j * t[i]);
			double curp = C[m][j];
		        for (int k = 1; k <= j; ++k)
				curp *= p[i];
			for (int k = 1; k <= m - j; ++k)
				curp *= (1 - p[i]);
			int cur = Find(curs);
			Add(i, cur, curp);
			*/
		}
	}
	for (int i = 1; i <= n; ++i) {
		double ans = 0;
		for (int j = 0; j <= m; ++j) {
			double curs = -(org[i] + j * t[i]);
			double curp = Pow(p[i], j) * Pow(1 - p[i], m - j) * C[m][j];
			//	cout << i << ' ' << j << ' ' << curp << endl;
			int cur = Find(curs);
			for (int k = 1; k <= n; ++k) if (i != k) {
					curp *= Query(k, cur - 1);
			}
			ans += curp;
			/*
			double curs = -(org[i] + j * t[i]);
			double curp = C[m][j];
			for (int k = 1; k <= j; ++k)
				curp *= p[i];
			for (int k = 1; k <= m - j; ++k)
				curp *= (1 - p[i]);
			//	cout << i << ' ' << j << ' ' << curp << endl;
			int cur = Find(curs);
			for (int k = 1; k <= n; ++k) if (i != k) {
					curp *= Query(k, cur - 1);
			}
			ans += curp;
			*/
		}
		printf("%.8f\n", ans);
	}

	return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++) 
        cin>>s[i];
    for(int i=1;i<=a+b+1;i++)
    {
        if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(i==a+1&&s[i]!='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
void main() {
	readAs!(int[]).map!(i => i - 1).reduce!((a, b) => a * b).writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

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

vector<vector<int>> As;

// current_a: A_1, A_2, ..., A_(N - remain)
// remain: 残りの数
void dfs(const vector<int>& current_a, const int remain, const int &max) {
  if (remain == 0) {
    As.push_back(current_a);
    return;
  }

  int min = 1;
  if (not current_a.empty()) min = current_a.back();

  for (int i = min; i <= max; ++i) {
    vector<int> next_a(current_a.begin(), current_a.end());
    next_a.push_back(i);
    dfs(next_a, remain - 1, max);
  }
}

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  dfs(vector<int>(), N, M);

  vector<int> a(Q), b(Q), c(Q), d(Q);
  rep(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  int ans = 0;
  for (vector<int> A : As) {
    int current = 0;
    rep(i, Q) {
      int ai = a[i] - 1, bi = b[i] - 1, ci = c[i], di = d[i];

      if(A[bi] - A[ai] == ci) current += di;
    }
    if (ans < current) ans = current;
  }

  cout << ans << endl;
}


Measured memory_bytes: 9780
N, M = map(int, input().split())
A = [0]*N
B = [0]*M
for _ in range(N):
    A[_] = input()
for _ in range(M):
    B[_] = input()

res = 'No'

for r in range(N-M+1):
    for c in range(N-M+1):
        if B == [e[r:r+M:1] for e in A[c:c+M:1]]:
            res = 'Yes'
            break

print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int a, b, ans;
	char c;
	while (cin >> a >> c >> b, c != '?') {
		if (c == '+') {
			cout << a + b << endl;
		}
		else if (c == '-') {
			cout << a - b << endl;
		}
		else if (c == '*') {
			cout << a*b << endl;
		}
		else if (c == '/') {
			cout << a / b << endl;
		}
		else {
			break;
		}
	}

    return 0;
}

Measured memory_bytes: 1160
# X: Yet Another Die Game
def main() :
    n = int(input())

    ans = 0
    ans += (n // 11 * 2)

    if n % 11 > 6 :
        ans += 2
    elif n % 11 > 0 :
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  long N;
  cin >> N;
  string S;
  cin >> S;

  set<string> first;
  bool f1 = false;
  set<string> second;
  bool f2 = false;
  set<string> third;
  bool f3 = false;

  rep(i, N){
    string d = {S[i]};
    if((i >= 2) && !f3){
      for(auto itr = second.begin(); itr != second.end(); itr++){
		third.insert((*itr) + d);
		// cout << (*itr) + d << " inserted." << endl;
      }
      f3 = (third.size() == 1000);
    }
    if((i >= 1) && (i <= N - 2) && !f2){
      for(auto itr = first.begin(); itr != first.end(); itr++){
		second.insert((*itr) + d);
		// cout << (*itr) + d << " inserted." << endl;
      }
      f2 = (second.size() == 100);
    }
    if((i <= N - 3) && !f1){
      first.insert(d);
      // cout << d << " inserted." << endl;
      f1 = (first.size() == 10);
    }    
  }

  /*
  for(auto itr = first.begin(); itr != first.end(); itr++) cout << (*itr) << endl;
  cout << endl;
  for(auto itr = second.begin(); itr != second.end(); itr++) cout << (*itr) << endl;
  cout << endl;
  for(auto itr = third.begin(); itr != third.end(); itr++) cout << (*itr) << endl;
  cout << endl;
  */

  cout << third.size() << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

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


int main() {
    int N; cin >> N;
    
    vector<vector<int>> A(N, vector<int>(N-1));
    rep(i, N){
        rep(j, N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    
    vector<vector<int>> id(N, vector<int>(N));
    int V = 0;
    rep(i, N){
        rep(j, N){
            if(i<j){
                id[i][j] = V++;
            }
        }
    }
    
    auto toId = [&](int i, int j){
        if(i>j) swap(i, j);
        return id[i][j];
    };
    
    vector<vector<int>> E(V);
    vector<int> Nyuji(V);
    for(int i=0; i<N; i++){
        for(int j=0; j<N-2; j++){
            int from = toId(i, A[i][j]);
            int to = toId(i, A[i][j+1]);
            E[from].push_back(to);
            Nyuji[to]++;
        }
    }
    
    queue<PII> S;
    for(int i=0; i<V; i++){
        if(Nyuji[i]==0){
            S.push({i, 1});
        }
    }
    
    int ans = 0;
    int done = 0;
    while(S.size()){
        PII p = S.front();
        done++;
//        cout << p.fs << " " << p.sc << endl;
        ans = max(ans, p.sc);
        S.pop();
        for(int to:E[p.fs]){
            Nyuji[to]--;
            if(Nyuji[to]==0){
                S.push({to, p.sc+1});
            }
        }
    }
    
    if(done!=V){
        cout << -1 << endl;
        return 0;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 37376
from sys import stdin
def main():
    readline=stdin.readline
    A,B=map(int,readline().split())
    low=B*10
    high=B*10+9
    for n in range(low,high+1):
        if int(n*0.08)==A:
            print(n)
            break
    else:
        print(-1)
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    vi in(1000,0);
    stack<int> s;
    rep(i,n){
        if(a[i] > 0){//いまから入る
            if(in[a[i]]){
                cout << i+1 << endl;
                return 0;
            }
            in[a[i]]++;
            s.push(a[i]);
        }else{//いまから出る
            a[i] *= -1;
            if(s.empty() || s.top() != a[i]){
                cout << i+1 << endl;
                return 0;
            }
            s.pop();
            in[a[i]] = 0;
        }
    }
    cout << "OK" << endl;
}



Measured memory_bytes: 3136
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[100],sum=0,smallest=100,ans,ten=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]%10==0){
			ten=ten+1;
		}
	}
	if(ten==n){
		cout<<"0"<<endl;
	}
	for(int i=0;i<n;i++){
			sum=sum+s[i];
	}
	if(sum%10!=0){
		cout<<sum<<endl;
	}
	else if(sum%10==0 && ten!=n){
		for(int i=0;i<n;i++){
			if(s[i]%10!=0 && s[i]<smallest){
				smallest=s[i];
			}
		}
		cout<<sum-smallest<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] d = new Integer[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d, Collections.reverseOrder());
        int stack = 0;
        int top = 100;
        for (int i = 0; i < d.length; i++) {
            if (i == 0 || top > d[i]) {
                top = d[i];
                stack++;
            }
        }
        System.out.println(stack);
    }

}


Measured memory_bytes: 22356
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD 1e9+7
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
		for(auto &&j : i) 
			cout << j << " ";
		cout << std::endl;
	}
}

int main()
{
	fast
	int n;
	cin>>n;
	vector <ll> arr(n);
	REP(i,n)
		cin>>arr[i];
	sort(arr.begin(),arr.end(),greater <int>());
	if(n == 2)
		cout<<arr[0]<<endl;
	else
	{
		ll sum = arr[0];
		if((n-2)%2 == 0)
		{
			int j = 1;
			REP(i,(n-2)/2)
			{
				sum += (2*arr[j]);
				j++;
			}
			cout<<sum<<endl;
		}
		else
		{
			int j = 1;
			REP(i,(n-2)/2)
			{
				sum += (2*arr[j]);
				j++;
			}
			sum += arr[j];
			cout<<sum<<endl;
		}
	}
}

Measured memory_bytes: 4780
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
void Comparison() {
	string s1, s2;
	cin >> s1 >> s2;
	if (s1.size() > s2.size()) {
		cout << "GREATER" << endl;
	}
	else if (s1.size() < s2.size()) {
		cout << "LESS" << endl;
	}
	else if(s1 == s2){
		cout << "EQUAL" << endl;
	}
	else {

		for (size_t i = 0; i < s1.size(); i++)
		{
			if (s1[i] == s2[i]) continue;
			if (s1[i] == '0') {
				cout << "LESS" << endl;
				return;
			}
			if (s2[i] == '0') {
				cout << "GREATER" << endl;
				return;
			}
			if (s1[i] < s2[i]) {
				cout << "LESS" << endl;
				return;
			}
			if (s1[i] > s2[i]) {
				cout << "GREATER" << endl;
				return;
			}

		}
	}
}
int main() {
	Comparison();
	return 0;
}



Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long a = sc.nextLong();
        double b = sc.nextDouble();
        long bb = Math.round(b * 100);
        long ans = a * bb / 100;
        System.out.println(ans);


    }
}


Measured memory_bytes: 37324
fun main(arg: Array<String>) {
    val (K, N) = listOfInt()
    val A = listOfInt()
    val B = mutableListOf<Int>()
    B.addAll(A)
    B.addAll(A.map { it + K })
//System.err.println(B)
    var ans = Int.MAX_VALUE
    for (n in 0 until N)
        ans = Math.min(ans, B[n + N - 1] - B[n])
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 80776