akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

#define all(bind) bind.begin(), bind.end()

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    if (v.size()) {
        cout << v.front();
        for (auto vi = v.begin() + 1; vi != v.end(); vi++)
            cout << " " << *vi;
    }
    return os;
}

int main()
{
    vector<int> list;

    for (int x; cin >> x;)
        list.push_back(x);

    sort(all(list), greater<int>());

    cout << list << endl;

    return 0;
}

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

#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

const int N=16666,P=998244353;

struct Div{
	ull m,x;
	int s;
	Div(){}
	Div(ull mo):m(mo){
		s=__lg(mo-1);
		x=((__uint128_t(1)<<(s+64))+m-1)/m;
	}
	friend ull operator/(ull a,Div d){
		return ((__uint128_t(a)*d.x)>>d.s)>>64;
	}
	friend ull operator%(ull a,Div d){
		return a-a/d*d.m;
	}
};
const Div mod(P);

uint fpow(uint a,int t){
	uint r(1);
	for(;t;t>>=1,a=(ull)a*a%mod)if(t&1)r=(ull)r*a%mod;
	return r;
}

int n,m,k;
uint fac[N],ifac[N],inv[N],tx[N],ty[N],tz[N],dp[N],ret;
uint *ww[20],*iww[20],pol[N<<2],*pl=pol;
void init(int n){
	int i,p,l;uint w;
	for(l=2,p=0;l<=n;l<<=1,p++){
		ww[p]=pl;w=fpow(3,(P-1)/l);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
		iww[p]=pl;w=fpow(w,P-2);
		for(i=*pl=1;i<l>>1;i++)pl[i]=(ull)pl[i-1]*w%mod;pl+=l>>1;
	}
}
void fft(uint a[],int n,int dft){
	int i,j,k,l,p;uint t,*w;
	for(i=1,j=n>>1;i<n-1;i++){
		if(i<j)swap(a[i],a[j]);
		for(k=n>>1;(j^=k)<k;k>>=1);
	}
	for(l=2,p=0;l<=n;l<<=1,p++){
		w=dft==1?ww[p]:iww[p];
		for(j=0,i=l>>1;j<n;j+=l)for(k=0;k<i;k++){
			uint&y=a[j+k];
			t=(ull)a[j+k+i]*w[k]%mod;
			(a[j+k+i]=y+P-t)<P?:a[j+k+i]-=P; 
			(y+=t)<P?:y-=P;
		}
	}
	if(dft==-1)for(i=0,t=fpow(n,P-2);i<n;i++)a[i]=(ull)a[i]*t%mod;
}

uint C(int n,int m){
	if(n<m)return 0;
	return (ull)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
 
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	fo(i,2,(n<<1)+2){
		fac[i]=(ull)fac[i-1]*i%mod;
		inv[i]=P-(ull)(P/i)*inv[P%i]%mod;
		ifac[i]=(ull)ifac[i-1]*inv[i]%mod;
	}
	dp[0]=1;
	for(k=1;k<=n<<1;k<<=1);
	init(k);
	fo(i,1,m){
		mms(tx,k);mms(ty,k);
		fo(j,0,n)tx[j]=(ull)dp[j]*ifac[j]%mod;
		fo(j,1,n)ty[j]=ifac[j+2];
		fft(tx,k,1);fft(ty,k,1);
		fo(j,0,k-1)tz[j]=(ull)tx[j]*ty[j]%mod;
		fft(tz,k,-1);
		fo(j,0,k-1)dp[j]=((ull)dp[j]*((j+1)*j/2+1)+(ull)tz[j]*fac[j+2])%mod;
	}
	fo(i,0,n)ret=(ret+(ll)dp[i]*C(n,i))%mod;
	printf("%u\n",ret);
	return 0;
}

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

struct mint{
    // 自動的にmodを取ってくれるクラスです。
    ll x;
    mint(ll x = 0):x(x%mod){}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint b = pow(t/2);
        b *= b;
        if(t%2 == 1) b *= *this;
        return b;
    }

    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        (*this) *= a.inv();
        return *this;
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};

int main(){
    ll n;
    cin >> n;
    mint u(10);
    mint w(8);
    mint y(9);
    mint juu = u.pow(n);
    mint kyuu =y.pow(n);
    mint hati = w.pow(n);
    mint ans = juu-hati;
    ans -= (kyuu-hati);
    ans -= (kyuu-hati);
    cout << ans.x << endl;
    
}

Measured memory_bytes: 3632
NX = input()
NX = "".join(NX).split(" ")
NX = [int(s) for s in NX]
N =NX[0]
X =NX[1]
D = NX[0]-NX[1]
A=X+D
def ans(x,y):
	global A
	if x%y==0:
		A+=2*y*(x/y)-y
		return print(int(A))
	A +=int(x/y)*y*2

	ans(y,x%y)

if X>D:
	ans(X,D)
else:	ans(D,X)


Measured memory_bytes: 3064
S = input()
divide = ["dream", "dreamer", "erase", "eraser"]
S = S[::-1]
divide = [divide[i][::-1] for i in range(4)]
 
while len(S) > 0:
    for i in range(4):
        if S[:len(divide[i])] == divide[i]:
            flag = "YES"
            S = S[len(divide[i]):]
            break
        else:
            flag = "NO"
    if flag == "NO":
        break

print(flag)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main (){
    int n,m; cin>>n>>m;int a[n];int ans=0 ;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<m;i++){
        ans=ans+a[i];
    }
    cout<<ans;






    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int A, B, k10000, k1000, k100,k10, k1, i, flag = 0;
	cin >> A >> B;
	for (i = A;i <= B;i++) {
		k10000 = i / 10000;
		k1000 = (i - k10000 * 10000) / 1000;
		k100 = (i - k10000 * 10000 - k1000 * 1000) / 100;
		k10 = (i - k10000 * 10000 - k1000 * 1000 - k100 * 100) / 10;
		k1 = i - k10000 * 10000 - k1000 * 1000 - k100 * 100 - k10 * 10;
		if (k10000 == k1&&k1000 == k10)
			flag++;
	}
	cout << flag << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())

start_idx = [i for i in range(k)]
hands = [0]*k
score = 0

for i in range(k):
    if t[i] == 'r':
        hands[i] = 'p'
        score += p
    
    elif t[i] == 's':
        hands[i] = 'r'
        score += r
    
    else:
        hands[i] = 's'
        score += s

for i in start_idx:
    for j in range(i+k,n,k):
        if t[j] == 'r':
            if hands[i] == 'p':
                hands[i] = 'a'
            
            else:
                hands[i] = 'p'
                score += p
        
        if t[j] == 's':
            if hands[i] == 'r':
                hands[i] = 'a'
            
            else:
                hands[i] = 'r'
                score += r
        
        if t[j] == 'p':
            if hands[i] == 's':
                hands[i] = 'a'
            
            else:
                hands[i] = 's'
                score += s
        
        
print(score)

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

typedef long long ll;
ll mod = 1000000007;
const int maxe = 200010;
vector < ll > fact(maxe, 1);
vector < ll > inv(maxe, 1);

ll binpow(ll x){
    ll res = 1;
    ll y = mod-2;
    while(y>0){
        if( y & 1){
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        y /= 2;
    }
    return res;
}

void factorial(){
    for(int i = 2; i< maxe; i++){
        fact[i] = i*fact[i-1];
        fact[i] %= mod;
    }
}

void inverse(){
    for(int i = 0; i < maxe; i++){
        inv[i] = binpow(fact[i]);
    }
}

ll ncr(ll n, ll r){
    return ((( fact[n] * inv[n-r] ) % mod ) * inv[r] ) % mod;
}

int main(){
    factorial();
    inverse();
    ll h, w, n;
    cin >> h >> w >> n;
    ll res = ncr(h+w-2, w-1);
    vector< pair< ll, ll > > abhi;
    for(int k = 0; k< n; k++){
        ll i, j;
        cin >> i >> j;
        abhi.push_back({i, j});
    }
    abhi.push_back({h,w});
    sort(abhi.begin(), abhi.end());
    vector< ll > dec(n+1);
    for(int i = 0; i <= n; i++){
        
        ll curr = 0;
        dec[i] = ncr(abhi[i].first+abhi[i].second - 2, abhi[i].first - 1);
        for(int j = 0; j < i; j++){
            if( i != j){
                if( abhi[i].first >= abhi[j].first && abhi[i].second >= abhi[j].second ){
                    ll inside_box = ncr( (abhi[i].first - abhi[j].first + 1) + (abhi[i].second - abhi[j].second + 1) - 2, (abhi[i].first - abhi[j].first + 1) - 1);
                    inside_box *= dec[j];
                    inside_box %= mod;
                    curr += inside_box;
                    curr %= mod;
                }
            }
        }
        dec[i] -= curr;
        dec[i] += mod;
        dec[i] %= mod;
    }
    cout << dec[n] << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<int> B(N);
    for(int i=N; i>0; i--)
    {
        int num = 0;
        for(int j=i*2; j<=N; j+=i)
        {
            if(B[j-1]==1) num++;
        }
        if(num%2==0 && A[i-1]==1) B[i-1] = 1;
        else if(num%2==1 && A[i-1]==0) B[i-1] = 1;
        else B[i-1] = 0;
    }

    int M = 0;
    for(auto b : B) if(b==1) M++;

    cout << M << endl;
    for(int i=0; i<N; i++)
    {
        static bool first = true;
        if(B[i]==1)
        {
            if(!first) cout << ' ';
            first = false;
            cout << i+1;
        }
    }
    if(M!=0) cout << '\n';

    return 0;
}


Measured memory_bytes: 4720
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
int cum[102];

bool solve(int h){
  int f=0;
  for(int i=0;i<m;i++){
    int j;
    for(j=f+1;j<=n;j++){
      if(h<cum[j]-cum[f]){
	j--;
	break;
      }
    }
    f=j;
  }
  if(f>=n) return true;
  return false;
}

int main(void){

  while(1){

    scanf("%d %d",&m,&n);
    if(!n && !m) break;

    for(int i=1;i<=n;i++){
      scanf("%d",&cum[i]);
      cum[i]+=cum[i-1];
      //printf("%d ",cum[i]);
    }
    //puts("");
    int ans=1500000;
    int s=0,h,e=1500000;
    while(s<=e){
      h=(s+e)/2;

      if( solve(h) ){
	//puts("a");
	ans=min(h,ans);
	e=h-1;
      } else {
	s=h+1;
      }

    }
    printf("%d\n",ans);
  }
}

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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=1e5+10;

int n, m, x;
int vis[N];
ll dp[N];

int main() {
	cin>>n>>m;
	for(int i=1; i<=m; i++) {
		cin>>x;
		vis[x]=1;
	}
	dp[0]=1;
	for(int i=1; i<=n; i++) {
		if (vis[i]) continue;
		dp[i]=dp[i-1];
		if (i>=2) dp[i]+=dp[i-2];
		dp[i]%=mod;
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1408
from collections import Counter
n = int(input())
s = input()
r = dict(Counter(s))
if 'W' not in r:
    r['W'] = 0
if 'E' not in r:
    r['E'] = 0
l = {'W': 0, 'E': 0}
a = []
for c in s:
    l[c] += 1
    r[c] -= 1
    l[c] -= 1
    a.append(l['W'] + r['E'])
    l[c] += 1
print(min(a))



Measured memory_bytes: 15800
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    int N, M; cin >> N >> M;
    string b;
    vi p(M);
    REP(i, N) {
        char c; cin >> c; b += c;
    }
    REP(i, M) cin >> p[i];

    string g1, g2;
    REP(k, M) {
        REP(i, p[k]) {
            g1 += k & 1 ? '0' : '1';
            g2 += k & 1 ? '1' : '0';
        }
    }

    using Pi = pair<int,string>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    map<string,int> dist;

    int ans = -1;

    que.emplace(0, b); dist[b] = 0;
    while (!que.empty()) {
        string s;
        int cost;
        tie(cost, s) = que.top(); que.pop();
        if (s == g1 or s == g2) {
            ans = cost;
            break;
        }

        REP(i, N-1) {
            string tmp = s;
            swap(tmp[i], tmp[i+1]);
            if (dist.count(tmp) == 0 or dist[tmp] > cost + 1) {
                dist[tmp] = cost + 1;
                que.emplace(cost + 1, tmp);
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3880
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    long h, w;
	    long ans = 0;
	    Scanner scan = new Scanner(System.in);

	    h = scan.nextLong();
	    w = scan.nextLong();

	    long ans1 = (h/2) * (w/2);
	    long ans2 = (h - (h/2)) * (w - (w/2));

	    if(h == 1 || w == 1) {
	    	System.out.println(1);
	    } else {
	    	ans = ans1 + ans2;

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

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

int main()
{
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  else if(s=="Cloudy")cout<<"Rainy"<<endl;
  else if(s=="Rainy")cout<<"Sunny"<<endl;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

template <class T1, class T2, class Pred = less<T2> >
struct sort_pair_first {
  bool operator()(const pair<T1, T2>&left, const pair<T1, T2>&right) {
    Pred p;
    return p(left.first, right.first);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> v;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    v.push_back(pair<long long, long long>(a, b));
  }
  sort(v.begin(), v.end());
  int i = 0;
  long long ans = 0;
  while(true) {
    if(M <= v[i].second) {
      ans += v[i].first * M;
      M -= M;
    } else {
      ans += v[i].first * v[i].second;
      M -= v[i].second;
    }
    i++;
    if(M == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int arr[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            // sort the arrays;
            Arrays.sort(arr);
            if (sum % 10 != 0) {
                out.println(sum);
            } else {
                for (int i = 0; i < arr.length; i++) {
//                sum = sum - arr[i];
                    if (arr[i] % 10 != 0) {
                        sum -= arr[i];
                        out.println(sum);
                        break;
                    }
                }
            }
            if (sum % 10 == 0) {
                out.println(0);
            }
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>

using namespace std;

int main() {
	int D,N;
	cin >> D >> N;
	
	int ans;
	if (N == 100) {
		ans = (N+1)*pow(100,D);
	} else{
		ans = N*pow(100,D);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <array>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int, const char**)
{
    int h, w;
    cin >> h >> w;
    const int CN = 10;
    array<array<int, CN>, CN> c;
    for(int i = 0; i < CN; ++i)
    {
        for(int j = 0; j < CN; ++j)
        {
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < CN; ++i)
    {
        for(int j = 0; j < CN; ++j)
        {
            for(int k = 0; k < CN; ++k)
            {
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    int cost = 0;
    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            int v;
            cin >> v;
            if(v == 1 || v == -1)
            {
                continue;
            }
            cost += c[v][1];
        }
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
using namespace std;

typedef long long ll;
const ll maxn=50+10;
ll n,m,sum[maxn][maxn],x[maxn],y[maxn],u[maxn],v[maxn];
ll ans=8e18;
map<ll,ll> mx,my;

int main(){
	cin>>n>>m;
	for(ll i=1;i<=n;++i)
		cin>>x[i]>>y[i],mx[x[i]],my[y[i]];
	ll cnt1=0,cnt2=0;
	for(map<ll,ll>::iterator i=mx.begin();i!=mx.end();++i)
		i->second=++cnt1,u[cnt1]=i->first;
	for(map<ll,ll>::iterator i=my.begin();i!=my.end();++i)
		i->second=++cnt2,v[cnt2]=i->first;
	for(ll i=1;i<=n;++i)
		++sum[mx[x[i]]][my[y[i]]];
	for(ll i=1;i<=cnt1;++i)
		for(ll j=1;j<=cnt2;++j)
			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	for(ll i=1;i<=cnt1;++i)
		for(ll j=1;j<=cnt2;++j)
			for(ll k=i;k<=cnt1;++k)
				for(ll l=j;l<=cnt2;++l)
					if(sum[k][l]-sum[k][j-1]-sum[i-1][l]+sum[i-1][j-1]>=m)
						ans=min(ans,(u[k]-u[i])*(v[l]-v[j]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 13.01.2020 23:37:41       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long e, t;
  cin >> n >> e >> t;
  n += 1;
  vector<long long> x(n);
  for (int i = 1; i < n; i++) {
    cin >> x[i];
  }
  vector<long long> dp(n);
  multiset<long long> far;
  multiset<long long> near;
  int j = 0;
  near.insert(dp[0] + t - x[0]);
  for (int i = 1; i < n; i++) {
    while (j < i && 2 * (x[i] - x[j + 1]) >= t) {
      near.erase(near.find(dp[j] + t - x[j]));
      far.insert(dp[j] - x[j] - 2 * x[j + 1]);
      j += 1;
    }
    dp[i] = (long long) 1e18;
    if (!near.empty()) {
      dp[i] = min(dp[i], *near.begin() + x[i]);
    }
    if (!far.empty()) {
      dp[i] = min(dp[i], *far.begin() + 3 * x[i]);
    }
    near.insert(dp[i] + t - x[i]);
  }
  cout << dp[n - 1] + e - x[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 6528
n = int(input())

btn_list = {i:int(input()) for i in range(1,n+1)}

count = 1
right = btn_list[1]

while True:
    if right == 2:
        print(count)
        break
    elif count == n:
        print(-1)
        break
    else:
        count += 1
        right = btn_list[right]

Measured memory_bytes: 17892
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    ll num=0,mi=0;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='(')num++;
        else{
            num--;
        }
        mi=min(mi,num);
    }
    mi=-mi;
    num+=mi;
    for(int i=0;i<mi;i++){
        cout << '(';
    }
    cout <<s;
    for(int i=0;i<num;i++){
        cout << ')';
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<char,int> P;

signed main(){
  string str;
  cin>>str;

  vector<P> A;
  int idx=0;
  while(idx<str.size()){
    char ch = str[idx];
    int cnt=0;
    while(str[idx] == ch) idx++,cnt++;
    A.push_back(P(ch,cnt));
  }

  int ans = 0;
  for(int i=1;i<(int)A.size() - 1;i++){
    if(A[i-1].first!='J' || A[i].first !='O' || A[i+1].first !='I')continue;
    int J = A[i-1].second;
    int O = A[i].second;
    int I = A[i+1].second;
    if(O<=I && O<=J) ans = max(ans,min(O,min(J,I)));
  }
  cout<<ans<<endl;
    
  return 0;
}

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

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

sys.setrecursionlimit(10000000)

T = input()

for loop in range(T):
    N = input()
    S = raw_input()
    S1 = 'N' + S[:N * 2] + 'N'
    S2 = 'N' + S[N * 2:] + 'N'
    sx1 = sx2 = 100000
    gx1 = gx2 = -1
    ans = 0
    for i in range(N + 1):
        if S1[i * 2] == 'Y' or S1[i * 2 + 1] == 'Y':
            ans += 1
            sx1 = min(sx1, i)
            gx1 = i
        if S2[i * 2] == 'Y' or S2[i * 2 + 1] == 'Y':
            ans += 1
            sx2 = min(sx2, i)
            gx2 = i
    if sx1 > sx2:
        ans += 1
    if gx1 < gx2:
        ans += 1
    print N + ans


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

int main()
{
	int n;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++)
		cin >> A[i];

	 int max = A[0];
	 int min = A[0];

	 for(int i = 1; i < n; i++){
		if(A[i] > max)
			max = A[i];
		if(A[i] < min)
			min = A[i];
	 }

	 cout << max - min << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


bool is_finished(string s, char c) {
    REP(i, s.size())if(s[i] != c) return false;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;

    int ans = INT_MAX;
    FOR(c, 'a', 'z') {
        int cnt = 0;
        string s_copy = s;
        while(!is_finished(s_copy, c)) {
            string prev_s = s;
            REP(i, s_copy.size())if(s_copy[i] != c) {
                s_copy.erase(i, 1);
                break;
            }
            REP(i, s_copy.size())if(prev_s[i] == c) s_copy[i] = c;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n;
int a[500010];
int b[500010];

int cnt;

void mg(int l,int r)
{
    int mid=(l+r)/2;

    int tmp=0;
    int i,j;
    cnt+=r-l;
    for(i=l,j=mid;i<mid&&j<r;)
    {
        if(a[i]>a[j])
        {
            b[tmp++]=a[j++];
        }else
        {
            b[tmp++]=a[i++];
        }
    }

    while(i<mid)
    {
        b[tmp++]=a[i++];
    }

    while(j<r)
    {
        b[tmp++]=a[j++];
    }

    for(int i=l;i<r;i++)
    {
        a[i]=b[i-l];
    }
}

void merge_sort(int l,int r)
{
    int mid=(l+r)/2;

    if(l+1==r)
    {
        return;
    }

    merge_sort(l,mid);
    merge_sort(mid,r);
    mg(l,r);
}

int main()
{

    while(scanf("%d",&n)!=EOF)
    {

        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }

        cnt=0;
        merge_sort(0,n);

        for(int i=0;i<n;i++)
        {
            if(i)
            {
                printf(" ");
            }
            printf("%d",a[i]);

        }
        printf("\n%d\n",cnt);
    }

    return 0;
}



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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;

	vector<bool> l1(n, false), l2(n, false);

	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1) l1[b] = true;
		if (b == n) l2[a] = true;
	}

	for(int i = 2; i < n; i++)
	{
		if(l1[i] && l2[i])
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

using namespace std;

int main() {

    int n,x;
    while(scanf("%d%d",&n,&x)&&(n!=0||x!=0))
    {
        int cant=0;
        for(int u=1;u<n+1;u++)
            for(int d=u+1;d<n+1;d++)
                for(int c=d+1;c<n+1;c++)
                {
                    if(u+d+c==x){cant++;}
                }
        cout << cant << "\n";
    }

    return 0;
}



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

int main(void){
  int n;
  cin >> n;
  long cnt = 0;
  
  rep(i,n+1){
  	if(i % 3 != 0 && i % 5 != 0 ){
      cnt += i;
    }
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            List<int> cnt = new List<int>();
            cnt.Add(0);
            for(int i = 0; i < S.Length; i++)
            {
                if(S.Substring(i,1)=="A"|| S.Substring(i, 1) == "C" || S.Substring(i, 1) == "G" || S.Substring(i, 1) == "T")
                {
                    cnt.Add(cnt[i]+1);
                }
                else
                {
                    cnt.Add(0);
                }
            }
            Console.WriteLine(cnt.Max());
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X ;
  int n = 0;
  
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(500*i + 100*j + 50*k == X){
          n++;
        }
      }
    }
  }
  cout << n <<endl;
          
  
}

Measured memory_bytes: 256
object Main extends App {
  def reverse(nums: List[Int]): Int = {
    def accumlator(acc: Int, nums: List[Int]): Int = {
      nums.forall(_ % 2 == 0) match {
        case true => accumlator(acc + 1, nums.map(_ / 2))
        case false => acc
      }
    }
    accumlator(0, nums)
  }
  val sc = new java.util.Scanner(System.in)
  val _ = sc.nextLine()
  val nums = sc.nextLine().split(" ").map(_.toInt).toList
  val ret = reverse(nums)
  println(ret)
}


Measured memory_bytes: 25536
#include <bits/stdc++.h>
const int maxn=1e5+10;
long long n,l,a[maxn];
int main(){
    std::cin>>n>>l;
    for(int i=1;i<=n;i++){
        std::cin>>a[i];
    }
    int temp=0;
    for(int i=2;i<=n;i++){
        if(a[i]+a[i-1]>=l){
            temp=i-1;
            break;
        }
    }
    if(temp){
        std::cout<<"Possible"<<std::endl;
        for(int i=1;i<temp;i++){
            std::cout<<i<<std::endl;
        }
        for(int i=n-1;i>temp;i--){
            std::cout<<i<<std::endl;
        }
        std::cout<<temp;
    }
    else {
        std::cout<<"Impossible";
    }
    return 0;
}


Measured memory_bytes: 1536
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
int n;
char s[10];
int main(){
        scanf("%d/%s",&n,s);
        printf("%d/%s",n+1,s);
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

string repl(string &s, string &a, string &b){
	string res;
	rep(i, s.size()){
		bool ok = false;
		if(i+a.size() <= s.size()){
			ok = true;
			rep(j, a.size()) if (s[i + j] != a[j]){
				ok = false;
				break;
			}
		}
		if (ok) res += b, i += a.size() - 1;
		else res += s[i];
	}
	return res;
}

int main(){
	int n;
	while (cin >> n, n){
		vector<string> vs(n), vt(n);
		rep(i, n){
			cin >> vs[i] >> vt[i];
		}
		string s, t;
		cin >> s >> t;
		int len = t.size();
		
		set<string> st;
		queue<pair<string, int>> q;
		st.insert(s);
		q.push(MP(s, 0));
		int ans = -1;
		while (!q.empty()){
			auto p = q.front();
			q.pop();

			if (p.first == t){
				ans = p.second;
				break;
			}

			if (p.first.size() == len) continue;
			rep(i, n){
				string x = repl(p.first, vs[i], vt[i]);
				if (x.size() > len || st.count(x)) continue;
				st.insert(x);
				q.push(MP(x, p.second + 1));
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1452
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, a[200000], b[200000];
	cin >> n;
	int maxi = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
		maxi = max(maxi, a[i]);
	}
	sort(b, b + n);
	int maxi2 = b[n - 2];
	
	for (int i = 0; i < n; i++) {
		if (a[i] == maxi) {
			cout << maxi2 << endl;
		}
		else {
			cout << maxi << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll cnt=0;
  string s;
  cin>>s;
  if(s[0]=='1') cnt++;
  if(s[1]=='1') cnt++;
  if(s[2]=='1') cnt++;
 cout<<cnt<<endl;
}


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

int main() {
	int t;
	while (cin >> t, t) {
		int n;
		cin >> n;

		int sa = 0;
		for (int i = 0;i < n;i++) {
			int s, f;
			cin >> s >> f;
			sa += (f - s);
		}

		if (sa < t)cout << t - sa << endl;
		else cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

static const int N = 100;
static const int INFTY = (1<<21);

main(){
  int n, ele, sum=0;
  int x, Mx, i, j;
  int M[N][N], a[N], b[N], X[N];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &ele);
      M[i][j] = (ele==-1)?INFTY:ele;
    }
  }

  for ( i = 0; i < n; i++ ) {
    a[i] = INFTY;
    b[i] = -1;
    X[i] = 0;
  }
  a[0] = 0;

  while(1){
    Mx = INFTY;
    x = -1;
    for ( i = 0; i < n; i++ ){
      if ( Mx > a[i] && !X[i] ){
        x = i;
        Mx = a[i];

      }
    }
    if ( x == -1 ) 
        break;

    X[x] = 1;
    for ( i = 0; i < n; i++ ){
      if ( !X[i] && M[x][i] != INFTY ){
        if ( a[i] > M[x][i] ){
          a[i] =  M[x][i];
          b[i] = x;

        }
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    if ( b[i] != -1 ) sum += M[i][b[i]];
  }

  printf("%d\n", sum);

  return 0;
}


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

int main(){
int i,fib[45],n;
cin>>n;
fib[0]=1,fib[1]=1;
for(i=2;i<=n;i++){
fib[i]=fib[i-1]+fib[i-2];
}
cout<<fib[n]<<endl;
}



Measured memory_bytes: 3104
N = int(input())
wordlist = []
for w in range(N):
    wordlist.append(input())

if len(set(wordlist)) != N:
    print('No')
else:
    for idx in range(1, N):
        if wordlist[idx-1][-1] != wordlist[idx][0]:
            print('No')
            break
    else:
        print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

class UnionFindTree {
   public:
    vector<int> parent;
    vector<int> siz;

    UnionFindTree(int n) {
        siz.resize(n, 1);
        parent.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); int ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        parent[ry] = rx;
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

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

    UnionFindTree uft(N);
    REP(i, 0, M) {
        int x, y, z; cin >> x >> y >> z;
        uft.unite(--x, --y);
    }

    bool used[N] = {}; int ans = 0;
    REP(i, 0, N) {
        if (used[uft.root(i)]) continue;
        used[uft.root(i)] = true;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace _20190316_01 {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToList();
            line.Insert(0, 0);
            var ans = 0;
            for (int i = 1; i < line.Count; i++) {
                if (line[i] > line[i - 1]) {
                    ans += line[i] - line[i - 1];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1000000000

int fact(int a){
    int num=1;
    while(a>=1){
        num*=a;
        a--;
    }
    return num;
}

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

    vector<pair<int,int>> P(n);
    for(int i=0;i<n;i++){
        cin>>P[i].first>>P[i].second;
    }

    double ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=sqrt((P[i].first-P[j].first)*(P[i].first-P[j].first)+(P[i].second-P[j].second)*(P[i].second-P[j].second));
        }
    }

    printf("%.10f\n",2.0*ans/n);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int c[12];
int a[12][12];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, x;
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int mn = 1e9;
  for (int i = 0; i < (1 << n); i++) {
    bitset<12> b = i;
    // cout << b << endl;
    int tmp[12], sum = 0;
    fill(tmp, tmp + 12, 0);
    for (int j = 0; j < n; j++) {
      if (b[j]) {
        sum += c[j];
        for (int k = 0; k < m; k++) {
          tmp[k] += a[j][k];
        }
      }
    }
    // for (int j = 0; j < m; j++) {
    //   cout << tmp[j] << ' ';
    // }
    // cout << endl;
    for (int j = 0; j < m; j++) {
      if (tmp[j] < x) {
        goto e;
      }
    }
    mn = min(sum, mn);
  e:
    void(0);
  }
  cout << (mn == 1e9 ? -1 : mn) << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,a[MAXN],last,q[MAXN],head=1,tail;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)a[i]=read();
	sort(a+1,a+n+1);
	Rep(i,2,n){
		if(a[i]==a[i-1])last^=1;
		else{
			int c=~(a[i]-a[i-1])&1;
			if(c!=last)q[++tail]=a[i-1]-last+i;
			last=0;
		}while(head<=tail&&q[head]<=i)head++;
	}
	puts(last^(a[n]&1)^((tail-head)&1)?"First":"Second");
	return 0;
}




Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL dp[MAXN];

int main(){
  fio();
  int n,w; cin>>n>>w;
  for1(i,MAXN-1) dp[i] = 1e18;
  forn(i,n){
  	LL a,b; cin>>a>>b;
  	for(LL i = MAXN; i>=0;i--){
  		if(i+b>MAXN) continue;
  		dp[i+b] = min(dp[i+b], dp[i] + a);
  	}
  }
  LL an = 0;
  forn(i,MAXN){
  	if(dp[i]>w) continue;
    an = max(an,(LL) i);
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 1024
# cook your dish here
# from math import * 
#for _ in range(int(input().strip())):


n,m = map(int,input().split())

denom=1 
num=(n-m)*100+m*1900
ans=0
for i in range(1,10000):
    numer=num*i
    if i>1:
        numer=((2**m-1)**((i-1)))*numer
    denom*=(2**m)
    ans= ans + numer/denom
    #print(ans)
print(round(ans))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >>n;
    for(int i=1;i<=n;i++)
    {
        int x=i;
        if(x%3 == 0)
        {
            cout << " "<<i;
          	continue;
        }
        while (x)
        {
        	if(x%10 == 3)
            {
            	cout << " "<<i;
                x=0;
            }
      		x /= 10;
        }
    }
    cout <<endl;
}


Measured memory_bytes: 3120
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[allow(unused_macros)]
macro_rules! echo {
    ($ x : expr ) => {
        println!("{}", $x);
    };
}

macro_rules! YesNo {
    ($ flag : expr ) => {
        if $flag {
            "Yes"
        } else {
            "No"
        }
    };
}

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        S: Chars
    }
    echo!(YesNo!(S[2] == S[3] && S[4] == S[5]));
}


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

int main(){
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n){
    if( (i+1)%3!=0 && (i+1)%5!=0 ) sum += i+1;
  }
  
  cout << sum << endl;
    
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{ int a[2];
    for(int i=0; i<2; i++)
    scanf("%d",&a[i]);
    if(a[0]==1 && a[1]==2)
       printf("3");
    else if(a[0]==1 && a[1]==3)
    printf("2");
    else if(a[0]==2 && a[1]==3)
    printf("1");
    else if(a[0]==3 && a[1]==1)            printf("2");
    else if(a[0]==3 && a[1]==2)
    printf("1");
    else if(a[0]==2 && a[1]==1)
    printf("3");


    
    
    
    
}

Measured memory_bytes: 128
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[200000];

int main()
{
  int i,j,n,k,ans;
  scanf("%d%d",&n,&k);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  if (n==k)
  {
    printf("1\n");
    return 0;
  }
  ans=(n-k-1)/(k-1)+1+1;
  printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define N 4005
int n,k,c[N][N],pw[N];
const int mod=998244353;
inline void reduce(int&x){x-=mod,x+=x>>31&mod;}
inline int upd(int x){return reduce(x),x;}
inline void init(int n=4000){
	pw[0]=c[0][0]=1;
	rep(i,1,n){
		c[i][0]=c[i][i]=1;
		rep(j,1,i-1) c[i][j]=upd(c[i-1][j]+c[i-1][j-1]);
	}
	rep(i,1,n) pw[i]=upd(pw[i-1]<<1);
}
inline int solve(int A,int B,int C,int ret=0){
	if(B<0) return 0;
	rep(i,std::max(0,1-B),std::min(A,C))
		(ret+=1ll*c[A][i]*pw[i]%mod*c[B+C-1][B+i-1]%mod)%=mod;
	return ret;
}
int main(){
	std::cin>>k>>n;
	init();
	rep(i,2,k<<1){
		int l=std::max(i-k,1),r=std::min(i-1,k);
		int now=r-l+1,ret=0;
		if(now<0) now=0;
		if(i&1) ret=solve(now>>1,k-now,n);
		else
			ret=upd(solve(now-1>>1,k-now,n)+solve(now-1>>1,k-now,n-1));
		std::cout<<ret<<'\n';
	}
	return 0;
}

Measured memory_bytes: 48876
#include <iostream>

using namespace std;
#define MAX 200000
#define S 2000000000
long long cnt;
void Merge(int A[],int left,int mid,int right){
    int L[MAX/2+1],R[MAX/2+1];
    int l1 = mid-left+1;
    int l2 = right-mid;
    for(int i=0;i<l1;i++){
        L[i] = A[left+i];
    }
    for(int i=0;i<l2;i++){
        R[i] = A[mid+i+1];
    }
    L[l1] = R[l2] = S;
    int i=0,j=0;
    for(int k=left;k<=right;k++){
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
            cnt+=l1-i;
        }
    }
}
void Mergesort(int A[],int left,int right){
    if(left<right){
        int mid = (left+right)/2;
        Mergesort(A,left,mid);
        Mergesort(A,mid+1,right);
        Merge(A,left,mid,right);
    }
}
int main()
{
    int n;
    cin>>n;
    int A[MAX];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cnt = 0;
    Mergesort(A,0,n-1);
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 4632
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)
    puts("Yes");
  else
    puts("No");
  return 0;
}

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

N = int(input())

a = []

for i in range(N):
    a.append(input().split())

Y = 0

for figure, kind in a:

    if kind == 'JPY':
        Y += int(figure)
    else:
        figure = float(figure) * 380000.00000000
        Y += figure
print(Y)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;
ll sl();

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  vector<int> ord(N);
  rep(i, N) cin >> A[i] >> B[i], ord[i] = i;
  sort(ord.begin(), ord.end(), [&](int i, int j) {
    return B[i] < B[j];
  });
  ll curr = 0;
  for (int i : ord) {
    if (curr + A[i] <= B[i]) {
      curr += A[i];
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

ll sl() {
  ll x;
  cin >> x;
  return x;
}

struct init {
  init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} init;


Measured memory_bytes: 4224
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int K =sc.nextInt();
		int c=0;
		int[]k = new int[N];
		for(int i=0;i<N;i++) {
			 k[i]= sc.nextInt();
			
		}
		Arrays.sort(k);
		for(int i=0;i<K;i++) {
			c+=k[i];
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 38972
//ll n_kai[pow(10.0, 5.0)]; なんでだめなの？


#include<iostream>
#include<queue>
#include<vector>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



int main(){
	int n, x, y;cin >> n >> x >> y;
	--x;--y;
	vector<int> cnt(n, 0);
	for(int i = 0;i < n;++i){
		vector<int> d(n, INF);
		queue<int> q;q.push(i);
		d[i] = 0;
		while(!q.empty()){
			int v = q.front();q.pop();

			auto bfs = [&](int v, int nv) {
				if(d[nv] != INF) return;
				q.push(nv);
				d[nv] = d[v] + 1;
				++cnt[d[nv]];
			};

			if(v-1 >= 0){
				bfs(v, v-1);
			}
			if(v+1 < n){
				bfs(v, v+1);
			}
			if(v == x){
				bfs(v, y);
			}
			if(v == y){
				bfs(v, x);
			}
		}
	}
	for(int i = 1;i < n;++i){
		cnt[i] /= 2;
		cout << cnt[i] << endl;
	}

	return 0;
}


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

vector<int> dd(9,0);

int ipow(int x,int y){
  int q=1;
  for(int i=0;i<y;i++){
    q*=x;
  }
  return q;
}

int thr(int X,int S){
  vector<int> cnt(3,0);
  for(int i=0;i<S;i++){
    dd[i]=X%3;
    cnt[X%3]++;
    X/=3;
  }
  int ans=0;
  for(int i=0;i<S;i++){
    ans+=(dd[i]*2+3)*ipow(10,i);
  }
  if(cnt[0]*cnt[1]*cnt[2]){
    return ans;
  }else
    return 1000000000;
}

int main(){
  int N; cin >> N;
  int sftc=0;
  for(int i=3;i<10;i++){
    for(int j=0;j<ipow(3,i);j++){
      if(thr(j,i)<=N)
        sftc++;
    }
  }
  cout<<sftc<<endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            if l[k] < l[i] + l[j]:
                ans += 1

print(ans)


Measured memory_bytes: 9176