akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void preorder(ll n, vector<vector<ll>> tree, ll root){
    cout<<"Preorder"<<endl;
    stack<ll> st;
    st.push(root);
    vector<ll> res;
    while(!st.empty()){
        ll x=st.top();
        st.pop();
        res.push_back(x);
        rep(y, 2){
            if(tree[x][1-y]!=-1) st.push(tree[x][1-y]);
        }
    }
    rep(i,n){
        cout<<' ';
        cout<<res[i];
    }
    cout<<endl;
}

void inorder(ll n, vector<vector<ll>> tree, ll root){
    cout<<"Inorder"<<endl;
    stack<ll> st;
    st.push(root);
    vector<ll> res;
    while(!st.empty()){
        ll x=st.top();
        st.pop();
        if(tree[x][0]==-1 && tree[x][1]==-1){
            res.push_back(x);
        }else{
            if(tree[x][1]!=-1) st.push(tree[x][1]);
            st.push(x);
            if(tree[x][0]!=-1) st.push(tree[x][0]);
            tree[x][0]=-1; tree[x][1]=-1;
        }
    }
    rep(i,n){
        cout<<' ';
        cout<<res[i];
    }
    cout<<endl;
}

void postorder(ll n, vector<vector<ll>> tree, ll root){
    cout<<"Postorder"<<endl;
    stack<ll> st;
    st.push(root);
    vector<ll> res;
    while(!st.empty()){
        ll x=st.top();
        if(tree[x][0]==-1 && tree[x][1]==-1){
            res.push_back(x);
            st.pop();
        }else{
            rep(y, 2){
                if(tree[x][1-y]!=-1) st.push(tree[x][1-y]);
            }
            tree[x][0]=-1; tree[x][1]=-1;
        }
    }
    rep(i,n){
        cout<<' ';
        cout<<res[i];
    }
    cout<<endl;
}

int main(){
    ll n; cin>>n;
    vector<vector<ll>> tree(n);
    vector<ll> par(n, -1);
    rep(i,n){
        ll id,left,right; cin>>id>>left>>right;

        if(left!=-1){
            tree[id].push_back(left);
            par[left]=id;
        }else{
            tree[id].push_back(-1);
        }

        if(right!=-1){
            tree[id].push_back(right);
            par[right]=id;
        }else{
            tree[id].push_back(-1);
        }
    }

    ll root;
    rep(i,n){
        if(par[i]==-1) root=i;
    }

    preorder(n, tree, root);
    inorder(n, tree, root);
    postorder(n, tree, root);
    
    return 0;
}


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

int main() {
    string o, e;
    cin >> o >> e;
    rep(i, o.size()) {
        cout << o.at(i);
        if(i < e.size()) cout << e.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll r, x, D;
  cin >> r >> D >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   sort(a.rbegin(), a.rend());
   ll ans = 0;
   rep(i, 1, n) {
      if (i == 1)
         ans += a[0];
      else
         ans += a[i/2];
   }

   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    int N,a[15000],b=0,c=0;
  cin>>N;
    for(int i=0;i<N;i++){
        cin >>a[i];
        while(a[i]%2==0){
            a[i]/=2;
           b++ ;
        }
    }
    sort(a,a+N);
    while(a[N-1]<1000000000){
        a[N-1]*=3;
        c++;
    }
    cout <<b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, d;
    long long a;
    cin >> n >> d >> a;
    vector<pair<int, long long> >v;
    for(int i = 0; i < n; i++){
        int p, q;
        cin >> p >> q;
        v.push_back({p, q});
    }
    sort(v.begin(), v.end());
    vector<int>bomb;
    vector<long long>val, pref;
    bomb.push_back(-2000000000);
    val.push_back(0);
    pref.push_back(0);
    for(int i = 0; i < n; i++){
        int p = lower_bound(bomb.begin(), bomb.end(), v[i].first - 2 * d) - bomb.begin();
        long long x;
        if(p == bomb.size()){
            x = v[i].second;
        }
        else{
            long long r = pref.back() - pref[p] + val[p];
            x = v[i].second - r * a;
        }
        if(x > 0){
            long long cnt = x/a + (x % a != 0);
            bomb.push_back(v[i].first);
            val.push_back(cnt);
            long long k = pref.back() + cnt;
            pref.push_back(k);
        }
    }
    cout << pref.back();
    return 0;
}

Measured memory_bytes: 13652
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000];
int main(){
    ll n,k,tmp=0,ans=0;
    string s;
    cin>>s;
    ll d=s.length();
    cout<<s[0];
    cout<<d-2;
    cout<<s[s.length()-1];

}

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

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    if(n != m){cout << "No" << endl; return 0;}
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(b.find(a.substr(j)) != string::npos and b.find(a.substr(0, j)) != string::npos){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl; return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }


    void run() {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int K = cin.nextInt();
        int now = 1;
        for (int i = 0; i < N; i++){
            //2倍とKを足すのの、値が小さくなる方を採用する
            now = Math.min(now * 2, now + K);
        }
        System.out.println(now);
    }
}


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

ll dp[411];

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

    ll n;
    cin>>n;

    ll ap[n+11],h[n+11];
    for(ll i=0;i<n;i++){
      cin>>ap[i];
    }

    for(ll i = 0;i<n;i++){
      cin>>h[i];
    }

    ll ans = 0;
    set<pair<ll,ll> >st;

    for(ll i = 0;i<n;i++){
      
      pair<ll,ll>p = make_pair(ap[i],h[i]);

      set<pair<ll,ll> >::iterator it = st.lower_bound(p);

      if(st.size()>0 && it!=st.begin()){

        it--;
        p.second = p.second + (*it).second;
        // cout<<i<<" "<<(*it).first<<" "<<(*it).second<<"\n";
      }
      // cout<<p.second<<" ";

      while(1){
        it = st.lower_bound(p);
        if(st.size() > 0&& it != st.end() && (*it).second < p.second){
          st.erase(it);
          continue;
        }
        break;
      }

      st.insert(p);

      ans = max(ans,p.second);


    }

    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

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

    ll n;
    cin >> n;
    if(n%2 != 0){
        cout << 0 <<endl;
        return 0;
    }

    ll ans = 0;
    int keta = log10(n);
    vector<int> s;

    ll five = 5;
    repeq(i,25) five *= 5;

    while(five>1){
        ans += (n/five)/2;
        five /= 5;
    }

    cout << ans <<endl;
    return 0;

}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)3e5 + 5;
using namespace std;

char s[15];

int main()
{
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	bool flag = true;
	int cnt = 0, pos;
	for(int i = 3; i <= len - 1; i++){
		if(s[i] == 'C') cnt++, pos = i;
	}
	for(int i = 2; i <= len; i++){
		if(s[i] >= 'A' && s[i] <= 'Z' && i != pos) flag = false;
	}
	if(s[1] != 'A' || cnt != 1) flag = false;
	flag ? puts("AC") : puts("WA");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  int64 ret = 0;
  if (a[0] > m) {
    ret += a[0] - m;
    a[0] = m;
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] + a[i - 1] > m) {
      ret += a[i] + a[i - 1] - m;
      a[i] = m - a[i - 1];
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int main()
{
    char ch[28];
    cin>>ch;
    string s="abcdefghijklmnopqrstuvwxyz";
    for(int i=0;i<s.size();i++){
        if(*ch==s[i]){
            cout<<s[(i+1)%26]<<endl;
            break;
        }
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

bool solve() {
    return !(s == "AAA" || s == "BBB");
}

void input() {
    cin >> s;
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    printf("%d %d %d\n", c, a, b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int A, B;
void input() {
  cin >> N >> A >> B;
  ;
  ;
}
void solve() {
  // 自明 pattern
  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  } else {
    int ans1 = min((B - 1), N - A);  // 1 or Nで戦う
    int ans2 = (N - B + 1) + (N - (A + N - B + 1)) / 2;
    int ans3 = A + (B - A - 1) / 2;
    if (ans2 <= 0) ans2 = INF;
    if (ans3 <= 0) ans3 = INF;

    cout << min({ans1, ans2, ans3}) << endl;
  }

  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,1,0,-1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    ll K;cin>>K;
    ll ans=1;
    ll N=K-1;
    map<ll,ll> a;
    repl(i,2,sqrt(N)+10){
        while(N%i==0){
            N/=i;
            a[i]++;
        }
    }
    if(N!=1)a[N]++;
    for(auto p:a)ans*=(p.se+1);
    ans--;
    repl(i,1,(ll)sqrt(K)+5){
        if(i*i>K)break;
        ll P=K;
        if(P%i)continue;
        ll A=i,B=P/i;
        while(P%A==0){
            P/=A;
            if(A==1)break;
        }
        if(P%A==1)ans++;
        if(A!=B){
            P=K;
            while(P%B==0){
                P/=B;
            }
            if(P%B==1)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;


int main(){
	long long n;
	string s;

	cin >> n >> s;


	if (n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	cout << (( s.substr(0,n/2) ==  s.substr(n/2))? "Yes" : "No") << endl;

	


	cin >> n;
	return 0;

	
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  int t=0,length,i;
  char w[11],T[1001];
  scanf("%s", w);
  while(1) {
    scanf("%s", T);
    if(strcmp(T, "END_OF_TEXT") == 0) break;
    length = strlen(T);
    for(i = 0; i < length; i++) {
      if(T[i] >= 'A' && T[i] <= 'Z') {
	T[i] += 'a' - 'A';
      }
    }
    if(strcmp(w, T) == 0) {
      t++;
    }
    memset(T, '\0', 1000);
  }
  printf("%d\n", t);
  
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
typedef stack<int>S;
int main(void){
	int n,q;
	int x,y,z;
	int i;
	S st[1000];
	cin>>n>>q;
	for(i=0;i<q;i++){
		cin>>x>>y;
		if(x==0){
			cin>>z;
			st[y].push(z);
		}
		else if(x==1){
			if(!st[y].empty())	cout<<st[y].top()<<endl;
		}
		else{
			if(!st[y].empty())	st[y].pop();
		}
	}
	return 0;
}


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

int main(void) {
    string x;
    while (cin >> x) {
        stack<char> sk;
        int len = x.size();
        sk.push(x[0]);
        for (int i = 1; i < len; ++i) {
            if (!sk.empty()) {
            	char top = sk.top();
	            if (top == 'S' && x[i] == 'T') {
	                sk.pop();
	            }else {
					sk.push(x[i]);
				} 
			}else {
				sk.push(x[i]);
			}
        }
        cout << sk.size() << endl;
   }
   return 0;
}

Measured memory_bytes: 644
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b;
    vector<string> s;
    for(int i=0;i<100;i++){
        if(i<50){
            string temp="";
            for(int j=0;j<100;j++){
                temp+='#';
            }
            s.push_back(temp);
        }
        else{
            string temp="";
            for(int j=0;j<100;j++){
                temp+='.';
            }
            s.push_back(temp);
        }
    }
    int i=0;
    int j=0;
    while(a!=1){
        s[i][j]='.';
        a--;
        j+=2;
        if(j>99){
            if(i%2==0){
                i+=2;
                j=1;
            }
            else{
                i+=2;
                j=0;
            }
        }
    }
    i=51;
    j=1;
    while(b!=1){
        s[i][j]='#';
        b--;
        j+=2;
        if(j>99){
            if(i%2==0){
                i+=2;
                j=1;
            }
            else{
                i+=2;
                j=0;
            }
        }
    }
    cout<<100<<" "<<100<<"\n";
    for(int i=0;i<100;i++){
        cout<<s[i]<<"\n";
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int Exhaustive(int n, int *a, int m,int i){
    int res;
    if(m==0) return 1;
    if(i>=n) return 0;
    res=(Exhaustive(n,a,m,i+1) || Exhaustive(n,a,m-*(a+i),i+1));
    return res;

}

int main(void){
    int n,q,j,B;
    int *a,m;
    scanf("%d\n",&n);
    a=malloc(sizeof(int)*(n));
    for(j=0;j<n;j++){
        scanf("%d",(a+j));
    }
    scanf("%d\n",&q);
    for(j=0;j<q;j++){
        scanf("%d",&m);
        B=Exhaustive(n,a,m,0);
        if(B==1) printf("yes\n");
        else printf("no\n");
    }

    free(a);
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#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(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = fastpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int comb(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int N; cin >> N;
    if(N == 2){
        cout << 1;
        return 0;
    }
    int mod = 1000000007;

    Combination C(N, mod);
    int ans = 0;

    //N - k - 1点以下の組み合わせ
    vec combs(N, 0);
    FOR(k, 0, (N - 2) / 2 + 1){
        int tmp = C.comb(N - k - 2, k);
        tmp = (tmp * C.fact[N - 1 - k]) % mod;
        tmp = (tmp * C.fact[k]) % mod;
        combs[k] = tmp;
    }

    FOR(k, 0, (N - 2) / 2 + 1){
        ans += (combs[k] - combs[k + 1] + mod) * (N - k - 1);
        ans %= mod;
    }

    cout << ans;
    
    return 0;
}


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

Measured memory_bytes: 23680
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        long ans = 100000001;
        long h2;
        long w2;
        long h3;
        long w3;
        long s1;
        long s2;
        long s3;
        for(int i=0;i<w;i++){
        	h2 = h;
        	w2 = w - i;
        	s1 = i*h;
        	s2 = h2/2*w2;
        	s3 = (h2-h2/2)*w2;
        	ans = (long)Math.min(ans, (long)Math.max(s1, (long)Math.max(s2, s3))-(long)Math.min(s1, (long)Math.min(s2, s3)));
        }
        for(int i=0;i<h;i++){
        	h2 = h - i;
        	w2 = w;
        	s1 = i*w;
        	s2 = w2/2*h2;
        	s3 = (w2-w2/2)*h2;
        	ans = (long)Math.min(ans, (long)Math.max(s1, (long)Math.max(s2, s3))-(long)Math.min(s1, (long)Math.min(s2, s3)));
        }

        if(true){
        	h2 = h;
        	w2 = w - w/3;
        	s1 = w/3 * h;
        	s2 = w2/2*h;
        	s3 = (w2-w2/2)*h;
			ans = (long)Math.min(ans, (long)Math.max(s1, (long)Math.max(s2, s3))-(long)Math.min(s1, (long)Math.min(s2, s3)));        	
        }
        if(true){
        	h2 = h - h/3;
        	w2 = w;
        	s1 = h/3*w;
        	s2 = h2/2*w;
        	s3 = (h2-h2/2)*w;
        	ans = (long)Math.min(ans, (long)Math.max(s1, (long)Math.max(s2, s3))-(long)Math.min(s1, (long)Math.min(s2, s3)));
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22228
#include<stdio.h>
int main(){
	int a,b,c=1,i;
	while(1){
		scanf("%d",&a);
		if(a==0)break;
		for(i=0;i<9;i++){
			scanf("%d",&b);
			a=a-b;
		}
		printf("%d\n",a);
	}
	return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j,k,maxi=0,x=0;
    cin>>n;
    char s[n+1];
    cin>>s;
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='I'){
            x++;
            maxi=max(maxi,x);
        }
        else if(s[i]=='D'){
            x--;
            maxi=max(maxi,x);
        }
    }
    cout<<maxi<<endl;

}



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

int C[3];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		C[S[i] - 'a']++;
	}

	if (C[0] > C[1])swap(C[0], C[1]);
	if (C[1] > C[2])swap(C[1], C[2]);
	if (C[0] > C[1])swap(C[0], C[1]);

	if (abs(C[0] - C[2]) <= 1)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{

    int a,b;

    cin >> a >> b;

    if(a>b)swap(a,b);

    if(a==1 && b==2)
    cout << 3 << endl;
   else if(a==1 && b==3)
    cout << 2 << endl;
    else if(a==2 && b==3)
        cout << 1 << endl;





    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		if(s.equals(t.substring(0,t.length()-1)))
			System.out.println("Yes");
		else
			System.out.println("No");
	}


	static class Pair {
		int x;
		int y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


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

vector<int> input(int N){
    vector<int> output(N);
    for(int i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,i,j;
    int result=0;
    vector<int> D;

    cin>>N;
    D=input(N);

    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            result+=D[i]*D[j];
        }
    }
    cout<<result<<endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x.at(i);
	}
	int a = 100100100;
	for (int p = 0; p < 100; p++) {
		int hp = 0;
		for (int i = 0; i < N; i++) {
			hp += (x.at(i) - p) * (x.at(i) - p);
		}
		a = min(hp, a);
	}
	cout << a << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string s, t;
  cin >> s >> t;

  map<char, vector<int>> mps;
  map<char, vector<int>> mpt;



  for (int i = 0; i < int(s.size()); i++) {
    mps[s[i]].push_back(i);
    mpt[t[i]].push_back(i);
  }


  for(auto a : mps)
  {
    bool flag = false;
    for(auto b : mpt)
    {
      if(a.second == b.second)
      {
        flag = true;
        break;
      }
    }
    if(!flag)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3352
#include <stdio.h>

int main(void)
{
	int n, rnk, x, i, j, a[4][13];
	char ptn;
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			a[i][j] = 0;
		}
	}
	
	scanf("%d%*c", &n);
	for(x = 0; x < n; x++){
		scanf("%c%d%*c", &ptn, &rnk);
		switch(ptn){
			case 'S' : i = 0; break;
			case 'H' : i = 1; break;
			case 'C' : i = 2; break;
			case 'D' : i = 3; break;
		}
		j = (rnk - 1);
		a[i][j] = 1;
	}
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(a[i][j] == 0){
				switch(i){
					case 0 : ptn = 'S'; break;
					case 1 : ptn = 'H'; break;
					case 2 : ptn = 'C'; break;
					case 3 : ptn = 'D'; break;
				}
				rnk = (j + 1);
				printf("%c %d\n", ptn, rnk);
			}
		}
	}
	
	return(0);
}



Measured memory_bytes: 1792
#include<stdio.h>


int main(void){
    int K;
    int A,B;
    int flag;

    scanf("%d", &K);
    scanf("%d %d", &A, &B);

    for(int i=A;i<=B;i++){
        flag=i%K;
        if(flag==0){
            printf("OK");
            break;
        }

    }
    if(flag!=0)
    printf("NG");

    return 0;
}

Measured memory_bytes: 1732
N = int(input())

count_ab = 0
count_fb = 0
count_ea = 0
count_fbea = 0
for i in range(N):
    s = input()
    count_ab += s.count("AB")
    if s[0] == "B" and s[len(s)-1] == "A":
        count_fbea += 1
    elif s[0] == "B":
        count_fb += 1
    elif s[len(s)-1] == "A":
        count_ea += 1

ans = count_ab
if count_fbea > 0:
    ans += count_fbea - 1
    if count_fb > 0:
        count_fb -= 1
        ans += 1
    if count_ea > 0:
        count_ea -= 1
        ans += 1
ans += min(count_fb, count_ea)
print(ans)

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

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(A != B && B == C || A == B && B != C || A == C && B != A) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = INT32_MAX - 1;
const double EPS = 1E-9;

int a[N];
int n, m;

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

#ifdef CF_DEBUG
    freopen("../cf/input.txt","r",stdin);
#endif
    int a,b,c;
    cin>>a>>b>>c;
    if(c-a-b < 0){
        cout<<"No";
    }else {
        cout << ((4LL * a * b < 1LL * (c - b - a) * (c - b - a)) ? "Yes" : "No");
    }

    return 0;
}

Measured memory_bytes: 256
a,b,c,k=[int(i) for i in input().split()]

if k % 2 ==1:
  #l=lambda x,y,z:((2**k)+1)/3 *(y+z+x)-x
  l=lambda x: -x
else:
  #l=lambda x,y,z:((2**k)-1)/3 *(y+z+x)+x
  l=lambda x: x
if l(a)-l(b)>=10**18:
  print('Unfair')
else:
  print(int(l(a)-l(b)))

Measured memory_bytes: 3060
/*
  A - キャンディーと2人の子供 / Fighting over Candies
  <http://abc047.contest.atcoder.jp/tasks/abc047_a>
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  if( (a<1 || a>100) || (b<1 || b>100) || (c<1 || c>100) ){
    fprintf(stderr, "INPUT ERROR!\n");
    return -1;
  }

  if( (a+b==c) || (a+c==b) || (b+c==a) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
package main                                  
                                              
import (                                      
        "fmt"                                 
        "regexp"                              
)                                             
                                              
func main() {                                 
        re := regexp.MustCompile("[ACGT]+")   
        var S string                          
        fmt.Scanf("%s", &S)                   
        ans := 0                              
        l := re.FindAllString(S, -1)          
        for i := range l {                    
                if ans < len(l[i]) {          
                        ans = len(l[i])       
                }                             
        }                                     
        fmt.Println(ans)                      
}                                             

Measured memory_bytes: 640
w = input()
alphabet = 'abcdefghijklmnopqrstuvwxyz'
cntArr = [0]*24
isBeautiful = True
for i in range(24):
    if(w.count(alphabet[i]) %2 == 1):
        isBeautiful = False
        break
if(isBeautiful):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A, B;
  cin>>A>>B;
  int s=0;
  for(int i=A;i<=B;i++)
  {
    int b=(i%100)+(i/1000);
    if(b%11==0)
    {if(i/10000==i%10)s+=1;}

      
    
  }
  cout<<s<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  string s; cin >> s;
  set<char> se;

  rep(i, si(s)) se.ep(s[i]);
  rep(i, 26) {
    char c = 'a' + i;

    if (!se.count(c)) {
      cout << c << endl;
      return (0);
    }
  }

  cout << "None\n";

  return (0);
}


Measured memory_bytes: 3724
#include <stdio.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    int  a, b;
    char op;

    scanf ( "%d %c %d", &a, &op, &b );
    if ( op == '?' ) break ;

    switch ( op )
    {
      case '+': printf ( "%d\n", a + b ); break ;
      case '-': printf ( "%d\n", a - b ); break ;
      case '*': printf ( "%d\n", a * b ); break ;
      case '/': printf ( "%d\n", a / b ); break ;
    }
  }

  return ( 0 );
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i,n+1)cin >> a[i];
    rep(i,n) cin>>b[i];
    ll ans = 0;
    rep(i,n){
        if(b[i]>=a[i]){
            ll diff =b[i]-a[i];
            ans += a[i];
            if(diff >= a[i+1]){
                ans += a[i+1];
                a[i+1]=0;
            }else{
                ans+= diff;
                a[i+1] -= diff;
            }
        }else{
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    rep(i, n + 1){
        rep(j, n + 1){
            if(i * r + j * g > n) continue;
            int B = n - i * r - j * g;
            if(B % b != 0) continue;
            if(i * r + j * g + B == n) ans++;
        }
    }
    print(ans);

}



Measured memory_bytes: 256
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 1050

int n, m;
vector<int> gr[N]; 
int root[N];
 
// Driver code to test above functions
int32_t main()
{
    
 
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> m;
    
    for(int i=1;i<=m;i++)
    {
        int u, v;
        cin >> u >> v;
        gr[u].push_back(v);
    }

    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
        memset(root, -1, sizeof root);
        queue<int> q;
        for(int j=0;j<gr[i].size();j++)
        {
            root[gr[i][j]] = i;
            q.push(gr[i][j]);
        }
        while(!q.empty())
        {
            int x = q.front();
            q.pop();

            if(x==i)
            {
                vector<int>temp;
                x = root[x];
                while(x!=i)
                {
                    temp.push_back(x);
                    x = root[x];
                }
                temp.push_back(i);

                if(ans.size()==0 or temp.size()<ans.size())
                    ans = temp;

                break;
            }

            for(int j=0;j<gr[x].size();j++)
            {
                if(root[gr[x][j]]==-1)
                {
                    root[gr[x][j]] = x;
                    q.push(gr[x][j]);
                }
            }
        }
    }

    if(ans.size()==0)
        cout << -1;
    else
    {
        cout << ans.size() << endl;
        for(int i=0;i<ans.size();i++)
            cout << ans[i] << endl;
    }

    return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::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> rev(N);
  for(int i = 0;i < N;i++){
    rev[A[i] - 1] = i + 1;
  }
  for(int i = 0;i < N;i++){
    cout<<rev[i]<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 2e5 + 5;
ll n, m, k, mx, a[N], b[N];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 0;i < n;++i)
    {
        cin >> a[i];
        if(i)   a[i] += a[i - 1];
    }
    for(int i = 0;i < m;++i)
    {
        cin >> b[i];
        if(i)   b[i] += b[i - 1];
    }
    for(int i = 0;i < n;++i)
    {
        if(a[i] <= k)
        {
            ll ans = i + 1 + (upper_bound(b, b + m, k - a[i]) - b);
            mx = max(mx, ans);
        }
    }
    ll z = upper_bound(b, b + m, k) - b;
    cout << max(mx, z);
    return 0;
}


Measured memory_bytes: 6724
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=2007;
const ll mod=1e9+7;
ll Pow(ll x,ll y){
	ll ans=1,now=x;
	while(y){
		if(y&1)ans=ans*now%mod;
		now=now*now%mod;
		y>>=1;
	}
	return ans;
}
ll f[N][N],fac[N*N],inv[N*N],s[N];
ll n,k;
ll C(ll x,ll y){return fac[x]*inv[y]%mod*inv[x-y]%mod;}
int main(){
	scanf("%lld%lld",&n,&k);
	if(k==1){
		puts("1");
		return 0;
	}
	fac[0]=1;
	rep(i,n*k)fac[i]=fac[i-1]*i%mod;
	inv[n*k]=Pow(fac[n*k],mod-2);
	for(ll i=n*k;i;i--)inv[i-1]=inv[i]*i%mod;
	f[0][0]=1;
	rep0(i,n){
		for(ll j=i;~j;j--)s[j]=(s[j+1]+f[i][j])%mod;
		rep0(j,i+1)f[i+1][j+1]=s[j]*C(i*k-j+k-2,k-2)%mod;
	}
	for(ll j=n;~j;j--)s[j]=(s[j+1]+f[n][j])%mod;
	printf("%lld\n",s[0]*fac[n]%mod);
	return 0;
}


Measured memory_bytes: 94592
input3 = loop (0,0) []
  where
    loop :: (Int,Int) -> [(Int,Int)] -> IO [(Int,Int)]
    loop tpl list = do
      temp <- getLine
      let [x,y] = map read $ words temp
      if x == 0 && y == 0
        then return list
        else do
        loop (x,y) (list ++ [(x,y)])

exchange3 (x,y)
  | y < x = (show y) ++ " " ++ (show x)
  | otherwise = (show x) ++ " " ++ (show y)

solve3 list = map exchange3 list


main = do
  list <- input3
  mapM_ putStrLn $ solve3 list



Measured memory_bytes: 5868
a, b, c, x, y = gets.chomp.split(" ").map(&:to_i)
ans = 0

while x > 0 || y > 0 do
    if x > 0 && y > 0 then
        if a+b > c*2 then
            ans += c*2
            x -= 1
            y -= 1
        else
            if a < b then
                ans += a
                x -= 1
            else
                ans += b
                y -= 1
            end
        end
    elsif x > 0 && y <= 0 then
        if a < c*2 then
            ans += a
            x -= 1
        else
            ans += c*2
            x -= 1
        end
    else
        if b < c*2 then
            ans += b
            y -= 1
        else
            ans += c*2
            y -= 1
        end
    end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;

//for(int32_t i = 0; i < N; i++)

int main(void)
{
    int32_t N;
    cin >> N;


    int32_t a[N];
    for(int32_t i = 0; i < N; i++) {
        cin >> a[i];
    }
    int32_t all = 0;
    for(int32_t i = 0; i < N; i++) {
        all += a[i];
        if (a[i] % 2 != 0) {
            cout << "first" << endl;
            return 0;
        }
    }

    if (all%2 == 0) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<pair<ll, ll> > arr(N);
  ll X, L;
  for(int i=0;i<N;++i) {
    cin>>X>>L;
    arr[i] = mp(X+L, X);
  }
  sort(arr.begin(), arr.end());
  ll tmp = arr[0].fi;
  int ans = 1;
  for(int i=1;i<N;++i) {
    X = arr[i].se;
    L = arr[i].fi-X;
    if(X-L<tmp) continue;
    ans++;
    tmp = X+L;
  }
  cout<<ans<<endl;
}



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

int main() {
    int A, B; cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
    return 0;
}

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

bool fin(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    map<int, int> mp;
    for(int a : A) mp[a]++;
    if(N%3){
        fin(mp[0] == N);
    }else{
        vector<int> c;
        for(auto& p : mp) for(int i=0; i<3*p.second/N; i++) c.push_back(p.first);
        fin(c.size() == 3 && ((c[0]^c[1]^c[2]) == 0));
    }
    return 0;
}


Measured memory_bytes: 4224
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var b = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long monsterCount = 0;

            for (int i = 0; i < b.Count(); i++)
            {
                if (a[i] >= b[i])
                {
                    monsterCount += b[i];
                }
                else
                {
                    monsterCount += a[i];
                    b[i] -= a[i];
                    monsterCount += Min(a[i + 1], b[i]);
                    a[i + 1] -= Min(a[i + 1], b[i]);
                }
            }

            Console.WriteLine(monsterCount);

        }
    }
}


Measured memory_bytes: 35996