akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i]%5!=0) {
			cout << "DENIED";
			return 0;
		}
	}
	cout << "APPROVED";
	
	return 0;
}









Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char a[11];
    int b[11]= {0};
    int c,d;
    int numb[10]= {0};
    scanf("%s",a);
    int i,j=0;
    for(i=0; a[i]!=EOF; i++)
    {
        if(a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')
            b[i]=1;
    }
    for(i=0; i<11; i++)
    {
        if(b[i]==1&&b[i+1]==0)
        {
            numb[j]++;
            j++;
        }
        if(b[i]==1&&b[i+1]==1)
            numb[j]++;
    }
    d=0;
    for(i=0;i<10;i++)
    {
        if(d<numb[i])
            d=numb[i];
    }
    printf("%d",d);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll mod_pow(ll x,ll n){
    if(n==0) return 1;
    ll res=mod_pow(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main() {
  int n,k;
  cin>>n>>k;
  ll a[n+1];
  a[0]=1;
  rep(i,1,n+1) a[i]=a[i-1]*i%mod;
  ll b[n+1];
  b[0]=1;
  rep(i,1,n+1) b[i]=mod_pow(a[i],1e9+5);
  
  rep(i,1,k+1){
    if(i<=n-k+1){
      ll c=(a[n-k+1]*b[i])%mod*b[n-k+1-i]%mod;
      ll d=(a[k-1]*b[i-1]%mod)*b[k-i]%mod;
      cout<<c*d%mod<<endl;
    }
    else cout<<0<<endl;
  }
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace CompetitiveProgramming
{

  class Solve
  {
 
    private void main()
    {
      int N = int.Parse(Console.ReadLine());
      ulong[] a = new ulong[N];

      for (int i = 0; i < N; i++)
      {
        a[i] = ulong.Parse(Console.ReadLine());
      }

      ulong ans = 0;
      ulong t = 0;
      for (int i = 0; i < N; i++)
      {
        if (a[i] == 0)
        {
          ans += t / 2;
          t = 0;
        }
        else
        {
          t += a[i];
        }
      }
      ans += t / 2;

      Console.WriteLine(ans);
    
    }


    public Solve()
    {
      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
      main();
      Console.Out.Flush();
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }

}

Measured memory_bytes: 7512
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    double n;
    cin >> n;
    double c = n / 2;
    c = ceil(c);
    cout << setprecision(10) << c / n << "\n";
}

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

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

            var total = b[0];
            for(var i = 1; i < n - 1; i++){
                total += Math.Min(b[i], b[i-1]);
            }
            total += b[n-2];

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13396
n = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)
counter = 0

loop do
  if array.select { |num| num % 2 == 0 }.size != n
    break
  end

  counter += 1
  array.collect! { |num| num / 2 }
end

puts counter


Measured memory_bytes: 1788
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
L = [[i-1, i+1] for i in range(1, N+1)]
L[0] = [L[0][1]]
L[-1] = [L[-1][0]]
L[X-1].append(Y)
L[Y-1].append(X)

def bfs(i):
    ni = deque(L[i-1])
    c = 1
    C = [0] * N
    C[i-1] = -1
    while ni:
        nii = ni
        ni = deque([])
        for niii in nii:
            if C[niii-1] != 0:
                continue
            C[niii-1] = c
            if niii > i:
                D[c] += 1
            ni.extend(L[niii-1])
        c += 1
    return True

for n in range(1, N+1):
    bfs(n)

for n in range(1, N):
    print(D[n])

Measured memory_bytes: 54108
// implement 7min
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, l;
pair<int, int> ants[100];


int main() {
  while (scanf("%d %d", &n, &l) > 0 && n) {
    REP(i, n) {
      char c;
      int p;
      scanf(" %c %d", &c, &p);
      int dir = c == 'L' ? -1 : 1;
      ants[i] = make_pair(dir, p);
    }
    int ans_sec = 0;
    int ans_ant = -1;
    int rest = n;
    while (rest > 0) {
      ans_sec++;
      map<int, int> hist;
      REP(i, n) {
        ants[i].second += ants[i].first;
        hist[ants[i].second]++;
      }
      REP(i, n) {
        if (hist[ants[i].second] >= 2) {
          ants[i].first *= -1;
        }
        if (ants[i].second == 0 || ants[i].second == l) {
          rest--;
          if (ans_ant == -1 || ants[ans_ant].second != 0) {
            ans_ant = i;
          }
        }
      }
    }
    printf("%d %d\n", ans_sec, ans_ant + 1);
  }
}

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた

//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！

std::vector<vector<int>> d;
void warshall_floyd(int n) { // ワーシャルフロイド nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
    int h,w;
    std::cin >> h>>w;
    RES(d,10,10);
    reprep(i,j,10,10){
        std::cin >> d[i][j];
    }
    vvector(a,int,h,w,0);
    reprep(i,j,h,w)std::cin >> a[i][j];
    warshall_floyd(10);
    int ans=0;
    reprep(i,j,h,w){
        if(a[i][j]==-1)continue;
        ans+=d[a[i][j]][1];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-poller","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 4e6 + 42;
const ll m = 1e9 + 7;
ll add(ll x, ll y) {
  x += y;
  while(x >= m) x -= m;
  while(x < 0) x += m;
  return x;
}
ll mul(ll x, ll y) {
  ll ans = (x * 1ll * y) % m;
  while(ans < 0) ans += m;
  return ans;
}
ll binpow(ll x, ll y) {
  ll z = 1;
  while(y) {
    if(y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
ll inv(ll x) {
  return binpow(x, m - 2);
}
ll divide(ll x, ll y) {
  return mul(x, inv(y));
}
ll fact[N];
void precalc() {
  fact[0] = 1;
  for(ll i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
ll C(ll n, ll k) {
  return divide(fact[n], mul(fact[k], fact[n - k]));
}
ll A(ll n, ll m) {
  return divide(fact[n], fact[n - m]);
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  precalc();

  ll s = 0;

  cin >> s;

  ll ans = 0;

  for(ll len = 1; len <= s / 3; len++) {
    ll rem = s - len * 3;
    ans = add(ans, C(len + rem - 1, len - 1));
  }

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 34896
n=list(map(int,input()))
if n[-1] == 2 or n[-1] == 4 or n[-1] == 5 or n[-1] == 7 or n[-1] == 9:
 print('hon')
elif n[-1] == 0 or n[-1] == 1 or n[-1] == 6 or n[-1] == 8:
  print('pon')
else:
  print('bon')

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

typedef long long ll;

int a[3005][3005];
ll dp[3005][3005];

const ll mod = 1e9 + 7;

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n ; i++){
		for(int j = 1; j <= m; j++){
			char c;
			cin >> c;
			if(c == '.') a[i][j] = 1;
		}
	}
	dp[1][1] = 1;
	
	
	for(int i = 1; i <= n ; i++){
		for(int j = 1; j <= m; j++){
			if(i == 1 && j == 1) continue;
			if(a[i][j] == 0) continue;
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][m] << "\n";
	return 0;
}

Measured memory_bytes: 38144
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int N, A;
int x[60];
ll dp[60][60][2510];
int main()
{
    cin >> N >> A;
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

   /* for (int i = 0; i < N; i++)
    {
        for (int k = 0; k <=i; k++){
            
                dp[i][1][x[k]] = 1;
        }
    }*/
    dp[0][0][0] = 1;
    //dp[0][1][x[0]] = 1;

    for (int i = 1; i <= N; i++)
    {   
        for (int k = 0; k <=N; k++)
        {
            for (int j = 0; j <=2510; j++)
            {   
                if(i>=1 && j<x[i-1]){
                    dp[i][k][j] = dp[i - 1][k][j];
                 //   cerr << i << k << j << endl;
                }


                else if(j>=x[i-1] && i>=1 && k>=1){
                    dp[i][k][j] = dp[i - 1][k][j] + dp[i - 1][k - 1][j - x[i-1]];
               // cerr << i<< k << j << endl;
                }
               
            }
        }
    }


    
    

    ll cnt = 0;
   /* for (int i = 0; i <= N+1; i++)
    {
        for (int j = 1; j <= 33; j++)
        {
            cerr <<i<<" "<<j<<" "<< dp[3][i][j] << endl;
        }
    }*/
    

    for (int i = 1; i <=N; i++)
    {   
        cnt += dp[N][i][A * i];
       // if(dp[N-1][i][A*i]>0)
       //     cerr << i << " " << A * i << " "<<dp[N-1][i][A*i]<<endl;
    }
    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 60544
n = int(input())
a = list(map(int, input().split()))
ans_list = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    prev = 0
    index = i+1
    for j in range(2, n+1):
        if (index * j)-1 >= n: break
        prev += ans_list[(index * j)-1]
    if prev % 2 != a[i]:
        ans_list[i] = 1

print(sum(ans_list))
if sum(ans_list) != 0:
    print(' '.join([str(i+1) for i, x in enumerate(ans_list) if x == 1]))


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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;
constexpr double PI=3.14159265358979323846;

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

    int x,n;
    cin >> x >> n;
    vector<int> p(n);
    if(n==0){
        cout << x << "\n";
    }else{
        rep(i,n) cin >> p[i];
        sort(all(p));
        int out;
        int dist=1000;
        int cur=0;
        fr(i,0,102){
            if(p[cur]==i){
                if(cur!=n-1) ++cur;
                continue;
            }
            if(dist > abs(i-x)) dist=abs(i-x) , out=i ;
        }
        cout << out << "\n";        
    }
}   

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

int64_t cnt = 0;

// A[left:mid], A[mid:right] をマージする
void merge(vector<int> &A, int left, int mid, int right) {
    vector<int> L, R;
    // L, R 作成
    for (int i = left; i < right; i++) {
        if (i < mid) {
            L.push_back(A[i]);
        } else {
            R.push_back(A[i]);
        }
    }
    int l = 0, r = 0;
    for (int i = left; i < right; i++) {
        if (!(l < L.size())) {
            A[i] = R[r];
            r++;
        } else if (!(r < R.size())) {
            A[i] = L[l];
            l++;
        } else if (L[l] <= R[r]) {
            A[i] = L[l];
            l++;
        } else {
            A[i] = R[r];
            r++;
        }
        cnt++;
    }
}

// A[left:right] をマージソートする
void mergeSort(vector<int> &A, int left, int right) {
    // A[left:right] のサイズが 2 以上の場合
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

void mergeSort(vector<int> &A) {
    mergeSort(A, 0, A.size());
}


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

    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) cin >> S[i];
    mergeSort(S);

    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 7372
#!/usr/bin/env python3
from scipy.special import comb

n, *s = open(0).read().split()
d = {}
for i in s:
    l = "".join(sorted(j for j in i))
    if l in d:
        d[l] += 1
    else:
        d[l] = 1
print(sum(comb(i, 2,exact=True) for i in d.values()))


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var m = long.Parse(inputs[1]);
            var x = long.Parse(inputs[2]);

            var a = 0;
            var b = 0;

            var inputs1 = Console.ReadLine().Split(" ");
            for (var i = 0; i < m; i++)
            {
                var r = int.Parse(inputs1[i]);
                if (r < x)
                    a++;
                else
                    b++;
            }

            var result = Math.Min(a, b);
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 998244353;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

ll combi(ll N_, ll C_, ll mo=MOD) {
  const int NUM_=4e5+10;
  static ll fact[NUM_+1]={},factr[NUM_+1]={},inv[NUM_+1]={};
  auto binpow = [&](ll x, ll e) -> ll{
    ll a = 1, p = x;
    while(e > 0) {
      if(e%2 == 0) {p = (p*p) % mo; e /= 2;}
      else {a = (a*p) % mo; e--;}
    }
    return a;
  };
  if (fact[0]==0) {
    fact[0] = factr[0] = inv[0] = 1;
    FOR(i, 1, NUM_+1) fact[i] = fact[i-1] * i % MOD;
    factr[NUM_] = binpow(fact[NUM_], mo-2);
    for(int i=NUM_-1; i>=0; --i) factr[i] = factr[i+1] * (i+1) % MOD;
    // fact[i] = fact[i-1] * i;
    // inv[i] = binpow(i, MOD-2);
    // factr[i] = factr[i-1] * inv[i];
  }
  if(C_<0 || C_>N_) return 0;
  // 前計算 O(max(N,K)) クエリ O(1)
  return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;
  // 前計算 O(max(N,K)log(mod)) クエリ O(K)
  // ll ret = 1;
  // for(;C_>0;N_--,C_--) (ret *= N_%MOD) %= MOD, (ret *= inv[C_]) %= MOD;
  // return ret;
}

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

  int n, a, b, k;
  cin >> n >> a >> b >> k;

  int ret = 0;
  REP(i, n+1) {
    int tmp = k - a * i;
    if(tmp<0 || tmp%b) continue;
    int j = tmp / b;
    (ret += combi(n, i) * combi(n, j) % MOD) %= MOD;
    // cerr << i << " " << ret << endl;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int W = 10000;

int dp[N+1][W+1];
vector<int> v,w;

int rec(int n,int m){
    if(dp[n][m] != -1){
        return dp[n][m];
    }

    if(n == v.size()){
        return 0;
    }

    if(m < w[n]){
        return dp[n][m] = rec(n+1,m);
    }else{
        return dp[n][m] = max(rec(n+1,m),rec(n+1,m-w[n])+v[n]);
    }
}

/* int main(){
    int n,m;

    cin >> n >> m;

    for(int i=0; i<n; i++){
        int s,t;
        cin >> s >> t;
        v.push_back(s);
        w.push_back(t);
    }

    for(int i=0; i<=m; i++){
        dp[0][i] = 0;
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<=m; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[n][m] << endl;
} */

int main(){
    int n,m;
    cin >> n >> m;

    for(int i=0; i<n; i++){
        int s,t;
        cin >> s >> t;
        v.push_back(s);
        w.push_back(t);
    }

    memset(dp,-1,sizeof(dp));

    cout << rec(0,m) << endl;
}

Measured memory_bytes: 5168
import java.util.Random;
import java.util.Scanner;

public class Main{
    public static void main(final String[] args){
        Scanner scanner = new Scanner(System.in);
        String string = scanner.nextLine();
        int length = string.length();
        String answer = "";
        for(int i = 0; i < length; i++){
            char ch = string.charAt(i);
            if(Character.isUpperCase(ch)){
                ch = Character.toLowerCase(ch);
            }else if(Character.isLowerCase(ch)){
                ch = Character.toUpperCase(ch);
            }
            answer = answer.concat(String.valueOf(ch));
        }
        System.out.println(answer);
        scanner.close();
    }
     
    

}


Measured memory_bytes: 27508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
     public static void main(String[] args) {
         FastScanner fs=new FastScanner();
         int T=1;
         for (int tt=0; tt<T; tt++) {
             int n= fs.nextInt();
            int []arr = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = fs.nextInt();
                int ans  =0;
            Arrays.sort(arr);
            for(int i=0;i<n;i++){
                for(int j=0;j<i;j++)
                    for(int k=0;k<j;k++){
                        if(arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k]){
                            if(arr[i]<arr[j]+arr[k])
                                ans++;
                        }
                    }
            }
            System.out.println(ans);
        }
}
 

static class FastScanner {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st=new StringTokenizer("");
     String next() {
     while (!st.hasMoreTokens())
         try {
             st=new StringTokenizer(br.readLine());
         } catch (IOException e) {
             e.printStackTrace();
         }
         return st.nextToken();
     }
     
     int nextInt() {
         return Integer.parseInt(next());
     }
     int[] readArray(int n) {
         int[] a=new int[n];
         for (int i=0; i<n; i++) a[i]=nextInt();
         return a;
     }
     long nextLong() {
         return Long.parseLong(next());
     }
 }

 
}


Measured memory_bytes: 33776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split("");

		int count = 0;
		for (int i = 0; i <= n - 3; i++) {
			if (str[i].equals("A")) {
				if (str[i + 1].equals("B")) {
					if (str[i + 2].equals("C")) {
						count++;
					}
				}
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 32920
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  string t="keyence.";
  s+='.';
  int n=(int)s.length();
  bool flag=false;
  rep(i,8){
    string buf=s.substr(0,i);
    buf+=s.substr(n-8+i,8-i);
    //cout<<buf<<endl;
    if(buf==t)flag=true;
  }
  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;

#define MOD 1000000007


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		ll ans=0LL;

		for(ll i=k;i<=n+1;i++)
		{
			ll sum_min=(i-1)*i/2;
			ll sum_max=n*i-sum_min;
			ans=(ans+sum_max-sum_min+1)%MOD;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int r;
    cin >> r;

    cout <<3*r*r << endl;

}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n, 0);
	int p = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		p += v[i];
	}
	p /= n;
	int res1 = 0;
	for (int i = 0; i < n; i++) {
		res1 += (p - v[i]) * (p - v[i]);
	}
	p++;
	int res2 = 0;
	for (int i = 0; i < n; i++) {
		res2 += (p - v[i]) * (p - v[i]);
	}
	cout << min(res1, res2) << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, T;
  cin >> n >> T;
  ll res = INF;
  bool flag = 1;
  rep(i, n) {
    ll c, t;
    cin >> c >> t;
    if (t <= T) {
      res = min(res, c);
      flag = 0;
    }
  }
  if (flag) {
    cout << "TLE" << endl;
  } else {
    cout << res << endl;
  }
}

Measured memory_bytes: 256
class UF():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
n,m,k = map(int,input().split())
uf=UF(n)
 
F=[set() for _ in range(n)]
for i in range(m):
   a,b=map(int,input().split())
   uf.union(a-1,b-1)
   F[a-1].add(b-1)
   F[b-1].add(a-1)
 
B=[0 for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    if uf.same(c-1,d-1):
        B[c-1]-=1
        B[d-1]-=1
A=[]
for i in range(n):
    A.append(uf.size(i)-len(F[i])+B[i]-1)
print(*A)


Measured memory_bytes: 123424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll suml = 0;
    ll summ = 0;
    for(int i = 0; i < k; i++){
        suml += i;
        summ += n - i;
    }
    ll sum = 0;
    ll j = 0;
    ll maxltmp= 0;
    for(int i = k; i <= n; i++,j++){
        sum += summ - suml  + 1;
        sum %= (ll)(1e9 + 7);
        summ += (n - k - j);
        suml += k + j;
    }  
    sum += (summ - suml + 1);
    printf("%lld\n",sum);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
    int n,x[105],y[105],h[105];
    int H;
    bool flag=true;
    cin>>n;
    rep(i,n){
        cin>>x[i]>>y[i]>>h[i];
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                H=h[k]+abs(x[k]-i)+abs(y[k]-j);
                for(int l=0;l<n;l++){
                    if(h[l]!=max((H-abs(x[l]-i)-abs(y[l]-j)),0)){
                        flag=false;
                        break;
                    }
                }
                if(flag){
                    cout<<i<<" "<<j<<" "<<H<<endl;
                    return 0;
                }
                flag=true;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    s=int(input())
    S=set()
    S.add(s)
    n=s
    for i in range(2,10**7):
        if n%2:
            n=3*n+1
        else:
            n=n//2
        if n in S:
            print(i)
            exit()
        S.add(n)
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  map<char, int> mp;
  rep(i, 0, n) mp[s[i]]++;

  int bases = n / 3;
  int remin = n % 3;

  for (auto m : mp) {
    if (m.second == bases)
      continue;
    if (remin > 0) {
      if (m.second == bases + 1) {
        remin--;
        continue;
      }
    }
    cout << "NO" << endl;
    return 0;
  }

  if (remin == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 3668
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		var c = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
		int h = c[0];
		int a = c[1];
		int ans = h/a;
		if(h%a!=0){ans++;}
		Console.WriteLine(ans);
		
	}
}

Measured memory_bytes: 13268
//include
//------------------------------------------
#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<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//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 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())
//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);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long add_modp(long long a, long long b, long long p){
    // a+b mod p
    return (a % p + b % p) % p;
}

long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long pow_modp(long long a, long long n, long long p){
    // a^n mod p
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}

int main(void){
    int N;
    cin >> N;
    ll A[N];
    REP(i,N) cin >> A[i];

    vector<ll> bit(60,0);
    REP(i,N){
        ll A_bit = A[i];
        int i_bit = 0;
        while(A_bit){
            if(A_bit & 1) bit[i_bit]++;
            i_bit++;
            A_bit >>= 1;
        }
    }

    vector<ll> num(60);
    REP(i,60) num[i] = bit[i]*(N-bit[i]);

    ll ans = 0;
    ll pow = 1;
    REP(i,60){
        ans = add_modp(ans, mul_modp(num[i], pow, INF), INF);
        pow = mul_modp(pow, 2, INF);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
	        for(long i=0;i<N-1;i++) {
	        	int ai = sc.nextInt()-1;
	        	int bi = sc.nextInt()-1;
	        	list.get(ai).add(bi);
	        	list.get(bi).add(ai);
	        }
	        long[] a = new long[N];
	        long sum =0;
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	            sum=sum+a[i];
	        }
	        Arrays.sort(a);
	        StringBuffer ans = new StringBuffer();
			LinkedList<Integer> q= new LinkedList<Integer>();
			q.add(0);
			q.add(-1);
			int cnt=N-1;
			long[] m = new long[N];
			while(!q.isEmpty()) {
				int now = q.poll();
				int pre = q.poll();
				m[now]=a[cnt];
				cnt--;
				for(int k:list.get(now)) {
					if(k==pre)continue;
					q.add(k);
					q.add(now);
					
				}
			}
			for(int i=0;i<N;i++) {
				ans.append(m[i]);
				if(i!=N-1)ans.append(" ");
			}
			System.out.println(sum-a[N-1]);
	        System.out.println(ans);
	    }
	}

Measured memory_bytes: 57504
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        int quesNum = sc.nextInt();
        String input = sc.next();

        Dp dp = new Dp(len, input);
        
        for(int i = 0; i < quesNum; i++){
            int ans = 0;
            int left = sc.nextInt();
            int right = sc.nextInt();
          
            ans = dp.part(right) - dp.part(left);
            System.out.println(ans);
        }
    }
}

class Dp {
    static int[] dp;
    String input;
    public Dp (int num, String input) {
        dp = new int[num+1];
        for(int i = 0; i <= num; i++) {
            dp[i] = -1;  
        }
        this.input = input;
    }

    public int part(int right) {
        if(dp[right] != -1)return dp[right];
        
        if(right <= 1) {
            dp[right] = 0;
            return dp[right];
        }
        
        int ans = 0;
        if(input.charAt(right-2) == 'A' && input.charAt(right-1) == 'C') {
            ans = part(right-2) + 1;
        }
        else ans = part(right-1);

        dp[right] = ans;
        return dp[right];
    }
}

Measured memory_bytes: 75168
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
	} else if (a * b == 15) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def solve2():
    N, K = [int(_) for _ in raw_input().split()]
    V = [int(_) for _ in raw_input().split()]
    MAX_GET = min(N, K)
    ans = 0
    for i in range(MAX_GET + 1):
        for j in range(MAX_GET + 1 - i):
            get = V[:i] + V[(N - j):]
            if len(get) == 0:
                continue
            get.sort(reverse = True)
            for k in range(K - i - j):
                if len(get) > 0 and get[-1] < 0:
                    get.pop()
                else:
                    break
            ans = max(ans, sum(get))
    print ans

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 32748
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
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 PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int r, t;
    int crtt = 90;
    double crtx = 0, crty = 0;
    while(1) {
        scanf("%d,%d", &r, &t);
        if (r == 0 && t == 0) break;
        crtx += cos(crtt * acos(-1) / 180) * r;
        crty += sin(crtt * acos(-1) / 180) * r;
        crtt -= t;
    }
    printf("%d\n%d\n", (int)crtx, (int)crty);
    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c || a+c==b || b+c==a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

const long long m = 1000000000 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  unsigned long long n;
  cin >> n;
  vector<unsigned long long> v(n);
  unsigned long long sum = 0;
  for(auto& el: v) {
    cin >> el;
    sum += el % m;
  }
  unsigned long long totalprod = 0;
  for(int i = 0; i < n - 1; i++) {
    sum -= v[i];
    totalprod += ((sum % m) * (v[i] %m)) % m;
  }
  cout << totalprod % m << "\n";
	return 0;
}


Measured memory_bytes: 4460
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll get(ll d, vector<ll>v1, vector<ll>v2, ll t)
{
	ll now = 0, na = 0, nb = 0;
	int pa = v1.size() - 1, pb = 0;
	//for (int i = 0; i < v1.size(); i++)printf("%lld ", v1[i]); printf("\n");
	//for (int i = 0; i < v2.size(); i++)printf("%lld ", v2[i]); printf("\n");
	for (;;)
	{
		if (d == 1)
		{
			ll x = v2[pb] - nb;
			if (x > t)
			{
				now += t;
				break;
			}
			pb++;
			nb += x;
			now += x;
			d = 2;
			t -= x;
		}
		else
		{
			ll x = na - v1[pa];
			if (x > t)
			{
				now -= t;
				break;
			}
			pa--;
			na -= x;
			now -= x;
			d = 1;
			t -= x;
		}
		//printf("---%lld\n", now);
	}
	return now;
}
typedef pair<ll, ll>pii;
ll INF = 1000000000000000000LL;
int main()
{
	int num;
	ll len, tim;
	scanf("%d%lld%lld", &num, &len, &tim);
	len *= 4;
	tim *= 4;
	tim--;
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		ll za, zb;
		scanf("%lld%lld", &za, &zb);
		za *= 4;
		v.push_back(make_pair(za, zb));
	}
	vector<ll>v1, v2;
	for (int i = 0; i < num; i++)
	{
		if (v[i].second == 1)
		{
			ll x = v[0].first - v[i].first;
			if (x <= 0)x += len;
			v1.push_back(-x);
			v1.push_back(-x - len);
			v1.push_back(-x - len - len);
		}
		else
		{
			ll x = v[i].first - v[0].first;
			if (x <= 0)x += len;
			v2.push_back(x);
			v2.push_back(x + len);
			v2.push_back(x + len + len);
		}
	}
	v1.push_back(-INF), v2.push_back(INF);
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	ll zt = (v[0].first + len + get(v[0].second, v1, v2, len + len) / 2) % len;
	//printf("%lld\n", zt);
	ll low = lower_bound(v.begin(), v.end(), make_pair(zt, -1LL)) - v.begin();
	ll now = low*(tim / len) % num;
	tim %= len;
	v1.clear(), v2.clear();
	for (int i = 0; i < num; i++)
	{
		if (v[i].second == 1)
		{
			ll x = v[now].first - v[i].first;
			if (x <= 0)x += len;
			v1.push_back(-x);
			v1.push_back(-x - len);
			v1.push_back(-x - len - len);
		}
		else
		{
			ll x = v[i].first - v[now].first;
			if (x <= 0)x += len;
			v2.push_back(x);
			v2.push_back(x + len);
			v2.push_back(x + len + len);
		}
	}
	v1.push_back(-INF), v2.push_back(INF);
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	ll ans = (v[now].first + len + get(v[now].second, v1, v2, tim + tim) / 2) % len;
	vector<ll>ret;
	for (int i = 0; i < num; i++)
	{
		if (v[i].second == 1)ret.push_back((v[i].first + tim) % len);
		else ret.push_back((v[i].first + len - tim) % len);
	}
	sort(ret.begin(), ret.end());
	low = lower_bound(ret.begin(), ret.end(), ans) - ret.begin();
	vector<ll>rr;
	for (int i = low; i < num; i++)rr.push_back(ret[i]);
	for (int i = 0; i < low; i++)rr.push_back(ret[i]);
	for (int i = 0; i < num; i++)
	{
		if (rr[i] % 4 == 1)rr[i] = (rr[i] - 1) / 4 % (len / 4);
		else rr[i] = (rr[i] + 1) / 4 % (len / 4);
		printf("%lld\n", rr[i]);
	}
}

Measured memory_bytes: 8388
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
print(max(0, a-b*2))

Measured memory_bytes: 38636
H, N = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
dp = [10000000000] * 10001
dp[0] = 0
for i in range(N):
    for j in range(10001):
        next = min(j + A[i], H)
        dp[next] = min(dp[next], dp[j] + B[i])
print(dp[H])


Measured memory_bytes: 43644
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const ll MOD=1000000007;

template <typename T>
T modinv(T a, T m){
  T b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main(){

  int X,Y;
  cin >> X >> Y;

  if((-X+2*Y)%3!=0 || (2*X-Y)%3!=0 || (-X+2*Y)<0 || (2*X-Y)<0){
    cout <<  0 << endl;
    return 0;
  }

  int N= (X+Y)/3;
  int N1=(-X+2*Y)/3;
  int N2=(2*X-Y)/3;

  ll res=1;
  for(int i=N1+1;i<N+1;i++){
    res*=i;
    res%=MOD;
  }

  for(int i=1;i<N2+1;i++){
    res*=modinv((ll)i,MOD);
    res%=MOD;
  }

  cout << res << endl;
    
  return 0;

}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0;i < n;i++){
    int x;
    cin >> x;
    h.at(i) = x; 
  }
  sort(h.begin(),h.end());
  int m = 1000000000;
  for (int i = 0;i < n-k+1;i++){
    m = min(m,h.at(i+k-1)-h.at(i));
  }
  cout << m << endl;
} 

Measured memory_bytes: 640
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int64_t H;
  cin >> H;
  int64_t ans = 0;
  int64_t attack = 1;
  while (H > 0) {
    ans += attack;
    attack *= 2;
    H /= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
ll  k, ans = 0, sum = 0, cnt = 0;
string s;

/*--------------------template--------------------*/


int main() {
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vp v, w;
	REP(i, n) {
		int a, b; cin >> a >> b;
		v.emplace_back(a, b);
	}
	REP(i, m) {
		int a, b; cin >> a >> b;
		w.emplace_back(a, b);
	}
	REP(i, n) {
		int res = -1, dist = 1e9;
		REP(j, m) {
			int d = abs(v[i].first - w[j].first) + abs(v[i].second - w[j].second);
			if (d < dist) {
				res = j + 1;
				dist = d;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 256