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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    ans = min(n, m / 2);

    n = max((ll)0, m - n * 2);

    ans += n / 4;

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}

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

int main() 
{
    int n;
    cin>>n;
    
    int temp=n;
    int sum=0;
    
    while(temp){
        sum+=(temp%10);
        temp/=10;
    }
    
    if(n%sum==0) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

struct ModCombination {
    vector<mint> Fac;
    vector<mint> Facinv;

    ModCombination(int x) {
        Fac.resize(x+1);
        Facinv.resize(x+1);
        Fac[0] = 1;
        for (long long i = 1; i <= x; i++) Fac[i] = Fac[i-1]*i;
        Facinv[x] = Fac[0]/Fac[x];
        for (long long i = x; i > 0; i--) Facinv[i-1] = Facinv[i]*i;
    }

    mint get(int n, int k) {
        if (k < 0 || k > n) return 0;
        return Fac[n]*Facinv[k]*Facinv[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int r1,r2,c1,c2; cin >> r1 >> c1 >> r2 >> c2;
    ModCombination MC(r2+c2+5);

    mint ans = 0;
    for (int i = r1; i <= r2; i++) {
        ans += MC.get(i+c2+1,i+1) - MC.get(i+c1,i+1);
    }

    cout << ans.a << endl;
}


Measured memory_bytes: 31488
#include <iostream>
#include <ios>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> p(m), y(m);
    std::vector<std::vector<int>> vec(n + 1);
    for(int i = 0; i < m; i++){
        std::cin >> p[i] >> y[i];
        vec[p[i]].push_back(y[i]);
    }
    for(int i = 1; i <= n; i++){
        std::sort(vec[i].begin(), vec[i].end());
    }

    for(int i = 0; i < m; i++){
        auto itr = std::lower_bound(vec[p[i]].begin(), vec[p[i]].end(), y[i]);
        std::cout
            << std::setfill('0') << std::right << std::setw(6) << p[i]
            << std::setfill('0') << std::right << std::setw(6) << std::distance(vec[p[i]].begin(), itr) + 1
            << std::endl;
    }

    return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a[n], dp[n];
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0] = 0;
	dp[1] = abs(a[0]-a[1]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>

using namespace std;

typedef long long ll;

ll gcd (ll p, ll q) {
  if (q == 0) return p;
  return gcd(q, p % q);
}

ll lcm (ll p, ll q) {
  ll gc = gcd(p, q);
  p /= gc;
  return p * q;
}

vector<ll> transf (vector<ll> v) {
  vector<ll> u;
  while ((int) v.size() > (int) u.size()) {
    ll x = v.back();
    v.pop_back();
    u.push_back(x);
  }

  vector<ll> ans;
  for (int i = 0; i < (int) max(u.size(), v.size()); i++) {
    if (i < (int) u.size()) ans.push_back(u[i]);
    if (i < (int) v.size()) ans.push_back(v[i]);
  }

  return ans;
}

const int MAX_P = 1e5 + 5;
const int MAX_N = 505;

int sieve [MAX_P];
ll grid [MAX_N][MAX_N];
int ni [4] = {1, 0, -1, 0};
int nj [4] = {0, 1, 0, -1};

int main () {
  vector<int> primes;
  for (int i = 2; i < MAX_P; i++) {
    if (!sieve[i]) {
      if (i > 7) primes.push_back(i);
      for (int j = i; j < MAX_P; j += i) {
        sieve[j] = 1;
      }
    }
  }
  
  int n;
  cin >> n;

  int ptr = 0;
  vector<ll> rowpot;
  vector<ll> colpot;
  while ((int) rowpot.size() < (n + 20) / 2) {
    rowpot.push_back(primes[ptr]);
    ptr++;
    colpot.push_back(primes[ptr]);
    ptr++;
  }

  rowpot = transf(rowpot);
  colpot = transf(colpot);

  vector<ll> rows;
  vector<ll> cols;
  int sgn = 0;
  for (ll p : rowpot) {
    rows.push_back(p);
    if (sgn) {
      rows.push_back(2 * p);
    } else {
      rows.push_back(5 * p);
    }
    sgn = !sgn;
  }

  sgn = 0;
  for (ll q : colpot) {
    cols.push_back(q);
    if (sgn) {
      cols.push_back(3 * q);
    } else {
      cols.push_back(7 * q);
    }
    sgn = !sgn;
  }

  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      grid[i][j] = 1;
    }
  }

  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      if ((i + j) % 2 == 0) {
        grid[i][j] = rows[i] * cols[j];
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if ((i + j) % 2 == 1) {
        for (int k = 0; k < 4; k++) {
          grid[i][j] = lcm(grid[i][j], grid[i + ni[k]][j + nj[k]]);
        }
        grid[i][j]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cout << grid[i][j] << " ";
    }
    cout << '\n';
  }
}


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

int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  int sum=0;
  rep(i,0,n){
    sum+=a[i];
  }
  int ans=0;
  rep(i,0,n){
    if(4*m*a[i]>=sum){
      ans++;
    }
  }
  if(ans>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

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

	//vector<int> l(m);
	//vector<int> r(m);
	//for (size_t i = 0; i < m; ++i)
	//{
	//	cin >> l[i];
	//	cin >> r[i];
	//}

	if (a == b && a == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{ 
    fastio;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum=0;
    if(k-a>=0)
    {
      sum+=a;
      k-=a;
    }
    else
    {
      sum+=k;
      k=0;
    }
    if(k-b>=0)
    {
      k-=b;
    }
    else
    {
      k=0;
    }
   //cout<<sum<<' '<<k<<endl;
    if(k-c>=0)
    {
      sum-=c;
      k-=c;
    }
    else 
    {
      sum-=k;
      k=0;
    }
    cout<<sum;
}



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

int main() {
  int K, X, S, M, N;
  cin >> K >> X;
  S = K - 1;
  M = X - S;
  N = X + S;
  if (M >= -1000000 && N <= 1000000) {
    for (int i = M; i < N + 1; i++) {
      if (i != N) {
        cout << i << " ";
      }
      else cout << i;
    }
  }
  else if (M < -1000000) {
    for (int i = -1000000; i < -1000000 + K; i++) {
      if (i != -1000000 + K) {
        cout << i << " ";
      }
      else cout << i;
    }
  }
  else if (N > 1000000) {
    for (int i = 1000000 - S; i < 1000001; i++) {
      if (i != 1000000) {
        cout << i << " ";
      }
      else cout << i;
    }
  }
}

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

using namespace std;

char a[4] = {'.', '.', '#', '#'};
char b[4] = {'#', '.', '#', '.'};

vector<char> vec1;
vector<char> vec2;

int main() {
    int cnt = 0;
    bool check = true;
    while(true) {
        string str;
        cin >> str;
        if(str == "end") break;
        else if(str == "T") {
            cnt = 0;
            if(check) {
                vec1.push_back(a[cnt]);
                vec2.push_back(b[cnt]);
                cnt++;
            }
            else {
                vec1.insert(vec1.begin(), a[cnt]);
                vec2.insert(vec2.begin(), b[cnt]);
                cnt++;
            }
        }
        else if(str == "F"){
            if(cnt == 4) {
                cnt = 0;
                check = false;
                vec1.erase(vec1.end() - 1);
                vec2.erase(vec2.end() - 1);
            }
            else if(check) {
                vec1.erase(vec1.end() - 1);
                vec2.erase(vec2.end() - 1);
                vec1.push_back(a[cnt]);
                vec2.push_back(b[cnt]);
                cnt++;
            }
            else if(!check) {
                vec1.erase(vec1.begin());
                vec2.erase(vec2.begin());
                vec1.insert(vec1.begin(), a[cnt]);
                vec2.insert(vec2.begin(), b[cnt]);
                cnt++;
            }
        }
        else {
            vec1.push_back(a[cnt]);
            vec2.push_back(b[cnt]);
            cnt++;
        }
        for(int i = 0; i < vec1.size(); i++) printf("%c", vec1[i]);
        printf("\n");
        for(int i = 0; i < vec2.size(); i++) printf("%c", vec2[i]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 596
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

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

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2;
}


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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
string S;
ll dp[4][100001];
void solve(){
	dp[0][0]=1;
	rep(i,S.size()){
		switch(S[i]){
			case 'A':
				dp[0][i+1]+=dp[0][i];
				dp[1][i+1]+=dp[0][i];
				dp[1][i+1]+=dp[1][i];
				dp[2][i+1]+=dp[2][i];
				dp[3][i+1]+=dp[3][i];
				break;
			case 'B':
				dp[0][i+1]+=dp[0][i];
				dp[1][i+1]+=dp[1][i];
				dp[2][i+1]+=dp[1][i];
				dp[2][i+1]+=dp[2][i];
				dp[3][i+1]+=dp[3][i];
				break;
			case 'C':
				dp[0][i+1]+=dp[0][i];
				dp[1][i+1]+=dp[1][i];
				dp[2][i+1]+=dp[2][i];
				dp[3][i+1]+=dp[2][i];
				dp[3][i+1]+=dp[3][i];
				break;
			case '?':
				dp[0][i+1]+=dp[0][i]*3;
				dp[1][i+1]+=dp[1][i]*3;
				dp[2][i+1]+=dp[2][i]*3;
				dp[3][i+1]+=dp[3][i]*3;
				dp[1][i+1]+=dp[0][i];
				dp[2][i+1]+=dp[1][i];
				dp[3][i+1]+=dp[2][i];
				break;
		}
		dp[0][i+1]%=MOD;
		dp[1][i+1]%=MOD;
		dp[2][i+1]%=MOD;
		dp[3][i+1]%=MOD;
	}
	cout<<dp[3][S.size()]<<endl;
}

int main(){
	cin>>S;
	solve();
	return 0;
}


Measured memory_bytes: 3584
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	    Scanner sc=new Scanner(System.in);
		  int n=sc.nextInt();
		  long sum=0;
		  for(int i=1;i<=n;i++)
		     {
		        if(i%3!=0 && i%5!=0 )
		         sum+=i;
		       
		          
		     }
		 System.out.println(sum);
	   }     
	catch(Exception e)
		 {}
	}
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int md = 1e9 + 7;
const int inv2 = 5e8 + 4;
const int maxn = 5005;
char str[maxn];
int dp[2][maxn];

void add(int &a, int b){
    a += b;
    if(a >= md) a -= md;
}

int main(){
    int n;
    scanf("%d%s", &n, str);
    int m = strlen(str);
    int now = 1, pre = 0;
    dp[now][0] = 1;
    for(int i = 1; i <= n; i++){
        now ^= 1, pre ^= 1;
        memset(dp[now], 0, sizeof dp[now]);
        for(int j = 0; j <= n; j++){
            add(dp[now][j + 1], dp[pre][j]);
            add(dp[now][j + 1], dp[pre][j]);
            add(dp[now][max(0, j - 1)], dp[pre][j]);
        }
    }
    int ret = dp[now][m];
    while(m--) ret = (LL)ret * inv2 % md;
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    ll N; cin>> N;
    
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    ll ans=0;
    
    map<ll,ll> L;
    map<ll,ll> R;
    rep(i,N){
        L[i+A[i]]++;
        R[i-A[i]]++;
    }
    rep(i,N){
        ans += R[i+A[i]];
    }
    
    cout << ans << endl;
    
    
    
    

    
    return 0;
}


Measured memory_bytes: 39096
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int A, B;
	string S;
	cin >> A >> B >> S;

	for (int i = 0; i <= A + B; i++) {
		if (S[i] == '-') {
			if (i == A);
			else {cout << "No"; return 0;}
		}
		else {
			if (i == A) { cout << "No"; return 0; }
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<int> B(N - 1);
	rep(i, N - 1) {
		cin >> B[i];
	}

	vector<int> A(N);
	A[0] = B[0];
	rep(i, N - 2) {
		if (B[i] <= B[i + 1]) {
			A[i + 1] = B[i];
		}
		else {
			A[i + 1] = B[i + 1];
		}
	}
	A[N - 1] = B[N - 2];
	int ans = 0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

long long n,a,b,k,ans = 0;
long long mod = 998244353;

long long fact[1000000];

long long extgcd(long long a,long long b,long long& x,long long& y){
	long long d = a;
	if(b != 0) {
		d = extgcd(b,a%b,y,x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

long long mod_inverse(long long a,long long m){
	long long x,y;
	extgcd(a,m,x,y);
	return (m + x % m) % m;
}

long long mod_fact(long long n,long long p ,long long& e){
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n/p,p,e);
	if(n/p%2 != 0 ) return res * (p - fact[n%p]) % p;
	return res *fact[n%p] % p;
}

long long mod_comb(long long n,long long k,long long p) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1,e2,e3;
	long long a1 = mod_fact(n,p,e1), a2 = mod_fact(k,p,e2), a3 = mod_fact(n-k,p,e3);
	if(e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p,p) % p;
}

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

	cin >> n >> a >> b >> k;

	long long g = a+b;

	fact[0] = 0;
	fact[1] = 1;

	for (long long i = 2;i < 1000000;i++){
		fact[i] = (fact[i-1] * i) % mod;
	}

	for(long long i = 0;i<=n;i++){
		if(i > n) break;
		long long c = k - i*a;
		if(c%b == 0){
			long long j = c/b;
			ans += (mod_comb(n,i,mod)*mod_comb(n,j,mod))%mod;
			ans %= mod;
		}

	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 8192
//TYPE
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;
#define cls(x) memset(x,0,sizeof(x))


const int INF = 0x3f3f3f3f;
const int SZ = 100;

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

  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
using pll = pair<long, long>;
//------グローバル変数-------//
long res = 0;
bool imp = false;
//---------------------------//

void IsDAG(vector<vector<long>>& fow, long now, vector<bool>& isactive, vector<bool>& visited) {
	visited[now] = true;
	isactive[now] = true;

	for (auto e : fow[now]) {
		if (isactive[e]) { imp = true; return; }
		else if (!visited[e]) IsDAG(fow, e, isactive, visited);
	}

	isactive[now] = false;
}

void Lpath(vector<vector<long>>& rev, long now , vector<long>& dist , vector<bool>& solved) {
	if (solved[now]) return;
	
	for (long e : rev[now]) {
		if (!solved[e]) Lpath(rev, e, dist, solved);
		dist[now] = max(dist[now], dist[e] + 1);
	}
	solved[now] = true;
	res = max(res, dist[now]);
}

int main() {


	long N; cin >> N;
	long A[1009][1009];
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N - 1; j++) cin >> A[i][j];//1-indexed

	//辞書
	long dic[1009][1009];
	long index = 0;
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N - 1; j++) {
		if (i > A[i][j]) continue;//順番を考慮
		dic[i][A[i][j]] = index;
		index++;
	}

	//隣接リスト A[i][j - 1] -> A[i][j]
	vector<vector<long>> fow(index) , rev(index);
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N - 1; j++) {
		if (j == 1) continue;
		long mn = min((long)i, A[i][j]);
		long mx = max((long)i, A[i][j]);
		long dmn = min((long)i, A[i][j - 1]);
		long dmx = max((long)i, A[i][j - 1]);
		fow[dic[dmn][dmx]].push_back(dic[mn][mx]);
		rev[dic[mn][mx]].push_back(dic[dmn][dmx]);
	}

	//グラフがDAGか判定
	//ソースの集合をとる
	vector<bool> issource(index, true);
	vector<long> sources;
	for (int i = 0; i < index; i++) {
		for (auto e : fow[i]) issource[e] = false;
	}
	for (int i = 0; i < index; i++) {
		if (issource[i]) sources.push_back(i);
	}
	if (sources.empty()) imp = true;

	vector<bool> isactive(index, false);
	vector<bool> visited(index, false);

	for (long e : sources) {
		IsDAG(fow, e, isactive, visited);
	}
    
	//DAG上の最長パス
	//DP? -> メモ化再帰
	vector<long> dist(index , 0);//ソースからの最短距離の最長距離(+1)
	vector<bool> solved(index, false);//distが計算済み
    
    if (imp) goto koko;
	for (auto e : sources) {
		dist[e] = 1;
		solved[e] = true;
	}

	for (int i = 0; i < index; i++) {
		if (solved[i]) continue;
		Lpath(rev, i, dist, solved);
    }
    
koko:;   
    //例外処理
	if (imp) res = -1;
	cout << res << endl;
}

Measured memory_bytes: 74624
from sys import stdin
def gcd(x, y):
	while(y):x, y = y, x % y 
	return x
n = int(stdin.readline())
a = list(map(int,stdin.readline().split()))
lcm = a[0]
for i in range(1,n):lcm = (lcm*a[i])//gcd(lcm,a[i])
b = [lcm // i for i in a]
print(sum(b)%1000000007)

Measured memory_bytes: 262756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n,m;
    int s[6];
    char c[6];
    cin >> n >> m;
    rep(i,m)cin >> s[i] >> c[i];
    bool ok =false;

        rep(i,1000){
            string now = to_string(i);
            if(now.size()==n){
                ok = true;
                rep(j,m){
                    if(now[s[j]-1]!=c[j]){
                        ok = false;
                        break;
                    }
                }
            }
            if(ok){
                cout << stoi(now);
                return 0;
            }
        }

    cout << -1;

    return 0;
}

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

int main(){
	string s;
	while(getline(cin, s )){
		if(s=="END OF INPUT")break;
		ll ans = 0;
		for(int i=0;i<s.size();i++){
			if(s[i]!=' '){
				ans++;
			}else{
				cout << ans;
				ans = 0;
			}
		}
		if(ans)cout<<ans;
		cout << endl;
	}
}


Measured memory_bytes: 3008
/*
AOJ 0525 Osenbei

?¢?????????????!?????????! ????\?????????\????\?!
?????????????\???¨?????\???r???c??????????\????????\??????\??£??¢???????????¨1??¨??????????????\?????¢???????????¨0??¨?????????
????¬?????°?????????????????????????????\???¨??¨?????¬?????°??¨??????????°?????????????????\?????????£??¢?????????
???????????????????°?????\???£??¢?????????

?????\??????????????\??????????¬¬??????????????´??°r, c (1 ??? r ??? 10, 1 ??? c ??? 10 000)???
??????r???c?????¨???????\?????§???¶??????r=c=0??¨????????\?????????

??????????????????????????\?????????????????????????°?????\???£??¢?????????
 */
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }

const int R = 10;
const int C = 10000;

int r, c;
int b[C];
int countbit[1<<R];
int main(int argc, char *argv[]) {
  countbit[0] = 0;
  REP(i, 1 << R) countbit[i] = countbit[i/2] + i % 2;
  while (scanf("%d %d", &r, &c) == 2 && r + c > 0) {
    CLR(b, 0);
    REP(i, r) REP(j, c) {
      int x;
      scanf("%d", &x);
      b[j] |= x << i;
    }
    int ans = 0;
    REP(mask, 1 << (r - 1)) {
      int current = 0;
      REP(i, c) {
        int cnt = countbit[b[i]^mask];
        current += max(cnt, r - cnt);
      }
      checkmax(ans, current);
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;

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

    if ((a - b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << (a - 1) + (b >= a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define f  first
#define s  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    inp(a);inp(b);
    int res= 2*b;
    res=a-res;
    if(res<0)res=0;
    print(res);
    return 0;
}

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

void	initialize(int *a, bool *opened, std::vector<int> &b)
{
	using namespace std;

	int	i;
	int	size;

	i = 0;
	while (i < 9)
	{
		opened[i] = 0;
		cin >> a[i];
		++i;
	}
	cin >> size;
	b.resize(size);
	i = 0;
	while (i < size)
	{
		cin >> b[i];
		++i;
	}
}

bool	is_row_bingo(bool *opened)
{
	int	i;
	int	j;

	i = 0;
	while (i < 3)
	{
		j = 0;
		while (j < 3)
		{
			if (!opened[3 * i + j])
				break;
			++j;
		}
		if (j == 3)
			return (true);
		++i;
	}
	return (false);
}

bool	is_col_bingo(bool *opened)
{
	int	i;
	int	j;

	j = 0;
	while (j < 3)
	{
		i = 0;
		while (i < 3)
		{
			if (!opened[3 * i + j])
				break;
			++i;
		}
		if (i == 3)
			return (true);
		++j;
	}
	return (false);
}

bool	is_diag_bingo(bool *opened)
{
	int	i;

	i = 0;
	while (i < 3)
	{
		if (!opened[3 * i + i])
			break;
		++i;
	}
	if (i == 3)
		return (true);
	i = 0;
	while (i < 3)
	{
		if (!opened[3 * (i + 1) - (i + 1)])
			break;
		++i;
	}
	if (i == 3)
		return (true);
	return (false);
}

bool	is_bingo_core(bool *opened)
{
	if (is_row_bingo(opened))
		return (true);
	if (is_col_bingo(opened))
		return (true);
	if (is_diag_bingo(opened))
		return (true);
	return (false);;
}
	
bool	is_bingo(int *a, bool *opened, std::vector<int> &b)
{
	int	i;
	int	j;
	int	size;

	size = b.size();
	i = 0;
	while (i < size)
	{
		j = 0;
		while (j < 9)
		{
			if (b[i] == a[j])
			{
				opened[j] = true;
				if (is_bingo_core(opened))
					return (true);
			}
			++j;
		}
		++i;
	}
	return (false);
}

int		main()
{
	using namespace std;

	vector<int>	b;
	int			a[9];
	bool		opened[9];

	initialize(a, opened, b);
	if (is_bingo(a, opened, b))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return (0);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int A[100][100];

int N, M;


class Kuhn {
	public:

		// Invoke clear() before this to reset all the vectors.
    void init(int _nLeft, int _nRight) {
      nLeft = _nLeft;
			nRight = _nRight;
      g.resize(nLeft);
      matchedTo.assign(nRight, -1);
    }

    void add_edge(int i, int j) {
      g[i].push_back(j);
    }

    int run() {
      int ans = 0;
      for (int v = 0; v < nLeft; ++v) {
        used.assign(nLeft, false);
        if (dfs(v))
					ans++;
      }
      return ans;
    }

    void clear() {
      g.clear();
      matchedTo.clear();
      used.clear();
    }
    
  vector<int> matchedTo;
	private:
		int nLeft, nRight;
    vector<vector<int> > g;
    
    vector<bool> used;

    bool dfs(int v) {
      if (used[v])
        return false;
      used[v] = true;
      for (int i = 0; i < (int)g[v].size(); i++) {
        int to = g[v][i];
        if (matchedTo[to] == -1 || dfs(matchedTo[to])) {
            matchedTo[to] = v;
            return true;
        }
			}
      return false;
    }
};



int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	FOR (i, N)
		FOR (j, M)
			cin >> A[i][j];
	
	int finalRow[100 * 101];
	FOR (i, N)
		FOR (j, M)
			finalRow[M * i + j + 1] = i;
	
	int B[100][100];
	SET(B, 255);
	Kuhn matching;
	FOR (C, M) {
		matching.clear();
		matching.init(N, N);
		FOR (i, N)
			FOR (j, M)
				if (A[i][j] != -1)
					matching.add_edge(finalRow[A[i][j]], i);
		matching.run();
		FOR (i, N) {
			int fr = matching.matchedTo[i];
			FOR (j, M)
				if (A[i][j] != -1 && finalRow[A[i][j]] == fr) {
					B[i][C] = A[i][j];
					A[i][j] = -1;
					break;
				}
		}
	}
	
	
	FOR (i, N) {
		FOR (j, M)
			cout << B[i][j] << " ";
		cout << endl;
	}
	
	int C[100][100];
	FOR (i, N)
		FOR (j, M)
			C[finalRow[B[i][j]]][j] = B[i][j];
			
	FOR (i, N) {
		FOR (j, M)
			cout << C[i][j] << " ";
		cout << endl;
	}	
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] guest = new int[N][2];
		for(int i = 0;i < N;++i) {
			guest[i][0] = sc.nextInt();
			guest[i][1] = sc.nextInt();
		}
		sc.close();
		
		int ans = 0;
		for(int i = 0;i < N;++i) {
			ans += guest[i][1] - guest[i][0] + 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25832
a,b = map(int,input().split())
ls = list(map(int, input().split()))

duration = 0 
max = 0

for i in ls :
  if  i <= max and max <= i+b :	
    duration += i + b - max  
    max = i + b
    
  elif max < i :
    duration += b
    max = i + b
    
print(duration)    

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <atcoder/all>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N, M;
	get(N, M);

	atcoder::dsu gr(N);
	int a, b;
	for (int i = 0; i < M; i++) {
		get(a, b); a--; b--;
		gr.merge(a, b);
	}
	int ans = gr.groups().size();
	printf("%d\n", ans - 1);
}


Measured memory_bytes: 8936
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  vector<int> a(9);
  vector<bool> bingo(9, false);
  rep(i, 9) cin >> a[i];
  int n;
  cin >> n;
  rep(j,n) {
    int b;
    cin >> b;
    rep(i,9) if(a[i] == b) bingo[i] = true;
  }
  bool ok = false;
  if(bingo[0] && bingo[1] && bingo[2]) ok = true;
  if(bingo[3] && bingo[4] && bingo[5]) ok = true;
  if(bingo[6] && bingo[7] && bingo[8]) ok = true;
  if(bingo[0] && bingo[3] && bingo[6]) ok = true;
  if(bingo[1] && bingo[4] && bingo[7]) ok = true;
  if(bingo[2] && bingo[5] && bingo[8]) ok = true;
  if(bingo[0] && bingo[4] && bingo[8]) ok = true;
  if(bingo[2] && bingo[4] && bingo[6]) ok = true;
  if(ok) cout << "Yes\n";
  else cout << "No\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 1002;
const ll M = 21;
ll q,dp[N][N];
string x,y;
vector <ll> ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>q;
	FOR(k,0,q){
		cin>>x>>y;
		FOR(i,0,x.size()+1){
			FOR(j,0,y.size()+1){
				dp[i][j]=0;
			}
		}
		FOR(i,0,x.size()+1){
			FOR(j,0,y.size()+1){
				if(i==0||j==0)dp[i][j]=0;
				else{
					if(x[i-1]==y[j-1])dp[i][j] = (dp[i-1][j-1]+1);
					else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
				} 
			}
		}
		ans.push_back(dp[x.size()][y.size()]);
	}
	FOR(i,0,ans.size()){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 10952
#include <algorithm>
#include <iostream>

using namespace std;

int abs(int a) {
    return a >= 0 ? a : -a;
}

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        res += min(2 * x, 2 * abs(x - k));
    }

    cout << res << endl;
}


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

bool isPrime(int n) {
    if (n == 2) return true;
    if (n == 1 || n % 2 == 0) return false;
    auto c = std::sqrt(n);
    for (int i = 3; i <= c; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int v[100001];
    v[0] = 0;
    for (int i = 1; i < 100001; i++) {
        v[i] = v[i-1] + ((isPrime(i)&&isPrime((i+1)/2))?1:0);
    }

    int q, l, r;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        std::cin >> l >> r;
        std::cout << v[r] - v[l-1] << std::endl;
    }

    return 0;
}

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

int main(){
  string s;
  int price = 700;
  cin >>s;
  if (s[0]=='o') price +=100;
  if (s[1]=='o') price +=100;
  if (s[2]=='o') price +=100;
  cout << price << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>a;
struct node{
	string str;
	int val;
}t[200001];
int n;
int cnt;
inline bool cmp(node x,node y){
	return x.val!=y.val?x.val>y.val:x.str<y.str;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		string u;
		cin>>u;
		if(a.count(u)){
			a[u]++;
		}
		else a[u]=1;
	}
	for(map<string,int>::iterator it=a.begin();it!=a.end();it++){
		t[++cnt].str=it->first;
		t[cnt].val=it->second;
	}
	sort(t+1,t+1+cnt,cmp);
	for(int i=1;i<=cnt;i++){
		if(t[i].val==t[1].val){
			cout<<t[i].str<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 28288
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)

const int N = 44, C = 133333, ZZQ = 1e9 + 7;

int n, x, y, z, f[N][C], Cm, ans = 1;

int main()
{
	//freopen("poem.in", "r", stdin);
	//freopen("poem.out", "w", stdout);
	
	int i, j, S;
	std::cin >> n >> x >> y >> z;
	Cm = (1 << x + y + z) - 1;
	f[0][0] = 1;
	For (i, 1, n) ans = 10ll * ans % ZZQ;
	For (i, 0, n - 1) For (S, 0, Cm)
	{
		if (!f[i][S]) continue;
		For (j, 1, 10)
		{
			int T = ((S << j) | (1 << j - 1)) & Cm;
			if (((T >> z - 1) & 1) && ((T >> y + z - 1) & 1)
				&& ((T >> x + y + z - 1) & 1)) continue;
			f[i + 1][T] = (f[i + 1][T] + f[i][S]) % ZZQ;
		}
	}
	For (S, 0, Cm) ans = (ans - f[n][S] + ZZQ) % ZZQ;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 20992
/*
 * Main.cpp
 *
 *  Created on: 26/03/2020
 *      Author: freyman
 */

#include <bits/stdc++.h>

using namespace std;

bool is_palindrome(int l, int r, string s) {
	while (l < r) {
		if (s[l] != s[r]) return false;
		l++;
		r--;
 	}
	return true;
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int n;
	cin >> s;
	n = s.length();
	bool p = true;
	p = p & (is_palindrome(0, (n-1)/2-1, s));
	p = p & (is_palindrome((n+3)/2-1, n-1, s));
	p = p & (is_palindrome(0, n-1, s));
	cout << (p?"Yes":"No") << "\n";



}














Measured memory_bytes: 256
n = int(input())
#s = input()
#n, m = map(int, input().split())
#s, t = input().split()
#n, m, l = map(int, input().split())
#s, t, r = input().split()
t = list(map(int, input().split()))
#a = input().split()
#a = [int(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

#t = input()
m = int(input())
#p, q = map(int, input().split())
#p, q = input().split()
#p, q, r = map(int, input().split())
#p, q, r = input().split()
#b = map(int, input().split())
#b = input().split()
#b = [int(input()) for _ in range(m)]
#b = [input() for _ in range(m)]
cnt, ans, mx, mn = 0, 0, 0, 100000000
for i in range(m):
    p, x = map(int, input().split())
    print(sum(t) - t[p - 1] + x)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    vector<int> beki(31);
    rep(i,31) beki[i]=pow(2,i);
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    
    int ans=0;
    while(sz(a)>1){
        int key=a.back();
        a.pop_back();
        rrep(i,31){
            if(beki[i]-key<1) continue;
            int x=lower_bound(all(a),beki[i]-key)-a.begin();
            if(x<sz(a) && a[x]==beki[i]-key){
                a.erase(a.begin()+x);
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 1024
package main

import "fmt"

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

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	x := make([][]int, n)
	for i := 0; i < n; i++ {
		x[i] = make([]int, d)
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			dd := 0
			for k := 0; k < d; k++ {
				x := abs(x[i][k] - x[j][k])
				dd += x * x
			}
			ok := false
			for k := 0; k*k <= dd; k++ {
				if k*k == dd {
					ok = true
				}
			}
			if ok {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int fun( int mid, int k,vector< int>&arr)
{
     int ans=0;
    for( int i=0;i<arr.size();i++)
    {
        if(arr[i]>mid)
        ans+=(arr[i]  / mid) ;
    }
    if(ans<=k)
    return 1;
    return 0;
}
int main()
{
   int n,k;
  cin>>n>>k;
  vector< int>arr(n);
  int mn=1;
 int mx=-1;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      mx=max(mx,arr[i]);
  }
  
  while(mn<=mx)
  {
       int mid=(mn+mx)/2;
      if(fun(mid,k,arr))
      mx=mid-1;
      else 
      mn=mid+1;

  }
  if(fun(mn,k,arr))
  cout<<mn;
  else
  cout<<mn-1;
  return 0;
}

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

/* O(N^1.5) implementation.
 * -- this may be poor code. */

int is_prime(int n)
{
    int i;

    if(n<2) return 0;

    for(i=2; i<(int)sqrt(n)+1; i++)
        if(n%i == 0) return 0;

    return 1;
}

int main(void)
{
    int a, d, n;

    while(scanf("%d %d %d", &a, &d, &n), a+d+n)
    {
        a -= d;

        while(n--)
        {
            a += d;
            while(!is_prime(a)) a += d;
        }

        printf("%d\n", a);
    }

    return 0;
}

Measured memory_bytes: 600
int main()
{
  int a[4];
  int i = 0;
  while (i < 4)
  {
    scanf("%d",&a[i]);
    i++;
  }
  if (a[0] <= a[1] && a[2] <= a[3])
    printf("%d",a[0]+a[2]);
  else if (a[1] <= a[0] && a[2] <= a[3])
    printf("%d",a[2]+a[1]);
  else if (a[0] <= a[1] && a[3] <= a[2])
    printf("%d",a[0]+a[3]);
  else
    printf("%d",a[1]+a[3]);
}

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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<n+1;i++){
        int sum =((i%10)+(i%100)/10+(i%1000)/100+(i%10000)/1000+i/10000);
        if(sum>=a&&sum<=b){
            ans=ans+i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    ll N; cin >> N;
    bool f=false;

    int numk=0;
    for(ll k=1; k<=2*N; k++){
        if(k*(k-1)/2==N){
            f=true;
            numk=k-1;
        }
    }

    if(!f){
        cout << "No" << endl;
        return 0;
    }

    vector<int>v[100010];

    int num=1;
    for(int i=0; i<numk; i++){
        for(int j=0; j<numk; j++){
            if(j<i+1) {
                v[i].push_back(num);
                num++;
            }else{
                v[i].push_back(0);
            }
        }
    }

    set<int> st[100010];
    for(int i=0; i<numk; i++){
        for(int j=0; j<=i; j++){
            st[j].insert(v[i][j]);
            st[i].insert(v[i][j]);
            if(i==j){
                st[numk].insert(v[i][j]);
            }
        }
    }


    cout << "Yes" << endl;
    cout << numk+1 << endl;

    for(int i=0; i<numk+1; i++){
        cout << st[i].size();
        for(auto a: st[i]){
            cout << " " << a;
        }
        cout << endl;
    }



    return 0;
}

Measured memory_bytes: 16384
n, h = gets.strip.split.map(&:to_i)
a = readlines.map {|line| line.strip.split.map(&:to_i) }.sort

categorized = a.group_by(&:first)

usual = categorized[categorized.keys.max].sort.first

tmp_h = h
result = 0
a.select {|e| e.last>usual.first }.map(&:last).sort.reverse.each do |thr|
  tmp_h -= thr
  result+=1
  if tmp_h<=0
    p result
    exit
  end
end

# 投げダメージだけだと倒せないので投げと振りで倒す
a.delete_at(a.index(usual))
result = 0

a.select {|e| e.last>usual.first }.map(&:last).sort.reverse.each do |thr|
  h -= thr
  result += 1

  if h<=0
    p result
    exit
  end
end

if usual.last > usual.first
  h -= usual.last
  result += 1
end

result += 1 if h%usual.first > 0

result += (h/usual.first)

p result


Measured memory_bytes: 25328
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

vector<int> arr[100010];
int dp[100010];

int solve(int src)
{
    if(arr[src].size()==0)
    {
        dp[src]=0;
        return 0;
    }

    if(dp[src]!=-1)
        return dp[src];
    int ans=0;
    for(int i=0;i<arr[src].size();i++)
    {
        int dest=arr[src][i];
        if(dp[dest]==-1)
            solve(dest);
        ans=max(ans,dp[dest]);
    }
    ans+=1;
    return dp[src]=ans;

}


int main()
{
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        a--,b--;
        arr[a].pb(b);
    }

    for(int i=0;i<n;i++)
        dp[i]=-1;

    int ans=0;

    for(int i=0;i<n;i++)
    {
       if(dp[i]==-1)
        solve(i);
       ans=max(ans,dp[i]);

    }
    cout<<ans;

    return 0;

}


Measured memory_bytes: 8832