akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
struct node
{
    string str;
    int cnt;
    bool operator < (const node &b)const
    {
        if(cnt==b.cnt)return str<b.str;
        else return cnt>b.cnt;
    }
}arr[MAXN];
int main()
{
    int n;
    cin>>n;
        map<string,int>vis;
        int num=1;
        for(int i=1;i<=n;i++)
        {
            string s;cin>>s;
            if(vis[s]==0)
            {
                vis[s]=num++;
            }
            arr[vis[s]].str=s;
            arr[vis[s]].cnt++;
        }
        sort(arr+1,arr+num);
        int p=arr[1].cnt;
        for(int i=1;i<num;i++)
        {
            if(arr[i].cnt!=p)break;
            cout<<arr[i].str<<endl;
        }
    return 0;
}


Measured memory_bytes: 28288
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
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)
#define pb(s) push_back(s)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
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;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  
  ll N;
    cin >>N;
  
  vl vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }

  vl vect(N);
  rep(i,N) {
if(vec.at(i)%2==0) {
  vect.at(i)=0;
}
    else {
      vect.at(i)=1;
    }
  }
  
  ll sum=0;
  ll a;
  rep(I,N) {
sum+=vect.at(I);
  }
  if(sum%2==0) {
    cout<<"YES"<<endl;
  }
else {
cout<<"NO"<<endl;
}
  
  
  
  
  
}
  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lli    long long int
#define pii    pair<int,int>
#define pll    pair<lli,lli>
#define vi     vector<int>
#define vii    vector<pair<int,int>>
#define vll    vector<lli>
#define pb     push_back
#define mp     make_pair
#define ss     second
#define ff     first
#define all(x) sort(x.begin(),x.end())
#define BLACK  0
#define WHITE  1

void solve()
{
    int n,k;cin>>n>>k;
    int lol[n+1];
    lli sum=0;
    for(int i=1;i<=n;i++)cin>>lol[i];
    for(int i=1;i<=n;i++)sum+=lol[i];
    if(sum<k)
    {
        cout<<"Impossible\n";return;
    }
    vector<int>ans;
    for(int i=1;i<n;i++)
    {
        if(lol[i]+lol[i+1]>=k)
        {
            if(i>1)
            {
                for(int j=1;j<i;j++)ans.pb(j);
            }
            if(i+1 < n)
            {
                for(int j=n-1;j>i;j--)ans.pb(j);
            }
            ans.pb(i);
            cout<<"Possible\n";
            for(int j:ans)cout<<j<<endl;
            return;
        }
    }
    cout<<"Impossible\n";return;

}
int main()
{
    solve();
}


Measured memory_bytes: 4256
N, K = list(map(int, input().split(" ")))

while True:
    if abs(N-K) < N:
        if N > K:
            if N % K < N:
                N = N % K
            else:
                break
        else:
            if K % N < N:
                N = K % N
            else:
                break
    else:
        break

print(N)


Measured memory_bytes: 2940
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

int n,k;
vi arr;

//int dp[100001];


int solve(int c,int i){
    if(i==n){
        if(c==0)
            return 1;
        else return 0;
    }
    //if(dp[c][i]!=-1)
      //  return dp[c][i];
    int a = 0;

    for(int j=0;j<=arr[i];j++){
        if(j <= c)
            a = (solve(c-j,i+1) + a)%mod;
    }
    //dp[c][i] = a;
    return a;

}

void mymain(){
    cin >> n >> k;
    arr.resize(n);
    for(int i=0;i<n;i++)
        cin >> arr[i];
    //cout << solve(k,0) << endl;
    vi dp(k+1);

    dp[0] = 1;
    for(int i=0;i<n;i++){
        int lim = arr[i];
        vi mast(k+1,0);
        for(int used = k;used >= 0; used--){
                int t = dp[used];
                int L = 1,R=min(lim,k-used);
                L+=used,R+=used;
                if(L<=R){
                mast[L] = (mast[L] + t)%mod;
                if(R+1 <= k){
                    mast[R+1] = (mast[R+1] - t+ mod)%mod;
                }
                }
            /*for(int give = 1;give<= min(lim,k-used);give++){
                dp[used+give] += t;
                if(dp[used+give] >= mod)
                    dp[used+give] -= mod;
            }*/
        }

        int p=0;
    //debarr(mast);
    for(int i=0;i<=k;i++){
        p = ( p + mast[i] ) % mod;
        dp[i] = (dp[i] + p)%mod;
    }
    }


    //debarr(mast);
    //debarr(dp);

    cout << dp[k] <<endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 1792
//
//  main.cpp
//  ALDS1_4_D
//
//  Created by ptyuan on 2018/10/25.
//  Copyright © 2018 Sy. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

int T[100000];
int n = 0;
int k = 0;

int check(int p) {
    int count = 0;
    for (int i = 0; i < k; i++) {
        int s = 0;
        while (s + T[count] <= p) {
            s += T[count];
            count++;
            if (count == n) {
                return n;
            }
        }
    }
    return count;
}

int main(int argc, const char * argv[]) {
    
    
    scanf("%d%d", &n, &k);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", T + i);
    }
    
    int left = 0;
    int right = 100000 * 10000;
    while (right - left > 1) {
        int middle = (right + left) / 2;
        int v = check(middle);
        if (v >= n) {
            right = middle;
        } else {
            left = middle;
        }
    }
    
    cout << right << endl;
    return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);  
	return s + n;  
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

//だから私は～
//#define int long long
// ===============================================================

/*signed*/int main() {
	char a;
	cin >>a;
	if (a == 'A') {
		cout << 'T' << endl;
	}
	if (a == 'T') {
		cout << 'A' << endl;
	}
	if (a == 'C') {
		cout << 'G' << endl;
	}
	if (a == 'G') {
		cout << 'C' << endl;
	}
}

Measured memory_bytes: 3632
import numpy as np

S = np.array([i for i in input()])
S_rev = S[::-1]
N = len(S)

ans = 'No'

if all(S == S_rev):
  temp_S = S[:(N-1)//2]
  temp_S_rev = temp_S[::-1]
  
  if all(temp_S == temp_S_rev):
    temp_S = S[(N+3)//2-1:]
    temp_S_rev = temp_S[::-1]
    
    if all(temp_S == temp_S_rev):
      ans = 'Yes'
print(ans)

Measured memory_bytes: 12384
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 305;

template <typename T> inline void read(T &AKNOI)
{
	T x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, k;
LL C[N][N], dp[N][N], sum[N][N], mod;

void solve()
{
	read(n); read(k); read(mod);
	for(int i=0;i<=n;++i){
		C[i][0] = 1;
		for(int j=1;j<=i;++j){
			C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
		}
	}
	for(int j=0;j<=k;++j){
		dp[1][j] = 1; sum[1][j] = k-j+1;
	}
    for(int i=2;i<=n+1;++i){
        for(int j=0;j<=k;++j){
        	for(int t=1;t<i;++t){
        		dp[i][j] = (dp[i][j] + C[i-2][t-1] * dp[i-t][j] % mod * sum[t][j+1] % mod) % mod;
        	}
        }
        for(int j=k;j>=0;--j){
        	sum[i][j] = (sum[i][j+1] + dp[i][j]) % mod;
        }
    }
    printf("%lld\n", dp[n+1][0]);
}

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


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-6;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int n;
    stack<int> q;
    while(cin>>n){
        if(n==0){
            cout<<q.top()<<endl;
            q.pop();
        }else{
            q.push(n);
        }
    }
}


Measured memory_bytes: 2996
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 998244353;
ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }
        else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}
const int MAX = 10010010;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}
signed main(){
    COMinit();
    int n,m,k; cin >> n >> m >> k;
    ll ans=0;
    for(int x=0;x<=k;x++){
        if(n-1-x<0) break;
        ll res=COM(n-1,x);
        res*=m; res%=MOD;
        res*=powmod(m-1,n-1-x); res%=MOD;
        ans+=res; ans%=MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


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

static const int MAX = 100000;

int N;
int prenum[MAX];
int parent[MAX];
int lowest[MAX];
vector<int> G[MAX];
bool visited[MAX];
int cur_time;

void dfs(int current, int prev) {
  prenum[current] = lowest[current] = cur_time;
  cur_time++;
  parent[current] = prev;
  visited[current] = true;
  for (int i = 0; i < G[current].size(); i++) {
    int next = G[current][i];
    if (!visited[next]) {
      dfs(next, current);
      lowest[current] = min(lowest[current], lowest[next]);
    } else if (next != prev) {
      lowest[current] = min(lowest[current], prenum[next]);
    }
  }
}

void art_points() {
  for (int i = 0; i < N; i++) visited[i] = false;
  cur_time = 1;
  dfs(0, -1);

  set<int> ap;
  int np = 0;
  for (int i = 1; i < N; i++) {
    int p = parent[i];
    if (p == 0) np++;
    else if (prenum[p] <= lowest[i]) ap.insert(p);
  }
  if (np > 1) ap.insert(0);
  // print
  for (set<int>::iterator it = ap.begin(); it != ap.end(); it++) {
    cout << *it << endl;
  }
}

int main() {
  int u, v, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  art_points();
  return 0;
}



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

#define REP(i,n) for(int i=0,_n=n;i<(int)_n;++i)
#define ALL(a) (a).begin(),(a).end()
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple

template<class T>bool chmin(T&a,const T&b){if(a<=b)return false;a=b;return true;}
template<class T>bool chmax(T&a,const T&b){if(a>=b)return false;a=b;return true;}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cerr<<*i<<" ";cout<<endl;}
typedef long long ll;
typedef vector<int> Vi;

int nextInt() {
  int x; scanf("%d", &x); return x;
}

int N, L;
int a[100000 + 10];


int main(){
  N = nextInt();
  L = nextInt();
  REP(i, N) a[i] = nextInt();

  int last = -1;
  for (int i = 0; i + 1 < N; i++)  {
    if (a[i] + a[i+1] >= L) {
      last = i;
      break;
    }
  }
  if (last == -1) {
    printf("Impossible\n");    
  } else {
    printf("Possible\n");
    for (int i = 1; i <= last; i++)
      printf("%d\n", i);
    for (int i = N - 1; i > last; i--) 
      printf("%d\n", i);
  }

}


Measured memory_bytes: 1152
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt(),w=s.nextInt();

		int[][] vertical=new int[h][w];
		int[][] horizontal=new int[h][w];
		for(int i=0;i<h;++i){
			String t=s.next();
			for(int j=0;j<w;++j){
				vertical[i][j]=horizontal[i][j]=t.charAt(j)=='.'?1:0;
			}
		}

		for(int i=0;i<h;++i){
			for(int j=1;j<w;++j){
				if(horizontal[i][j]>0)
					horizontal[i][j]+=horizontal[i][j-1];
			}
			for(int j=w-2;j>=0;--j){
				if(horizontal[i][j]>0&&horizontal[i][j+1]>0)
					horizontal[i][j]=horizontal[i][j+1];
			}
		}
		for(int j=0;j<w;++j){
			for(int i=1;i<h;++i){
				if(vertical[i][j]>0)
					vertical[i][j]+=vertical[i-1][j];
			}
			for(int i=h-2;i>=0;--i){
				if(vertical[i][j]>0&&vertical[i+1][j]>0)
					vertical[i][j]=vertical[i+1][j];
			}
		}
		System.out.println(
				IntStream.range(0,h*w).map(i->vertical[i/w][i%w]+horizontal[i/w][i%w])
				.max().getAsInt()-1
				);
	}
}

Measured memory_bytes: 86920
bingo1 = [int(x) for x in input().split()]
bingo2 = [int(x) for x in input().split()]
bingo3 = [int(x) for x in input().split()]

N = int(input())
for _ in range(N):
    b = int(input())
    bingo1 = [0 if x == b else x for x in bingo1]
    bingo2 = [0 if x == b else x for x in bingo2]
    bingo3 = [0 if x == b else x for x in bingo3]

bingos = [bingo1, bingo2, bingo3]
flag = "No"
if sum(bingo1) * sum(bingo2) * sum(bingo3) == 0:
    flag = "Yes"
else:
    tbingo1 = [x[0] for x in bingos]
    tbingo2 = [x[1] for x in bingos]
    tbingo3 = [x[2] for x in bingos]
    if sum(tbingo1) * sum(tbingo2) * sum(tbingo3) == 0:
        flag = "Yes"
    else:
        nbingo1 = [0 if bingos[i][i] == b else bingos[i][i] for i, x in enumerate(bingos)]
        nbingo2 = [0 if bingos[i][2-i] == b else bingos[i][2-i] for i, x in enumerate(bingos)]
        if sum(nbingo1) * sum(nbingo2) == 0:
            flag = "Yes"
print(flag)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[2222];
bool isok(int a,int b,int c)
{
	if(b+c>a)
		return true;
	else
		return false;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int ans=0;
	for(int i=0;i<n-2;i++)
		for(int j=i+1;j<n-1;j++)
			for(int k=j+1;k<n;k++)
				if(isok(a[i],a[j],a[k]))
					ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

bool compare_by_pair(pair<long,long> a, pair<long,long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, M;
    cin >> N >> M;
    vector<long> X(M);
    for(size_t i=0;i<M; i++)
    {
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    vector<pair<long, long>> distance(M-1);
    for(size_t i=1;i<M; i++)
    {
        distance[i-1] = make_pair(i, X[i] - X[i-1]);
    }
    sort(distance.rbegin(), distance.rend(), compare_by_pair);
    //最初に置くコマを決める
    long counter = 1;
    long short_cut = 0;
    for(const auto& d:distance)
    {
        if(counter < N)
        {
            short_cut += d.second;
            counter++;
        }
        else break;
    }
    cout << (X.back() - X.front()) - short_cut << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

bool comp	(long long a,	long long b) {return a>b;}
	int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	ios::sync_with_stdio(false),cin.tie(0);

	long long N,M;
	cin >> N >> M;
	long long K;
	cin >> K;
	long long A[N];
	long long B[M];
	if (N>0) cin >> A[0];
	for	(long long i=1;i<N;i++){
		long long a; cin >> a;
		A[i] = a+A[i-1];
	}
	if(M>0)	cin >> B[0];
	for	(long long i=1;i<M;i++){
		long long a; cin >> a;
		B[i] = a+B[i-1];
	}

	int nb = 0;
	long long act = A[N-1];
	int ind = N-1;
	int indB = 0;
	while(A[ind]>K) ind--;
	nb = ind+1;
	while(ind>=0){
		while(indB<M && A[ind]+B[indB]<=K) indB++;
		//cout << indB+ind+1<<endl;
		nb = max(nb,indB+ind+1);
		ind--;
	}
	while(indB<M && B[indB]<=K) indB++;
	nb = max(nb,indB);
	cout << nb << endl;

	return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,w,i,j,ans;
    cin>>n>>w;
    vector<ll> v(n+1);
    vector<ll> p(n+1);
    for(i=1;i<=n;i++) cin>>v[i]>>p[i];
    ll dp[n+1][n*1000+1];
    for(i=0;i<n*1000+1;i++) dp[1][i]=INT_MAX;
    dp[1][0]=0;
    dp[1][p[1]]=v[1];
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=n*1000+1;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-p[i]>=0) dp[i][j]=min(dp[i][j],v[i]+dp[i-1][j-p[i]]);
        }
    }
    ans=INT_MIN;
    for(j=0;j<n*1000+1;j++)
    {
        if(dp[n][j]<=w) ans=max(ans,j);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>

typedef long long ll;
#define fi first
#define se second

ll ans = 1;
int N;
ll T[112345];
ll A[112345];
int idx[112345];

using namespace std;

int main(){
  
  cin>>N;
  int i;
  int j;
  
  fill( idx, idx + 112345, 112345 );
  
  for( i = 0; i < N; i++ ){
    scanf("%lld", T+i);
  }
  
  for( i = 0; i < N; i++ ){
    scanf("%lld", A+i);
  }
  
  //puts("1");
  
  int before;
  before = 0;
  
  j = 0;
  
  for( i = 0; i < N; i++ ){
    if( before < T[i] ){
      if( T[i] > A[i] ) ans = 0;
      idx[j] = i;
      j++;
    }
    before = T[i];
  }
  
  before = 0;
  
  for( i = N-1; i >= 0; i-- ){
    if( before < A[i] ){
      if( A[i] > T[i] ) ans = 0;
      idx[j] = i;
      j++;
    }
    before = A[i];
  }
  
  //puts("2");
  
  sort( idx, idx+j );
  
  before = idx[0];
  
  int cnt = 0;
  
  for( i = 1; i < j; i++ ){
    if( idx[i] == before ){
      idx[i] = 112345;
      cnt++;
    }
    before = idx[i];
  }
  
  //puts("3");
  
  sort( idx, idx+j );
  
  j -= cnt;
  
  before = idx[0];
  
  ll k;
  ll o;
  
  for( i = 1; i < j; i++ ){
    k = idx[i] - before - 1;
    if( k ){
      o = (ll)min( A[idx[i]-1], T[idx[i]-1] );
      while( k-- ){
        ans *= o;
        ans %= 1000000007;
      }
      //      123456789
    }
    before = idx[i];
  }
  
  printf("%lld", ans );
  
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(void){
    int ans;
    int x;
    ans = 0;
    
    for (int i=0;i < 5;i++) {
        
        cin >> x;
        
        if (x == 0 && i == 0) 
            ans += 1;
        
        
        if (x == 0 && i == 1) 
            ans += 2;
        
    
        if (x == 0 && i == 2) 
            ans += 3;
        
    
        if (x == 0 && i == 3) 
            ans += 4;
        

        if (x == 0 && i == 4) 
            ans += 5;
        
    }
    cout << ans << endl;
}

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

int main(){
    string A, B;
    cin >> A;
    cin >> B;
    if(A.length() == B.length()){
        if(A > B){
            cout << "GREATER" << endl;
        }else if(A < B){
            cout << "LESS" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }else if(A.length() > B.length()){
        cout << "GREATER" << endl;
    }else{
        cout << "LESS" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] ab = str.split(" ", 0);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
 
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else if(a==b){
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 24224
#include<stdio.h>
#define N 100


 int n,pos,count=0;
 int pre[N],in[N],post[N];
 
 int find(int in[n],int root){
     int i;
     for(i=0;i<n;i++){
            if(in[i]==root)return i;
            }
     return in[n-1];
     }

void rec(int l, int r){
  int root, m;
  if(l >= r) return;
  root = pre[pos++];
  m = find(in, root);
  rec(l, m);
  rec(m + 1, r);
  post[count++] = root;
}
 

 void solve(){
      int i;
      pos=0;
      rec(0,n);
      for(i=0;i<n;i++){
              if(i)printf(" ");
              printf("%d",post[i]);
              }
      printf("\n");
      }

 int main(){
      int i,k;
      scanf("%d",&n);

      for(i=0;i<n;i++){
              scanf("%d",&k);
              pre[i]=k;
              }
      for(i=0;i<n;i++){
              scanf("%d",&k);
              in[i]=k;
              }
      solve();
      return 0;
      }



Measured memory_bytes: 2144
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
flag=[[0,0,0] for i in range(3)]
for i in range(3):
    for j in range(3):
        flag[i][j]=False
        for k in range(n):
            if a[i][j]==b[k]:
                flag[i][j]=True
for i in range(3):
    if flag[i][0] and flag[i][1] and flag[i][2]:
        print('Yes')
        break
    if flag[0][i] and flag[1][i] and flag[2][i]:
        print('Yes')
        break
    if flag[0][0] and flag[1][1] and flag[2][2]:
        print('Yes')
        break
    if flag[0][2] and flag[1][1] and flag[2][0]:
        print('Yes')
        break
    if i==2:
        print('No')

Measured memory_bytes: 9160
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

const int CMax = 100002;

int n, m;
long long ats;

int main() {
    scanf("%d %d", &n, &m);
    
    if (n == 1 && m == 1) printf("1\n");
    else if (n == 1 || m == 1) printf("%d\n", max(n, m) - 2);
    else {
        ats = (long long)n * (long long)m - (long long)(2 * n) - (long long)(2 * m) + 4;
        printf("%lld\n", ats);
    }    
}

Measured memory_bytes: 256
N,M = map(int,input().split())

A =  list(map(int,input().split()))

sum_votes = sum(A)

base_line = sum_votes / (4*M)

count = 0

for i in range(N):
    if A[i] >= base_line:
        count += 1

if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        ll h=0;
        for(int x=1;x<=sqrt(n);x++)
        {
            for(int y=1;y<=sqrt(n);y++)
            {
                if(x*x+y*y<n){
                int c=x*x+y*y+x*y-i;
                int b=x+y;
                int k=b*b-4*c;
                if(k>=0)
                {
                    int p=sqrt(k);
                    if(p*p==k&&(-b+p)%2==0&&(-b+p)>=2)
                    {
                        h++;
                    }
                }
            }
                else
                break;
            }
        }
        cout<<h<<"\n";
    }
    }

Measured memory_bytes: 3700
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
	map<int,long long int> mp;
	vector<int> vec;
	int n,now,a;
	long long int b,c;
	while(cin>>n,n){
		now=0;
		mp.clear();
		vec.clear();
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(!mp[a]){
				vec.push_back(a);
			}
			mp[a]+=b*c;
		}
		for(int i=0;i<vec.size();i++)
			if(mp[vec[i]]>=1000000){
			cout<<vec[i]<<endl;
				now++;
			}
		if(now==0)
		cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
a,b,c = map(int, input().split())
if  a==b==c and a%2 ==0:
    print(-1)
else:
    res = 0
    while True:
        if a%2 != 0 or b%2 != 0 or c%2 != 0:
            break
        a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
        res += 1
    print(res)

Measured memory_bytes: 38256
n = int(input())
ans = ''
for l in range(1, 99):
    if n <= 26 ** l:
        n -= 1
        for _ in range(l):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26 ** l
print(ans[::-1])

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

int main(){
    int ans=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            if(s.at(i)==s.at(j))ans++;
        }
    }

    if(ans==s.size())cout<<"yes"<<endl;
    else if(ans!=s.size()) cout<<"no"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef struct {
  double x;
  double y;
} P;

double dist(P a, P b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double cos(double a, double b, double c) {
  return (a * a + b * b - c * c) / (2 * a * b);
}

int main() {
  vector<P> v(3);
  for (int i = 0; i < 3; i++) cin >> v[i].x >> v[i].y;

  double ans = 0;
  for (int i = 0; i < 3; i++) {
    double a = dist(v[i], v[(i + 1) % 3]);
    double b = dist(v[(i + 1) % 3], v[(i + 2) % 3]);
    double c = dist(v[(i + 2) % 3], v[i]);
    double cos1 = cos(a, b, c);
    double cos2 = cos(b, c, a);
    ans = max(ans, b / (2.0 + sqrt((1 + cos1) / (1 - cos1)) + sqrt((1 + cos2) / (1 - cos2))));
  }

  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;


int main() {
   int a,b;
  cin>>a>>b; 
int dp[a][b];
  char mp[a][b];
    for(int i=0;i<a;i++)
  {
  for(int j=0;j<b;j++)
  {
  char p;
    cin>>p;
  mp[i][j]=p;
  }
  
  }
  for(int i=0;i<a;i++)
  {
  for(int j=0;j<b;j++)
  {
  
  if(mp[i][j]=='#') dp[i][j]=0;
 else if(j!=0) dp[i][j]=dp[i][j-1]+1;
    else dp[i][j]=1;
  }
  
  }
int  ds[a][b];
  for(int i=0;i<a;i++)
  {
  for(int j=0;j<b;j++)
  {
  
  if(mp[i][j]=='#') ds[i][j]=0;
 else if(i!=0) ds[i][j]=ds[i-1][j]+1;
    else ds[i][j]=1;
  }
  
  }
  int ans=1;
  int t=0;
      for(int i=0;i<a;i++)
  {
        t=0;
  for(int j=b-1;j>=0;j--)
  {
 if(t==0 & dp[i][j]!=0) t=dp[i][j];
    else if(t!=0 & dp[i][j]!=0) dp[i][j]=t;
    else t=0;
  }
  
  }
        for(int j=0;j<b;j++)
  {
        t=0;
  for(int i=a-1;i>=0;i--)
  {
 if(t==0 & ds[i][j]!=0) t=ds[i][j];
    else if(t!=0 & ds[i][j]!=0) ds[i][j]=t;
    else t=0;
  }
  
  }
    for(int i=0;i<a;i++)
  {
  for(int j=0;j<b;j++)
  {
ans=max(ans,dp[i][j]+ds[i][j]-1);
  }
  
  }
  cout<<ans;
}
 

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> wa(n);
    vector<bool> ac(n);
    for (int i=0; i<m; i++) {
        int p; string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            ac[p] = true;
        } else {
            if (ac[p] == false) wa[p]++;
        }
    }
    int sumw = 0;
    int numac = 0;
    for (int i=0; i<n; i++) {
        if (ac[i] == true) {
            numac++;
            sumw += wa[i];
        }
    }
    cout << numac << " " << sumw << endl;
}

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

int main() {
    int N;
    cin >> N;
    int flag = 1;  
    int M = 0; 
    for (int i = 0; i < N; i++) {
    	 int A; 
   		 cin >> A; 
   		 if( M-A > 1){ flag = 0;  }
   		 M = max( M, A ); 
    }            
	if(flag==1){ 
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
            }

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

typedef int64_t ll;

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A==B && B==C) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

void Main(){

	ll N, K;
	cin >> N >> K;
	vl v(N);
	rep(i, N) cin >> v[i];
	
	vl cmb(N + 10);
	cmb[K - 1] = 1;
	rep2(i, K, N + 1){
		mint tmp = cmb[i - 1] * i;
		tmp /= (i - K + 1);
		cmb[i] = tmp.x;
	}

	mint ans = 0;
	SORT(v);
	rep(i, N){
		ans -= v[i] * cmb[N - i - 1];
		ans += v[i] * cmb[i];
	}
	
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 4752
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b; cin>>a>>b;
    cout << a*b << '\n';
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#define meow(args...) fprintf(stderr, args)
#define swap(x, y) ({register typeof(x) &_x=x, _=_x; register typeof(y) &_y=y; _x=_y; _y=_; ;})
#define cmin(x, y) ({register typeof(x) &_x=x; register const typeof(y) &_y=(y); _y<_x?(_x=_y, 1):0;})
#define cmax(x, y) ({register typeof(x) &_x=x; register const typeof(y) &_y=(y); _y>_x?(_x=_y, 1):0;})
#define dmin(x, y) ({register const typeof(x) &_x=(x); register const typeof(y) &_y=(y); _x<_y?_x:_y;})
#define dmax(x, y) ({register const typeof(x) &_x=(x); register const typeof(y) &_y=(y); _x>_y?_x:_y;})
const int N=302, M=N<<1, P=1e9+7;
int match[M], cnt[M], minmatch[M][M], maxmatch[M][M], tot[N], f[M][M];
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	tot[0]=1;
	for(register int i=1; i<=n; ++i) tot[i]=tot[i-1]*(2*i-1ll)%P;
	n<<=1;
	for(register int i=1; i<=n; ++i) match[i]=i;
	while(k--) {
		int a, b;
		scanf("%d%d", &a, &b);
		match[a]=b;
		match[b]=a;
	}
	for(register int i=1; i<=n; ++i) cnt[i]=cnt[i-1]+(match[i]==i);
	for(register int i=1; i<=n; ++i) {
		register int *Min=minmatch[i], *Max=maxmatch[i];
		Min[i]=Max[i]=match[i];
		for(register int j=i+1; j<=n; ++j) {
			Min[j]=dmin(Min[j-1], match[j]);
			Max[j]=dmax(Max[j-1], match[j]);
		}
	}
	register int ans=0;
	for(register int i=2; i<=n; i+=2) {
		for(register int l=1, r=i; r<=n; ++l, ++r) {
			if(minmatch[l][r]<l || maxmatch[l][r]>r) continue;
			f[l][r]=tot[cnt[r]-cnt[l-1]>>1];
			for(register int m=l+1; m<r; m+=2) {
				if(maxmatch[l][m]>m || minmatch[m+1][r]<=m) continue;
				f[l][r]=(f[l][r]-(long long)f[l][m]*tot[cnt[r]-cnt[m]>>1]%P+P)%P;
			}
			ans=(ans+(long long)f[l][r]*tot[cnt[l-1]+cnt[n]-cnt[r]>>1])%P;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
using namespace std;

#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    bool flag = false;
    for(int i = 0; ; i++) {
        if(abs(A-i) == abs(B-i)) {
            cout << i << endl;
            return 0;
        }
        if(i == max(A, B)) {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	cout << " ";
	cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
N = int(input())
S = list(map(int,input().split()))
Q = int(input())
T = list(map(int,input().split()))

count =set()

for i in range(Q):
    for j in range(N):
        if T[i]==S[j]:
            count.add(T[i])
if len(count)>0:
    print(len(count))
    
else:
    print("0")



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

#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)

using ll = long long;
#define INF 1e9

int main(){
  int x, y;
  cin >> x >> y;
  bool ans = false;
  vector<int> a = {4, 6, 9, 11}, b = {1, 3, 5, 7, 8, 10, 12};
  if(x == 2 && y == 2){
    ans = true;
  }
  else if(find(a.begin(), a.end(), x) != a.end() && find(a.begin(), a.end(), y)!= a.end()){
    ans = true;
  }
  else if(find(b.begin(), b.end(), x)!= b.end() && find(b.begin(), b.end(), y)!= b.end()){
    ans = true;
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;
ll ans1 = 0;
ll dp1[5010] = {};
ll dp2[5010*5010] = {};

int main()
{
ll n;
cin >> n;
ll rate[2][3] = {};
rep(i, 2)
{
    cin >> rate[i][0] >> rate[i][1] >> rate[i][2];
}
dp1[0] = n;
rep(i, n)
{
    rep(j, 3)
    {
        if (i + rate[0][j] < n + 1)
            dp1[i + rate[0][j]] = max(dp1[i + rate[0][j]], dp1[i] - rate[0][j] + rate[1][j]);
    }
}
rep(i, n+1)
{
    ans1 = max(ans1, dp1[i]);
}

dp2[0] = ans1;
rep(i, ans1)
{
    rep(j, 3)
    {
        if (i + rate[1][j] < ans1 + 1)
            dp2[i + rate[1][j]] = max(dp2[i + rate[1][j]], dp2[i] - rate[1][j] + rate[0][j]);
    }
}


rep(i, ans1+1)
{
    ans = max(ans, dp2[i]);
}

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

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

vector<pair<int, char>> RLE(const string &s){
    int cnt=0;
    vector<pair<int, char>> res;
    rep(i, 0, s.size()){
        ++cnt;
        if(i == s.size()-1){
            res.push_back(make_pair(cnt, s[i]));
        }
        else if(s[i] != s[i+1]){
            res.push_back(make_pair(cnt, s[i]));
            cnt=0;
        }
    }
    return res;
}

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

    string s; cin >> s;
    int x,y; cin >> x >> y;

    vector<pair<int, char>> rle = RLE(s);

    vector<int> tate, yoko;
    int tcnt=0;
    rep(i, 0, (int)rle.size()){
        pair<int, char> p = rle[i];
        if(p.second=='T') tcnt += p.first; // not "++tnct"!!
        else{
            if(tcnt%2==0) yoko.push_back(p.first);
            else tate.push_back(p.first);
        }
    }


    // dpx[i][j] := i回目(1-indexed)の移動でj-baseにたどり着けるか
    vector<vector<bool>> dpx((int)yoko.size()+5, vector<bool>(16005, false));
    vector<vector<bool>> dpy((int)tate.size()+5, vector<bool>(16005, false));

    int base=8000;
    dpx[0][base]=dpy[0][base]=true;

    rep(i, 0, (int)yoko.size()){
        rep(j, 0, 16005){
            if(dpx[i][j]){
                if(!(s[0]=='F' && i==0)) dpx[i+1][j-yoko[i]]=true;
                dpx[i+1][j+yoko[i]]=true;
            }
        }
    }

    rep(i, 0, (int)tate.size()){
        rep(j, 0, 16005){
            if(dpy[i][j]){
                dpy[i+1][j-tate[i]]=true;
                dpy[i+1][j+tate[i]]=true;
            }
        }
    }
    

    // rep(i, 0, (int)yoko.size()) cout << yoko[i] << ' ';
    // cout << '\n';
    // rep(i, 0, (int)tate.size()) cout << tate[i] << ' ';
    // cout << '\n';
    // cout << dpx[2][x+base] << endl;
    // cout << dpy[0][y+base] << endl;

    if(dpx[(int)yoko.size()][x+base] && dpy[(int)tate.size()][y+base]) cout << "Yes\n";
    else cout << "No\n";

    
    
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<int> red(a), green(b), white(c);
	priority_queue<int> pq;
	for (int i = 0; i < a+b+c; ++i)
	{
		if (i < a) cin >> red[i];
		else if (i < a+b) cin >> green[i-a];
		else cin >> white[i-a-b];
	}
	sort(all(red));
	sort(all(green));
	sort(all(white));
	ll ans = 0, cur = 0;
	for (int i = 0; i < x and i < a; ++i)
	{
		pq.push(-red[a-1-i]);
		cur += red[a-1-i];
	}
	for (int i = 0; i < y and i < b; ++i)
	{
		pq.push(-green[b-1-i]);
		cur += green[b-1-i];
	}
	if (pq.size() == x+y) ans = cur;
	for (int i = c-1; i >= 0; --i)
	{
		pq.push(-white[i]);
		cur += white[i];
		if (pq.size() == x+y) ans = cur;
		if (pq.size() > x+y)
		{
			cur += pq.top();
			ans = max(ans, cur);
			pq.pop();
		}
	}
	if (pq.size() < x+y) cout << 0;
	else cout << ans << ' ';
}

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

#define int long long int
#define MOD 1000000007
#define N 100001
#define pii pair<int,int>
#define MAX 1e18
#define _mp make_pair
#define pb push_back
#define _sort(v) sort(v.begin(),v.end())
#define _rsort(v) sort(v.rbegin(),v.rend())
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

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

int32_t main(){
SPEED
int n,sum=0,x,y,q;
cin>>n;

vector<int> v(N,0);
for(int i=0;i<n;i++){
    cin>>x;
    v[x]++;
    sum+=x;
}
cin>>q;
for(int i=0;i<q;i++){
    cin>>x>>y;
    sum-=x*v[x];
    sum+=y*v[x];
    v[y]+=v[x];
    v[x]=0;
    cout<<sum<<"\n";
}

    // end_timer = std::chrono::high_resolution_clock::now();
    // ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer - start_timer).count();

return 0;
}

Measured memory_bytes: 3972
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	mp := make(map[string]int)

	var n int
	fmt.Fscan(read, &n)
	cnt := 0
	for i := 0; i < n; i++ {
		s := ""
		fmt.Fscan(read, &s)
		mp[s]++
		if cnt < mp[s] {
			cnt = mp[s]
		}
	}

	ans := make([]string, 0)
	for key, val := range mp {
		if cnt == val {
			ans = append(ans, key)
		}
	}
	sort.Strings(ans)
	for _, str := range ans {
		fmt.Fprintln(write, str)
	}
}


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

int main(){
	int N, D; scanf("%d %d", &N, &D);
	int d[N+1], ans[N+1], ma[N+1], pos[N+1];
	pos[0] = D, ma[N] = 0;
	rep(i, N){
		scanf("%d", &d[i+1]);
		pos[i+1] = min(pos[i], abs(pos[i] - d[i+1]));
	}
	for(int i=N; i>0; i--){
		if(i == N) ma[i-1] = ((d[i]==1)?1:0);
		else ma[i-1] = ma[i] + ((d[i]/2>ma[i])?0:d[i]);
		ans[i] = (pos[i-1] > ma[i]);
	}
	int Q; scanf("%d", &Q);
	rep(i, Q){
		int q; scanf("%d", &q);
		printf((ans[q])?"YES\n":"NO\n");
	}
	return 0;
}


Measured memory_bytes: 11516
N,X,Y = map(int,input().split())
l = [0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        a = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        l[a] += 1

[print(i) for i in l[1:]]


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (b-a==c-b) {
  cout << "YES" << endl;
  return 0;
  }
  
  
  cout << "NO" << endl;
  
}


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

int main() {

    int N;
    cin >> N; 
	vector<int> H(N);
	for(int i=0;i<N;i++){
		cin >> H.at(i);
	}
	int count = 0;
	for(int i=0;i<N;i++){
		bool ok = true;
		for(int j=0;j<i;j++){
			if(H.at(j) > H.at(i)){
				ok = false;
				break;
			}
		}
		if(ok){
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 764