akhauriyash/Code-Regression huggingface dataset:
n, k ,q = gets.chomp.split.map(&:to_i)
a = Array.new(n,k - q)

q.times{
  n = gets.chomp.to_i
  a[n - 1] += 1
}

a.each{ |score|
  if (score > 0)
    puts "Yes"
  else
    puts "No"
  end
}

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

int main(){
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int &e : v)
		cin >> e;
	
	int cnt = 0;
	for(int i = 0;i < n;++i){
		cnt += (i+1 != v[i]);
	}

	cout << (cnt <= 2 ? "YES" : "NO"); 
}


Measured memory_bytes: 3400
N = int(input())
A = [int(i) for i in input().split()]
S = [0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+A[i]
S.sort()
L=[]
k=0
p=0
for i in range(N+2):
    if i==N+1:
        L.append(p)
        continue
    if S[i]==k:
        p+=1
    else:
        L.append(p)
        p=1
        k=S[i]
ans=0
for x in L:
    ans+=(x*(x-1))//2
print(ans)


Measured memory_bytes: 25724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n, k; cin >> n >> k;
  cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    string s, t;
    cin1(s);
    cin1(t);
    lli ans = 0;
    REP(i, 0, 3) {
        if (s[i] == t[i])
            ans++;
    }
    cout << ans << endl;
}


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

int d[100100];

signed main() {

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

    int mid = n / 2;
    sort ( d, d+n );

    cout << d[mid] - d[mid-1] << endl;

    return 0;
}

Measured memory_bytes: 640
from itertools import accumulate as f

def main():
	n, c, *L = map(int, open(0).read().split())
	acc = [a - x for x, a in zip(L[::2], f(L[1::2]))]
	acc_max = list(f(acc, max))[::-1]
	R = L[::-1]
	rev = [a - (c - x) for x, a in zip(R[1::2], f(R[::2]))]
	rev_max = list(f(rev, max))[::-1]
	p = max([a - b + d for a, b, d in zip(acc, L[::2], rev_max[1:])]+[0])
	q = max([a - (c - b) + d for a, b, d in zip(rev, R[1::2], acc_max[1:])]+[0])
	r = max(0, acc_max[0], rev_max[0])
	print(max(p, q, r))

if __name__ == "__main__":
	main()


Measured memory_bytes: 28852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));



int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	ll res = -1;
	repn(i, 100000) {
		ll a = i*0.08, b = i*0.1; 
		if (a == A && b == B) {
			res = i;
			break;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  long long x;
  cin >> N >> x;
  long long a[N];
  rep(i, N)
    cin >> a[i];
  //ここまで入力

  long long ans = 0;

  //1項目の値をx以下まで下げる
     if(a[0] > x){
      ans += (a[0]-x);
      a[0] = x;
     }
     
  long long sum;
  for(int i=1; i<N; i++){
    sum = a[i-1]+a[i];
    //二項間の和の超過分を計算していく
    //二項のうち，右側を書き換えていく
    if(sum > x){
      ans += (sum-x);
      a[i] -= (sum-x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b; cin>>a>>b;
	cout<<lcm(a,b)<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i,j;
	int MAX=-1;
	cin>>n;
	for(i=2;i<n;i++){
		int x=i;
		x*=i;
		//cout<<x<<endl;
		while(n>=x){
			//cout<<x<<endl;
			MAX=max(MAX,x);
			x*=i;
		}
	}
	if(n==1)	MAX=1;
	cout<<MAX<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  
  for (i = 0;i<=VMAX;i++){
    C[i] = 0;
  }
  
  /* C[i] に i の出現数を記録する */
  for (j = 1;j<=n;j++){
    C[A[j]]++;
  }

  /* C[i] に i 以下の数の出現数を記録する*/
  for (i = 1 ;i <= VMAX;i++){
    C[i] = C[i] + C[i-1];
  }

  for (j = n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }


  for(i=1;i<=n-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  return 0;
}



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

#define N 200002
const int mod = 998244353;

bool cmp(bitset<N> &y, bitset<N> &x) {
	for (int i = N - 1; i >= 0; i --) {
		if (y[i] != x[i]) return y[i] < x[i];
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	bitset<N> x;
	cin>>n>>x;
	vector<int> pre(n+1);
	for (int i = n - 1; i >= 0; i --) pre[i] = (2 * pre[i+1] + x[i]) % mod;
	vector<int> f(n+1);
	for (int d = 1; d <= n; d += 2) if (n % d == 0) {
		int l = n / d;
		f[d] = pre[n-l];
		bitset<N> y = x;
		for (int i = n - l - 1; i >= 0; i --) y[i] = !y[i+l];
		if (cmp(y, x)) {
			f[d] = (f[d] + 1) % mod;
		}
	}
	for (int i = ((n&1)?n:n-1); i >= 1; i -= 2) if (n % i == 0) {
		for (int j = 3 * i; j <= n; j += 2 * i) if (n % j == 0) {
			f[i] = (f[i] + mod - f[j]) % mod;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i += 2) ans = (ans + 2ll * n / i * f[i]) % mod;
	cout<<ans;
}


Measured memory_bytes: 4996
#include <iostream>
#include <algorithm> 
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	int aa = 0;
	for (int i = 0; i < b; i++)
		aa = aa * 10 + a;
	int bb = 0;
	for (int i = 0; i < a; i++)
		bb = bb * 10 + b;
	cout << (aa > bb ? aa : bb);
	return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };



int main()
{
	string a, b, c;
	cin >> a >> b >> c;

	cout << a[0] << b[1] << c[2] << endl;
}


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

int main(void) {
	string str;
	cin >> str;

	for (int i = 0; i < 3; i++) {
		if (str[i] == '9') str[i] = '1';
		else if (str[i] == '1') str[i] = '9';
	}
	cout << str << endl;
	return 0;
}

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

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    --ch; --cw; --dh; --dw;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    
    vector<vector<int>> dist(h, vector<int>(w,INF));
    deque<P> deq;
    deq.push_back(P(ch, cw));
    dist[ch][cw] = 0;

    while(!deq.empty()) {
        P p = deq.front(); deq.pop_front();
        if (p.first == dh && p.second == dw) break;

        int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
        for (int i = 0; i < 4; i++) {
            int nx = p.first+dx[i], ny = p.second+dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#'
                && (dist[nx][ny] == INF || dist[nx][ny] > dist[p.first][p.second])) {
                dist[nx][ny] = dist[p.first][p.second];
                deq.push_front(P(nx, ny));
            }
        }

        for (int i = -2; i < 3; i++) {
            for (int j = -2; j < 3; j++) {
                if (i == 0 && j == 0) continue;
                int nx = p.first+i, ny = p.second+j;
                 if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#'
                    && (dist[nx][ny] == INF || dist[nx][ny] > dist[p.first][p.second]+1)) {
                     dist[nx][ny] = dist[p.first][p.second]+1;
                     deq.push_back(P(nx, ny));
                 }
            }
        }
    }
    if (dist[dh][dw] == INF) cout << -1 << endl;
    else cout << dist[dh][dw] << endl;
  return 0;
}

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

int main()
{
    ll x,n;
    cin>>x>>n;
    ll p[n],val=0;
    ll a[105]={0};
    for(ll i=0;i<n;++i)
    {
        cin>>p[i];
        a[p[i]]=1;
    }

    for(ll i=0;i<=101;++i)
    {
        if(a[i])    continue;
        if(abs(val - x) > abs(i - x))    val=i;
    }
    cout<<val<<endl;
}

Measured memory_bytes: 3636
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const ll MOD = TEN(9) + 7;
const int MAX_N = 200000;
int n;
vi g[MAX_N];
ll cnt[MAX_N];
ll dp[MAX_N];
ll fact[MAX_N + 1];
vl ans;

template <long long mod>
long long mod_pow(long long a, long long b) {
    if (b == 0) return 1;
    long long ret = mod_pow<mod>(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret = a * ret % mod;
    return ret;
}

const auto mpow = [](ll a, ll b) { return mod_pow<MOD>(a, b); };

ll inv(ll x) {
    return mpow(x, MOD - 2);
}

void dfs(int i, int p) {
    ll ans = 1;
    ll c = 0;
    for (int j : g[i]) {
        if (j == p) continue;
        dfs(j, i);
        ans = ans * dp[j] % MOD * inv(fact[cnt[j]]) % MOD;
        c = (c + cnt[j]) % MOD;
    }

    ans = ans * fact[c] % MOD;
    cnt[i] = c + 1;
    dp[i] = ans;
}

void pre_calc() {
    fact[0] = 1;
    for (ll i = 1; i <= MAX_N; i++) {
        fact[i] = i * fact[i - 1] % MOD;
    }
}

void go(int i, int p) {
    ans[i] = dp[i];

    for (int j : g[i]) {
        if (j == p) continue;
        ll dpi = dp[i];
        ll ci = cnt[i];
        ll dpj = dp[j];
        ll cj = cnt[j];

        dp[i] = dp[i] * inv(fact[n - 1]) % MOD * inv(dp[j]) % MOD * fact[cj] % MOD * fact[n - 1 - cj] % MOD;
        cnt[i] = n - cj;
        //printf("dp[%d]=%lld cnt[%d]=%lld\n", i, dp[i], i, cnt[i]);
        dp[j] = dp[j] * inv(fact[cj - 1]) % MOD * dp[i] % MOD * inv(fact[cnt[i]]) % MOD * fact[n - 1] % MOD;
        cnt[j] = n;

        go(j, i);
        dp[i] = dpi;
        dp[j] = dpj;
        cnt[i] = ci;
        cnt[j] = cj;
    }
}

int main() {
    fastio();

    pre_calc();

    cin >> n;
    forn(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans = vl(n);
    dfs(0, -1);
    go(0, -1);

    for (ll x : ans) {
        cout << x << "\n";
    }

    return 0;
}

Measured memory_bytes: 20212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2=1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i;  cin>>n;
    if(n>=30) cout<<"Yes";
    else      cout<<"No";
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> t(N);
  
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    t.at(i) = make_tuple(S, 100 - P, i + 1);
  }
  sort(t.begin(), t.end());
  
  
      
  
  for (int i = 0; i < N; i++) {
    int a;
    tie(ignore, ignore, a) = t.at(i);
    cout << a << endl;
  }
  
  
  
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
const ll mod = 1e9 + 7;
ll inv[maxn];
void init()
{
    inv[1] = 1;
    for (int i = 2; i < maxn; i++)
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}

ll getpc(ll m, ll n) //m 中 选 n 个
{
    long long ans = 1;
    for (long long k = 1; k <= n; k++)
    {
        ans = (ans * (m - n + k)) % mod * inv[k] % mod;
        // ans %= mod;
    }
    return ans;
}
ll gao(ll n, ll m)
{
    return (getpc(n + m , m) - 1ll + mod) % mod;
}
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    init();
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1++;
    c1++;
    r2++;
    c2++;
    ll ans = gao(r2, c2);
    // chu(ans);
    ans = (ans - gao(r1 - 1, c2) + mod) % mod;
    // chu(ans);
    ans = (ans - gao(r2, c1 - 1) + mod) % mod;
    // chu(ans);
    ans = (ans + gao(r1 - 1, c1 - 1)) % mod;
    printf("%lld\n", ans );
    return 0;
}




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

int main()
{
	ios::sync_with_stdio(false);
	
	string s;
	int n;
	cin>>s;
	n=s.size();
	
	if(s[0]==s[n-1])
	{
		if(n%2==0)
			cout<<"First"<<endl;
		else
			cout<<"Second"<<endl;
	}
	else
	{
		if(n%2==0)
			cout<<"Second"<<endl;
		else
			cout<<"First"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
def main():
    S = input()
    div = pow(10, 9) + 7
    rem = [0 for _ in range(13)]
    rem[0] = 1
    for c in S:
        temp = [0 for _ in range(13)]
        if c != "?":
            for i in range(13):
                r = (i*10+int(c)) % 13
                temp[r] += rem[i] % div
        else:
            for i in range(13):
                for j in range(10):
                    r = (i*10+j) % 13
                    temp[r] += rem[i] % div
        rem = temp
    return rem[5] % div

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 43484
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
#define mod 998244353
#define N 1000010
using namespace std;
map <int ,int > mp;
int main()
{
    int n,k;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>k;
        int t=-k-i;
        mp[t]++;
        if(mp.count(k-i))
        {
            ans+=(ll)mp[k-i];
        }

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


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

int main(){
	int n,a,b,c,x=0,y=0,t=0,pos=1;
  	scanf("%d",&n);
    while(n--){
    	scanf("%d%d%d",&c,&a,&b);
        int step = abs(x-a) + abs(y-b);
        x = a, y = b;
        pos = pos && (c-t-step >= 0 && (c-t-step)%2 == 0);
    	t = c;
    }
    if(pos)printf("Yes");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI

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

    if(s<=w){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}





Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 10005
//<<fixed << setprecision(9)

int dp[space][1001];
int main()
{
    int n,i,j,t;
    boost;

    int h;
    cin>>h>>n;

    pii arr[n];
    rep(i,0,n)cin>>arr[i].F>>arr[i].S;
    
    rep(i,1,h+1)
    {
        dp[i][0]=1e9;
        rep(j,1,n+1)
        {
            if(arr[j-1].F>i)
            {
                dp[i][j]=min(dp[i][j-1],arr[j-1].S);
            }
            else dp[i][j]=min(dp[i][j-1],dp[i-arr[j-1].F][j] + arr[j-1].S);
            //cout<<dp[i][j]<<" ";
        }
        //cout<<"\n";
    }
    cout<<dp[h][n];
    
    
    return 0;
}



Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
#define swp(x,y) (x^=y^=x^=y)
int w,a,b,l1,r1,l2,r2;
int main()
{
    scanf("%d %d %d",&w,&a,&b);if(a>b) swp(a,b);
    l1=a;r1=a+w;l2=b;r2=b+w;
    if(r1>=l2) puts("0");else printf("%d\n",l2-r1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
typedef long long ll;
int a[MAXN],n;
ll srk[MAXN][2],frk[MAXN][2];
inline ll Abs(ll num){
	return num>0?num:-num;
}
bool check(int pos1,ll sum1,ll sum2){
	ll t1 = Abs(sum1-sum2-sum2);
	ll t2 = Abs(sum1-sum2-sum2-a[pos1]-a[pos1]);
	if(t2<t1)return true;
	else return false;
}
ll BigOf4(ll e,ll b,ll c,ll d){
	return max(max(e,b),max(c,d));
}
ll SmaOf4(ll b,ll c,ll d,ll e){
	return min(min(b,c),min(d,e));
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	ll sum=0,sum1=0;
	sum=sum1=a[1];
	int pos=1;
	for(int i=2;i<=n;i++){
		sum+=a[i];
		while(pos+1<i&&check(pos+1,sum,sum1)){
			pos++;
			sum1+=a[pos];
		}
		frk[i][0]=sum-sum1;
		frk[i][1]=sum1;
	//	cout<<sum<<" "<<sum1<<" "<<i<<endl;
	}
	sum=sum1=a[n];
	pos=n;
	for(int i=n-1;i>=1;i--){
		sum+=a[i];
		while(pos-1>i&&check(pos-1,sum,sum1)){
			pos--;
			sum1+=a[pos];
		}
		srk[i][0]=sum-sum1;
		srk[i][1]=sum1;
	}
	ll ans=1000000000000000LL;
	for(int i=2;i+2<=n;i++){
		ans=min(ans,BigOf4(frk[i][0],frk[i][1],srk[i+1][0],srk[i+1][1])-SmaOf4(frk[i][0],frk[i][1],srk[i+1][0],srk[i+1][1]));
	}
	cout<<ans;
	return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N, K, ans=0;
  cin >> N >> K;
  VI l(N);
  REP(i,N) {
    cin >> l.at(i);
  }
  SORT(l);
  REP(i,K) {
    ans += l.at(N-i-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
now = 0
while True:
    if ("#" in a[now]):
        now += 1
    else:
        a.pop(now)
    if (now >= len(a)):
        break
#print(a)
ans = [[] for _ in range(len(a))]
for i in range(w):
    f = 0
    for j in range(len(a)):
        if (a[j][i]=="#"):
            f += 1
    if (f>0):
        for j in range(len(a)):
            ans[j].append(a[j][i])
for i in range(len(a)):
    print(''.join(ans[i]))

Measured memory_bytes: 3188
n = gets.to_i
L_arr = gets.chomp.split.map(&:to_i)
abs_arr = []

(1..(n-1)).to_a.each do |i|
  abs_arr <<  ((L_arr.slice(0,i).inject(&:+)) - (L_arr.slice(i,n).inject(&:+))).abs
end

p abs_arr.min


Measured memory_bytes: 1788
#include<stdio.h>
#define N 500000
#define INF 1000000000
int n,count=0;
void merge(int a[],int left,int mid,int right);
void mergeSort(int a[],int left,int right);
int main()
{
  int i,A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
      if(i) printf(" ");
      printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}
void merge(int a[],int left,int mid,int right){
    int n1,n2,i,j,k;
    n1=mid-left;
    n2=right-mid;
     int L[n1+1],R[n2+1];
    for(i=0;i<n1;++i) 
    L[i]=a[left+i];
    for(i=0;i<n2;++i)
     R[i]=a[mid+i];
    L[n1]=INF;
    R[n2]=INF;
    i=0;j=0;
    for(k=left;k<right;k++){
        count++;
        if(L[i]<=R[j])
        a[k]=L[i++];
        else 
        a[k]=R[j++];
    }
}
void mergeSort(int a[],int left,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}


Measured memory_bytes: 5624
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i=0; i<N; i++) cin>>P[i];
  for ( int i=0; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i=0; i<N; i++)v.push_back(i+1);
  int idx =0, a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i=0; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i=0; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    idx++;
  }while(next_permutation(v.begin(),v.end()));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n){
        cin >> p.at(i);
    }
    sort(all(p));
    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
}


Measured memory_bytes: 3484
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            // writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut buf = String::new();
    
    let n = sc.read();
    let mut dic = HashSet::new();
    for _ in 0..n {
        let com: String = sc.read();
        let s: String = sc.read();
        match com.as_str() {
            "insert" => {
                dic.insert(s);
            },
            _ => {
                if dic.contains(&s) {
                    buf += "yes\n";
                } else {
                    buf += "no\n";
                }
            },
        }
    }

    print!("{}", buf);
}



Measured memory_bytes: 37512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val ab = (0 until n).map { sc.next().toLong() to sc.next().toLong() }
    println(problem131d(n, ab))
}

fun problem131d(n: Int, ab: List<Pair<Long, Long>>): String {
    val dp = (0 until n).map { 0L to 0L }.toMutableList()
    val ab = ab.sortedBy { it.second }
    dp[0] = ab[0]
    if (dp[0].first > dp[0].second) return "No"
    for (i in 1 until ab.size) {
        dp[i] = (dp[i - 1].first + ab[i].first) to ab[i].second
        if (dp[i].first > dp[i].second) return "No"
    }
    return "Yes"
}

Measured memory_bytes: 147192
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  cout << x % b << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

odd = 0
even = 0

n = ni()
a = list(li())

for ai in a:
    if ai%2:
        odd += 1
    else:
        even += 1
        
if odd%2:
    print("NO")
else:
    print("YES")

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string s;
  cin >> s;
  int n = s.size();

  int cnt = 0;
  string ans = "AC";
  if(s[0]!='A'){
    ans = "WA";
    cout << ans << endl;
    return 0;
  }
  if(s[0]=='A'){
    for(int i=1; i<n; ++i){
      if(isupper(s[i])){
        if(i==1||i==n-1||s[i]!='C'){
          ans = "WA";
        }
        ++cnt;
      }
    }
  }
  if(cnt != 1){
    cout << "WA";
    return 0;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    List<Integer> collect = list.stream().sorted().collect(Collectors.toList());
    int sum = 0;
    for (int i = 0; i < k; i++) {
      sum += collect.get(i);
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 34392
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,m;
struct node { int l,r; } a[N];
priority_queue<int,vector<int>,greater<int>> L;
priority_queue<int> R;

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) a[i].l=read(),a[i].r=read();
	sort(a+1,a+n+1,[](node a,node b) { return a.l<b.l; });
	int l=1,r=m,ans=0;
	for (int i=1;i<=n;++i) {
		L.push(a[i].r);
		if (l<=r&&l<=a[i].l) ++l;
		else R.push(L.top()),L.pop();
	}
	while (!R.empty()) {
		if (l<=r&&r>=R.top()) --r;
		else ++ans;
		R.pop();
	}
	printf("%d\n",ans);
	return 0;
}

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

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N, M;

struct Job {
  int a;
  int b;
  int e;
};

vector<Job> jobs;

int main(int argc, char** argv) {
  cin >> N >> M;

  jobs.reserve(N);

  for (int i=0; i<N; i++) {
    Job j;
    cin >> j.a >> j.b;
    j.e = M-j.a;
    jobs.push_back(j);
  }

  sort(begin(jobs), end(jobs),
       [](const Job& lhs, const Job& rhs) {
         return lhs.e > rhs.e;
       });
  auto it = jobs.begin();

  priority_queue<int> q;
  ll ret = 0;

  for (int i=M; i>=0; i--) {

    while (it != jobs.end()) {
      if (it->e != i) break;

      q.push(it->b);
      it++;
    }

    if (q.empty()) continue;

    ret += q.top();
    q.pop();
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
int main(){
  int n,i,result[10000],amount=0,x;

  scanf("%d",&n);
  for(i=3;i<=n;i++){
    x = i;
    if(i % 3 == 0){
      result[amount] = i;
      amount++;
    }
    else if(i>=10){
      for(;;){
        if(x%10 == 3){
          result[amount] = i;
          amount++;
          break;
        }
        else{
          x /= 10;
          if(x == 0) break;
        }
      }

    }
  }
  for(i=0;i<amount;i++){
    printf(" %d",result[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;ans%=mod;}b/=2;a*=a;a%=mod;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INF=0x3f3f3f3f;
#define PII pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
const int INT=1000000000;
char a[55][55];
int dp[55][55];
int n,m;
bool vis[55][55];

bool check(int x,int y)
{
    return x>=0 && y>=0 && x<n && y<m;
}
void bfs(int i,int j)
{
    queue<pair<int,int> > q;
    q.push(mp(i,j));
    int cnt=0;
    int ff=0;
    
    while(!q.empty()){
        PII p=q.front();
        q.pop();
        
        if(vis[p.F][p.S] || a[p.F][p.S]=='#') continue;
        
        vis[p.F][p.S]=true;
        int x=p.F;
        int y=p.S;
        
        if(check(x+1,y) && !vis[x+1][y]) {dp[x+1][y]=1+dp[x][y];q.push(mp(x+1,y));}
        if(check(x-1,y) && !vis[x-1][y]) {dp[x-1][y]=1+dp[x][y];q.push(mp(x-1,y));}
        if(check(x,y-1) && !vis[x][y-1]) {dp[x][y-1]=1+dp[x][y];q.push(mp(x,y-1));}
        if(check(x,y+1) && !vis[x][y+1]) {dp[x][y+1]=1+dp[x][y];q.push(mp(x,y+1));}
    }
}

int main()
{
    si(n);si(m);
    int h=0;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) {
            cin>>a[i][j];
            if(a[i][j]=='#') h++;
        }
    }
    dp[0][0]=0;
    bfs(0,0);
    if(dp[n-1][m-1]==-1) cout<<"-1"<<endl;
    else cout<<((n*m)-dp[n-1][m-1]-h-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

a=int(input())
b=int(input())
if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")

Measured memory_bytes: 38256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
 
int n,a[1 << 18];
 
int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}	
	int lcm = a[1];
	for(int i = 2;i <= n;i++)
	{
		lcm *= (1LL * a[i]) / (1LL * __gcd(lcm,a[i]));
	}
	rc(lcm);
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

bool dp[80][80][13000];
vector<vector<int>> da(80,vector<int>(80));

int main(){
    int h,w;
    cin >> h >> w;
    rip(i,h,0){
        rip(j,w,0){
            cin >> da[i][j];
        }
    }
    int jjj;
    rip(i,h,0){
        rip(j,w,0){
            cin >> jjj;
            da[i][j] = abs(da[i][j] - jjj);
        }
    }
    rip(i,h,0){
        rip(j,w,0){
            rip(k,13000,0){
                dp[i][j][k] = false;
            }
        }
    }
    dp[0][0][da[0][0]] = true;
    rip(i,h,0){
        rip(j,w,0){
            rip(k,12800,0){
                if(i){
                    if(dp[i- 1][j][k + da[i][j]]){
                        dp[i][j][k] = true;
                    }
                    if(dp[i -1][j][abs(k - da[i][j])]){
                        dp[i][j][k] = true;
                    }
                }
                if(j){
                    if(dp[i][j - 1][k + da[i][j]]){
                        dp[i][j][k] = true;
                    }
                    if(dp[i][j - 1][abs(k - da[i][j])]){
                        dp[i][j][k] = true;
                    }
                }
            }
        }
    }
    int ans = 0;
    while(!dp[h - 1][w -1][ans]){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81536
n = input()

ans = ""
if (n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1]=='9'):
    ans = "hon"
elif (n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8'):
    ans = "pon"
else:
    ans = "bon"

print(ans)


Measured memory_bytes: 9116
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char[] s = S.toCharArray();
		boolean A = true;
		if(N%2 != 0) {
			A = false;
		}
		for(int i = 0; i < N/2; i++) {
			if(s[i] != s[(N/2)+i]) {
				A = false;
				break;
			}
		}
		if(A == true) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

int a[30];

int main () {

string s;
cin>>s;
for (int i=0; i<s.size(); i++) {
    a[s[i]-'a']++;
}
for (int i=0; i<26; i++) {
    if (a[i]==0) {cout<<(char) (i+(int)'a'); return 0;}
}
cout<<"None";

return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	fmt.Println(solve(a, b, c, d))
}

func solve(a, b, c, d int) string {
	if abs(c-a) <= d {
		return "Yes"
	}
	if abs(b-a) <= d && abs(c-b) <= d {
		return "Yes"
	}
	return "No"
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

Measured memory_bytes: 512
#include <iostream>

#define _USE_MATH_DEFINES
#include "math.h"

int main()
{
	double r;
	std::cin >> r;
	double area = r * r*M_PI;
	double circumference = 2 * r*M_PI;
	printf("%lf %lf\n", area, circumference);

	return 0;
}


Measured memory_bytes: 3176
module ABC088B
	sub Main(ByVal args() as String)
		dim n,i,r,t as integer
		n=Console.ReadLine()
		dim arrs(n) as string
		dim arr(n) as integer
		arrs=Split(Console.ReadLine())
		arr=Array.ConvertAll(of string,integer)(arrs,addressof Integer.Parse)
		Array.Sort(arr)
		Array.Reverse(arr)
		r=0
		t=1
		for i=1 to n
			r+=t*arr(i-1)
			t=-t
		next
		Console.WriteLine(r)
	end sub
end module


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for (int i=0; i<n; i++) {
  	cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  
  sort(b.begin(), b.end(), greater<int>());
  
  for (int i=0; i<n; i++) {
    if (a.at(i) == b.at(0)) {
      cout << b.at(1) << endl;
    }else{
      cout << b.at(0) << endl;
    }
  }
  
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a<=8 && b<=8){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i-1]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512