akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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 print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 1, 0);
    for(int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int a;
            cin >> a;
            cnt[a]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(cnt[i] == 0) {
            ans++;
        }
    }
    print(ans);
}

Measured memory_bytes: 3628
/**
 *      AGC 22 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-25 15:48:55
**/

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

bool isTasai(string S){
    for (auto c = 'a'; c <= 'z'; ++c) {
        if (count(S.begin(), S.end(), c) > 1){
            return false;
        }
    }
    return true;
}

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

    if (S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl; return 0;
    }

    vector<char> rm;

    if ((int) S.size() < 26){
        for (char c = 'a'; c <= 'z'; ++c){
            if (S.find(c) == string::npos){
                cout << S << c << endl; return 0;
            }
        }
    }

    else {
        for (auto i = 0; i < 26; ++i) {
            rm.push_back(S[(int) S.size() - 1]);
            sort(rm.begin(), rm.end());
            S.pop_back();
            for (auto x : rm){
                if (S[(int) S.size() - 1] < x){
                    S.pop_back();
                    cout << S << x << endl; return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int first = min(n*x,k*x);
	int second = max(0,(n-k)*y);
	cout << first+second << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<int> ruiseki_E(N, 0);
  vector<int> ruiseki_W(N, 0);
  for (int i = 1; i < N; ++i) {
    if (S[i - 1] == 'W') {
      ruiseki_E[i] = ruiseki_E[i - 1] + 1;
    } else {
      ruiseki_E[i] = ruiseki_E[i - 1];
    }
  }
  for (int i = N - 2; i != -1; --i) {
    if (S[i + 1] == 'E') {
      ruiseki_W[i] = ruiseki_W[i + 1] + 1;
    } else {
      ruiseki_W[i] = ruiseki_W[i + 1];
    }
  }
  int ans = ruiseki_E[0] + ruiseki_W[0];
  for (int i = 1; i < N; ++i) {
    ans = min(ans, ruiseki_E[i] + ruiseki_W[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
#include<cstdio>
int a,b,c;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	if (a==b&&a==c) printf("No");
	else if (a!=b&&a!=c&&b!=c) printf("No");
	else printf("Yes");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  long long k[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int u;
  cin>>u;
  cout<<k[u-1];
}

Measured memory_bytes: 256
m,n = list(map(int, input().split()))

def mod_pow(a,n,mod):
    ret = 1
    while n>0:
        if (n & 1): ret = ret * a % mod
        a = a * a % mod
        n >>= 1
    return ret

print(mod_pow(m,n,10**9+7))


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

using namespace std;

int a[100001], l[100001], r[100001];

int gcd(int a, int b) {
    return a == 0 ? b : gcd(b % a, a);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    l[0] = a[0];
    r[n - 1] = a[n - 1];
    for (int i = 0; i < n - 1; ++i) {
        l[i + 1] = gcd(l[i], a[i + 1]);
        r[n - 1 - i - 1] = gcd(r[n - 1 - i], a[n - 1 - i - 1]);
    }
    int answer = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            answer = max(answer, r[1]);
        } else if (i == n - 1) {
            answer = max(answer, l[n - 2]);
        } else {
            answer = max(answer, gcd(l[i - 1], r[i + 1]));
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
    int a[5] = {}, k;

    FOR(i, 0, 5)
    cin >> a[i];
    cin >> k;

    FOR(i,0,5)
    {
        FOR(j,i+1,5)
        {
            if(a[j]-a[i]>k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, k, s, a[N];
ll fac[N]{1, 1}, inv[N]{1, 1}, fiv[N]{1, 1};

ll com(ll p, ll q) {
	if (p < q) return 0;
	return fac[p] * fiv[p - q] % M * fiv[q] % M;
}

int main()
{
	ll i;
	cin >> n >> k;
	for (i = 2; i <= n; i++) {
		fac[i] = fac[i - 1] * i % M;
		inv[i] = inv[M % i] * (M - M / i) % M;
		fiv[i] = fiv[i - 1] * inv[i] % M;
	}
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		s = (s + a[i] * (com(i, k - 1) - com(n - i - 1, k - 1))) % M;
	}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h> 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
 
 
using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_pbds;
 
 
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
 
typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define f first
#define se second
#define N 100001
 
ll n,t,m,k;

ll ans;

int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("alchemy_input.txt","r",stdin); 
// freopen("out.txt","w",stdout); 
cout.precision(2);
cin>>n>>m;
vector<int>a(n);
lp(i,n)cin>>a[i],a[i]%=m;
map<int,int>mp;
mp[0]=1;
int sum=0;
lp(i,n){
  sum+=a[i];
  sum%=m;
  ans+=mp[sum];
  mp[sum]++;
}
cout<<ans;


  
  
}

 
 
 
 
 
 
  
 
 
 
 
// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }  


Measured memory_bytes: 6624
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c,d;cin>>a>>b>>c>>d;
    int e=a+b;int f=c+d;
    if(e>f) cout << "Left";
    else if(e<f) cout << "Right";
    else cout << "Balanced";
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] n = Read.ints();
        string a = Console.ReadLine();
        if (a[n[0]] != '-')
        {
            Console.WriteLine("No"); goto H;
               
        }
        int fs = 0;
        for (int i = 0; i < a.Length ; i++)
        {
            if (a[i] == '-'){ fs++; }
        }
        Console.WriteLine(fs==1?"Yes":"No");
        Console.ReadLine();
        H: { }
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
const int mod = 1e9 + 7;
const int nax = 2 * 1e5 + 5;
int n, m, k, q;
int main(){
	fast();
	cin >> n;
	vector<int> a(n + 2, 0);
	for(int i = 0; i < n - 1; ++i){
		int t;
		cin >> t;
		a[t]++;

	}
	for(int i = 1; i <= n; ++i)
		cout << a[i] << " ";
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    int X, Y; cin >> X >> Y;
    rep(i, X+1){
        if(4*X-2*i==Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
N = gets.to_i
S = gets.chomp
dp = Array.new(N + 1, 0)
S.chars.each_index.group_by{|i| S[i] }.each do |k, v|
  s = v.first
  t = v.last
  dp[s + 1] += 1
  dp[t + 1] -= 1
end
(1 .. N).each do |i|
  dp[i] += dp[i - 1]
end
puts dp.max

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

int main() {
  string s;
  int n;
  std::cin >> n>>s;

  int re=0;
  for (int i = 2; i < s.length(); i++) {

    if(s[i-2]=='A'&& s[i-1]=='B' && s[i]=='C')re++;
  }
  std::cout << re << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
        }
        long max = Arrays.stream(arr).max().getAsLong();
        if (max % 2 == 0) {
            if (Arrays.stream(arr).allMatch(value -> value % 2 == 0)) {
                System.out.println("second");
            } else {
                System.out.println("first");
            }
        } else {
            System.out.println("first");
        }
    }
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


bool setwise(const vector<int>& a) {
        int g = 0;
        for (int i = 0; i < sz(a); i++) {
                g = __gcd(g, a[i]);
        }

        return g == 1;
}

#define MAXN   1000001

int spf[MAXN];
void sieve() {
        spf[1] = 1;
        for (int i = 2; i < MAXN; i++) spf[i] = i;
        for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
        for (int i = 3; i * i < MAXN; i++) {
                if (spf[i] == i) {
                        for (int j = i * i; j < MAXN; j += i)
                                if (spf[j] == j) spf[j] = i;
                }
        }
}


void factorize(int x, map<int, int>& m) {
        set<int> vis;
        while (x != 1) {
                if (!vis.count(spf[x])) m[spf[x]]++, vis.emplace(spf[x]);
                assert(spf[x] != 0);
                x /= spf[x];
        }
}



bool pairwise(vector<int> a) {
        sort(all(a));
        map<int, int> pf;
        for (auto x: a) {
                factorize(x, pf);
        }

        for (auto it: pf)  {
                if (it.second >= 2) return 0;
        }

        return 1;
}


void _main() {
        sieve();
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        if (pairwise(a)) cout << "pairwise coprime";
        else if (setwise(a)) cout << "setwise coprime";
        else cout << "not coprime";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


#define debug(x) cout << #x << "==" << x << endl;

const int inf = 1e+8;

const int mod = 1e+9 + 7;

typedef long long ll;

// nHk = n+k-1Ck のために二倍にとる
#define MAX_N 2000

int N, A, B, C, D;

ll pow(ll a, int b){
    int ret = 1;
    while(b){
        if(b & 1) ret = (1ll) * ret * a % mod;
        b >>= 1;
        a = (1ll) * a * a % mod;
    }
    return ret;
}

ll add(ll a, ll b) {
  return (a + b) % mod;
}

ll mul(ll a, ll b) {
  return (a * b) % mod;
}

ll div(ll a, ll b) {
  return mul( a, pow(b, mod-2) );
}


ll fact[MAX_N+1], fact_inv[MAX_N+1];
void create_fact() {
  fact[0] = 1;
  fact_inv[0] = 1;
  for(int i = 1; i < MAX_N; i++) {
    fact[i] = mul(fact[i-1], i);
    fact_inv[i] = pow(fact[i], mod - 2);
  }
}

ll nPk(int n, int k) {
  // n! / (n-r)!
  return mul(fact[n], fact_inv[n-k]);
}

ll nCk(int n, int k) {
  // nPk / k!
  return mul(nPk(n, k), fact_inv[k]);
}


// g人以下のグループで p人 を分ける
ll memo[MAX_N][MAX_N];
bool checked[MAX_N][MAX_N];
ll rec(int g, int p) {

  if (p == 0) return 1;
  if (g == 0) return 0;

  if(checked[g][p]) return memo[g][p];

  ll ret = 0;

  // g人グループを使わない
  ret = add(ret, rec(g-1, p) );

  // g人グループを使う（使えるなら，使える範囲で）
  if( A <= g and g <= B ) {
    for(int k = C; k <= D; k++) {
      if( k*g <= p ) {
        ll rest = rec(g-1, p - k*g );
        // pPg*k / (g!)^k / k!
        ll comb = nPk(p, g*k);
        comb = mul( comb, pow(fact_inv[g], k) );
        comb = mul( comb, fact_inv[k] );
        ret =  add(ret, mul(rest, comb) );
      }
    }
  }

  checked[g][p] = true;
  memo[g][p] = ret;
  return ret;

}


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

  create_fact();

  cin >> N >> A >> B >> C >> D;

  cout << rec(N, N) << "\n";

  return 0;
}


Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

mt19937 rng(2137);
int rd(int a, int b) {
	return uniform_int_distribution<int>(a, b)(rng);
}

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

	auto start = chrono::steady_clock::now();

	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	REP(i, n) cin >> c[i];
	vector<vector<int>> s(d, vector<int>(n));
	REP(i, d) REP(j, n) cin >> s[i][j];

	auto get_score = [&](vector<int> &ans) {
		LL score = 0;
		vector<int> last(n, -1);
		REP(i, d) {
			score += s[i][ans[i]];
			last[ans[i]] = i;
			REP(j, n) score -= c[j] * (i - last[j]);
		}
		return score;
	};

	auto get_time = [&]() {
		auto curr = chrono::steady_clock::now();
		return int(chrono::duration_cast<chrono::milliseconds>(curr - start).count());
	};

	vector<int> best(d);
	REP(i, d) best[i] = i % n;
	LL best_score = get_score(best);
	cerr << best_score << "\n";

	while(get_time() <= 1900) {
		auto cur = best;
		int x = rd(0, d - 1);
		cur[x] = rd(0, 25);

		LL new_score = get_score(cur);
		if(new_score >= best_score) {
			best = cur;
			best_score = new_score;
		}
	}

	for(int x : best)
		cout << x + 1 << "\n";
}


Measured memory_bytes: 3736
#include<iostream>

using namespace std;

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



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

//----------------------------------------------------------------

int main()
{
    ll n, t;
    cin >> n >> t;
    ll a;
    cin >> a;
    long long before = 0;
    long long muda = 0;
    for (int i = 1; i < n; i++)
    {
        cin >> a;
        if (a - before < t)
        {
            muda += t - a + before;
        }
        before = a;
    }
    cout << n * t - muda << endl;
}


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

int main()
{
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans(0);
  for (int i = 0; i <= n; i += r) {
    for (int j = 0; j <= n - i; j += g) {
      int k = n - i - j;
      if (k % b == 0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = NM[0], M = NM[1];
        var H = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Graph<int> G = new Graph<int>(N);
        for (int i = 0; i < M; i++)
        {
            var r = Console.ReadLine().Split().Select(_=>int.Parse(_)-1).ToArray();
            G.Add(r[0], r[1]);
            G.Add(r[1], r[0]);
        }

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            bool frag = true;
            foreach (var j in G[i])
            {
                if (H[i] <= H[j])
                {
                    frag = false;
                    break;
                }
            }

            if (frag) ans++;
        }

        Console.WriteLine(ans);
    }
}
class Graph<T>
{
    private List<T>[] G;
    public Graph(int size)
    {
        G = new List<T>[size];
        for (int i = 0; i < size; i++)
        {
            G[i] = new List<T>();
        }
    }

    public List<T> this[int i] => G[i];
    public void Add(int from, T to) => G[from].Add(to);
    public List<T>[] ToListArray() => G;

}

Measured memory_bytes: 56432
s=int(input())


def func(n):
  if n%2==0:
    return int(n/2)
  else:
    return 3*n+1

m=1
L=[s]
t=s
while True:
  m+=1
  t=func(t)
  if t in L:
    print(m)
    break
  else:
    L.append(t)


Measured memory_bytes: 2940
import collections

n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
cnt=collections.defaultdict(int)
cnt[0]+=1
for i in range(1,n+1):
  arr[i]+=arr[i-1]
  arr[i]%=m
  cnt[arr[i]]+=1
ans=0
for key in cnt.keys():
  ans+=(cnt[key]*(cnt[key]-1))//2
print(ans)

Measured memory_bytes: 20932
H,W = map(int,input().split())
m = [input() for _ in range(H)]
##「離れ小島」がなければよし
vector = [[0,1],[1,0],[-1,0],[0,-1]]

for i in range(H):
    for j in range(W):
        if m[i][j] == "#":
            flag = False
            for dx,dy in vector:
                x = i + dx
                y = j + dy

                if 0 <= x < H and 0 <= y < W:
                    if m[x][y] == "#":
                        flag = True
            if not flag:
                print("No")
                exit()
                
print("Yes") 

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

int ans[26];
int last[26];

int main(){
	string s; cin >> s;
	memset(last, -1, sizeof(last));
	for (int i = 0; i < s.length(); i++){
		ans[s[i] - 'a'] = max(ans[s[i] - 'a'], i - last[s[i] - 'a'] - 1);
		last[s[i] - 'a'] = i;
	}
	int minj = 0x3f3f3f3f;
	for (int i = 0; i < 26; i++){
		ans[i] = max(ans[i], (int)s.length() - last[i] - 1);
		minj = min(minj, ans[i]);
	}
	cout << minj << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>

using namespace std;
static const int MAX=100000;

vector<int> G[MAX];
list<int> result;
int n;
int indeg[MAX]; //??????????????\???
bool Visited[MAX];

void bfs(int s)
{
    queue<int> Q;
    Q.push(s); //???????????\???
    Visited[s]=true;
    while(!Q.empty())
    {
        int u=Q.front(); Q.pop();
        //enqueue
        result.push_back(u); //??¨???bfs????????????????°±??????????????????
        //trav
        for(int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            indeg[v]--; //??\?????????
            if(indeg[v]==0&&!Visited[v])  //????¬??°???\??????0??????????????\????????????
            {
                Visited[v]=true;
                Q.push(v);
            }
        }
    }
}

void tsort()
{
    //init
    for(int i=0;i<n;i++)
        indeg[i]=0;
    //count the indeg of every node
    for(int i=0;i<n;i++)
        for(int j=0;j<G[i].size();j++)
            indeg[G[i][j]]++;
    //begin bfs
    for(int i=0;i<n;i++)
        if(indeg[i]==0&&!Visited[i]) bfs(i); //??\??????0??????????????????????????????bfs??????
    //print
    for(list<int>::iterator it=result.begin();it!=result.end();it++)
        cout<<*it<<endl;
}
int main()
{
    int e;
    cin>>n>>e;
    //init
    for(int i=0;i<n;i++) Visited[i]=false;

    int s,t;
    for(int i=0;i<e;i++)
    {
        cin>>s>>t;
        G[s].push_back(t);
    }

    //begin tsort
    tsort();
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N,M;
int s[6], c[6];
int k(int, int);

int main()
{
  int n;
  int i;
  int kmin, kmax;
  int ret=0;

  cin >> N >> M;
  for (i=0; i<M; i++) {
    cin >> s[i] >> c[i];
  }
  switch(N) {
  case 1: kmin = 0; kmax = 9; break;
  case 2: kmin = 10; kmax = 99; break;
  case 3: kmin = 100; kmax = 999; break;
  }

  for (n=kmin; n<=kmax; n++) {
    for (i=0; i<M; i++) {
//printf("k(%d, %d) = %d , %d\n", n, s[i], k(n, s[i]), c[i]);
      if (k(n, s[i]) != c[i]) break;
    }
    if (i>=M) break;
  }

  if (n<=kmax)
    printf("%d\n", n);
  else
    printf("-1\n");

  return 0;
}

int k(int num, int idx) {
  int k10, i;
  int nx;
  for (nx = num, k10=0; nx > 00; nx/=10) k10++;
//printf("%d: ", k10);
  for (nx = num, i=0; nx > 0; nx/=10, i++) {
    if (k10-i ==idx) return nx%10;
  }
  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <stack>
#include <iostream>

using namespace std;

bool linearSearch(int T[], int q, int key){
    int j,count=0;
    T[q]=key;
    j=0;
    while(T[j]!=key){
        j++;
    }
    return j!=q;
}
bool binarySearch(int T[], int q, int key){
    int left=0, right=q,middle;
    while(left<right){
        middle=(right+left)/2;
        if(T[middle]<key){
            left=middle+1;
        }else if(T[middle]>key){
            right=middle;
        }else{
            return true;
        }
    }
    return false;
}

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

    scanf("%d",&q);
    int T[50000];
    for(i=0;i<q;i++){
        scanf("%d", &T[i]);
    }
    int sum=0;
    for(i=0;i<q;i++){
        if(binarySearch(S,n,T[i])) sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3732
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int k, x;
    scan(k, x);
    writeln(500*k >= x ? "Yes" : "No");
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int a;
  int min=1000000;
  int max=-1000000;
  long long sum=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a;
    sum=sum+a;
    if(a<min){
      min=a;
    }
    if(a>max){
      max=a;
    }
  }
  cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        char[] s = new char[S.length()];
        char[] t = new char[T.length()];
        int max = 0;
        for(int i=0;i<S.length();i++){
            s[i] = S.charAt(i);
        }
        for(int i=0;i<T.length();i++){
            t[i] = T.charAt(i);
        }
        if(S.length() == T.length()){
            int count = 0;
            for(int j=0;j<T.length();j++){
                if(s[j] == t[j]){
                    count++;
                }
            }
            System.out.println(T.length() - count);
            return;
        }
        for(int i=0;i<S.length()-T.length();i++){
            int count = 0;
            for(int j=0;j<T.length();j++){
                if(s[i+j] == t[j]){
                    count++;
                }
            }
            if(count > max)max = count;
        }
        System.out.println(T.length() - max);
    }
}

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

int main(){
    long long n;
    cin>>n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    } 
    long long five=10;
    long long res=0;
    while(n>=five){
        res+=n/five;
        five*=5;
    }

    cout<<res<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  
  int sum = 0;
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }

  if (sum <=  N) {
    cout << N - sum << endl;
  }
  else {
    cout << "-1" << endl;
  }
  
  
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;
const LL mod = 1e9 + 7;

int N , M , K;
LL c[600010];
LL t[600010];
LL p[900010];
LL r[600010];
LL ans;

LL conv(int a , int b){
	return (p[a] * r[b] % mod) * r[a - b] % mod;
}

int main(){
	scanf("%d%d%d" , &N , &M , &K);
	p[0] = p[1] = 1;
	for(int i = 2 ; i < N + M + K ; ++i){
		p[i] = (p[i - 1] * i) % mod;
	}
	int s = M + K + N - 1;
	LL x = p[s];
	r[s] = 1;
	for(int i = (int)mod - 2 ; i > 0; i /= 2 , x = (x * x) % mod){
		if(i % 2 == 1) r[s] = (r[s] * x) % mod;
	}
	for(int i = s - 1 ; i >= 0 ; --i){
		r[i] = r[i + 1] * (i + 1) % mod;
	}
	c[0] = t[0] = 1;
	for(int i = 1 ; i <= M + K ; ++i){
		t[i] = (t[i - 1] * 3) % mod;
	}
	if(K < M){
		K ^= M;
		M ^= K;
		K ^= M;
	}
	s = K + M;
	for(int i = 1 ; i <= M ; ++i){
		c[i] = c[i - 1] * 2 % mod;
	}
	c[s] = conv(s , K);
	for(int i = s - 1 ; i >= K ; --i){
		c[i] = (c[i + 1] + conv(i , K) + conv(i , M)) * r[2] % mod;
	}
	for(int i = K - 1 ; i > M ; --i){
		c[i] = (c[i + 1] + conv(i , M)) * r[2] % mod;
	}
	for(int i = s ; i >= 0 ; --i){
		x = p[i + N - 1] * t[s - i] % mod;
		x = x * r[N - 1] % mod;
		x = x * c[i] % mod;
		x = x * r[i] % mod;
		ans += x;
		ans %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 21248
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define spe pair<string,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

int main(){
    
    int n;
    vector<spe> v;
    map<int,int> m;
    cin >> n;
    rep(i,n){
        string s;
        int p;
        cin >> s>> p;
        m[p]=i+1;
        v.push_back(spe(s,p));
    }
    sort(all(v));
    
    int ite=0;
    while(ite<n){
        string check = v[ite].first;
        int cnt=1;
        vector<int> c;
        c.push_back(v[ite].second);
        while(ite+cnt<n&&check==v[ite+cnt].first){
            c.push_back(v[ite+cnt].second);
            cnt++;
        }
        sort(all(c));
        reverse(all(c));
        rep(i,c.size()){
            cout << m[c[i]]<<endl;
        }
        ite+=cnt;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
int dy[] = {1, 0, 0, -1};
int dx[] = {0, 1, -1, 0};
int b[110][110];
int w, h;
int xs, ys, xg, yg;
int color;
bool flag = false;
bool used[110][110];

void dfs(int y, int x, int py, int px){
	rep(i, 4){
		int ny = y + dy[i], nx = x + dx[i];
		if(used[ny][nx]) continue;//???????????¨???????????????????????????
		if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
		if(b[ny][nx] != color) continue;
		if(ny == py && nx == px) continue;
		if(ny == yg && nx == xg){
			// used[ny][nx] = true;
			flag = true; return;//????????????
		}
		used[ny][nx] = true;
		dfs(ny, nx, y, x);
	}
	return;//????????¢?????¨???????????????
}

int main(void){
	while(1){
		rep(i, 110)rep(j, 110){
			b[i][j] = -1; used[i][j] = false;
		}
		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		cin >> xs >> ys >> xg >> yg;
		xs--; ys--; xg--; yg--;
		int n; cin >> n;
		rep(i, n){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			x--; y--;
			if(d == 0){//?¨?
				b[y][x] = b[y][x + 1] = b[y][x + 2] = b[y][x + 3] = c;
				b[y + 1][x] = b[y + 1][x + 1] = b[y + 1][x + 2] = b[y + 1][x + 3] = c;
			}else{//???
				b[y][x] = b[y][x + 1] = c;
				b[y + 1][x] = b[y + 1][x + 1] = c;
				b[y + 2][x] = b[y + 2][x + 1] = c;
				b[y + 3][x] = b[y + 3][x + 1] = c;
			}
		}
		color = b[ys][xs];
		if(color == -1) {//?????????????????????????????????
			printf("NG\n"); continue;
		}
		used[ys][xs] = true; flag = false;
		dfs(ys, xs, -1, -1);
		if(flag) printf("OK\n");
		else printf("NG\n");
	}
}

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

int main(){
  int n,m;
  cin >> n >> m;
  map<long long,int> lis;
  for (int i=0; i<n; i++){
    int a,b;
    cin >> a >> b;
    if(lis.count(a)) lis[a]+=b;
    else lis[a]=b;
  }
  long long ans=0;
  int count=0;
  for(auto l:lis){
    auto k = l.first;
    auto v = l.second;
    if(v>m-count){
      ans += k*(m-count);
      count = m;
    }
    else{
      count += v;
      ans += k*v;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
import collections
N, A = map(int, input().split())
xs = list(map(int, input().split()))

dp = collections.defaultdict(lambda: 0)
dp[(0, 0)] = 1
for n, x in enumerate(xs, start=1):
    for (k, accum), count in list(dp.items()):
        dp[(k + 1, accum + x)] += count
found = 0
for (k, accum), count in dp.items():
    if k > 0 and k * A == accum:
        found += count
print(found)

Measured memory_bytes: 8688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    ll n; cin>>n;
    ll bigsum=n*(n+1)/2;
    ll sum1=0;
    ll sum2=0;
    ll sum3=0;
    rep(i,n/3 + 1){
        sum1+=3*i;
    }
    rep(i,n/5 + 1){
        sum2+=5*i;
    }
    rep(i,n/15 + 1){
        sum3+=15*i;
    }
    ll ans=bigsum-sum1-sum2+sum3;
    cout<<ans<<endl;
}


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

int main()
{
    int k, x;
    cin >> k >> x;

    if (k * 500 >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a,b;
  cin>>a>>b;
  if(a<=b){
    cout << a << endl;
  }
  else{
    cout << a-1 << endl;
  }
  return 0;
}

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

Measured memory_bytes: 596
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			String in = scanner.next();
			String[] w = in.split(",");
			
			int[] n = new int[5];
			for(int i=0; i<5; i++)
			{
				n[i] = Integer.parseInt(w[i]);
			}
			
			for(int i=0; i<5; i++)
			{
				for(int j=i+1; j<5; j++)
				{
					if(n[i] > n[j])
					{
						int buf = n[i];
						n[i] = n[j];
						n[j] = buf;
					}
				}
			}
			
			int strate = 1;
			int pair = 1;
			int pair_max = 0;
			int pair_cnt = 0;
			for(int i=1; i<5; i++)
			{
				if(n[i] == n[i-1])
				{
					pair ++;
				}
				else
				{
					if(pair > pair_max)
					{
						pair_max = pair;
					}
					if(pair > 1)
					{
						pair_cnt ++;
					}
					pair = 1;
				}
				
				if(strate > 0)
				{
					if(n[i] == n[i-1]+1)
					{
						strate ++;
					}
					else
					{
						if(strate==1 && n[4]==13 && n[0]==1)
						{
							strate ++;
						}
						else 
						{
							strate = 0;
						}			
					}
				}
			}
			
			if(pair > pair_max)
			{
				pair_max = pair;
			}
			if(pair > 1)
			{
				pair_cnt ++;
			}
								
			int result = 0;
			switch(pair_max)
			{
				case 2:
					if(pair_cnt == 2)
					{
						result = 2;
					}
					else 
					{
						result = 1;
					}
					break;
				case 3:
					if(pair_cnt == 2)
					{
						result = 5;
					}
					else 
					{
						result = 3;
					}
					break;
				case 4:
					result = 6;
					break;
			}
			
			if(strate == 5)
			{
				result = 4;
			}

			
			String[] out =
				{
					"null",
					"one pair",
					"two pair",
					"three card",
					"straight",
					"full house",
					"four card",
				};
			System.out.println(out[result]);
		}
	}
}

Measured memory_bytes: 25884
n, a = map(int, input().split())
nums = list(map(lambda x: int(x) - a, input().split()))

dp = {0 : 1}

for n in nums:
	for k, v in list(dp.items()):
		dp[k+n] =dp.get(k+n, 0) + v
print(dp[0] - 1)


Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i <= n; i++)
        {
            if (n == i * 108 / 100)
            {
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine(":(");
    }
}

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

int prev[200000],next[200000];
bool ok[200000];
int N,M,Q;


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

    for(int i=0;i<N;i++){
        prev[i]=(i-1+N)%N;
        next[i]=(i+1)%N;
    }

    int cur=0;
    while(M--){
        int a;
        cin>>a;

        if(a&1)while(a--)cur=prev[cur];

        else while(a--)cur=next[cur];

        ok[cur]=true;
        next[prev[cur]]=next[cur];
        prev[next[cur]]=prev[cur];

        cur=next[cur];
    }

    while(Q--){
        int q;
        cin>>q;
        cout<<1-ok[q]<<endl;
    }
}

Measured memory_bytes: 2916
n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
ab.sort(key=lambda x:x[1])
t = 0
for a, b in ab:
    if a+t>b:
        print('No')
        break
    t += a
else:
    print('Yes')


Measured memory_bytes: 31860
program main
    integer :: A,B,C,D,E,F, asn1, ans2, ac=0, bc = 0, nw = 0, max_num, cc=0, dc=0, sg, agres, k=1
    logical :: flag = .true.
    integer :: water(1000) = 0

    read *, A,B,C,D,E,F
    do i = 0,1000
        do j = 0,1000
            if(A*i+B*j <= F/100) then
                water(k) = A*i+B*j
                k = k + 1
            else
                exit
            end if
        end do
    end do

    max_num = k-1
    ans1 = A*100
    ans2 = 0

    do i=2,max_num
        do j=0,(F/100)*E/C
            do l=0,E*F/100/D
                if(real(C*j+D*l) <= E*water(i) .and. water(i)*100 + C*j+D*l <= F) then
                    sg = C*j+D*l
                else
                    exit
                end if
            end do
            if(real(ans2)/real(ans1) < real(sg)/real(water(i)*100+sg)) then
                ans1 = water(i)*100 + sg
                ans2 = sg
            end if
        end do
    end do
    print *, int(ans1), ans2
end program main

Measured memory_bytes: 256
using System;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			string str = Console.ReadLine();

			int a = int.Parse(str.Substring(0, 1));
			int b = int.Parse(str.Substring(1, 1));
			int c = int.Parse(str.Substring(2, 1));
			int d = int.Parse(str.Substring(3, 1));

			string op1 = "";
			string op2 = "";
			string op3 = "";

			for (int i = 0; i < 2; i++)
			{
				int tmp = a;

				if (i % 2 == 0)
				{
					tmp += b;
					op1 = "+";
				}
				else
				{
					tmp -= b;
					op1 = "-";
				}

				for (int j = 0; j < 2; j++)
				{
					if (j % 2 == 0)
					{
						tmp += c;
						op2 = "+";
					}
					else
					{
						tmp -= 2 * c;
						op2 = "-";
					}
					if (tmp + d == 7)
					{
						op3 = "+";
					}
					else if (tmp - d == 7)
					{
						op3 = "-";
					}
					else continue;
					Console.WriteLine(a + op1 + b + op2 + c + op3 + d + "=7");
					return;
				}
			}

		}


	}
}


Measured memory_bytes: 13140
#include<iostream>
#include <iterator>
#include <vector>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1ll << 60;
ll dp[100001];
int h[100001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 100001; i++) dp[i] = INF;
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> h[i];
    dp[0] = 0;

    for(int i = 0; i < N; i++)
        for (int j = 1; j <= K; j++) 
            chmin(dp[i], dp[max(i - j, 0)] + abs(h[i] - h[max(i - j, 0)]));

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,count1=0,count2=0;
    cin>>n; 
    string a[n],b[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    for (int i=0;i<n;i++){
        for (int j=n-1;j>i;j--){
            if (a[j][1]<a[j-1][1]){
                string ans=a[j];
                a[j]=a[j-1];
                a[j-1]=ans;
                count1++;
            }
        }
    }
    
    for (int i=0;i<n;i++){
        int min =i;
        for(int j=i;j<n;j++){
            if(b[j][1]<b[min][1]){
                min=j;
            }
        }
        if(min!=i){
            string ans=b[i];
            b[i]=b[min];
            b[min]=ans;
            count2++;
        }
    }
    int flag=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            flag=1;
            break;
        }
    }
    for (int i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }cout<<a[n-1]<<endl;
    cout<<"Stable"<<endl;
    
    for (int i=0;i<n-1;i++){
        cout<<b[i]<<" ";
    }cout<<b[n-1]<<endl;
    if(flag==0){
        cout<<"Stable"<<endl;
    }
    else if(flag==1){
        cout<<"Not stable"<<endl;
    }
    return 0;
    
}



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

int main(){
    int n, i, j;
    cin >> n;
    int t[n+1];
    for (i = 0; i < n; i++) cin >> t[i];
    int m;
    cin >> m;
    int p[m+1], x[m+1];
    for (i = 0; i < m; i++){
        cin >> p[i] >> x[i];
    } 

    for (i = 0; i < m; i++){
        int sum = 0;
        for (j = 0; j < n; j++){
            if (p[i]-1 == j){
                sum += x[i];
            }else{
                sum += t[j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

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

typedef long long ll;

int main() {
	ll x, y;
	scanf("%lld%lld", &x, &y);
	printf("%lld", 1+(ll)(logl(y) / logl(2) - logl(x) / logl(2)));

	return 0;
}

Measured memory_bytes: 2188
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;

void solve(int _t){
	int n;
	cin >> n;
	n%=1000;
	cout << (1000-n)%1000<<endl;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 3652