akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  ll N,M;cin>>N>>M;
  if(N==1&&M==1){
    print(1);
    return 0;
  }
  else if(N==1){
    print(max(M-2,0LL))
    return 0;
  }
  else if(M==1){
    print(max(N-2,0LL))
    return 0;
  }
  print(max((N-2)*(M-2),0LL))
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}void __print(long x) {cerr << x;}void __print(long long x) {cerr << x;}void __print(unsigned x) {cerr << x;}void __print(unsigned long x) {cerr << x;}void __print(unsigned long long x) {cerr << x;}void __print(float x) {cerr << x;}void __print(double x) {cerr << x;}void __print(long double x) {cerr << x;}void __print(char x) {cerr << '\'' << x << '\'';}void __print(const char *x) {cerr << '\"' << x << '\"';}void __print(const string &x) {cerr << '\"' << x << '\"';}void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        vector<ll> a(n);
        loop(i,0,n-1) cin>>a[i];
        map<ll,ll>m1,m2;
        for(ll i=0;i<n;i+=2) m1[a[i]]++;
        for(ll i=1;i<n;i+=2) m2[a[i]]++;
        vector<pair<ll,ll>> x,y;
        for(auto i:m1) x.pb({i.ss,i.ff});
        for(auto i:m2) y.pb({i.ss,i.ff});
        sort(rall(x));
        sort(rall(y));
        if(x[0].ss!=y[0].ss) cout<<n-x[0].ff-y[0].ff;
        else
        {
            if(sz(x)>1 and sz(y)>1)
            {
                if(x[1]>y[1]) cout<<n-y[0].ff-x[1].ff;
                else cout<<n-x[0].ff-y[1].ff;
            }
            else if(sz(x)>1 or sz(y)>1)
            {
                if(sz(x)>1) cout<<n-y[0].ff-x[1].ff;
                else cout<<n-x[0].ff-y[1].ff;
            }
            else cout<<n-max(x[0].ff,y[0].ff);
        }
    }
    return 0;
}


Measured memory_bytes: 12476
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int H,W;
    for(int a = 0; a < 100; a++){
        cin >> H >> W ;
        if (H == 0 && W == 0) break;
        for(int b = 0; b < H; b++){
            for(int c = 0; c < W; c++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int L;
    cin >> L;

    vi v;

    int x = 0;
    while (L >= (1 << x)) {
        v.push_back(x);
        x++;
    }
    // v.push_back(x);

    int n = v.size();
    vector<tuple<int, int, int>> es;
    REP(i, x) {
        if (L < (1 << (i + 1))) break;
        es.emplace_back(i, i + 1, 0);
        es.emplace_back(i, i + 1, 1 << i);
    }

    int y = (1 << x - 1);
    L -= y;
    for (int i = x - 2; i >= 0; i--) {
        if (L & (1 << i)) {
            es.emplace_back(i, n - 1, y);
            y += (1 << i);
            // L -= (1 << i);
        }
    }

    cout << n << " " << es.size() << endl;
    for (auto& tup: es) {
        int i, j, k;
        tie(i, j, k) = tup;

        cout << i + 1 << " " << j + 1 << " " << k << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  float n,m;
  cin>>n>>m;
  int cnt=0;
  vector<int> v;
  for(int i=0;i<=n-1;i++){
    int a;
    cin>>a;
    v.push_back(a);
  }
  int all_vote=0;
  for(auto& i:v){
    all_vote+=i;
  }
  float t;
  t=all_vote*(1/(4*m));
  int ans=0;
  for(auto& i:v){
    if(i>=t){
      ans+=1;
    }
  }
  if(ans>=m){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    VE v;
    int a, b, c;
    cin >> a >> b >> c;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(all(v));
    cout << v[2] * 10 + v[0] + v[1];
    return 0;
}

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

int main(){
  int n,x;
  cin >> n >> x;
  int m[105];
  for(int i=0;i<n;i++){
    cin >> m[i];
  }
  int m_min = m[0];
  for(int i=1;i<n;i++){
    m_min = min(m_min,m[i]);
  }
  int m_sum = 0;
  for(int i=0;i<n;i++){
    m_sum += m[i];
  }
  int ans = (x-m_sum)/m_min+n;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a,b,p,q,x;
	cin >>  a >> b;
	p=0;
	q=0;
	for (int i = 0; i < b; i++) {
    	p=10*p+a;
  	}
	for (int i = 0; i < a; i++) {
    	q=10*q+b;
  	}
 	if ( a< b ) {  
	cout <<p << endl;
	}

	else{
	cout <<q<< endl;
	}
}

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

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<pair<int, int>> que;
  vi a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) que.push(make_pair(a[i], 1));
  rep(i,m){
    int b, c;
    cin >> b >> c;
    que.push(make_pair(c, b));
  }
  ll ans = 0;
  rep(i,n){
    auto v = que.top(); que.pop();
    if(v.second > 1){
      v.second --;
      que.push(v);
    }
    ans += v.first;
  }
  cout << ans << endl;
}


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

int main()
{
    char c[105][105];
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> c[i][j];
    for (int i = 1; i <= 2 * h; i++)
    {
        for (int j = 1; j <= w; j++)
            cout << c[(i + 1) / 2][j];
        cout << endl;
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ld a, b;
    cin >> a >> b;
    b *= 1000;
    cout << (ll)(a * b / 1000) << endl;
    
    return 0;
}



Measured memory_bytes: 3772
N, W = map(int, input().split())
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for sum_w in range(1, W+1):
        if sum_w - w[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

print(dp[N][W])


Measured memory_bytes: 171656
n=int(input())
l=list(map(int, input().split(' ')))

l=sorted(l)[::-1]

ans=l[0]
a=2

for i in range(1,n):
    ans+=(min(2,n-a))*l[i]
    a+=min(2,n-a)
    if a==n:
        break

print(ans)
    



Measured memory_bytes: 99992
#include<stdio.h>
int main(void)
{
		int n,t,i,k,j,g,s;
	while(1)	{
		scanf("%d",&t);
		if(t==-1)	break;
		if(10>=t){
			printf("3130\n");
			}
		if(t>10&&t<20){
			n=t-10;
			i=4280-(n*125+1150);
			printf("%d\n",i);
			}
		if(t>20&&t<30){
			k=t-20;
			j=4280-((k*140)+2400);
			printf("%d\n",j);
		}
		 if(t>30){
			s=t-30;
			g=4280-((s*160)+3800);
			printf("%d\n",g);
		}
		if(t==20){
			printf("1880\n");
			}
		if(t==30){
			printf("480\n");
			}
	}
	return 0;
}

Measured memory_bytes: 1040
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if ( A + B > C + D )
	{
		cout << "Left" << endl;
	}
	else if ( A + B == C + D )
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
A, B, C ,D = map(int, input().split())

def cal(n):
    global B, D
    if B <= D:
        print(B-n)
    else:
        print(D-n)

if A >= D or B <= C:
    print(0)
elif A >= C:
    cal(A)
else:
    cal(C)

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
 int i, j, x, y;
 do {
  scanf("%d%d", &x, &y);
  for(i = 0; i < x; i++) {
   for(j = 0; j < y; j++) {
    printf("#");
   }
   printf("\n");
  }
  if(x != 0 && y != 0)
   printf("\n"); 
 } while(x != 0 && y != 0);
 return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
#define cint(...) ll __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__);

int main() {
	cint(r, g);
	cout << 2 * g - r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	reverse(all(a));
	reverse(all(b));
	reverse(all(c));

	char now = 'a';
	while (true)
	{
		if (now == 'a')
		{
			if(a.size() == 0){
				cout << "A" << endl;
				return 0;
			}
			now = a.back();
			a.pop_back();
		}
		if(now == 'b'){
			if(b.size() == 0){
				cout << "B" << endl;
				return 0;
			}
			now = b.back();
			b.pop_back();
		}
		if(now == 'c'){
			if(c.size() == 0){
				cout << "C" << endl;
				return 0;
			}
			now = c.back();
			c.pop_back();
		}
	}

	return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main(){
    ll l, r; cin >> l >> r;
    ll ans = 2019;
    bool flg = false;
    for(ll i=l; i<=r; i++){
        for(ll j=i+1; j<=r; j++){
            ll tmp = (i*j) % 2019;
            ans = min(ans, tmp);
            if(tmp==0){
                flg = true; break;
            }
        }
        if(flg) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace Competitive
{
    internal class Solution
    {
        private int N;
        private int[] X;
        private int[] XSort;

        public void Run()
        {
            N = Input.ReadInt();
            X = Input.ReadIntArray();
            XSort = X.ToArray();
            Array.Sort(XSort);

            foreach(var x in X) 
                Console.WriteLine(answer(x));
        }

        private int answer(int x)
        {
            int m1 = N / 2 - 1;
            int m2 = N / 2 ;
            int v1 = XSort[m1];
            int v2 = XSort[m2];
            if (x <= v1) return v2;
            return v1;
        }
    }

    
    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 39928
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll k, x, y;
    cin >> k >> x >> y;
    if(k%2 == 0 && (x+y) % 2) {
        puts("-1");
        return 0;
    }else if(abs(x)+abs(y) == k){
        puts("1");
        cout << x << " " << y << "\n";
        return 0;
    }
    int negax = 0, negay = 0, swapxy = 0;
    if(x < 0) negax = 1, x = -x;
    if(y < 0) negay = 1, y = -y;
    if(y > x) swapxy = 1, swap(x, y);
    vector<pair<ll, ll>> v;
    ll step = (x+y+k-1)/k;
    if(x + y < k) {
        if((x+y)%2 == 0) step = 2;
        else step = 3;
    }
    if(x + y >= k && ((step*k)-x-y)%2) step++;
    if(step == 3 && (x+y) < k && (x+y)%2){
        for (ll p = k; p <= step*k; p += k) {
            if(p <= k-x){
                v.emplace_back(0, -p);
            }else if(p <= k+(k+x-y)/2){
                v.emplace_back(p-(k-x), x-k);
            }else if(p <= 2*k+(k-x+y)/2){
                v.emplace_back(x+(k+x-y)/2,p-(k+(k+x-y)/2)+x-k);
            }else {
                v.emplace_back(x, y);
            }
        }
    }else {
        for (ll p = k; p <= step*k; p += k) {
            if(p <= (k*step-x-y)/2){
                v.emplace_back(0, -p);
            }else if(p <= x + (k*step-x-y)/2){
                v.emplace_back(p-(k*step-x-y)/2, -(k*step-x-y)/2);
            }else {
                v.emplace_back(x, -(k*step-x-y)/2+p-(x + (k*step-x-y)/2));
            }
        }
    }
    cout << v.size() << "\n";
    for (auto &&i : v) {
        if(!swapxy) cout << (negax ? -i.first : i.first) << " " << (negay ? -i.second : i.second)  << "\n";
        else cout <<  (negax ? -i.second : i.second) << " " << (negay ? -i.first : i.first)  << "\n";
    }
    return 0;
}

Measured memory_bytes: 5484
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	std::string n;

	std::cin >> n;

	if (n.length() < 4) {
		std::cout << "No" << std::endl;
	} else {
		if (n[0] == 'Y' && n[1] == 'A' && n[2] == 'K' && n[3] == 'I') {
			std::cout << "Yes" << std::endl;
		} else {
			std::cout << "No" << std::endl;
		}
	}

	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int MAX_N = 30;
int n;
int dp[MAX_N+1];

int main()
{
  dp[1]=1;  dp[2]=2;  dp[3]=4;
  erep(i, 4, MAX_N) dp[i] = dp[i-3] + dp[i-2] + dp[i-1];

  while((cin >> n) && n){
    cout << dp[n] / 3650 + (dp[n]%3650 ? 1 : 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
let inp = readLine()!.split(separator: " ").map { Int($0)! }

let H = inp[0]
let W = inp[1]
let K = inp[2]

var grid: [[String]] = .init(repeating: .init(repeating: "", count: W), count: H)
var blacks = 0

for row in 0..<H {
  var black = 0
  grid[row] = readLine()!.map { c in 
                if c == "#" {
                  black += 1
                }
                return String(c) 
              }
  blacks += black
}

func fillRows(_ grid: inout [[String]], _ row: Int) -> Int {
  var diff = 0
  for col in 0..<grid[row].count {
    if grid[row][col] == "#" {
      diff += 1
    }
    grid[row][col] = "@"
  }
  return diff
}
func fillCols(_ grid: inout [[String]], _ col: Int) -> Int {
  var diff = 0
  for row in 0..<grid.count {
    if grid[row][col] == "#" {
      diff += 1
    }
    grid[row][col] = "@"
  }
  return diff
}

func backtrack(_ grid: [[String]], _ row: Int, _ col: Int, _ black: Int) -> Int {
  if row >= grid.count && col >= grid[0].count {
    return black == 0 ? 1 : 0
  }
  let take: Int
  let notTake: Int
  var tmp = grid
  if row < grid.count {
    let diff = fillRows(&tmp, row)
    take = backtrack(tmp, row + 1, col, black - diff)
    notTake = backtrack(grid, row + 1, col, black)
  } else {
    let diff = fillCols(&tmp, col)
    take = backtrack(tmp, row, col + 1, black - diff)
    notTake = backtrack(grid, row, col + 1, black)
  }
  return take + notTake
}
let res = backtrack(grid, 0, 0, blacks - K)
print(res)

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

int main(){
int n;
cin>>n;
if(n<1000){
cout<<"ABC";
return 0;
}else{
cout<<"ABD";
return 0;
}
}

Measured memory_bytes: 3592
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

import heapq

N = int(input())
A = []
for _ in range(N):
    A.append(-int(input()))

B = []

for a in A:
    i = bisect.bisect_right(B, a)
    if i != len(B):
        B[i] = a
    else:
        B.append(a)

# print(B)
print(len(B))

pass


Measured memory_bytes: 54872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+105;
const ll MAXN=9e18+105;
struct node{
    ll u,v,w;
    node(ll u,ll v,ll w):u(u),v(v),w(w){}
    bool operator <(const node&A)const{return w<A.w;}
};
ll n,d,ans,cnt;
ll A[N],lv[N],fa[N],deep[N];
vector<node>edge;
int find(int x){
    if(fa[x]==x)return x;
    else return fa[x]=find(fa[x]);
}
void combine(int x,int y){
	x=find(x),y=find(y);
	if(lv[x]<lv[y])fa[x]=y;
	else if(lv[x]==lv[y])fa[y]=x,lv[x]++;
	else fa[y]=x;
}
void divide(int L,int R){
	if(L==R)return; 
	ll mid=(L+R)/2,pL,pR,mL=MAXN,mR=MAXN;
	for(int i=L;i<=mid;i++)if(A[i]-d*i<mL)mL=A[i]-d*i,pL=i;
	for(int i=mid+1;i<=R;i++)if(A[i]+d*i<mR)mR=A[i]+d*i,pR=i;
	for(int i=L;i<=mid;i++)edge.push_back(node(i,pR,mR+A[i]-d*i));
	for(int i=mid+1;i<=R;i++)edge.push_back(node(pL,i,mL+A[i]+d*i));
	divide(L,mid),divide(mid+1,R);
}
void kruskal(){
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=0;i<edge.size();i++){
		int u=edge[i].u,v=edge[i].v;
		if(find(u)!=find(v)){
			ans+=edge[i].w;
			combine(u,v);
			cnt++;
		}
		if(cnt==n-1)break;
	}
	return;
}
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	divide(1,n);
	sort(edge.begin(),edge.end());
	kruskal();
	cout<<ans<<endl;
	return 0;
} 

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

bool    comp(vector<long> &A, vector<long> &B) {
        if (A.at(0) == B.at(0)) return (A.at(1)>B.at(1));
        else return (A.at(0)<B.at(0));
}

int     main() {
        long N, K;
        cin >>N >>K;
        vector<vector<long> > SU(N, vector<long>(2, 0));
        for (long i = 0; i < N; i++) {
                cin >> SU.at(i).at(0);
                cin >> SU.at(i).at(1);
        }
        sort(SU.begin(), SU.end(), comp);
        vector<long> A;
        vector<long> B;
        for (long i=0, ii=-1; i<SU.size(); i++) {
                if (ii != SU.at(i).at(0)) {
                        ii = SU.at(i).at(0);
                        A.push_back(SU.at(i).at(1));
                } else {
                        B.push_back(SU.at(i).at(1));
                }
        }
        sort(A.begin(), A.end());
        reverse(A.begin(), A.end());
        sort(B.begin(), B.end());
        reverse(B.begin(), B.end());
        long S=0;
        long j=0;
        while((j<K) && (j<A.size())) {
                S += A.at(j);
                j++;
        }
        long k=0;
        if (K>A.size()) for (;k<K-A.size(); k++) S += B.at(k);
        long SS=S+j*j;
        j--;
        while( (k<B.size()) && (B.at(k)>A.at(j)) ) {
                S += B.at(k) - A.at(j);
                SS=max(SS, S+j*j);
                k++;
                j--;
        }
        cout << SS << endl;
        return 0;
}

Measured memory_bytes: 7808
def main():
    n = int(input())
    p = [0] * n

    for i in range(n):
        p[i] = tuple(map(int, input().split()))

    p.sort(key=lambda x: x[2], reverse=True)


    for x in range(0, 101):
        for y in range(0, 101):
            flag = True
            h = abs(x - p[0][0]) + abs(y - p[0][1]) + p[0][2]
            for xi, yi, hi in p:
                if hi != max([0, h - abs(x - xi) - abs(y - yi)]):
                    flag = False
                    break

            if flag:
                print('{} {} {} '.format(x, y, h))
                return
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  P v[N];
  FOR(i,0,N) {
    int a; cin >> a;
    v[i] = P(a, i+1);
  }
  sort(v, v+N);
  FOR(i,0,N) {
    if (i) cout << " ";
    cout << v[i].second;
  }
  cout << endl;
}

Measured memory_bytes: 1664
n,m,x,y = map(int,input().split())
x_l = list(map(int,input().split()))
y_l = list(map(int,input().split()))
j = 0
for i in range(x+1,y+1):
    if i > max(x_l) and i <= min(y_l):
        j+= 1
print("No War" if j else "War") 


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> T(n), A(n);
  for (int i = 0; i < n; i++) {
    cin >> T.at(i) >> A.at(i);
  }
  
  int64_t t = 1;
  int64_t a = 1;
  int64_t s, x, y;
  for (int i = 0; i < n; i++) {
    x = (t+(T.at(i)-1)) / T.at(i);
    y = (a+(A.at(i)-1)) / A.at(i);
    s = max(x, y);
    t = s * T.at(i);
    a = s * A.at(i);
  }
  
  cout << t + a << endl;
}
             
 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    if(N == 0){
        print(0);
        return 0;
    }

    string s = "";
    ll now = 1;
    while(N != 0){
        ll k = abs(now * 2);
        ll d = (N % k + k) % k;
        ll c = d / abs(now);

        s = to_s(c) + s;
        N -= now * c;
        now *= -2;
    }

    print(s);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string n;
    cin>>n;
    ll sum=0,m,i,j;
    for(i=0; i<n.length(); i++)
    {
        sum += n[i]-48;
    }
    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define rep(i,n) for(int i=0;i<(n);i++)
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
    string s, ans, hoge;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        for (int j = 0; j < s.size() - i + 1;j++){
            hoge = s.substr(i, j);
            bool ok = true;
            for (int k = 0; k < hoge.size(); k++)
            {
                if(!(hoge[k] =='A'|| hoge[k] == 'C' || hoge[k] == 'G' || hoge[k]== 'T'))
                    ok = false;
            }
            if(ok && hoge.size() > ans.size())
                ans = hoge;
        }
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

      int S = scanner.nextInt();
      int h ;
      int m ;
      int s ;
      h = S/3600;
      m = ((S%3600) / 60);
      s = S % 60;
      System.out.println(h + ":" + m + ":" + s);
      scanner.close();
  }
}


Measured memory_bytes: 26412
#include <stdio.h>

int main(void)
{
    int i, n, m, k, pos;

    while(1) {
        scanf("%d %d", &n, &m);
        if(n==0 && m==0) break;

        int mas[n];
        int me[m];
        for(i=0; i<n; i++) scanf("%d", &mas[i]);
        for(i=0; i<m; i++) scanf("%d", &me[i]);
    
        k = 0;
        pos = 0;
        while(pos < n-1) {
            if((pos + me[k]) <= n-1) {
                pos = pos + me[k] + mas[(pos + me[k])];
            } else {
                pos = pos + me[k];
            }
    
            k++;
        }
    
        printf("%d\n", k);
    }

    return (0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
int main ()
{
    ll T,W;
	scanf("%lld%lld",&T,&W);
    ll U = T*W;
    if (T == 1 || W == 1) {
        cout << 1 << endl;
         return 0;
    }
    if (U%2) {
        cout << U/2 + 1LL << endl;
    } else {
        cout << U/2 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 100007;
struct card{
	char c;
	int num;
};
struct card cards[MAXN];
struct card cards2[MAXN];
int partition(struct card a[], int l, int r){
	int tmp = a[r].num;
	int i = l-1;
	for(int j = l; j < r; j++){
		if(a[j].num<=tmp){
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i+1], a[r]);
	return i+1;
}
void quickSort(struct card a[], int l, int r){
	if(l<r){
		int q = partition(a, l ,r);
		quickSort(a, l , q-1);
		quickSort(a, q+1, r);
	}
	
}
bool cmp(struct card c1, struct card c2){ return c1.num < c2.num;}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> cards[i].c;
		cin >> cards[i].num;
		cards2[i].c = cards[i].c; 
		cards2[i].num = cards[i].num; 
	}
	stable_sort(cards2, cards2+n,cmp);
	quickSort(cards, 0, n-1);
	int stable = 1;
	for(int i = 0; i < n; i++){
		if(cards[i].c!=cards2[i].c){
			stable = 0;
		}
	}
	if(stable == 1){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	for(int i = 0; i < n; i++){
		printf("%c %d\n", cards[i].c, cards[i].num);
	}
	return 0;
}


Measured memory_bytes: 4704
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

import sys
sys.setrecursionlimit(1000000)

n = ii()
s = set()
l = []
cnt = 0
def solve(index,cnt):
    if l[index] == 2:
        print(cnt+1)
        exit()
    elif l[index] in s:
        print(-1)
        exit()
    else:
        s.add(l[index])
        solve(l[index]-1,cnt+1)
    return 0

for i in range(n):
    num = ii()
    l.append(num)

solve(0,cnt)



Measured memory_bytes: 106520
#include<iostream>
#include<algorithm>
using namespace std;
const int nmax = 40, abmax = 10, inf = 1000000;
int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1];
int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];
	for (int i = 0; i <= n; i++) {
		for (int ia = 0; ia <= nmax*abmax; ia++) {
			for (int ib = 0; ib <= nmax*abmax; ib++) {
				dp[i][ia][ib] = inf;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int ia = 0; ia <= nmax*abmax; ia++) {
			for (int ib = 0; ib <= nmax*abmax; ib++) {
				if (dp[i][ia][ib] == inf)continue;
				dp[i + 1][ia][ib] = min(dp[i + 1][ia][ib], dp[i][ia][ib]);
				dp[i + 1][ia + a[i]][ib + b[i]] = min(dp[i + 1][ia + a[i]][ib + b[i]], dp[i][ia][ib] + c[i]);
			}
		}
	}
	int ans = inf;
	for (int ia = 1; ia <= nmax*abmax; ia++) {
		for (int ib = 1; ib <= nmax*abmax; ib++) {
			if (ma*ib == mb*ia)ans = min(ans, dp[n][ia][ib]);
		}
	}
	if (ans == inf)ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 25984
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n'

const int MAXN=10;
const int MOD=10000000;

int c;

int main(){
	SIS;
	char s[100];
	cin.getline(s,100);
	int lena = strlen(s);
	int t=0;
	for(int i=0;i<lena;i++){
		if(s[i]<='z' && s[i] >='a'){
			t++;
			cout<<s[i];
		}
		if(t==3)break;
	} 
	
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<pii> ab(N);
    for(int i = 0; i < N; ++i)
        cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());

    ll sum = 0;
    for(auto p : ab) {
        sum += p.second;
        if(sum >= K) {
            cout << p.first << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    long long l;
    cin >> l;
    printf("%.12f\n",(double)l*l*l/27);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main() 
{
  cin>>a>>b;
  if(a==1 && b==2)
  {
    cout<<3;
    return 0;
  }
   if(a==1 && b==3)
  {
    cout<<2;
    return 0;
  }
   if(a==2 && b==1)
  {
    cout<<3;
    return 0;
  }
   if(a==2 && b==3)
  {
    cout<<1;
    return 0;
  }
   if(a==3 && b==1)
  {
    cout<<2;
    return 0;
  }
   if(a==3 && b==2)
  {
    cout<<1;
    return 0;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from itertools import product

N = int(input())

cnt = 0
# 候補となりうる9桁までの数字を列挙
for prod in product(['0', '3', '5', '7'], repeat=9):
    # チェック用に変形
    num = int(''.join(prod))
    s = str(num)
    # 753数ではない
    if (s.find('3') == -1 or s.find('5') == -1
            or s.find('7') == -1 or s.find('0') != -1):
        continue
    # N以下ではない
    if num > N:
        continue
    cnt += 1
print(cnt)


Measured memory_bytes: 42732
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

char test[11][11], kari[11][11], aa[11][11];
signed main() {
	ll n, m, kuro, ans = 0; cin >> n >> m >> kuro;
	rep(h, n) {
		rep(i, m) {
			cin >> test[h][i];
		}
	}
	for (int h = 0; h < (1 << n); h++) {
		rep(a, n) {
			rep(b, m) {
				kari[a][b] = test[a][b];
			}
		}
		for (int i = 0; i <= n - 1; i++) {
			if ((h & (1 << i)) > 0) {
				rep(c, m) {
					kari[i][c] = '.';
				}
			}
		}

		for (int j = 0; j < (1 << m); j++) {
			rep(a, n) {
				rep(b, m) {
					aa[a][b] = kari[a][b];
				}
			}
			for (int k = 0; k <= m - 1; k++) {
				if ((j & (1 << k)) > 0) {
					//cout << j << ' ' << k << endl;
					rep(c, n) {
						aa[c][k] = '.';
					}
				}
			}
			ll cnt = 0;
			//cout << h << ' ' << j << endl;
			rep(a, n) {
				rep(b, m) {
					//cout << aa[a][b];
					if (aa[a][b] == '#') { cnt++; }
				}
				//cout << endl;
			}
			if (cnt == kuro) { ans++; }
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,v,b,w,t;
    scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
    if(v*t-w*t>=fabs(a-b))
        printf("YES\n");
    else printf("NO\n");
}


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

void caluculatoion(int &n, int &ans, int now, vector<int> &c, vector<int> &s, vector<int> &f) {
    if (now < n-1)  {
        if (ans%f.at(now)) {
            if (ans >= s.at(now)) {
                ans = s.at(now) + (((ans-s.at(now))/f.at(now)) + 1) * f.at(now) + c.at(now);
                caluculatoion(n, ans, now+1, c, s, f);
            } else {
                ans = s.at(now) + c.at(now);
                caluculatoion(n, ans, now+1, c, s, f);
            }
        } else {
            if (ans >= s.at(now)) {
                ans += c.at(now);
                caluculatoion(n, ans, now+1, c, s, f);
            } else {
                ans = s.at(now) + c.at(now);
                caluculatoion(n, ans, now+1, c, s, f);
            }
        }
    }
}

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

    vector<int> c(n-1), s(n-1), f(n-1);
    for (int i=0; i<n-1; i++) {
        cin >> c.at(i) >> s.at(i) >> f.at(i);
    }

    int ans=0;

    for (int i=0; i<n-1; i++) {
        ans = 0;
        caluculatoion(n, ans, i, c, s, f);
        cout << ans << endl;
    }

    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define ld long double
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;


vector<string> vec_splitter(string s) {
		s += ',';
		vector<string> res;
		while(!s.empty()) {
				res.push_back(s.substr(0, s.find(',')));
				s = s.substr(s.find(',') + 1);
		}
		return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
		if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define deb(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define deb(...) 42
#endif


int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));

	ll n, k;
	cin >> n >> k;

	ll arr[n];
	ll hi = 0, lo = 1;
	for(auto &x : arr)	cin >> x, hi = max(hi, x);

	sort(arr, arr + n);
	ll mid, tmp;
	while(hi > lo) {
		mid = (hi + lo ) / 2;

		tmp = 0;
		for(auto x : arr)	tmp += ((x + mid - 1ll) / mid);
		tmp -= n;
		deb(mid, tmp);
		if(tmp <= k)	hi = mid;
		else	lo = mid + 1;
	}

	cout << hi;
}



Measured memory_bytes: 5152
x1, y1, x2, y2 = map(int,input().split())

xd = x2 - x1
yd = y2 - y1

x3 = x2 - yd
y3 = y2 + xd
x4 = x1 - yd
y4 = y1 + xd

print(x3, y3, x4, y4)

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		for (int i=0; i<N-1; i++){
			System.out.print(A[i] + " ");
		}
		System.out.print(A[N-1]);

		int v;
		int j;
		for (int i=1; i<N; i++){
				v = A[i];
				j = i - 1;
				while (j >= 0 && A[j] > v){
				    A[j+1] = A[j];
				    j--;
					A[j+1] = v;
				}
				System.out.println();
				for (int k=0; k<N-1; k++){
					System.out.print(A[k] + " ");
				}
				System.out.print(A[N-1]);
		}
		System.out.println();
	}
}


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

#define EPS (1e-6)
#define EQ(a, b) (abs((a) - (b)) < EPS)

typedef complex<double> vector2;
typedef pair<vector2, vector2> line;

double dot(vector2 a, vector2 b) { return real(conj(a) * b); }
double cross(vector2 a, vector2 b) { return imag(conj(a) * b); }

vector<vector2> cc_cross(vector2 a, vector2 b, double r) {
  double d = abs(b - a);
  double rc = d / 2;
  double rs = sqrt(r * r - rc * rc);
  vector2 diff = (b - a) / d;
  return {a + diff * vector2(rc, rs), a + diff * vector2(rc, -rs)};
}

int main() {
  int n, m;
  cin >> n;
  vector<vector2> p(n);
  for (auto &e : p) {
    double x, y;
    cin >> x >> y;
    e = {x, y};
  }
  cin >> m;
  vector<vector2> c(m);
  for (auto &e : c) {
    double x, y;
    cin >> x >> y;
    e = {x, y};
  }

  double ng = 0, ok = 1e6, r;
  while (ng + EPS < ok) {
    r = (ng + ok) / 2.0;
    bool isok = true;

    vector<int> v(n, -1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (abs(c[j] - p[i]) < r) {
          v[i] = j;
          break;
        }
      }
      if (v[i] == -1) {
        isok = false;
      }
    }

    if (isok) {
      vector<vector<bool>> g(m, vector<bool>(m));
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          if (abs(c[j] - c[i]) < 2 * r) {
            g[i][j] = true;
          }
        }
      }
      for (int k = 0; k < m; k++) {
        for (int i = 0; i < m; i++) {
          for (int j = 0; j < m; j++) {
            if (g[i][k] && g[k][j]) {
              g[i][j] = true;
            }
          }
        }
      }

      for (int i = 0; i < m; i++) {
        isok &= g[0][i];
      }
    }

    if (isok) {
      vector<vector2> u;
      for (int i = 0; i < m; i++) {
        for (int j = i + 1; j < m; j++) {
          vector<vector2> w = cc_cross(c[i], c[j], r);
          for (auto e : w) {
            bool outer = true;
            for (int k = 0; k < m; k++) {
              if (k == i || k == j) {
                continue;
              }
              outer &= abs(e - c[k]) > r;
            }
            if (outer) {
              u.push_back(e);
            }
          }
        }
      }

      for (auto e : u) {
        double t = 0;
        for (int i = 0; i < n; i++) {
          int j = (i + 1) % n;
          vector2 a = p[i] - e, b = p[j] - e;
          t += atan2(cross(a, b), dot(a, b));
        }
        if (!EQ(t, 0)) {
          isok = false;
          break;
        }
      }
    }

    if (isok) {
      ok = r;
    } else {
      ng = r;
    }
  }

  cout << fixed << setprecision(6) << r << endl;
}



Measured memory_bytes: 3668
#include<iostream>
#include<map>

using namespace std;

int main(){
	long long n, ans = 0;
	cin >> n;
	map<long long, long long> mp;
	for(int i = 0; i < n; i++){
		long long a;
		cin >> a;
		mp[a]++;
	}
	long long x = 0, y = 0;
	for(auto&& i : mp){
		if(i.second >= 4){
			x = i.first;
			y = i.first;
		}else if(i.second >= 2){
			x = y;
			y = i.first;
		}
	}
	ans = x * y;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
bool adj[205][205];
int dis[205];

int main()
{
  finp;
  cin>>n;
  afor(i, 1, n)
  {
    string s;
    cin>>s;
    afor(j, 1, n)
    {
      if(s[j - 1] == '1')adj[i][j] = 1;
    }
  }

  int ans = -1;
  afor(st, 1, n) //V1 node
  {
    int dist = 0;
    bool f = true;
    queue<int> q;
    q.push(st);
    afor(i, 1, n)dis[i] = infs;
    dis[st] = 0;
    while(q.size())
    {
      int xx = q.front();
      dist = max(dist, dis[xx]);
      q.pop();
      afor(j, 1, n)
      {
        if(j==xx || !adj[xx][j])continue;
        if(dis[j] == infs)
        {
          dis[j] = dis[xx] + 1;
          q.push(j);
        }
        else if(dis[j] == dis[xx])f = false;
      }

    }
    if(f)ans = max(ans, dist + 1);
  }

  cout<<ans;
  
return 0;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]

maxi = float("inf")
mini = 0

for i in range(m):
    l, r = [int(i) for i in input().split()]
    maxi = min(r, maxi)
    mini = max(l, mini)

print(max(0, maxi-mini+1))


Measured memory_bytes: 3060