akhauriyash/Code-Regression huggingface dataset:
import java.math.BigInteger

fun main(args : Array<String>) {
    val t = readLine()!!.toInt()

    repeat(t) {
        val (n, m, a, b) = readLine()!!.split(" ").map { it.toLong() }
        println(Math.floorSum(n, m, a, b))
    }
}

object MathInternal {
    fun safeMod(x: Long, m: Long): Long {
        var xx = x
        xx %= m

        if (xx < 0L) xx += m
        return xx
    }

    /**
     * @param m 1 <= m
     */
    data class barrett(var m: UInt) {
        var im: BigInteger = BigInteger.ONE.shiftLeft(64).divide(this.m.toLong().toBigInteger())

        /**
         * @return m
         */
        fun umod(): UInt {
            return this.m
        }

        /**
         * NOTE: values could be approx. m^3 during the calculation.
         *
         * @param a 0 <= a < m
         * @param b 0 <= b < m
         * @return a * b % m
         */
        fun mul(a: UInt, b: UInt): UInt {
            // [1] m = 1
            // a = b = im = 0, so okay

            // [2] m >= 2
            // im = ceil(2^64 / m)
            // -> im * m = 2^64 + r (0 <= r < m)
            // let z = a*b = c*m + d (0 <= c, d < m)
            // a*b * im = (c*m + d) * im = c*(im*m) + d*im = c*2^64 + c*r + d*im
            // c*r + d*im < m * m + m * im < m * m + 2^64 + m <= 2^64 + m * (m + 1) < 2^64 * 2
            // ((ab * im) >> 64) == c or c + 1

            var z = a.toLong().toBigInteger()
            val bb = b.toLong().toBigInteger()
            z = z.multiply(bb)

            val x = z.multiply(this.im).shiftRight(64)
            var v = z.subtract(x.multiply(this.m.toLong().toBigInteger())).toLong().toUInt()

            if (this.m <= v) v += this.m

            return v
        }
    }
}

object Math {
    fun powMod(x: Long, n: Long, m: Int): Long {
        if (m == 1) return 0L

        val bt = MathInternal.barrett(m.toUInt())
        var r: UInt = 1u
        var y: UInt = MathInternal.safeMod(x, m.toLong()).toUInt()

        var nn = n

        while (nn > 0L) {
            if (nn and 1L > 0L) r = bt.mul(r, y)
            y = bt.mul(y, y)
            nn = nn.shr(1)
        }
        return r.toLong()
    }

    fun floorSum(n: Long, m: Long, a: Long, b: Long): Long {
        var ans = 0L
        var aa = a
        var bb = b

        if (aa >= m) {
            ans += (n - 1) * n * (aa / m) / 2
            aa %= m
        }
        if (bb >= m) {
            ans += n * (bb / m)
            bb %= m
        }

        val yMax = (aa * n + bb) / m
        val xMax = (yMax * m - bb)

        if (yMax == 0L) return ans

        ans += (n - (xMax + aa - 1) / aa) * yMax
        ans += floorSum(yMax, aa, m, (aa - xMax % aa) % aa)

        return ans
    }
}

Measured memory_bytes: 63520
#include <iostream>
    #include <algorithm>
    using namespace std;
    
    int main() {
        int N; cin >> N;
        int A[N];
        for (int i = 0; i < N; ++i) cin >> A[i];
        bool f = 1;
        int count = 0;
        while(f) {
            f = 0;
            for (int i = 0; i < N-1; ++i ) {
                if (A[i] > A[i+1]) {
                    swap(A[i], A[i+1]);
                    f = 1;
                    ++count;
                }
            }
        }
        for (int i = 0; i < N; ++i) {
            if (i > 0) cout << " ";
            cout << A[i];
        }
        cout << endl;
        cout << count << endl;
        return 0;
    }


Measured memory_bytes: 3088
using System;

namespace List_of_Top_3_Hills
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hills = new int[10];

            for (int i = 0;i < hills.Length; i++)
            {
                hills[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(hills);
            Array.Reverse(hills);

            for (int j = 0; j < 3; j++)
            {
                Console.WriteLine(hills[j]);
            }
            
        }
    }
}

Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string code;
  cin >> code;
  
  if(adjacent_find(code.begin(), code.end()) == code.end())
  {
    cout << "Good" << endl;
  }
  else
  {
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        int in;
        cin >> in;
        a.at(i) = in;
    }
    sort(a.begin(),a.end());
    rep(i,n - 1){
        if(a.at(i) == a.at(i + 1)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

const int MAX = 1e5;

vector<pair<int, int>> G[MAX];

int a[MAX];

void dfs(int v, int prev) {
	for (auto e : G[v]) if (e.first != prev) {
		a[e.first] = a[v] ^ (e.second & 1);
		dfs(e.first, v);
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w; --u, --v;
		G[u].emplace_back(v, w & 1);
		G[v].emplace_back(u, w & 1);
	}
	a[0] = 0;
	dfs(0, -1);
	for (int i = 0; i < N; i++) {
		puts(a[i] ? "1" : "0");
	}
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  bool ok = 1;
  for(int i = 0; i < n; ++i) {
    if(i & 1) {
      if(s[i] == 'R') {
        ok = 0;
        break;
      }
    } else {
      if(s[i] == 'L') {
        ok = 0;
        break;
      }
    }
  }
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=10000007;

int main() {
  string S;
  int K;
  cin>>K>>S;
    if(S.size()<=K) cout<<S;
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"...";
  } 
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
#define FOR(i,s,e) for(int i = s;i < e;i++)
#define debug(x) cout << #x << ": " << x << endl
const int INF = (1 << 30);
const ll LINF = (1LL << 60);
 
int ans = -1;
 
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
void dfs(pii at,int n, vector<vector<int>> masu) {
    if (n == 10) return;
    int y = at.first, x = at.second;
    for (int i = 0; i < 4; i++) {
        int yy = y + dy[i], xx = x+  dx[i];
        if (masu[yy][xx] == 1) continue;
        if (masu[yy][xx] == -1)  continue; 
        if (masu[yy][xx] == 3) { if (ans == -1) ans = n+1; else ans = min(ans, n+1); return; }
        bool f = false;
        while (masu[yy + dy[i]][xx + dx[i]] != 1) {
            yy += dy[i];
            xx += dx[i];
            if (masu[yy][xx] == -1) { f = true; break; }
            if (masu[yy][xx] == 3) { if (ans == -1) ans = n + 1; else ans = min(ans, n + 1); return; }
        }
        if (f) continue;
        if (masu[yy + dy[i]][xx + dx[i]] == 1) {
            masu[yy + dy[i]][xx + dx[i]] = 0;
            dfs({ yy,xx }, n + 1, masu);
            masu[yy + dy[i]][xx + dx[i]] = 1;
        }
    }
    return;
}
 
 
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int w, h;
    while (cin >> w >> h, w|h) {
        ans = -1;
        vector<vector<int>> masu(h + 2, vector<int>(w + 2, -1));
        pii s;
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                cin >> masu[i][j];
                if (masu[i][j] == 2) s = { i,j };
            }
        }
        //for (int i = 0; i <= h + 1; i++) {
        //  for (int j = 0; j <= w + 1; j++) {
        //      cout << setw(3) <<  masu[i][j] << " ";
        //  }
        //  cout << endl;
        //}
        dfs(s,0, masu);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, k; cin>>n>>k;
  vector<pair<int, int>> td(n);
  rep(i, n) cin>>td[i].first>>td[i].second;
  sort(td.begin(), td.end(), [](auto x, auto y) { return x.second > y.second; });

  long long ans = 0, cur = 0;
  set<int> s;
  stack<int> q;
  rep(i, k) {
    if (s.count(td[i].first)) q.push(td[i].second);
    s.emplace(td[i].first);
    cur += td[i].second;
  }
  ans = cur + s.size() * s.size();

  REP(i, k, n) {
    if (q.empty()) break;
    if (s.count(td[i].first)) continue;
    cur -= q.top(); q.pop();
    cur += td[i].second;
    s.emplace(td[i].first);
    ans = max(ans, cur + (long long)(s.size() * s.size()));
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 4096
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    x,k,d = map(int,ipt().split())
    if abs(x) > k*d:
        print(abs(abs(x)-k*d))
    else:
        t = abs(x)//d
        dd = abs(x)%d
        if (t-k)%2:
            print(d-dd)
        else:
            print(dd)


    return None

if __name__ == '__main__':
    main()


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

int main(){
  int n,i;
  cin >> n;
  vector<int> v(n);
  map<int,int> gu,ki;
  int max_va,se_va,kimax_va,kise_va,gumax,kimax,ans;
  max_va=0;
  se_va=0;
  kimax_va=0;
  kise_va=0;
  gumax=0;
  kimax=0;
  for(i=0;i<n;++i){
    cin >> v[i];
    if(i%2==0){
      gu[v[i]]++;
    }else{
      ki[v[i]]++;
    }
  }
  for(auto& gup : gu){
    if(gumax<=gup.second){
      se_va=gumax;
      max_va=gup.first;
      gumax=gup.second;
    }
  }
  for(auto& kip : ki){
    if(kise_va<=kip.second){
      kise_va=kip.second;
    if(kimax<=kip.second){
      kise_va=kimax;
      kimax_va=kip.first;
      kimax=kip.second;
    }
  }
}
  if(max_va!=kimax_va){
    ans=((n/2)-gumax)+((n/2)-kimax);
  }else{
    ans=min(((n/2)-se_va)+((n/2)-kimax),((n/2)-gumax)+((n/2)-kise_va));
  }

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


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,M;
    cin >> N >> M;
    vi ans(N,-1);
    
    rep(i,M){
        int s,c;
        cin >> s >> c;
        s--;
        if(ans[s] == -1) ans[s] = c;
        else if(ans[s] != c){
            cout << -1 << endl;
            return 0;
        }
    }

    if(ans[0] == 0 && N > 1){
        cout << -1 << endl;
        return 0;
    }
    if(ans[0] == -1 && N > 1) ans[0] = 1;
    rep(i,N) cout << (ans[i] == -1 ? 0 : ans[i]);
    cout << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int N;
vi V;

signed main(){
    io();
    in(N);

    V.resize(N);
    rep(i,N) {
        in(V[i]);
        V[i]--;
    }
    int ans=0;
    rep(i,N){
        if(i==V[i]) {
            ans++;
            i++;
        }
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int mod=998244353;
#define Rint register int
#define C(n,m) (n<m?0:1ll*fac[n]*invfac[n-m]%mod*invfac[m]%mod)
using namespace std;//nantftxdy
int T,n,m,p,k;
bool f[310][310][310];
int dp[310][310][310],C[610][610],ans=0;
char s[310];
int main(){
	scanf("%s",s),n=strlen(s);
	for(int i=0;i<=2*n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod; 
	} 
	for(int j=0;j<=n;j++) for(int k=0;k<=n;k++) dp[n][j][k]=C[j+k][j];
	for(int i=n-1;i>=0;i--) for(int j=0;j<=i;j++) for(int k=0;k<=i;k++){
		dp[i][j][k]=dp[i+1][j][k];
		if(s[i]=='0'&&k) dp[i][j][k]=(dp[i][j][k]+dp[i][j][k-1])%mod;
		if(s[i]=='1'&&j) dp[i][j][k]=(dp[i][j][k]+dp[i][j-1][k])%mod;
	}
	f[0][0][0]=true;
	for(int i=0;i<=n;i++){
		for(int j=i;j>=0;j--){
			for(int k=i;k>=0;k--){
				if(j&&j+k>=2) f[i][j-1][k]|=f[i][j][k];
				if(k&&j+k>=2) f[i][j][k-1]|=f[i][j][k];
				if(i+1<=n){
					if(j&&s[i]=='1') f[i+1][j-1][k+1]|=f[i][j][k];
					if(k&&s[i]=='0') f[i+1][j+1][k-1]|=f[i][j][k];
					if(j+k) f[i+1][j][k]|=f[i][j][k];
				}
				if(i+2<=n){
					if(s[i]=='0'||s[i+1]=='0') f[i+2][j+1][k]|=f[i][j][k];
					if(s[i]=='1'||s[i+1]=='1') f[i+2][j][k+1]|=f[i][j][k];
				}
			}
		}
	}
	for(int i=n;i>=0;i--){
		for(int j=i;j>=0;j--){
			for(int k=i;k>=0;k--){
				if(!f[i][j][k]) continue;
				ans=(ans+dp[i][j][k])%mod;
				int cnt[2]={};
				for(int l=i-1;l>=0;l--){
					cnt[s[l]-'0']++;
					if(j<cnt[0]||k<cnt[1]) break;
					f[l][j-cnt[0]][k-cnt[1]] = false;
				}
			}
		}
	}
	printf("%d\n",ans);
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int maxL =  -1, minR = 1001001001;
    rep(i, m) {
        int l,r;
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }
    int d = minR - maxL;
    if(d < 0) {
        cout << 0 << endl;
    }
    else {
        cout << d + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())

ans = 0
if n >= k:
    ans += (n - k + 1) / n

a = k
for i in range(1, 18):
    b = -(-a // 2)
    if b <= n:
        ans += min(a - b, n + 1 - b) / n * (0.5) ** i
    a = b
print(ans)


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

int main() {
  int N;
  cin >> N;
  
  long long sum = 0;
  for (int i = 1; i <= N; i++)  {
    if (i % 5 != 0 && i % 3 != 0) {
      sum += i;
    }
  }
  
  cout << sum << endl;
}

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

const int N=2e+5+4;
long long int M=1e+9+7;
int n;
long long int c[N];
long long int powe(int i)
{
    if(i==0)
        return 1;
    long long int a=powe(i/2);
    a=(a*a)%M;
    if(i%2==1)
        a=(a*4)%M;
    return a;
}

int main()
{
    long long int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>c[i];
    sort(c+1,c+n+1,greater<long long int>());
    for(int i=1;i<=n;i++)
    {
        // long long int tans=pow(4,n-i);
        ans=(ans+(i+1)*c[i])%M;
    }
    ans=(ans*powe(n-1))%M;
    cout<<ans;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long x,y;
	cin >> x >> y;

	long long ans=1;
	long long now=x;

	while(true)
	{
		now*=2;
		if(now>y)break;
		ans++;
	}

	cout << ans << endl;

}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var keys = "keyence";

            var count = 0;
            var cur = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == keys[count])
                    count++;
                else
                {
                    cur = i;
                    break;
                }

                if (count == keys.Length)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            var minCount = 6;
            for (var i = s.Length - 1; i > cur; i--)
            {
                if (s[i] == keys[minCount])
                {
                    minCount--;
                    count++;
                }
                else
                    break;

                if (count == keys.Length)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	long long dp[101][21];
	for(int i=0;i<=100;i++)for(int j=0;j<=20;j++)dp[i][j]=0;
	dp[0][0]=1;
	cin>>n;
	int tmp;
	for(int i=0;i<n-1;i++){
		cin>>tmp;
		for(int j=0;j<=20;j++){
			if(dp[i][j]>0){
				if(j+tmp<=20)dp[i+1][j+tmp]+=dp[i][j];
				if(j-tmp>=0 && i>0)dp[i+1][j-tmp]+=dp[i][j];
			}
		}
	}
	cin>>tmp;
	cout<<dp[n-1][tmp]<<endl;
	return 0;
}


Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  int dmin = 100;
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int d = 0;
    while (A % 2 == 0) {
      A /= 2;
      d++;
    }
    dmin = min(dmin, d);
  }
  cout << dmin << endl;
}   

Measured memory_bytes: 256
use proconio::{input, fastout};

const MAX: usize = 100_001;

#[fastout]
fn main() {
    input! {
        q: i32,
        ranges: [(usize, usize); q],
    }

    let mut primes = [i8::from(-1); MAX];
    primes[0] = 0;
    primes[1] = 0;
    primes[2] = 1;
    primes[3] = 1;
    let mut cal = [0; MAX];
    
    for i in (3..MAX).step_by(2) {
        let res1 = i;
        let res2 = (i+1) / 2;

        if primes[res1] == -1 {
            primes[res1] = is_prime(res1);
        }

        if primes[res2] == -1 {
            primes[res2] = is_prime(res2);
        }

        if primes[res1] == 1 && primes[res2] == 1 {
            cal[i] = cal[i-2] + 1;
        } else {
            cal[i] = cal[i-2];
        }
    }

    for (l, r) in ranges {
        println!("{}", cal[r] - cal[l.saturating_sub(2)]);
    }
}

fn is_prime(n: usize) -> i8 {
    let max = (n as f32).sqrt();
    for i in 2..=max as usize {
        if n % i == 0 {
            return 0;
        }
    }

    return 1;
}

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

using namespace std;
int main(){
    int a[3],n;
    cin >> a[0] >> a[1] >> a[2] >> n;
    int res=0, mod;
    for(int i=0; true; i++){
        mod = n - a[0]*i;
        if (mod < 0 ) break;
        for(int j=0; true; j++){
            int mod2 = mod - a[1]*j;
            if( mod2<0) break;
            if( (mod2%a[2])==0 ) res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/**
* 氏名: 阿部寛之
* 学籍番号: 170441004
***/


#include<stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
    vector<int> x(6);
    REP(i,1,5) {
        cin>>x[i];
        if(x[i]==0) {
            cout<<i;
            return;
        }
    }
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    vector<int> d1(h + 1,0), d2(w + 1,0);

    for (int i = 0; i < h; i++){
        int white = 0;
        for (int j = 0; j < w; j++) {
            cin >> grid.at(i).at(j);
                if (grid.at(i).at(j) == '.') white++;
                else white = 0;
        }
        if (white == w) d1.at(i) = 1;
    }

    for (int i = 0; i < w; i++) {
        int white = 0;
        for (int j = 0; j < h; j++) {
            if (grid.at(j).at(i) == '.') white++;
            else white = 0;
        }
        if (white == h) d2.at(i) = 1;
    }

    for (int i = 0; i < h; i++) {
        if (d1.at(i) == 1) continue;
        else {
            for (int j = 0; j < w; j++) {
                if (d2.at(j) == 1) continue;
                else {
                    cout << grid.at(i).at(j);
                }
            }
        cout << endl;
        }
    }
}

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

int main() {
  int N,m;
  cin >> N;
  
  m = N%10;
  
  if (m==2 || m==4 || m==5 || m==7 || m==9){
  	cout << "hon" << endl; 
  }
  
  if (m==0 || m==1 || m==6 || m==8){
    cout << "pon" << endl;
  }
  
  if (m==3){
    cout << "bon" << endl;
  }
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll N,K;
ll x[100],y[100];
map<ll,map<ll,ll>> imos;

signed main(){
	ll ans = LLONG_MAX;
	cin >> N >> K;
	FOR(i,0,N)cin >> x[i] >> y[i];
	vl X(N),Y(N);
	FOR(i,0,N)X[i] = x[i];
	FOR(i,0,N)Y[i] = y[i];
	sort(ALL(X));
	sort(ALL(Y));
	map<ll,ll> mx,my;
	FOR(i,0,N)mx[X[i]] = i;
	FOR(i,0,N)my[Y[i]] = i;
	FOR(i,0,N)x[i] = mx[x[i]];
	FOR(i,0,N)y[i] = my[y[i]];
	FOR(i,0,N)imos[x[i]][y[i]] += 1;
	FOR(i,0,N+1)FOR(j,0,N+1)imos[i+1][j] += imos[i][j];
	FOR(i,0,N+1)FOR(j,0,N+1)imos[i][j+1] += imos[i][j];
	FOR(i,0,N)FOR(j,0,N)FOR(k,i,N)FOR(l,j,N){
		ll Count = imos[k][l] + imos[i-1][j-1] - imos[k][j-1] - imos[i-1][l];
		if(Count >= K){
			ll S = (X[k] - X[i]) * (Y[l] - Y[j]);
			chmin(ans,S);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);
	if(k<a){
		printf("%lld %lld",a-k,b);
	}else if(k<a+b){
		printf("0 %lld",a+b-k);
	}else{
		printf("0 0");
	}
}


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

int main()
{
	int n,m;
	string s[100],t[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>s[i];
	cin>>m;
	for(int i=0;i<m;i++) cin>>t[i];
	
	int maxv=0;
	for(int i=0;i<n;i++){
		int v=0;
		for(int j=0;j<n;j++){
			if(s[i]==s[j]) v++;
		}
		for(int j=0;j<m;j++){
			if(s[i]==t[j]) v--;
		}
		maxv=max(maxv,v);
	}
	
	cout<<maxv<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    long long ans=0;
    int r=0,mask=0;
    for (int l=0; l<n; l++){
        while(r<n && (mask^a[r])==mask+a[r]){
            mask^=a[r];
            r++;
        }
        ans+=r-l;
        mask^=a[l];
    }
    cout << ans << endl;
}


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

int main() {
  long long X;
  cin>>X;
  for(int i=-1000;i<1000;i++){
    for(int j=-1000;j<i;j++){
      if(i*i*i*i*i-j*j*j*j*j==X){
        cout<<i<<" "<<j<< endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll mod = 1000000007;
const int MAX = 1000100;

ll modpow(ll a, ll p){
    ll ret = 1;
    while(p){
        if(p & 1) ret = ret * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return ret;
}

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

int main(){
    int n; cin >> n;
    ll ans = 1, cnt = 0;
    map<pair<ll, ll>, pair<ll, ll>> mp;
    for(int i = 0; i < n; i++){
        ll a, b; cin >> a >> b;
        if(a == 0 && b == 0){
            cnt++;
            continue;
        }
        else if(a == 0){
            mp[{0, 1}].first++;
        }
        else if(b == 0){
            mp[{0, 1}].second++;
        }
        else{
            ll g = gcd(a, b);
            a /= g;
            b /= g;
            if(b < 0) a = -a, b = -b;
            if(a < 0){
                mp[{b, -a}].second++;
            }
            else mp[{a, b}].first++;
        }
    }

    for(auto P : mp){
        pair<ll, ll> p = P.second;
        ans = ans * (((modpow(2, p.first) - 1) + (modpow(2, p.second) - 1) + 1) % mod) % mod;
    }
    cout << (ans + cnt + mod - 1) % mod << endl;
}

Measured memory_bytes: 19104
#include <bits/stdc++.h>
#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 chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;ll K; cin >> N >> K;
	{
		ll ab=0,c=0;
		rep(i,N){
			ab += K+i + K+N+i;
			c += K+N+N+i;
		}
		if(ab > c){
			cout << -1 << endl;
			return 0;
		}
	}
	V<ll> A(N),B(N),C(N);
	rep(i,N) C[i] = K+N+N+i;
	set<ll> a,b;
	rep(i,N){
		a.insert(K+i);
		b.insert(K+N+i);
	}
	rep(i,N){
		if(i%2 == 0){
			A[i] = *a.begin(); a.erase(A[i]);
			auto it = b.upper_bound(C[i]-A[i]);
			assert(it != b.begin()); it--;
			B[i] = *it; b.erase(B[i]);
		}else{
			B[i] = *b.begin(); b.erase(B[i]);
			auto it = a.upper_bound(C[i]-B[i]);
			assert(it != a.begin()); it--;
			A[i] = *it; a.erase(A[i]);
		}
	}
	rep(i,N){
		cout << A[i] << " " << B[i] << " " << C[i] << '\n';
	}
}


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

template<typename T>
void read(T &x)
{
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }
	while (isdigit(c)) { x = x * 10 + c - 48; c = getchar(); }
	x *= f;
}

template<typename T> inline int chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; }

const int MAXN = 3e3 + 9, Mod = 1e9 + 7;

inline int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
inline void updateA(int &a, int b) { a = add(a, b); }

int n, m, s[MAXN];
std::unordered_map<int, int> to;

int f[MAXN][MAXN]; // 1 - i - 1 已经确定，还有 j 个可选的 1 的方案数

inline int Calc(int L, int R) { return s[R] - s[L - 1]; }

int main()
{
	read(n), read(m);
	for (int i = 1; i <= n; ++i)
	{
		char str = getchar();
		s[i] = s[i - 1] + str - 48;
		to[i] = i;
	}
	s[n + 1] = s[n];
	for (int i = 1; i <= m; ++i)
	{
		int l, r;
		read(l), read(r);
		chkmax(to[l], r);
	}
	for (int i = 2; i <= n + 1; ++i)
		chkmax(to[i], to[i - 1]);

	f[1][s[to[1]]] = 1;

	for (int i = 1; i <= n; ++i) 
		for (int j = 0; j <= n; ++j)
			if (f[i][j]) // 很有效的一个剪枝
			{
				int l = to[i] + 1, r = to[i + 1];
				int a = j, b = to[i] - i + 1 - a; // 1 的个数，0 的个数
				if (a) updateA(f[i + 1][j + Calc(l, r) - 1], f[i][j]);
				if (b) updateA(f[i + 1][j + Calc(l, r)], f[i][j]);
			}

	printf("%d\n", f[n + 1][0]);

	return 0;
}

Measured memory_bytes: 34048
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      for(int k = 1; k < 10; k++){
        if(i+j+k < 11){
          vector<string> tmp;
          rep(a,i) tmp.push_back("3");
          rep(a,j) tmp.push_back("5");
          rep(a,k) tmp.push_back("7");
          do{
            string res = "";
            for(string x : tmp) res += x;
            if(stoll(res) <= n) ans++;
          }while(next_permutation(all(tmp)));
        }
      }
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3672
#!/usr/bin/env python3
import sys
from collections import deque
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(H, W, Ch, Cw, Dh, Dw, walkable):
    N = HEIGHT * WIDTH
    visited = [0] * N

    start = (Ch + 1) * WIDTH + (Cw + 1)
    goal = (Dh + 1) * WIDTH + (Dw + 1)
    toVisit = []
    toVisit.append(start)

    currentDistance = 0
    while True:
        nextJumpOrigin = []
        while toVisit:
            p = toVisit.pop()
            if p == goal:
                return currentDistance
            if visited[p]:
                continue

            visited[p] = 1
            nextJumpOrigin.append(p)
            for d in [-1, +1, -WIDTH, +WIDTH]:
                if walkable[p + d] and not visited[p + d]:
                    toVisit.append(p + d)

        # no continuous cell
        nextJump = set()
        for origin in nextJumpOrigin:
            for dx in [-2, -1, 0, +1, +2]:
                for dy in [-WIDTH * 2, -WIDTH, 0, WIDTH, WIDTH * 2]:
                    p = origin + dx + dy
                    if not walkable[p]:
                        continue
                    if visited[p]:
                        continue
                    nextJump.add(p)
        for p in nextJump:
            toVisit.append(p)

        currentDistance += 1
        if not toVisit:
            return -1


def readMap(H, W):
    global SENTINEL, HEIGHT, WIDTH
    SENTINEL = 2
    HEIGHT = H + SENTINEL * 2
    WIDTH = W + SENTINEL * 2
    data = [0] * (HEIGHT * WIDTH)
    ok = ord(".")
    for i in range(H):
        S = input().strip()
        y = (i + SENTINEL) * WIDTH
        for j in range(W):
            data[y + (j + SENTINEL)] = 1 if S[j] == ok else 0
    return data


def main():
    # parse input
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    D = readMap(H, W)
    print(solve(H, W, Ch, Cw, Dh, Dw, D))


# tests
T1 = """
4 4
1 1
4 4
..#.
..#.
.#..
.#..
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
4 4
1 4
4 1
.##.
####
####
.##.
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
-1
"""

T3 = """
4 4
2 2
3 3
....
....
....
....
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
0
"""

T4 = """
4 5
1 2
2 5
#.###
####.
#..##
#..##
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
2
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


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

int main() {

    int s, cnt = 1;
    cin >> s;
    map< int, int > used;
    used[s] = 1;
    while(++cnt) {
        if(s % 2) s = s * 3 + 1;
        else s /= 2;

        if(used[s]) {
            cout << cnt << endl;
            return 0;
        }
        used[s] = cnt;
    }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// i番目の数値までチェック済みの時、着目中の数値が左からj番目に小さいパターン数
ll dp[3001][3001];

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

  dp[0][0]=1;

  rep(i, n-1)for(int j=0; j <= i+1; j++){
    if(s[i]=='<'){
      for(int k=0; k<j; k++){
        dp[i+1][j] += dp[i][k];
      }
    }else{
      for(int k=j; k<=i; k++){
        dp[i+1][j] += dp[i][k];
      }
    }
    dp[i+1][j] %= MOD;
  }

  int result = 0;
  rep(i, n)result = (result + dp[n-1][i])%MOD;
  cout << result << endl;

  return 0;

rep(i, n){
  rep(j, n)cout<<dp[i][j]<<' ';cout<<endl;
}

  return 0;
}


Measured memory_bytes: 49764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll r,d,x,i;
  cin>>r>>d>>x;
  for(i=0;i<10;i++)
      {
        x=((r*x)-d);
        cout<<x<<endl;
      }
}
  


Measured memory_bytes: 256
is753number :: Int -> Bool
is753number n = let s = show n in all (\x -> x `elem` s) "357" 

main :: IO ()
main = do
  n <- readLn :: IO Int
  let s = concat $ map (filter is753number) $ take 9 $ iterate (\xs -> concat [map (\y -> x*10+y) [3,5,7] | x<-xs]) [3,5,7]
  
  print $ length $ filter (<=n) s


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

/*
int main(){
    string s;
    cin >> s;

    if (s == "ABC"){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}
*/

long long A, B, C, K;

void input(){
    cin >> A >> B >> C >> K;
}

void solve(){
    if(K < A){
        cout << K << endl;
    } else if(A <= K && K <= A + B){
        cout << A << endl;
    } else{
        cout << A - (K - A - B) << endl;
    }
}

int main(){
    input();

    solve();
}

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

int main() {
  int a, b, N;
  cin >> a >> b >> N;
  
  int reserve[1100] = {};
  for (int i = a; i < b; i++) reserve[i]++;
  for (int i = 0; i < N; i++) {
    int s, f;
    cin >> s >> f;
    for (int j = s; j < f; j++) reserve[j]++;
  }

  for (int i = 0; i <= 1000; i++) {
    if (reserve[i] > 1) {
      cout << 1 << endl;
      return 0;
    }
  }

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


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

using namespace std;

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string s = "";
    rep(i, ty - sy){
        s += "U";
    }
    rep(i, tx - sx){
        s += "R";
    }
    rep(i, ty - sy){
        s += "D";
    }
    rep(i, tx - sx){
        s += "L";
    }
    //ここまででSに戻る
    s += "L";
    rep(i, (ty+1) - sy){
       s += "U";
    }
    rep(i, (tx+1) - sx){
        s += "R";
    }
    s += "DR";
    rep(i, (ty+1) - sy){
        s += "D";
    }
    rep(i, (tx+1) - sx){
        s += "L";
    }
    s += "U";
    cout << s << endl;
}


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

int main(){
    ll n,m,x,y;
    cin>>n>>m>>x>>y;
    ll a_max=-101;
    ll b_min=101;
    ll tmp;
    rep(i,n){
        cin>>tmp;
        a_max=std::max(a_max, tmp);
    }
    rep(i,m){
        cin>>tmp;
        b_min=std::min(b_min, tmp);
    }

    if(a_max<b_min && x<b_min && a_max<y){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }


}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE

ll x;
cin>>x;
cout<<(x+1)%2;


return 0;
 }



Measured memory_bytes: 3608
N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
v.reverse()
print(sum(v[:A]) / A)

def fuct(n):
	ret = 1
	while n > 1:
		ret *= n
		n -= 1
	return ret

def P(n,k):
	return fuct(n) // fuct(n-k)

def C(n,k):
	return P(n,k) // fuct(k)

if v[0] != v[A-1]:
	num = v.count(v[A-1])
	pick = 0
	for i in range(A):
		if v[i] == v[A-1]:
			pick += 1
	print(C(num, pick))
else:
	num = v.count(v[A-1])
	ans = 0
	for i in range(A, min(num+1, B+1)):
		ans += C(num, i)
	print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = a + (b - a) * ((k - a + 1) / 2) + (k - a + 1) % 2;
        ans = Math.max(k + 1, ans);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include <stdio.h>

int main(void)
{
    int a[10000], n, i;
    long min, max, sum;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    
    min = a[0];
    max = a[0];
    sum = 0;
    
    for(i=0; i<n; i++)
    {
        if(min>=a[i])
        {
            min = a[i];
        }
        
        if(max<=a[i])
        {
            max = a[i];
        }
        
        sum = sum + a[i];
        
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    return 0;

}



Measured memory_bytes: 2112
<?php
fscanf(STDIN,"%s",$str);

$cnt=0;
$out=false;

for($i=0;$i<strlen($str);$i++){
	if(substr($str,$i,1)=="x"){
		$cnt++;
	}
	if($cnt==8){
		$out=true;
		break;
	}
}

if($out){
	echo "NO";
}else{
	echo "YES";
}

?>

Measured memory_bytes: 3700
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Lmax = 0, Rmin = Integer.MAX_VALUE;
		for(int i = 0; i < M; i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			Lmax = Math.max(Lmax, L);
			Rmin = Math.min(Rmin, R);
		}
		System.out.println(Rmin-Lmax >= 0 ? Rmin-Lmax+1 : 0);
	}

}


Measured memory_bytes: 63496
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
string s;
int main()
{
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
  return 0;
}


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

using namespace std;

typedef vector<int> vec;
typedef vector<vec> Graph;

int G[110][110];

int main()
{
	memset(G,0,sizeof(G));
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int u,t;
		scanf("%d%d",&u,&t);
		u--;
		for(int j=0;j<t;j++)
		{
			int v;
			scanf("%d",&v);
			v--;
			G[u][v]=1;
		}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			printf("%d%c",G[i][j],j+1==n?'\n':' ');
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x)h & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;
const LL mod = 998244353;

int a[N];

bool vis[N];

int tmp[N], tot = 0;

void solve() {

    int n;

    LL k;

    scanf("%d %lld", &n, &k);

    k++;

    rep(i, 1, n) scanf("%d", &a[i]);

    int now = 1;

    while(!vis[now]) {

        vis[now] = 1;

        tmp[++tot] = now;

        now = a[now];

    }

    int up = tot;

    int st;

    rep(i, 1, tot) {

        if(now == tmp[i]) {

            st = i;

            break;

        }

        up--;

        k--;

        if(k == 0) {

            printf("%d\n", tmp[i]);

            return ;

        }

    }

    k %= up;

    tmp[st - 1] = tmp[tot];

    printf("%d\n", tmp[k + st - 1]);

}

int main() {

//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


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

int main(){
    vector<bool> prime(100'001, true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i <= sqrt(100'001); i++){
         if (prime[i]){
             for (int j = i * 2; j < 100'001; j += i){
                  prime[j] = false;
              }
         }
    }
    vector<long long> acc(100'001, 0);
    for (int i = 0; i < 100'001; i++){
         if (prime[i] && prime[(i+1)/2]) acc[i]++;
    }
    for (int i = 0; i < 100'000; i++){
         acc[i+1] += acc[i];
    }
         int q;
         cin >> q;
         int l, r;
         for (int i = 0; i < q; i++){
             cin >> l >> r;
             cout << acc[r] - acc[l-1] << endl;
         }
}





Measured memory_bytes: 1408
// A -Kyu in AtCoder
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
    int x;
    cin >> x;
    if(400 <= x && x < 600) cout << 8 << endl;
    else if(600 <= x && x < 800) cout << 7 << endl;
    else if(800 <= x && x < 1000) cout << 6 << endl;
    else if(1000 <= x && x < 1200) cout << 5 << endl;
    else if(1200 <= x && x < 1400) cout << 4 << endl;
    else if(1400 <= x && x < 1600) cout << 3 << endl;
    else if(1600 <= x && x < 1800) cout << 2 << endl;
    else cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 3640