akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int X, Y; cin >> X >> Y;
    int ans;
    if(X % Y == 0) ans = -1;
    else ans = X;
    cout << ans << endl;

    return 0;
}


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

int main(){
	
	int n, x;
	cin >> n;
	int count = 0, flag = 0;
	for(int i = 0; i < n; ++i){
		cin >> x;
		if(x%2 == 0){
			count++;
			if(x%3 == 0 || x%5== 0) flag++;
		}
	}
	if(flag == count) cout <<"APPROVED";
	else cout <<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 1<<30;
const ll LINF = 1LL<<61;

vector<vector<P>> G;
vector<int> ans;

void func(int cur, int p, int c)
{
    int nc = 1;
    for(auto [to, e]:G[cur])
    {
        if(to == p) continue;
        if(nc == c) nc++;
        ans[e] = nc;
        func(to, cur, nc);
        nc++;
    }
    return;
}

int main()
{
    int n;
    cin >> n;
    G.assign(n, vector<P>(0));
    ans.assign(n-1, 0);
    rep(i,n-1)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v, i);
        G[v].emplace_back(u, i);
    }
    func(0, -1, 0);
    ll ans1 = 0;
    for(auto x:ans) chmax(ans1, x);
    cout << ans1 << endl;
    for(auto x:ans) cout << x << "\n";
    

    return 0;
}

Measured memory_bytes: 11084
local n=io.read("n")
local a={}
for i=1,n do
    a[i]={}
    for j=1,n do
        a[i][j]=io.read("n")
    end
end

local dp={}
for i=0,n do
    dp[i]={}
end

local bit=require("bit")
local band=bit.band
local bxor=bit.bxor
local lshift=bit.lshift
local mod=1000000007
local function solve(i,S)
    if i==n then
        return 1
    end
    if dp[i][S] then
        return dp[i][S]
    end
    local pattern=0
    for j=0,n-1 do
        if band(S,lshift(1,j))<1 and a[i+1][j+1]>0 then
            pattern=pattern+solve(i+1,bxor(S,lshift(1,j)))
            pattern=pattern%mod
        end
    end
    dp[i][S]=pattern
    return dp[i][S]
end

print(solve(0,0))

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

using namespace std;

typedef long long int ll;

const int NMax = 2e5 + 5;
const int LIM = 1e9;


int main(){

    /*#ifndef ONLINE_JUDGE
    freopen("debug.in", "r", stdin);
    #endif // ONLINE_JUDGE*/

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c;
    cin >> a >> b >> c;

    if(a >= b && a >= c) {
        if(a == b + c) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return 0;
    }
    if(b >= a && b >= c) {
        if(b == a + c) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return 0;
    }
    if(c >= b && c >= a) {
        if(c == b + a) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return 0;
    }

    cout << "\n";
    return 0;

}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int p, q, r;
    cin >> p >> q >> r;

    cout << p + q + r - max({p,q,r}) << endl;

    return 0;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7

def factorial(n, mod):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
        fact %= mod
    return fact

N, M = map(int,input().split())
if abs(N - M) > 1:
    print(0)
else:
    ans = 1
    ans *= factorial(N, mod)
    ans *= factorial(M, mod)
    ans *= 2 - abs(N - M)
    ans %= mod
    print(ans)

Measured memory_bytes: 9196
#include <stdio.h>

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

Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int count = 0;
  while(a > 0 && c > 0){
    if(count % 2 == 0){
      c-=b;
    }else{
      a-=d;
    }
    // cout << a << " " << c << endl;
    count++;
  }
  if(a <= 0){
    cout << "No" << endl;
  }else if(c <= 0){
    cout << "Yes" << endl;
  }
  return 0;
}


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

#define ll 				long long
#define vi 				vector<ll>
#define vvi				vector<vector<ll>>
#define mii 			map<ll,ll>
#define rev(a); 		reverse(a.begin(), a.end());
#define sortv(a); 		sort(a.begin(), a.end());
#define sortd(a); 		sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) 		for (int i = (a); i < (b); i++)
#define ROF(i,a,b) 		for (int i = (b)-1; i >= (a); i--)
#define pb 				push_back
#define mp 				make_pair
#define printv(a);		FOR(_Q,0,(int)(a).size()) cout<<(a)[_Q]<<" "; cout<<'\n';

ll MOD = 1000000007;
ll INF = LLONG_MAX;

/*****************************************************************************/
const int N = 200006;
ll fact[N];
ll power(ll x, ll y, ll m) { // x ^ y
    if (y == 0) return 1; 
    ll p = power(x, y/2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; 
} 
ll inv(ll a) { return power(a, MOD - 2, MOD) % MOD; } 
ll choose(ll n, ll k) { if (k>n) return 1; else return (((fact[n] * inv(fact[k])) % MOD) * inv(fact[n-k])) % MOD; }

void solve() {
	
}

signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, k; cin>>n>>k;
	ll cum[n+1];
	cum[0]=0;
	FOR(i,1,n+1) {
		cum[i]=cum[i-1]+i;
		// cum[i]%=MOD;
	}
	// FOR(i,0,n+1) cout<<cum[i]<<" ";cout<<endl;
	ll out = 1;
	FOR(i,k,n+1) {
		out += cum[n]-cum[n-i] - cum[i-1]+1;
		out%=MOD;
		// cout<<i<<" "<<cum[n]-cum[n-i]<<" "<<cum[i-1]<<endl;
	}

	cout<<out;
}

Measured memory_bytes: 5188
#!/usr/bin/env pypy3

import sys
sys.setrecursionlimit(10 ** 6)
memo = [1, 1]
def fact(n):
	if len(memo) > n:
		return memo[n]
	else:
		for i in range(len(memo), n+1):
			memo.append(memo[i-1] * i)
		return memo[n]
def nCr(n, r):
	a = 1
	for i in range(r):
		a *= n - i
	return a //fact(r)
def main():
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	cnt = {}
	sumcase = 0
	for i in range(n):
		cnt[a[i]] = 0
	for i in range(n):
		cnt[a[i]] += 1
	# print(a, cnt)
	for ai in cnt:
		if cnt[ai] >= 2:
			sumcase += nCr(cnt[ai], 2)
	for i in range(n):
		if cnt[a[i]] == 2:
			print(sumcase - nCr(cnt[a[i]], 2))
		elif cnt[a[i]] > 2:
			#print("hoge", a,  cnt[a[i]], sumcase, cnt)
			print(sumcase - nCr(cnt[a[i]], 2) + nCr(cnt[a[i]]-1, 2))
		else:
			print(sumcase)
main()

Measured memory_bytes: 90316
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    ll N, M;
    cin >> N >> M;
    ll L = 1, Li, R = N, Ri;
    for(int i = 0; i < M; i++){
        cin >> Li >> Ri;
        L = L<Li ? Li : L;
        R = R>Ri ? Ri : R;
    }
    cout << (R - L + 1 > 0 ? R - L + 1 : 0) << endl;
    return 0;
}

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

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

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    string S; cin >> S;
    deque<char> V;
    for(auto c : S)
        V.push_back(c);

    int Q; cin >> Q;

    bool f = false;
    while(Q--){
        int T; cin >> T;
        if(T == 1) f = !f;
        else{
            int fl; char c; cin >> fl >> c;
            fl--;

            if(fl == 0 and f) V.push_back(c);
            else if(fl == 0) V.push_front(c);
            else if(f) V.push_front(c);
            else V.push_back(c);
        }
    }
    if(f) reverse(all(V));
    for(auto v : V)
        cout << v;
    cout << endl;

    return 0;
}

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

int main(){
  long long int A, B, C;
  cin >> A >> B >> C;
  
  int ans = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
    if (A == B && B == C){
      cout << "-1" << endl;
      exit(0);
    }
    
    long long int pA = (B + C) / 2, pB = (A + C) / 2, pC = (A + B) / 2;
    A = pA;
    B = pB;
    C = pC;
    
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 3050;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
int n , dp[maxn][maxn], ans;
char c[maxn];
//dp[i][j]  安排完前i个数第i个数是j的方案
int main()
{
    cin >> n;
    scanf("%s",c+1);
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++){
        if(c[i-1] == '<'){
            for(int j = 2; j <= i; j++){
                dp[i][j] = (dp[i][j-1]+dp[i-1][j-1]) % mod;
            }
        }else {
            for(int j = i-1; j ; j--){
                dp[i][j] = (dp[i][j+1]+dp[i-1][j]) % mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        add(ans, dp[n][i]);
    }
    cout << ans << endl;
}

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

int main(){
    int i, j, k, n, b, flag = 0, a[3][3], count[3][3] = {};
    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(k=0; k<n; k++){
        cin >> b;
        for(i=0; i<3; i++){
            for(j=0; j<3; j++){
                if(a[i][j] == b) count[i][j]++;
            }
        }
    }
    for(i=0; i<3; i++){
        if(count[i][0] > 0 && count[i][1] > 0 && count[i][2] > 0) flag = 1;
        if(count[0][i] > 0 && count[1][i] > 0 && count[2][i] > 0) flag = 1;
    }
    if(count[0][0] > 0 && count[1][1] > 0 && count[2][2] > 0) flag = 1;
    if(count[0][2] > 0 && count[1][1] > 0 && count[2][0] > 0) flag = 1;
    if(flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int c = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) c++;
	}
	
	cout << c << endl;
	
	return 0;
}

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

int main(void) {

    int N, K;
    cin >> N >> K;

    vector<int> p;
    for (int i = 0; i < N; i++) {
        int input;
        cin >> input;
        p.push_back(input);
    }

    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; i++) ans += p[i];

    cout << ans << '\n';


}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define hw_Max 1400 

int a[hw_Max][hw_Max];
int dp[hw_Max][hw_Max];

int main() {
	int h,w,i,j,maxWidth;
	
	scanf("%d %d",&h,&w);
	
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			scanf("%d",&a[i][j]);
		}
	}
	
	maxWidth=0;
	
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			dp[i][j]=(a[i][j]+1)%2;
			maxWidth=maxWidth | dp[i][j];
		}
	}
	
	for(i=1;i<h;i++) {
		for(j=1;j<w;j++) {
			if(a[i][j]) {
				dp[i][j]=0;
			} else {
				dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
				maxWidth=max(maxWidth,dp[i][j]);
			}
		}
	}
	
	printf("%d\n",maxWidth*maxWidth);
	
	return 0; 
}


Measured memory_bytes: 18464
I,O,T,J,L,S,Z = map(int,input().split())
p = 2*(I//2 + J//2 + L//2)
if I and J and L:
    p = max(p, 2*((I-1)//2 + (J-1)//2 + (L-1)//2) + 3)
print(O + p)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    int UP,DOWN;
    UP=(S[0]-'0')*10+S[1]-'0';
    DOWN=(S[2]-'0')*10+S[3]-'0';
    if(UP==0&&DOWN==0)cout<<"NA"<<endl;
    if(UP==0&&1<=DOWN&&DOWN<=12)cout<<"YYMM"<<endl;
    if(UP==0&&13<=DOWN&&DOWN<=99)cout<<"NA"<<endl;
    if(1<=UP&&UP<=12&&DOWN==0)cout<<"MMYY"<<endl;
    if(1<=UP&&UP<=12&&1<=DOWN&&DOWN<=12)cout<<"AMBIGUOUS"<<endl;
    if(1<=UP&&UP<=12&&13<=DOWN&&DOWN<=99)cout<<"MMYY"<<endl;
    if(13<=UP&&UP<=99&&DOWN==0)cout<<"NA"<<endl;
    if(13<=UP&&UP<=99&&1<=DOWN&&DOWN<=12)cout<<"YYMM"<<endl;
    if(13<=UP&&UP<=99&&13<=DOWN&&DOWN<=99)cout<<"NA"<<endl;
}


Measured memory_bytes: 384
N = int(input())
a = [''.join(sorted(list(input()))) for _ in range(N)]
import collections
c = collections.Counter(a)
c_ls = list(c.values())
ans = 0
for i in range(len(c_ls)):
  ans += c_ls[i] * (c_ls[i]-1)//2
print(ans)


Measured memory_bytes: 19760
N = int(input())
h = list(map(int, input().split(" ")))

c = {}
c[0] = 0
c[-1] = float('inf')

for i in range(1, N):
    c[i] = min(c[i-1] + abs(h[i]-h[i-1]), c[i-2] + abs(h[i] - h[i-2]))

print(c[N-1])


Measured memory_bytes: 23228
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#include <ext/pb_ds/tree_policy.hpp>
#define forn(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define TEST_CASE   int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool check(int n){
    int cnt = 0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}

vi tre[100000];

bool ans = true;
bool vis[100000] = { false };
void dfs(int s){
    vis[s]=true;
    if(tre[s].size()>1){
        int cnt = 0;
        for(int i=0;i<tre[s].size();i++){
            int child = tre[s][i];
            if(tre[child].size()==1){
                cnt++;
            }
        }
        if(cnt<3){
            ans=false;
        }
    }
    for(int i=0;i<tre[s].size();i++){
        if(vis[tre[s][i]]==false)
            dfs(tre[s][i]);
    }
}
void solve(){
ll n,b,r;
cin>>n>>b>>r;
    ll k =n/(b+r);
    cout<<b*k+(min(n%(b+r),b))<<endl;


}


int main(){
   //TEST_CASE
   solve();
return 0;
}



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

int main()
{
	string s;
	cin >> s;
	if (s == "SUN") cout << 7;
	else if (s == "MON") cout << 6;
	else if (s == "TUE") cout << 5;
	else if (s == "WED") cout << 4;
	else if (s == "THU") cout << 3;
	else if (s == "FRI") cout << 2;
	else cout << 1;
}


Measured memory_bytes: 764
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
  print(max(A))
  exit()
def f(x):
  cnt=0
  for i in A:
    if i%x==0:
      cnt+=i//x-1
    else:
      cnt+=(i//x)
  if cnt<=K:
    return True
  else:
    return False
ok=1
ng=1000000000
for i in range(50):
  mid=(ok+ng)//2
  if f(mid):
    ng=mid
  else:
    ok=mid
print(ng)

Measured memory_bytes: 93628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

#define endl "\n"

bool vis[N][3];
vector<int> G[N];
int n,m,S,T;

struct node{
	int now,t;
};

void bfs(){
	node p,q;
	p.now=S;
	p.t=0;
	vis[p.now][p.t]=1;
	queue<node> Q;
	Q.push(p);
	while(!Q.empty()){
		q=Q.front();
		Q.pop();
		if(q.now==T&&q.t%3==0) {
			cout<<q.t/3<<endl;
			return;
		}
		int t=(q.t+1)%3,v=q.now,u;
		for(int i=0;i<G[v].size();i++){
			u=G[v][i];
			if(!vis[u][t]){
				vis[u][t]=1;
				p.now=u;
				p.t=q.t+1;
				Q.push(p);
			}
		}
	}
	cout<<-1<<endl;
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	memset(vis,0,sizeof(vis));
	int v,u;
	while(m--){
		cin>>v>>u;
		G[v].push_back(u);
	}
	cin>>S>>T;
	bfs();
	return 0;
}

Measured memory_bytes: 6016
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b;
  cin >> a >> b;

  cout << 6 - a- b;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import math
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
conf=0
for i in range(N):
    if i==N-1:
        if a[i]==x:
            conf=conf+1
    else:
        if a[i]<=x:
            conf=conf+1
            x=x-a[i]
        else:
            break
print(conf)

Measured memory_bytes: 38384
h = Hash.new(-1)
while s = gets
	n,r = s.split
	next if h[n]>=0
	if r == 'AC'
		h[n] = -1-h[n]
	elsif r == 'WA'
		h[n] -= 1
	end
end
w = 0
a = h.values.select {|n| if n>=0; w+=n; end}
puts [a.size,w] * ' '

Measured memory_bytes: 16764
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	k := 0
	for i := 1; i <= n+10; i++ {
		j := i * (i - 1) / 2
		if j == n {
			k = i
			break
		}
	}

	if k == 0 {
		fmt.Println("No")
		return
	}

	c := 1
	ss := make([][]int, k)
	for i := 0; i < k-1; i++ {
		for j := i + 1; j < k; j++ {
			ss[i] = append(ss[i], c)
			ss[j] = append(ss[j], c)
			c++
		}
	}

	fmt.Println("Yes")
	fmt.Println(k)
	for i := 0; i < len(ss); i++ {
		l := len(ss[i])
		fmt.Printf("%d", l)
		for j := 0; j < l; j++ {
			fmt.Printf(" %d", ss[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>

int main()
{
    int n;
    long long h;
    scanf("%lld %d",&h,&n);
    int a[n];
    int add=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        add+=a[i];
    }
    if(add<h)printf("No");
    else printf("Yes");
}



Measured memory_bytes: 512
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- getl $ wrds toInt
  unless (all (==0) xs) $ do
    putStrLn $ solve xs
    main

data Expr = N Int | Op Char Expr Expr

f1 :: [Char] -> [Int] -> Expr
f1 [o1,o2,o3] [n1,n2,n3,n4] = Op o2 (Op o1 (N n1) (N n2)) (Op o3 (N n3) (N n4))

f2 :: [Char] -> [Int] -> Expr
f2 [o1,o2,o3] [n1,n2,n3,n4] = Op o3 (Op o2 (Op o1 (N n1) (N n2)) (N n3)) (N n4)

f3 :: [Char] -> [Int] -> Expr
f3 [o1,o2,o3] [n1,n2,n3,n4] = Op o3 (Op o1 (N n1) (Op o2 (N n2) (N n3))) (N n4)

f4 :: [Char] -> [Int] -> Expr
f4 [o1,o2,o3] [n1,n2,n3,n4] = Op o1 (N n1) (Op o3 (Op o2 (N n2) (N n3)) (N n4))

f5 :: [Char] -> [Int] -> Expr
f5 [o1,o2,o3] [n1,n2,n3,n4] = Op o1 (N n1) (Op o2 (N n2) (Op o3 (N n3) (N n4)))

calc :: Expr -> Int
calc (N x) = x
calc (Op '+' l r) = calc l + calc r
calc (Op '*' l r) = calc l * calc r
calc (Op '-' l r) = calc l - calc r

instance Show Expr where
  show (N x) = show x
  show (Op o l r) = "("++ show l ++ [' ',o,' '] ++ show r ++ ")"

solve :: [Int] -> String
solve xs
  | null ls = "0"
  | otherwise = show . head $ ls
  where
    ls = filter ((== 10) . calc) [f [o1,o2,o3] ns | ns <- permutations xs, o1 <- "*+-", o2 <- "*+-", o3 <- "*+-", f <- [f1,f2,f3,f4,f5]]

toInt :: String -> Int
toInt s = read s

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4104
n, x, m = map(int, input().split())
a = [-1]*10**5; a[x%m] == 0; b = [x%m]
for i in range(1, n):
    x = x**2%m
    if a[x%m] == -1:
        a[x%m] = i; b.append(b[-1]+x%m)
    else:
        s = a[x%m]-1; g = i-1
        print((b[g]-b[s])*((n-s-1)//(g-s))+b[s+(n-s-1)%(g-s)])
        break
else: print(b[-1])

Measured memory_bytes: 13656
#include <iostream>
using namespace std;
int main(){
  int a,n;
  long max,sam;
  while(cin>>a,0!=a){
    cin>>n;
    max=sam=n;
    for(int i=0;i<a-1;i++){
      cin>>n;
      if(sam<0)sam=n;
      else{
        sam+=n;
      }
      if(sam>max)max=sam;
    }
    cout<<max<<endl;
  }
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

template<int mod> class modint
{   
private:
    int val;
public:
    int value(){ return val; }
    modint(int x=0){ val=x%mod; }
    modint pow(int n){
        modint res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    modint inv(){ return pow(mod-2); }
    modint& operator+=(modint rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator-=(modint rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator*=(modint rhs){ val=val*rhs.val%mod; return *this; }
    modint& operator/=(modint rhs){ *this*=rhs.inv(); return *this; }
    modint operator+(modint rhs){ return modint(val)+=rhs; }
    modint operator-(modint rhs){ return modint(val)-=rhs; }
    modint operator*(modint rhs){ return modint(val)*=rhs; }
    modint operator/(modint rhs){ return modint(val)/=rhs; }
};

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

    using mint=modint<1000000007>;
    int N,K; cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    vector<vector<mint>> dp(N+1,vector<mint>(K+1));
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=K;j++){
            /*
            for(int k=0;k<=a[i];k++){
                if(j+k<=K) dp[i+1][j+k]+=dp[i][j];
            }
            */
            int l=j,r=j+a[i];
            dp[i+1][l]+=dp[i][j];
            if(r+1<=K) dp[i+1][r+1]-=dp[i][j];
        }
        for(int j=0;j<K;j++){
            dp[i+1][j+1]+=dp[i+1][j];
        }
    }
    cout<<dp[N][K].value()<<endl;
    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
void solve(){
	ll n,m,k;
	ll count=0;
	cin>>n>>m>>k;
	vector<ll> prefA(200005),prefB(200005);
	prefA[0]=0;
	prefB[0]=0;
	for(int i=1;i<=n;i++){
		ll temp;
		cin>>temp;
		prefA[i]=prefA[i-1]+temp;
	}
	for(int i=1;i<=m;i++){
		ll temp;
		cin>>temp;
		prefB[i]=prefB[i-1]+temp;
	}
	for(int i=0;i<=n;i++){
		if(prefA[i]>k)break;
		ll rem = k - prefA[i];
		ll l=0,r=m,ans,mid;
		while(l<=r){
			mid=(l+r)/2;
			if(prefB[mid]<=rem){
				l=mid+1;
				ans=mid;
			}else{
				r=mid-1;
			}
		}
		count=max(count,i+ans);
	}
	cout<<count<<"\n";
}
int main(){
	FASTIO
	solve();
	return 0;
}


Measured memory_bytes: 6360
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=998244353;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=998244353;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)

int32_t main()
{
    IOS
  
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
}       


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret), greater<int>());
  return (ret);
}

int main() {
    int n,k;
    int ans=1;
    cin >> n>>k;
    int a[n];
    fr(i,n){
      cin>>a[i];
    }
    int sum=0;
    fr(i,n){
      sum+=a[i];
    }
	vector<int> ret = divisor(sum);
    int size=ret.size();
    fr(i,size-1){
      int now = ret[i];
      int b[n];
      int sumf = 0;
      fr(i,n){
       b[i]=a[i]%now;
       sumf+=b[i];
      }
      sort(b,b+n);
      int sums = sumf/now;
      int kai=0;
      fr(i,n-sums){
        kai+=b[i];
      }
        
      if(k>=kai){
        ans=now;
        break;
      }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,p,i,cnt=0;
  char s[100010];
  scanf("%s",s);
  n=strlen(s);
  for(i=0;i<n;i++)
    if(s[i]=='p') cnt++;
  printf("%d\n",n/2-cnt);
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getLine >>= putStrLn

solve :: String -> String
solve ss = take 4 ss ++ (' ' :  drop 4 ss)

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[10];
        int i=0;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                String tokens = line;
                arg[i] = Integer.parseInt(tokens);
                i++;
            }
        }



		int[] store=new int[3];
		for(i=0;i<10;i++){
			int s=arg[i];
			for(int j=0;j<3;j++){
				if(s>store[j]){
					if(j==0){
						store[j+2]=store[j+1];
						store[j+1]=store[j];
						store[j]=s;
						break;
					}else if(j==1){
						store[j+1]=store[j];
						store[j]=s;
						break;
					}else{
						store[j]=s;
					}
				}
			}
		}
		for(i=0;i<store.length;i++){
			System.out.println(store[i]);
		}
	}

}

Measured memory_bytes: 24268
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, n, a[10];

	i=0;
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			i--;
			printf("%d\n", a[i]);
			continue;
		}
		a[i] = n;
		i++;
	}
	return 0;
}

Measured memory_bytes: 600
s = input()
n1 = int(s[:2])
n2 = int(s[2:])

if n1>=1 and n1<=12 and n2>=1 and n2<=12:
    print('AMBIGUOUS')
elif n1>=1 and n1<=12:
    print('MMYY')
elif n2>=1 and n2<=12:
    print('YYMM')
else:
    print('NA')

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

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

  int d = n.length();
  int f = 0;
  for (int i = 0; i < d; i++) {
      string k{n[i]};
      int m = stoi(k);
      f += m;
  }
  
  if (stoi(n) % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,k,a[200005],mx=0;
int main()
{
	cin>>k>>n;
	rep2(i,1,n+1) cin>>a[i];
	sort(a+1,a+n+1);
	a[0]=a[n]-k; 
	rep2(i,1,n+2) if(a[i]-a[i-1]>mx) mx=a[i]-a[i-1];
	cout<<k-mx<<endl;
	return 0;}

Measured memory_bytes: 1024
import math
N,M=map(int,input().split())
sw=[list(map(int,input().split())) for i in range(M)]
for i in range(len(sw)):
    del sw[i][0]
p=list(map(int,input().split()))
#print(sw)
ans=0

for i in range(2**N): #i番目のスイッチの組み合わせ
    bini=format(i,"b")
    #print(bini)
    num="0"*(len(format(2**N-1,"b"))-len(bini))+bini
    #print(num)
    #print(len(format(2**N-1,"b")))
    #print(len(bini))
    #print(format(2**N-1,"b"))

    light=[0]*M
    for j in range(M):#j番目の電球がおんかオフか
        int1=0
        #print("j="+str(j))
        for k in sw[j]:#スイッチk
            #print("k="+str(k))
            int1+=int(num[k-1])
        if int1%2==p[j]:
            light[j]=1
    if light==[1]*M:
        ans+=1
print(ans)


Measured memory_bytes: 3064
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int n, a[N], b[N], aa[N], bb[N];
int main(){
 //   IN;
    //OUT;
    II(n);
    FF(i, 1, n) II(a[i]);
    FF(i, 1, n) II(b[i]);
    int ans = 0;
    LL pre = 0, a1, a0, b1, b0;
    for(int bit = 2; bit <= (1 << 28); bit <<= 1){
        a1 = a0 = b1 = b0 = 0;
        int po = bit >> 1;
        FF(i, 1, n){
            aa[i] = a[i] & (bit - 1);
            bb[i] = b[i] & (bit - 1);
            if(a[i] & po) ++a1;
            else ++a0;
            if(b[i] & po) ++b1;
            else ++b0;
        }
        if((a1 * b0 + a0 * b1 + pre) & 1) ans |= po;
        sort(aa + 1, aa + 1 + n);
        sort(bb + 1, bb + 1 + n);
        int i = 1, j = n;
        LL cnt = 0;
        for(i = 1; i <= n; ++i){
            while(aa[i] + bb[j] >= bit) --j;
            cnt += n - j;
        }
        pre = cnt;
    }
    if(pre & 1) ans |= (1 << 28);
    PR(ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> A;
vector<int> B;

int& arr(int idx){
    return (idx%2 == 0 ? A : B)[(idx / 2)];
}

int solve(int l, int r){
    int n = r - l;
    if(n <= 1)
        return 0;
    int count = 0;
    count += solve(l, l + n/2);
    count += solve(l + n/2, r);
    int l_size = n/2;
    int r_size = r - (l + n/2);
    //cout << "size:" << l_size << " "<< r_size << endl;
    auto L = [&](int idx)->int&{
        return arr(l + idx);
    };
    auto R = [&](int idx)->int&{
        return arr(l + n/2 + idx);
    };
    for(int i = 0, j = 0, k = n/2;i < n;i++){
        if(k == r_size) L(i) = L(j++);
        else if(j == l_size) L(i) = R(k++);
        else if(L(j) <= R(k)) L(i) = L(j++);
        else {
            L(i) = R(k++);
            count += n/2 - j;
        }
    }
    cout << "(" << l << " ," << r << ") -> " << count << endl;
    return count;
}

int mergecount(vector<int> &a) {
    int count = 0;
    int n = a.size();
    if (n > 1) {
        vector<int> b(a.begin(), a.begin() + n/2);
        vector<int> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i)
            if (k == c.size())       a[i] = b[j++];
            else if (j == b.size())  a[i] = c[k++];
            else if (b[j] <= c[k])   a[i] = b[j++];
            else                   { a[i] = c[k++]; count += n/2 - j; }
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> v;

    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        v.push_back(make_pair(tmp, i));
    }
    auto sorted = v;
    sort(sorted.begin(), sorted.end());
    for(int i=0;i<N;i++){
        auto& t = sorted[i];
        int idx = t.second;
        v[idx].second = i%2 == 1;
    }
    int na = 0;
    int nb = 0;
    for(int i=0;i<N;i++){
        int& n = i%2==0 ? na : nb;
        bool f = i%2==1;
        if(v[i].second != f)
            n++;
    }
    cout << max(na, nb) << endl;
}


Measured memory_bytes: 1908
use std::io;
use std::collections::BTreeMap;

fn main() {
    let mut first = String::new();
    io::stdin().read_line(&mut first);
    let mut fitr = first.split_whitespace();
    let n = fitr.next().unwrap().parse::<i64>().unwrap();
    let k = fitr.next().unwrap().parse::<i64>().unwrap();

    let mut bt = BTreeMap::<i64, i64>::new();
    for _ in 0..n {
        let mut line = String::new();
        io::stdin().read_line(&mut line);
        let mut itr = line.split_whitespace();
        let a = itr.next().unwrap().parse::<i64>().unwrap();
        let b = itr.next().unwrap().parse::<i64>().unwrap();
        
        *bt.entry(a).or_insert(0) += b;
    }

    let mut kmin = 0i64;
    let mut d = k;
    for (key, val) in bt.iter() {
        if d <= *val {
            kmin = *key;
            break;
        }
        d -= *val;
    }

    println!("{}", kmin);
}

Measured memory_bytes: 4352
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) #配列を昇順ソートしておく(配列に0がある場合0が先頭に来るので、場合分けの必要がなくなる)
ans=1
for val in arr:
 ans*=val #Pythonは多倍長整数をサポートしているので単に積を求めれば十分
 if ans>10**18:
   print(-1)
   break
else:
 print(ans)

Measured memory_bytes: 21788
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,a,b,sum=0,f=0;
    string s;
    cin>>n>>a>>b>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a'&&sum<a+b){sum++;cout<<"Yes"<<endl;}
        else if(s[i]=='b'&&sum<a+b&&f<b){sum++;f++;cout<<"Yes"<<endl;}
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 896
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    int ans;
    for(int i=0;i<5;i++)
    {
    	int a;
    	cin >> a;
    	if(a==0)ans=i+1;
   }
   cout<<ans<<endl;
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


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

int main() {
	string A, B;
	bool in_j = false;
	cin >> A >> B;
	int A_size = A.size();
	int B_size = B.size();

	if (A_size > B_size) {
		cout << "GREATER" << endl;
	}
	else if (A_size < B_size) {
		cout << "LESS" << endl;
	}
	else {
		for (int i = 0; i < A_size; i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				in_j = true;
				break;
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				in_j = true;
				break;
			}
		}
		if (in_j == false) {
			cout << "EQUAL" << endl;
		}
	}
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {
  unsigned long long n;
  cin >> n;
  unsigned long long  ans = INF;
  for(unsigned long long  i = 1;i <= sqrt(n);i++)
  {
    if(n % i != 0)
    {
      continue;
    }
    unsigned long long  a = i;
    unsigned long long  b = n / i;
    unsigned long long  A = to_string(a).length();
    unsigned long long  B = to_string(b).length();

    ans = min(ans,max(A,B));
  }
  cout << ans << endl;
  
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(ll h, ll a){
    cout<<(h+a-1)/a<<endl;
}

int main(){
    ll h;
    scanf("%lld",&h);
    ll a;
    scanf("%lld",&a);
    solve(h, a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  int n,m,L[110000],R[110000];
  cin >> n >> m;
  for(int i = 0; i < m; i++)
    cin >> L[i] >> R[i];

  int LL[110000],RR[110000];
  LL[0] = L[0], RR[0] = R[0];
  LL[1] = L[1]; RR[1] = R[1];
  for(int i = 0; i < m-1; i++) {
    if(L[i+1] > LL[i]) LL[i+1] = L[i+1];
    else LL[i+1] = LL[i];
    if(R[i+1] < RR[i]) RR[i+1] = R[i+1];
    else RR[i+1] = RR[i];
  }
  if(LL[m-1] <= RR[m-1])
    cout << RR[m-1] - LL[m-1] + 1 << endl;
  else 
    cout << 0 << endl;
}

Measured memory_bytes: 5216
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();
	
 if(a < b && b < c){

     System.out.println("Yes");

     }else{

     System.out.println("No");
}
	sc.close();
		
}
	}



Measured memory_bytes: 26056
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)

typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
ll const MAX = 500010;
ll dp[MAX];

int main() {
	ll n;
	string s;
	cin >> n >> s;
	s = "0" + s + "0";
	ll start = -1;
	REP(i, 0, n + 1) {
		dp[i] = 0;
	}
	ll last0 = 0;
	REP(i, 1, n) {
		dp[i] = max(dp[i], dp[i - 1]);
		if (s[i] == '0') {
			if (s[i + 1] == '1') {
				for (ll j = i - 1; j >= last0 + 1; j--) {
					dp[i + 1] = max(dp[i + 1], i - j + dp[j - 1]);
				}
			}
			if (s[i - 1] == '1') {
				ll j = i + 1;
				while (s[j] == '1') {
					dp[j] = max(dp[j], dp[i - 2] + j - i);
					j++;
				}
			}
			last0 = i;
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 4760