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

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace NyaGadget
{

#define rep(i, begin, end) for (ll i = begin; i < end; i++)
#define size(collection) ((ll) (collection).size())
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)

	struct Imos2D
	{	// 二次元IMOS法ライブラリ
		vector<vector<ll>> grid;

		Imos2D(ll w, ll h)
		{
			grid.resize(h + 1);
			each(i, e, grid)
				e.resize(w + 1);
		}

		void Add(ll hmin, ll hmax, ll wmin, ll wmax, ll v)
		{
			grid[hmin][wmin] += v;
			grid[hmin][wmax + 1] -= v;
			grid[hmax + 1][wmin] -= v;
			grid[hmax + 1][wmax + 1] += v;
		}

		void Update(void)
		{
			rep(i, 0, size(grid))
			{
				rep(j, 1, size(grid[i]))
					grid[i][j] += grid[i][j - 1];
			}
			rep(i, 1, size(grid))
			{
				rep(j, 0, size(grid[i]))
					grid[i][j] += grid[i - 1][j];
			}
		}
	};

#undef rep
#undef size
#undef fori
#undef each

}

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;

struct Range
{
	ll l;
	ll r;
};

int main(void)
{
	ll N, M, Q; cin >> N >> M >> Q;

	vector<Range> train(M);
	each(i, e, train)
	{
		cin >> e.l >> e.r;
		e.l--; e.r--;
	}

	vector<Range> query(Q);
	each(i, e, query)
	{
		cin >> e.l >> e.r;
		e.l--; e.r--; 
	}

	Imos2D imos(N, N);
	each(i, e, train)
		imos.Add(0, e.l, e.r, N - 1, 1);

	imos.Update();

	each(i, e, query)
		cout << imos.grid[e.l][e.r] << endl;

	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N; cin >> N;
    pii p[N];
    rep(i, N){
        cin >> p[i].first;
        p[i].first--;
        p[i].second = i+1;
    }
    sort(p, p+N);
    int now = 0;
    vector<int> ans(N*N, 0);
    rep(i, N){
        //k番目のkのidがpos(0-indexed)である
        int pos = p[i].first, k = p[i].second;
        rep(j, k-1){
            while(ans[now]) now++;
            if(now >= pos) {cout << "No" << endl; return 0;}
            ans[now] = k;
        }
        ans[pos] = k;
    }
    now = N*N-1;
    rep3(i, N-1, 0){
        //k番目のkのidがpos(0-indexed)である
        int pos = p[i].first, k = p[i].second;
        rep(j, N-k){
            while(ans[now]) now--;
            if(now <= pos) {cout << "No" << endl; return 0;}
            ans[now] = k;
        }
    }
    cout << "Yes" << endl;
    rep(i, N*N) cout << ans[i] << ' ';
    cout << endl;
}

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



int main(){
  int N;
  cin>>N;
  if(N%10==0||N%10==1||N%10==6||N%10==8) cout<<"pon";
  else if(N%10==3) cout<<"bon";
  else cout <<"hon";

}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int n,tmp,max=0,min=1000000001;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tmp;
        if(tmp>max)max=tmp;
        if(tmp<min)min=tmp;
    }
    cout<<max-min<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

ans = '1'
if n == 1:
    ans = '0'
for i in range(n-1):
    ans += '0'

while len(ans) == n:
    if all([ans[s-1] == str(c) for s, c in sc]):
        print(ans)
        exit()
    ans = str(int(ans)+1)
print(-1)

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n > 0)
	{
		ans++;
		n -= k - 1;
		if (n == 1)
			break;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n,T = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
time = 0

for i in t:
    if time <= i:
        ans += T
        time = i + T
    else:
        ans += T - (time-i)
        time += T -  (time-i)
print(ans)



    


Measured memory_bytes: 26836
import math
n = int(input())
A, B = [], []
for i in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

res = 0
for i in range(n)[::-1]:
    A[i] += res
    res += math.ceil(A[i]/B[i])*B[i] - A[i]
print(res)

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define int long long int

signed main(){
    int a,b,c;
    while(cin>>a>>b>>c){
        bool f=true;
        int now=0;
        for(int i=0;i<10000000;i++){
//            cout<<now<<" "<<c<<endl;
            if(now<=c&&c<=now+a){
                cout<<c<<endl;
                f=false;
                break;
            }
            now+=a+b;
            if(now>c)c+=60;
        }
        if(f)cout<<"-1"<<endl;
    }
}

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

class DoublyLinkedList {
  struct Element {
    int key;
    Element *prev;
    Element *next;
  };
  Element *nil;

  void del(Element *e) {
    if(e == nil) return;
    e->prev->next = e->next;
    e->next->prev = e->prev;
    delete e;
  }
public:
  DoublyLinkedList() {
    nil = new Element;
    nil->next = nil;
    nil->prev = nil;
  }

  void insert(int key) {
    Element *e = new Element{key, nullptr, nullptr};
    e->next = nil->next;
    nil->next->prev = e;
    nil->next = e;
    e->prev = nil;
  }

  void deleteFristKey(int key) {
    Element *e = nil->next;
    while(e != nil && e->key != key) e = e->next;
    del(e);
  }

  void deleteFirst() {
    del(nil->next);
  }

  void deleteLast() {
    del(nil->prev);
  }

  void print() {
    Element *e = nil->next;
    while(true) {
      cout << e->key;
      e = e->next;
      if(e == nil) {
        cout << endl;
        break;
      } else {
        cout << " ";
      }
    }
  }
};

int main () {
  int n;
  cin >> n;
  auto list = new DoublyLinkedList;
  string c;
  int key;
  rep(i,n) {
    cin >> c;
    if(c == "insert") {
      cin >> key;
      list->insert(key);
    } else if (c == "delete") {
      cin >> key;
      list->deleteFristKey(key);
    } else if (c == "deleteFirst") {
      list->deleteFirst();
    } else if (c == "deleteLast"){
      list->deleteLast();
    }
  }
  list->print();

  return 0;
}



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

int main(){
  int n,A=0,B=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<n-1;i++){
    if(a.at(i)>=a.at(i+1)){
      B++;
    }
         
    else{
 if(A<B){
        A=B;
      }
      B=0;
    }
    if(A<B){
        A=B;
      }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N;
	cin>>N;
	queue<int> que;
	int y;
	cin>>y;
	que.push(y);
	rep(i,N-1){
		int x;
		cin>>x;
		if(que.back()!=x)que.push(x);
	}
	int ans=0;
	while(!que.empty()){
		ans++;
		int a=que.front();
		que.pop();
		if(que.empty())break;
		int b=que.front();
		if(a==b)break;
		else if(a<b){
			int c=a,d=b;
			while(c<d){
				que.pop();
				if(que.empty())break;
				c=d;
				d=que.front();
			}
		}
		else{
			int c=a,d=b;
			while(c>d){
				que.pop();
				if(que.empty())break;
				c=d;
				d=que.front();
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

int main()
{
	int K;
	std::string S;
	std::cin >> K >> S;

	if (K < S.size())
	{
		for (int i = 0; i < K; ++i)
		{
			std::cout << S.at(i);
		}
		std::cout << "...\n";
	}
	else
	{
		std::cout << S << "\n";
	}

	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>

int main(void) {
	int x,y,s;
	int map[10][10],w=0,m=0,t=0;
	int i,j;

	for(i=0;i<10;i++) { for(j=0;j<10;j++) { map[j][i] = 0; } }
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF) {
		switch(s) {
			case 3:
				if(x-2>=0) { map[x-2][y]++; }
				if(x+2<10) { map[x+2][y]++; }
				if(y-2>=0) { map[x][y-2]++; }
				if(y+2<10) { map[x][y+2]++; }
			case 2:
				if(x-1>=0) {
					if(y-1>=0) { map[x-1][y-1]++; }
					if(y+1<10) { map[x-1][y+1]++; }
				}
				if(x+1<10) {
					if(y-1>=0) { map[x+1][y-1]++; }
					if(y+1<10) { map[x+1][y+1]++; }
				}
			case 1:
				if(x-1>=0) { map[x-1][y]++; }
				if(x+1<10) { map[x+1][y]++; }
				if(y-1>=0) { map[x][y-1]++; }
				if(y+1<10) { map[x][y+1]++; }
			default:
				map[x][y]++;
				break;
		}
	}
	for(i=0;i<10;i++) {
		for(j=0;j<10;j++) {
			if(map[j][i]==0) { w++; }
			if(map[j][i]==m) { t++; }
			else if(map[j][i]>m) { m=map[j][i];t=0; }
			//printf("%d ", map[j][i]);
		}
		//printf("\n");
	}
	printf("%d\n%d\n", w, m);
	return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define fn(k, n) for(int k = 0; k < n; ++k)

#define EPS 1.0e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll H;

	cin >> H;

	ll attacks = 0, p = 1;

	while(H > 0) {

		attacks += p;
		p <<= 1;
		H >>= 1;
	}

	cout << attacks << '\n';

    return 0;
}


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

int main(){
  ll N, K; cin >> N >> K;
  ll ans = N%K;
  ans = min(ans, abs(ans-K));
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005,mod=1e9+7;
int n;
ll a[N],fac[N],ni[N],ans;
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n)a[i]=read()+a[i-1];
	For(i,fac[0]=1,n)fac[i]=fac[i-1]*i%mod; 
	ni[n-1]=1;
	Rep(i,n-1,1)ni[i-1]=ni[i]*i%mod;
	For(i,1,n-2){
		ll s=a[n-1]-a[n-1-i]-a[i];
		//cout<<s<<" "<<ni[i+1]<<" "<<fac[i-1]<<endl;
		ans=(ans+s%mod*ni[i+1]%mod*fac[i-1])%mod;
	}
	For(i,1,n-1){
		ans=(ans+(a[n]-a[n-1]-a[n-i]+a[n-i-1]+mod)*ni[i]%mod*fac[i-1])%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void solve(){
    ll a;
    double b;
    cin >> a >> b;
    ll c = llround(b*100);
    cout << a*c/100;


}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3732
N, M, r = map(int, input().split())
R = list(map(lambda x:int(x)-1, input().split()))
d = [[1<<30]*N for _ in range(N)]
for i in range(M): #ひとまず枝があるペアは枝の長さをセット
  a,b,t = map(int, input().split())
  d[a-1][b-1] = t
  d[b-1][a-1] = t

for i in range(N):
  d[i][i] = 0 #自身への最短経路は0
#三重ループ
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j] = min(d[i][j], d[i][k]+d[k][j])
from itertools import groupby, accumulate, product, permutations, combinations
ans = 1<<30
for per in permutations(R,r):
  cnt = 0
  for i in range(r-1):
    cnt += d[per[i]][per[i+1]]
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 74992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios_base::sync_with_stdio(0),cin.tie(0)
int32_t main()
{int m,n,i,j,len;
 string s,t,str="";
 fast();
 cin>>s>>t;
 m=s.length();
 n=t.length();
 vector<vector<int>> dp(m+1,vector<int> (n+1,0));
 for(i=0;i<=m;++i)
 {for(j=0;j<=n;++j)
  {if(!i || !j)
   dp[i][j]=0;
   else if(s[i-1]==t[j-1])
   dp[i][j]=dp[i-1][j-1]+1;
   else
   dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
  }
 }
 len=dp[m][n];
 //for(i=0;i<=m;++i)
 //{for(j=0;j<=n;++j)
 // cout<<dp[i][j]<<" ";
 // cout<<"\n";
 //}
 //cout<<"here\n";
 for(i=m,j=n;j>=0 && i>=0 && len>0;)
 {if(s[i-1]==t[j-1])
  {str+=s[i-1];
   --i,--j,--len;
  }
  else if(dp[i-1][j]>dp[i][j-1])
  --i;
  else
  --j;
 }
 reverse(str.begin(),str.end());
 cout<<str;
 return 0;
}





Measured memory_bytes: 70784
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

typedef pair<int,int> P;
typedef long long ll;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int a,b;cin>>a>>b;
  cout << 6-a-b << 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 INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a),q(b),r(c);
  rep(i,a) cin >> p.at(i);
  rep(i,b) cin >> q.at(i);
  rep(i,c) cin >> r.at(i);
  sort(ALLR(p));
  sort(ALLR(q));
  rep(i,x) r.push_back(p.at(i));
  rep(i,y) r.push_back(q.at(i));
  sort(ALLR(r));
  ll ans = 0;
  rep(i,x+y) ans+=r.at(i);
  cout << ans << endl;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  string s;
  cin >> s;
  int ans=0;
  rep(i,3){if(s[i]=='1')ans++;}
  cout << ans << endl;
}

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

int N, A, B, C, D;

int main() {
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	if (abs(A - B) > (long long)(N - 1) * D) {
		printf("NO\n");
		return 0;
	}
	long long allowance = 0;
	while (N >= 2) {
		if (abs(A - B) >= (long long)(N - 1) * C - allowance && abs(A - B) <= (long long)(N - 1) * D + allowance) {
			printf("YES\n");
			return 0;
		}
		N -= 2;
		allowance += D - C;
	}
	printf("NO\n");
}


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

int digits[10] = {0};


bool is_valid(int x) {
  while (x) {
    int d = x % 10;
    if (digits[d]) return false;
    else x /= 10;
  }

  return true;
}

int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  int n, k;
  cin >> n >> k;

  for (int i = 0; i < k; ++i) {
    int x; cin >> x;
    digits[x] = 1;
  }

  int max_int = ~(1 << 31);

  int res = -1;
  do {
    if (is_valid(n)) res = n;
  } while (n++ < max_int && res == -1);

  cout << res << '\n';
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool one = a == b;
  bool two = c == d;
  for (int i = 0; i < N - 2; i ++) {
    int k, j;
    cin >> k >> j;
    bool thr = k == j;
    if (one && two && thr) {
      cout << "Yes" << endl;
      return 0;
    }
    one = two;
    two = thr;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define P 2019
int l,r,i,j,ans,mi;
int main() {
	scanf("%d%d",&l,&r);
	if(r-l>=2018) {
		puts("0");
		return 0;
	}
	ans=P;
	for(i=l; i<r; i++)
		for(j=i+1; j<=r; j++)
			mi=1ll*i*j%P,ans=min(ans,mi);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if(n % 2 == 1) {
    for(int i = 0; i < m; i++) {
      cout << i + 1 << ' ' << n - (i + 1) << endl;
    }
  }
  else {
    int k = n / 2;
    cout << k << ' ' << n - 1 << endl;
    int count = 1;
    if((k - 1) % 2 == 1) {
      for(int i = 1; i <= (k - 2) / 2; i++) {
        if(count == m) break;
        cout << i << ' ' << k - i << endl;
        count++;
      }
      for(int j = 1; j <= (k - 2) / 2; j++) {
        if(count == m) break;
        cout << k + j << ' ' << n - 1 - j << endl;
        count++;
      }
    }
    else {
      for(int i = 1; i <= (k - 1) / 2; i++) {
        if(count == m) break;
        cout << i << ' ' << k - i << endl;
        count++;
      }
      for(int j = 1; j <= (k - 1) / 2; j++) {
        if(count == m) break;
        cout << k + j << ' ' << n - 1 - j << endl;
        count++;
      }
    }
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int maxn = 200007;
const ll inf = 1e9 + 7;
ll dp[maxn];
ll arr[maxn];
int n, k;

ll solve(ll pos)
{
    if (pos == n - 1)
        return 0;
    if (pos >= n)
        return inf;

    if (dp[pos] != -1)
    {
        return dp[pos];
    }

    ll ans1 = inf, ans2 = inf, mincost = inf;
    for (int i = 1; i <= k; i++)
    {

        if (pos + i < n)
        {

            mincost = min(mincost, solve(pos + i) + abs(arr[pos] - arr[pos + i]));
        }
    }

    dp[pos] = mincost;
    return mincost;
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i < maxn; i++)
    {
        dp[i] = -1;
    }
    cout << solve(0);

    return 0;
}

Measured memory_bytes: 12204
n = int(input())
A = list(map(int,input().split()))
count = 0

flag = 1
while flag == 1:
    flag = 0
    for i in range(n-1,0,-1):
        if A[i] < A[i-1]:
            v = A[i]
            A[i] = A[i-1]
            A[i-1] = v
            count += 1
            flag = 1
    

print(' '.join(map(str,A)))
print(count)


Measured memory_bytes: 5596
N,M=map(int,input().split())
A=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
for a in A:
    heappush(q,(-a,a,0))
while M>0:
    _,X,n=heappop(q)
    n+=1
    heappush(q,(-(X//2**n),X,n))
    M-=1
r=0
for _,X,n in q:
    r+=X//2**n
print(r)

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define form(i,x,N) for(int i=x;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using umap=unordered_map<int,int>;
using uset=unordered_set<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N,K;
cin>>N>>K;
vector<int> d(10);
forn(i,K) {
  int x;
  cin>>x;
  d[x]=1;
}
for(int i=N;i<=100000;i++) {
  int c=i;
  bool ok=true;
  while(c) {
    if(d[c%10]) {
      ok=false;
      break;
    }
    c/=10;
  }
  if(ok) {
    cout<<i<<endl;
    return 0;
  }

}
return 0;
}


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

int n;
int cnt[50][30];
string S[50];
char res[51];
 
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> S[i];
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < S[i].length(); j++) {
            cnt[i][S[i][j]-'a']++;
        }
    }
    int index = 0;
    for (int i = 0; i < 26; i++) {
        int c = cnt[0][i];
        for (int k = 1; k < n; k++) {
            c=min(c,cnt[k][i]);
        }
        for (int k = index; k < index+c; k++) {
            res[k] = 'a' + i;
        }
        index += c;
    }
    cout << res << endl;
 
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n;
	lli a = 1, t = 1;
	cin >> n;
	
	rep(i, n){
		int p, q;
		scanf("%d%d", &p, &q);
		lli j = max(a/p+!!(a%p), t/q+!!(t%q));
		a = p*j; t = q*j;
	}

	cout << a+t << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var (
        n     int
    )
    fmt.Scan(&n)
    v := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Scan(&v[i])
      }
    c := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Scan(&c[i])
      }
    cost := make([]int, n)
    var ans int
    for i := 0; i < n; i++ {
      cost[i] = v[i] - c[i]
      if (cost[i] > 0){
        ans = ans + cost[i]
      }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int a,b,c;cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    A = cin.mapInt()
    B = cin.mapInt()

    ans = sum(A)
    for i in range(N):
        n = min(A[i],B[i])
        A[i]-=n
        B[i]-=n
        n = min(A[i + 1],B[i])
        A[i + 1] -= n
        B[i]-=n
    ans -= sum(A)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 76544
import java.util.Scanner;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                if(a > b)
                    System.out.println("a > b");
                else if(a < b)
                    System.out.println("a < b");
                else
                    System.out.println("a == b");
        }
}


Measured memory_bytes: 26096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

class LSquare
{
public:
  int h,w;
  vector<vector<int>> t;
  vector<vector<int>> dp;
  LSquare(){}
  LSquare( int h, int w ) : h(h), w(w), t(h, vector<int>(w)), dp(h, vector<int>(w,-1)) {}
  int solve();
};

int LSquare::solve()
{
  for ( auto i = 0; i < h; ++i )
    {
      for ( auto j = 0; j < w; ++j )
        {
          if ( t[i][j] == 1 )
            dp[i][j] = 0;
          else
            {
              if ( i == 0 || j == 0 )
                dp[i][j] = 1;
            }
        }
    }

  for ( auto i = 1; i < h; ++i )
    {
      for ( auto j = 1; j < w; ++j )
        {
          if ( dp[i][j] == 0 ) continue;
          
          int mv = min( dp[i-1][j], dp[i][j-1]);
          mv = min( mv, dp[i-1][j-1] );
          
          dp[i][j] = mv + 1;
        }
    }

  int ret = 0;
  
  for ( auto i = 0; i < h; ++i )
    for ( auto j = 0; j < w; ++j )
      ret = max( ret, dp[i][j] );
          
  cout << ret * ret << endl;
  
  return 0;
}

int main()
{
  int h,w;
  cin >> h >> w;

  LSquare ls( h, w );

  for ( auto i = 0; i < h; ++i )
    for ( auto j = 0; j < w; ++j )
      cin >> ls.t[i][j];
  
  ls.solve();

  return 0;
}

Measured memory_bytes: 16572
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;

int main(){
   int m1,d1;
   cin >> m1>>d1;
   int m2,d2;
   cin>> m2 >>d2;
   if(m1!=m2) cout <<1 <<endl;
   else cout << 0 <<endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

#ifdef LOCAL
#include "local.h"
#endif

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


bool check(string a, string b)
{
    rep(i, a.size())
    {
        if (a[i] != b[i] && b[i] != '_')
            return false;
    }
    return true;
}
int main()
{
    string a, b;
    cin >> a >> b;
    rep(i, sz(a) - sz(b) + 1)
    {
        if (check(a.substr(i, b.size()), b))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin >> s;
    string ans = "";
    for(int i = 0; i < s.size(); i++)
    {
        if(i%2 == 0)
        {
            ans += s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
bool overlap(int a,int b,int c,int d){
   if(d <= a){
       return false;
   }
   if(b <= c){
       return false;
   }
   return true;
}
int main(void){
   int a,b,s,f,n;
   cin >> a >> b >> n;
   for(int i=0; i<n; i++){
       cin >> s >> f;
       if(overlap(a,b,s,f)){
           cout << 1 << endl;
           return 0;
       }
   }
   cout << 0 << endl;
   return 0;
}


Measured memory_bytes: 3104
// B - ∵∴∵
#include <bits/stdc++.h>
using namespace std;

int main(){
	vector<string> s(2);
	cin>>s[0]>>s[1];
	for(int i=0; i<s[0].size()+s[1].size(); i++){
		cout<< s[i%2][i/2];
	}
	cout<<"\n";
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 14;

set<int> g[MAX];
int c[MAX];
int ans[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	FOR(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].insert(v);
		g[v].insert(u);
	}
	FOR(i, 0, n)
		cin >> c[i];
	sort(c, c + n);
	unordered_set<int> leaves;
	FOR(i, 0, n)
	{
		if(SZ(g[i]) == 1)
		{
			leaves.insert(i);
		}
	}
	LL sum = 0;
	FOR(i, 0, n)
	{
		int v = *leaves.begin();		
		if(i < n - 1)
		{
			int u = *g[v].begin();
			g[v].erase(u);
			g[u].erase(v);
			leaves.erase(v);
			if(SZ(g[u]) <= 1)
				leaves.insert(u);
			sum += c[i];
		}
		ans[v] = c[i];
	}
	cout << sum << "\n";
	FOR(i, 0, n)
		cout << ans[i] << " ";
	return 0;
}

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

using namespace std;


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

int dx[] = { 0,0,1,-1,-1,-1,1,1 };
int dy[] = { 1,-1,0,0,-1,1,1,-1 };




template <class T> inline T biton(T n, T pos)
{
	return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
	return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
	return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
	while (b)
	{
		a = a % b;
		swap(a, b);
	}
	return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
	T ret = 1;
	for (; e > 0; e >>= 1)
	{
		if (e & 1)
			ret = (ret * p) % m;
		p = (p * p) % m;
	}
	return (T)ret;
};

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif

long long INF = 1e18;

void solve()
{
	long long n, tw;
	cin >> n >> tw;

	vector<pair<long long, long long>> items(n+1);

	for (long long i = 1; i <= n; i++) {
		cin >> items[i].first >> items[i].second;
	}

	vector<vector<long long>> dp(n+1, vector<long long>(tw + 1));



	for (long long i = 1; i <= n; i++) {

		for (long long w = 1; w <= tw; w++) {
			if (w - items[i].first < 0) {
				dp[i][w] = dp[i - 1][w];
			}
			else {
				dp[i][w] = max(dp[i - 1][w - items[i].first] + items[i].second, dp[i - 1][w]);
				//debug(i,w,dp[i][w]);
			}
		}
	}

	cout << dp[n][tw] << nl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);
	cout.tie(nullptr);
	cin.tie(nullptr);

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 80256
import math

def combinations(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def int2ans(i):
    return i%(10**9+7)

N,K=[int(e) for e in input().split(' ')]
L=N-K

for i in range(1,1+K):
    if i > L+1:
        ans=0
    else:
        ans=combinations(L+1,i)*combinations(K-1,i-1)
    print(int2ans(ans))

Measured memory_bytes: 3316
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

MOD = 10 ** 9 + 7

def fact(n):
    if n <= 1:
        return 1
    return fact(n - 1) * n

n, k = map(int, raw_input().split())
k -= 1

print fact(n + k) / fact(k) / fact(n) % MOD


Measured memory_bytes: 6524
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        char s[] = sc.next().toCharArray();
        int len = s.length;

        System.out.println((len % 2 == 1) ^ (s[0] == s[len - 1]) ? "First" : "Second");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 26704
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

double W, H, x, y;

int main() {
	cin >> W >> H >> x >> y;
	printf("%.5f ", W / 2 * H);
	cout << bool(x == W / 2 && y == H / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int pick = 0, sum = 0;
    while (pick != k)
    {
        if (a > 0)
        {
            sum += 1;
            a--;
            pick++;
            continue;
        }
        if (a == 0 && b > 0)
        {
            sum += 0;
            b--;
            pick++;
            continue;
        }
        if (b == 0 && c > 0)
        {
            sum += -1;
            c--;
            pick++;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>

using namespace std;
int main(){
    int ans=0;
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0; i<n;i++){
        if(i%2==0){
            ans-=int(s[i]=='p');
        }
        else{
            ans+=int(s[i]=='g');
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = 3;
		int[] PQR = new int[N];
		Arrays.setAll(PQR, $ -> Integer.parseInt(sc.get()));
		Arrays.sort(PQR);
		System.out.println(PQR[0] + PQR[1]);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 27604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
const int MAX_N = 1000;

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

    int dp[MAX_N+1][MAX_N+1];

    while(q > 0){
        string x, y; cin >> x >> y;

        int X = x.size(), Y = y.size();
        rep(i, 0, X){
            rep(j, 0, Y){
                if(x[i] == y[j]) dp[i+1][j+1] = dp[i][j] + 1;
                else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }

        cout << dp[X][Y] << endl;

        q--;
    }

    return 0;
}


Measured memory_bytes: 7088
#include <iostream>
#include <algorithm>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)

int graph[200][200];

int main() {
    int V, M, R;
    cin >> V >> M >> R;
    int r[8];
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    sort(r, r + R);

    rep(i, V)rep(j, V)graph[i][j] = INF / 2;
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        graph[A][B] = graph[B][A] = C;
    }
    rep(k, V)rep(i, V)rep(j, V)graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);

    ll ans = INF;
    do {
        ll sum = 0;
        rep(i, R - 1)sum += graph[r[i]][r[i + 1]];
        ans = min(ans, sum);

    } while (next_permutation(r, r + R));

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int P = sc.nextInt();
		int costX = A * P;
		int costY;
		int cost;
		if (P <= C) {
			costY = B;
		} else {
			costY = B + D * (P - C);
		}
		if (costX > costY) {
			cost = costY;
		} else {
			cost = costX;
		}
		System.out.println(cost);
	}
}



Measured memory_bytes: 26388
import bisect
import random

D = int(input())
C = list(map(int, input().split()))#下がりやすさ
S = [list(map(int, input().split())) for _ in range(D)]#増加分
#T = [int(input()) for _ in range(D)]#コンテストの開催
T = [0] * D
Last = [[-1] for _ in range(26)]

ans = 0

for i in range(D):
    tt = max(S[i])
    t = S[i].index(tt)
    #t = T[i]
    ans += S[i][t-1]
    Last[t-1].append(i) 
    for k in range(26):
        ans -= C[k] * (i - max(Last[k]))
    #print(ans)
    T[i] = t

M = 10**5

for i in range(M):
    d = random.randrange(D)
    q = random.randrange(26)
    
    old = T[d]
    T[d] = q 
    
    tmp = ans
    tmp += S[d][q] - S[d][old]
    
    if max(Last[q]) < d:
        tmp += C[q] * (D - d - 1)
    else:
        q_ind = bisect.bisect_left(Last[q], d)
        tmp += C[q] * (Last[q][q_ind-1] - d)

    if max(Last[old]) < d:
        tmp -= C[old] * (D - d - 1)
    else:
        old_ind = bisect.bisect_left(Last[old], d)
        tmp -= C[old] * (Last[old][old_ind-1] - d) 
    
    if tmp <= ans:
        T[d] = old
        continue
    if d in Last[old]:
        Last[old].remove(d)
    bisect.insort_left(Last[q], d)
    #print(i)

for t in T:
    print(t+1)

    
#Last = [[-1] for _ in range(26)]
#ans = 0
#for i in range(D):
#    t = T[i]
#    ans += S[i][t-1]
#    Last[t-1].append(i) 
#    for k in range(26):
#        ans -= C[k] * (i - max(Last[k]))
#    print(ans)

Measured memory_bytes: 84828
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = sorted(A, key=lambda x:x[0])
cnt = 0
ans = 0
for i,j in B:
    for k in range(j):
        if cnt == M:
            break
        cnt += 1
        ans += i
else:
    print(ans)

Measured memory_bytes: 29796
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,y;
    scanf("%d %d", &n, &y);

    int A = 10000, B = 5000, C = 1000;

    reppp(a, 0, y/A+1){
        reppp(b, 0, (y-A*a)/B+1){
            int c = (y-A*a-B*b)/C;
            if(a+b+c == n){
                printf("%d %d %d\n", a,b,c);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=3001;
ll dp[N][N];
ll a[N];
ll solve(int i,int j)
{
  if(i>j)
    return 0;
  if(dp[i][j]!=LLONG_MIN)
    return dp[i][j];
  ll ans=a[i]-solve(i+1,j);
  ans=max(ans,a[j]-solve(i,j-1));
  return dp[i][j]=ans;
}
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  for(int i=1;i<=n;i++)
  for(int j=1;j<=n;j++)
   dp[i][j]=LLONG_MIN;
  cout<<solve(1,n)<<endl;
}

Measured memory_bytes: 70784