akhauriyash/Code-Regression huggingface dataset:
/// authorrr: ZhakudaMagzhan 
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

// c+++++++++++++++++
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;


using namespace std;

//#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;

typedef tree < int, null_type,
less < int >, rb_tree_tag,
tree_order_statistics_node_update > ordered_set; // find_by_order(), order_of_key(). 

#define file_name ""

#define lb lower_bound
#define ub upper_bound

#define endl "\n"
#define next nxt
#define y1 OIOIO

#define ins insert
#define ers erase

#define fi first
#define se second
#define ff first.first
#define fs first.second
#define sf second.first 
#define ss second.second

#define mp make_pair
#define pb push_back
#define pbp pop_back
#define pf push_front
#define pfp pop_front

#define sz(x) ((int)(x.size()))
#define isgreater isgreaterequal
#define all(x) x.begin(), x.end()
#define log2(x) (log10(x)/log10(2))
#define tcase(x) cout<<"Case: #"<< x<<' '

#define rmin(a, b) (a) = min((a), (b))
#define rmax(a, b) (a) = max((a), (b))

#define ggg exit (0) // Gennady Gennadyevich Golovkin

#define modfix(a, mod) ((((a) % (mod)) + (mod)) % (mod))
#define mod_sum(a, b, mod) modfix(((a) + (b)), (mod))
#define mod_sub(a, b, mod) modfix(((a) - (b)), (mod))
#define mod_mul(a, b, mod) modfix(((ll)(a) * (ll)(b)), (mod))

#define forit(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int pr = 49999; // prime number
const int maxn = 899821;
const int mod = (int)1e9+7;
const ll dx[] = {0, 0, 1, -1};
const ll dy[] = {1, -1, 0, 0};

// real const
const ld pi=4*atan(1);
const ld eps = 1e-7;
const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const ull ulinf = ULLONG_MAX;           

int main () 
{ 
	#ifdef ioi
		freopen(file_name".in","r",stdin);  
		// freopen(file_name".out", "w", stdout);
	#endif
	fast_cin; srand (time (0));
	int n, odd = 0;
	cin >> n;
	for (int i = 1; i <= n; ++ i) {
	  int x;
		cin >> x;
		if (x & 1) ++ odd;
	}

	if (odd & 1) 
		cout << "NO", exit (0);
	cout << "YES", exit (0);
	return 0;
}

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

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    map<ll, ll> m;
    ll s = 0;
    REP(i, N) {
        cin >> A[i];
        ++m[A[i]];
        s += A[i];
    }
    int Q;
    cin >> Q;
    PRINT(s);
    REP(i, Q) {
        int B, C;
        cin >> B >> C;
        s -= B * m[B];
        s += C * m[B];
        m[C] += m[B];
        m[B] = 0;
        cout << s << '\n';
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 9592
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		 while (true) {
			int n = in.nextInt();
			if (n == 0) break;

			int[] cnt = new int[24*60*60+1];

			for (int i=0; i<n; i++) {
				String[] s = in.next().split(":");
				String[] t = in.next().split(":");

				int start = Integer.parseInt(s[0])*3600 + Integer.parseInt(s[1])*60 + Integer.parseInt(s[2]);
				int end = Integer.parseInt(t[0])*3600 + Integer.parseInt(t[1])*60 + Integer.parseInt(t[2]);

				cnt[start]++;
				cnt[end]--;
			}

			int ans = cnt[0];
			for (int i=1; i<=24*60*60; i++) {
				cnt[i] += cnt[i-1];
				ans = Math.max(ans,cnt[i]);
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 73888
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> a){
    sort(ALL(a)); reverse(ALL(a));
    vll b(N, 0), btmp(N, 0);
    ll bsum=0;
    do{
        bsum = 0;
        REP(i, N){
            btmp[i] = a[i]/ N;
            a[i] %= N;
            bsum += btmp[i];
            b[i] += btmp[i];
        }
        REP(i, N) {
            btmp[i] = bsum - btmp[i];
            a[i] += btmp[i];
        }
    }while(bsum > 0);
    ll res = 0;
    REP(i, N) res += b[i];
    cout << res << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int A,B,C,result;
  scanf("%d %d %d",&A,&B,&C);
  if ((A+B+1)>=C) result=B+C;
  else result=2*B+A+1;
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#abc139c

n=int(raw_input())
h=map(int,raw_input().split())
res=0
cnt=0
for i in xrange(n-1):
 if h[i]>=h[i+1]:
  cnt+=1
 else:
  res=max(res,cnt)
  cnt=0
print max(res,cnt)


Measured memory_bytes: 11316
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]

    H_list = [int(item) for item in input().split()]

    path_list = [[int(item) for item in input().split()] for _ in range(M)]

    path_list2 = [[] for _ in range(N+1)]

    for A, B in path_list:
        path_list2[A] += [B]
        path_list2[B] += [A]

    temp_list = []
    for item in path_list2:
        temp_list.append(list(set(item)))
    
    path_list2 = temp_list

    # print(path_list2)

    def nice(i):
        if len(path_list2[i]) >= 1:
            for j in path_list2[i]:
                if H_list[i-1] <= H_list[j-1]:
                    return False
            else:
                return True
                
        else:
            return True


    cnt = 0
    for i in range(N):
        if nice(i+1):
            cnt += 1
            # print(i+1)
    
    print(cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 48772
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	rep(i,n) cout << a[i];
 	return 0;
}

Measured memory_bytes: 3500
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 2e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
//  freopen("input.txt", "r", stdin);
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < (int)s.length() && k > 0; ++i) {
    if (s[i] == 'a') {
      continue;
    }
    int need = 'z' - s[i] + 1;
    if (k >= need) {
      k -= need;
      s[i] = 'a';
    }
  }
  k %= 26;
  while (k > 0) {
    s[s.length() - 1] = (s[s.length() - 1] - 'a' + 1) % 26 + 'a';
    k--;
  }
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	p, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}

	even := 0
	odd := 0
	for _, v := range a {
		if v%2 == 0 {
			even++
		} else {
			odd++
		}
	}
	ans := math.Pow(2.0, float64(even))
	if odd == 0 {
		if p != 0 {
			ans = 0
		}
	} else {
		ans *= math.Pow(2.0, float64(odd-1))
	}
	fmt.Println(int(ans))
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		int X = nextInt();

		long ans =X/500 * 1000;
		X=X%500;
		ans+=X/5 * 5;
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
#define MX 5003
using namespace std;

int main() 
{
	IOS;
	int l;
	cin>>l;
	double ll = ((double)l)/3;
	double temp = (ll*ll*ll);
	cout<<fixed<<setprecision(12)<<temp<<endl;
}


Measured memory_bytes: 256
N=int(input())
dst = list(map(int, input().split()))

cmax = 0
count = 0
for i in range(N-1):
    if dst[i] >= dst[i+1]:
        count += 1
        if count > cmax:
            cmax = count
    else:
        count = 0
        
print(cmax)

Measured memory_bytes: 14224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	ll x,a;
	cin >> x >> a;
	
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate,product

N,W=map(int,input().split())
d={}
for i in range(N):
    w,v=map(int,input().split())
    if not i:
        for j in range(w,w+4):
            d[j]=[]
    d[w].append(v)

for i in d.keys():
    d[i].sort(reverse=True)
    *d[i],=accumulate([0]+d[i])

ans=0
i,j,k,l=d.keys()
for ai,bi in enumerate(d[i]):
    for aj,bj in enumerate(d[j]):
        for ak,bk in enumerate(d[k]):
            for al,bl in enumerate(d[l]):
                if i*ai+j*aj+k*ak+l*al<=W:
                    ans=max(ans,bi+bj+bk+bl)

print(ans)


Measured memory_bytes: 42732
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int facctorialMethod(int k){
  if(k==0)return 0;
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  cin>>n;
  vector<ll>a(n,0);
  vector<ll>b(n,0);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  for(ll i=0;i<n;i++){
    cin>>b[i];
  }
  vector<ll>v(n,0);
  ll aa=0;
  ll bb=0;
  for(ll i=0;i<n-1;i++){
    ll t=0;
    for(ll j=0;j<n;j++){
      if(v[j]!=0){
        continue;
      }
      if(a[i]==j+1){
        aa+=(t)*facctorialMethod(n-i-1);
        v[j]=1;
        break;
      }
      t++;
    }
  }
  v.assign(n,0);
  for(ll i=0;i<n-1;i++){
    ll t=0;
    for(ll j=0;j<n;j++){
      if(v[j]!=0){
        continue;
      }
      if(b[i]==j+1){
        bb+=(t)*facctorialMethod(n-i-1);
        v[j]=1;
        break;
      }
      t++;
    }
  }
  ans=abs(aa-bb);
  cout<<ans<<endl;
}


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

using namespace std;

int main() {
  string str; cin >> str;
  int w; cin >> w;
  int idx = 0;
  string ans = "";
  while (idx < str.size()) {
    ans += str[idx];
    idx += w;
  }
  cout << ans << endl;
  return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    vector<int> A(N);

    int sum = 0;

    for(int i = 0; i < N; i ++){
        cin >> A[i];

        sum += A[i];
    }
    vector<int> ans;

    for(int i = 1; i * i <= sum; i ++){
        if(sum % i == 0){
            ans.push_back(i);
            ans.push_back(sum / i);
        }
    }
    sort(ans.begin(), ans.end(), greater<int>());

    for(int i = 0; i < ans.size(); i ++){
        vector<int> AA(N);

        for(int j = 0; j < N; j ++){
            AA[j] = A[j] % ans[i];
        }
        sort(AA.begin(), AA.end());

        for(int j = 0; j <= N; j ++){
            int minus = 0;

            for(int k = 0; k < j; k ++){
                minus -= AA[k];
            }
            int plus = 0;

            for(int k = j; k < N; k ++){
                plus += ans[i] - AA[k];
            }
            if(plus + minus == 0){
                if(plus <= K){
                    cout << ans[i] << endl;

                    return 0;
                }
                break;
            }
        }
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/04  Problem: codefestival2017_team_relay A / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	LL K,A,B;
	cin>>K>>A>>B;
	if(A<=B){
		if(K<=A){cout<<1<<endl;    }
		else cout<<-1<<endl;
		return 0;
	}
	else {
		ans =2*( K / abs(A-B))-100;
		LL taka = abs(A-B)*(ans/2);
		while(taka<K){
			taka+=A;ans++;
			if(taka>=K)break;
			taka-=B;ans++;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
// Problem : C - Guess The Number
// Contest : AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n,m;
	
	cin >> n >> m;
	
	vector<pair<int,int>> b(m);
	
	for(int i = 0; i < m; i++){
		cin >> b[i].first >> b[i].second;
	}
	
	int ans = INT_MAX;
	
	for(int i = 0; i <= 999; i++){
		string s = to_string(i);
		
		bool ok = true;
		for(int i = 0; i < m; i++){
			int x = b[i].first - 1;
			int y = b[i].second;
			
			if (s[x] != char('0' + y)){
				ok = false;
			}
		}		
		if (ok && s.size() == n){
			ans = min(ans,i);		
		}
	}
	
	if (ans == INT_MAX){
		cout << -1 << endl;
	}else {
		cout << ans << endl;
	}
	
	return 0;	
}


Measured memory_bytes: 256
using AtCoderBeginnerContest116.Questions;
using AtCoderBeginnerContest116.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest116.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var a = inputStream.ReadInt();
            var hashSet = new HashSet<int>();

            for (int m = 1; true; m++)
            {
                if (!hashSet.Add(a))
                {
                    yield return m;
                    yield break;
                }
                a = F(a);
            }
        }

        int F(int n)
        {
            if (n % 2 == 0)
            {
                return n / 2;
            }
            else
            {
                return 3 * n + 1;
            }
        }
    }
}


namespace AtCoderBeginnerContest116
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest116.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest116.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
n,k=map(int,input().split())
b=1
sum=0
while 1:
	if b*k>n*2:
		break
	if b*k%2==0:
		a=b*k/2
		sum+=((n-a)//k-(-a//k+1)+1)*((n+a)//k-a//k)
	b+=1
print(int(sum))

Measured memory_bytes: 39920
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N], B[N];
    ll asum = 0;
    ll bsum = 0;
    vector<plglg> vec;
    REP(i, 0, N) {
        cin >> A[i] >> B[i];
        vec.push_back(plglg(A[i], i));
        vec.push_back(plglg(B[i], i));
        asum += A[i];
        bsum += B[i];
    }
    sort(vec.begin(), vec.end());
    ll tmp = 0;
    ll used[N];
    fill(used, used + N, -1);
    bool ok = false;
    REP(i, 0, N) {
        plglg p = vec[i];
        tmp += p.first;
        if (used[p.second] != -1) {
            ok = true;
        }
        used[p.second] = p.first;
    }
    if (ok) {
        cout << tmp << endl;
    } else {
        ll minnum = inf;
        plglg p = vec[N];
        REP(i, 0, N) {
            if (i == p.second) {
                ll mintmp = tmp - used[i] + vec[N + 1].first;
                minnum = min(minnum, mintmp);
            } else {
                ll mintmp = tmp - used[i] + p.first;
                minnum = min(minnum, mintmp);
            }
        }
        ll ans = min(min(asum, bsum), minnum);
        cout << ans << endl;
    }
}


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

int n,m;
int a[10000];
int v[10000];
int f[100000];

int main(){
    scanf("%d%d",&m,&n);
    for(int i = 1;i <= m; i++){
        scanf("%d%d",&v[i],&a[i]);
    }
    for(int i = 1;i <= m; i++){
        for(int j = a[i];j <= n; j++){
            f[j] = max(f[j],f[j-a[i]]+v[i]);
        }
    }
    printf("%d\n",f[n]);
}

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

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

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

  int T;
  cin >> T;
  while(T--) {
    int N, M, A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << '\n';
  }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, K;
int xs[100], ys[100];

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

    std::cin >> N >> K;

    for(int i=0;i<N;++i){
        std::cin >> xs[i] >> ys[i];
    }

    ll sq = numeric_limits<ll>::max();

    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int x0 = xs[i], x1 = xs[j];
            if(x0 > x1){swap(x0, x1);}
            
            for(int k=0;k<N;++k){
                for(int l=k+1;l<N;++l){
                    int y0 = ys[k], y1 = ys[l];
                    if(y0 > y1){swap(y0, y1);}
                    int cnt = 0;
                    
                    for(int m=0;m<N;++m){
                        if(x0 <= xs[m] && xs[m] <= x1 &&
                           y0 <= ys[m] && ys[m] <= y1){
                            ++cnt;
                        }
                    }

                    if(cnt >= K){
                        sq = min(sq, 1ll * (x1 - x0) * (y1 - y0));
                    }
                }
            }
        }
    }

    std::cout << sq << std::endl;
}


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

int main()
{
  int N;
  cin >> N;
  string w;
  unordered_map<string,int> mp;
  rep(i,N) {
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  for(auto p : mp){
    ll count = p.second;
    ans += count * (count-1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 10660
#include <queue>
#include <iostream>
using namespace std;
typedef unsigned long ul;
int main(){
  queue<ul> q;
  int n;
  long t=0,u=0;
  ul l,c=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l;
    if(c&l){
      do{
        c-=q.front();
        q.pop();
        u--;
      }while(c&l);
    }
  c+=l;
  q.push(l);
  t+=++u;
  }
  cout<<t;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    for(int i=0;i<N;i++) cin >> A[i];

    std::sort(A.rbegin(), A.rend());

    string ans = "YES";

    for(int i=1;i<N;i++){
        if(A[i] == A[i-1]){
            ans = "NO";
            break;
        }
    }

    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string.h>
int main() 
{ 
    string s;cin>>s;
    long int length=s.length();
    long long int sum=0;
    while(length--){
        //cout<<s[length]-48<<" ";
        sum+=s[length]-48;
    }
    if (sum%9==0)cout<<"Yes";
    else cout<<"No";
        
}         

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,h,i,j,k,l,m,n,v,w,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n;
	
	for(a=1;a<n;a++) {
		b = (n-1) / a;
		ans += b;
	}
	
	cout << ans << endl;
	return 0;
}


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

int main(){
  string S;
  long long count=0;
  cin>>S;
  map<long long,long long> saves;
  saves[0]++;
  long long tens=1;
  long long a=0;
  reverse(S.begin(),S.end());
  for(long long i=0;i<S.size();i++){
	a=(a+(S[i]-'0')*tens)%2019;
    tens=(tens*10)%2019;
    //cout<<i<<" "<<a<<endl;
  	saves[a]++;
}

    for(auto k=saves.begin();k!=saves.end();k++){
    //cout<<k->first<<" "<<k->second<<endl;
      int amari=k->second;
      count=count+(amari*(amari-1))/2;
  }  
      cout<<count<<endl;
}

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

int main() {
  string s;
  cin >> s;
  int a = 0;
  char b = '1';
  string sample = "abcdefghijklmnopqrstuvwxyz";
  sort(s.begin(),s.end());
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == b){
      continue;
    }else{
      if(s.at(i) != sample.at(a)){
        break;
      }else{
        if(s.at(i) == 'z'){
          a++;
          break;
        }
        a++;
        b = s.at(i);
      }
    }
  }
  if(a < 26)
    cout << sample.at(a) << endl;
  else
    cout << "None" << endl;
}


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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define append push_back
const int maxn = 3e3 + 10;
int a[maxn];
vector<int> adl[maxn];
bool dfs(int x, int p = -1)
{
	for (int y : adl[x])
	{
		if (y == p)
			continue;
		if (a[y] < a[x] && !dfs(y, x))
		{
			return true;
		}
	}
	return false;
}
/*5
5 4 1 2 3
1 2
1 3
2 4
2 5
*/
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		x--, y--;
		adl[x].append(y);
		adl[y].append(x);
	}
	for (int i = 0; i < n; i++)
		if (dfs(i))
			cout << i + 1 << ' ';
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, d;
    cin >> n >> d;

    int ans;
    ans = n / (2*d +1);
    if ((n % (2*d +1)) != 0) ans ++;

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M,P;
vector<int>G[2501],rG[2501];
int A[5000],B[5000],C[5000];
int d[2501];
bool neg[2501],used[2501],usedr[2501];
void dfs(int u)
{
	used[u]=true;
	for(int v:G[u])if(!used[v])dfs(v);
}
bool dfsr(int u)
{
	bool ret=used[u]&&neg[u];
	usedr[u]=true;
	for(int v:rG[u])if(!usedr[v])ret|=dfsr(v);
	return ret;
}
main()
{
	cin>>N>>M>>P;
	for(int i=0;i<M;i++)
	{
		cin>>A[i]>>B[i]>>C[i];
		C[i]-=P;
		G[A[i]].push_back(B[i]);
		rG[B[i]].push_back(A[i]);
	}
	for(int i=2;i<=N;i++)d[i]=-2e9;
	for(int i=0;i<N;i++)for(int j=0;j<M;j++)
	{
		d[B[j]]=max(d[B[j]],d[A[j]]+C[j]);
	}
	for(int j=0;j<M;j++)
	{
		if(d[B[j]]<d[A[j]]+C[j])neg[B[j]]=true;
	}
	dfs(1);
	cout<<(dfsr(N)?-1:max(d[N],0))<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp make_pair
#define sqr(x) (x)*(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=100007;
const ll inf=0x3f3f3f3f;
const int mod=998244353;
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int main(){
    int n=read(),m=read();
    if(n%2){
        for(int i=1;i<=m;i++){
            printf("%d %d\n",i,n-i+1);
        }
    }
    else{
        for(int i=1;i<=(m-1)/2+1;i++){
            printf("%d %d\n",i,n/2-i+1);
        }
        for(int i=1;i<=m/2;i++){
            printf("%d %d\n",n/2+i,n-1-i+1);
        }
    }
    return 0;
}

Measured memory_bytes: 3764
import heapq
K, T = map(int, input().split())
a = tuple(map(int, input().split()))
cakes = []
heapq.heapify(cakes)
for i in range(T):
    heapq.heappush(cakes, [-1*a[i], i])
# print(cakes)
now = -1
ans = 0
for _ in range(K):
    cake_num, cake_idx = heapq.heappop(cakes)
    cake_num *= -1
    if cake_idx == now and len(cakes) > 1 and cakes[0][0] != 0:
        next_cake_num, next_cake_idx = heapq.heappop(cakes)
        next_cake_num *= -1
        next_cake_num -= 1
        heapq.heappush(cakes, [-1 * next_cake_num, next_cake_idx])
        now = next_cake_idx
    else:
        cake_num -= 1
        if now == cake_idx:
            ans += 1
        now = cake_idx
    heapq.heappush(cakes, [-1 * cake_num, cake_idx])
# print(cakes)
print(ans)


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

int main() {
  int a,d;
  cin >> a;
  int b[220];
  for(int i=0; i<a;i++)
    cin >> b[i];
   d =0;
  while(true){
   for(int i =0; i<a;i++){
     
     if(b[i]%2 != 0){
       cout << d<< endl;
       return 0;
     }
   }
     for(int i =0; i<a ;i++){
      
       b[i] /= 2;
      }
  d++;
     }
  cout << d << endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
    cin>>n;
    vector<array<int,2>> ar(n);
    for(int x=0;x<n;x++){
        cin>>ar[x][0]>>ar[x][1];
    }
    bool poss=false;
    for(int x=0;x<=n-3;x++){
        bool found=true;
        for(int y=x;y<x+3;y++){
            if(ar[y][0]!=ar[y][1]){

                found=false;
                break;
            }
        }
        poss|=found;
    }
    if(poss)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;

}


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

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

    if (n == 0 && k == 0) {
      break;
    }

    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }

    for (int i = 1; i <= n - 1; ++i) {
      a[i + 1] += a[i];
    }

    int ans = -1000000001;
    for (int i = 0; i < n - k; ++i) {
      ans = max(a[i + k] - a[i], ans);
    }

    cout << ans << endl;
  }
}



Measured memory_bytes: 3100
#include<stdio.h>
int main(){
char a[1000010];
int i,b=0;
while(scanf("%s",a)!=EOF){
for(i=0;a[i]!='\0';i++){
if(a[i]=='a' && a[i+1]=='p' && a[i+2]=='p' && a[i+3]=='l' && a[i+4]=='e'){
a[i]='p',a[i+1]='e',a[i+2]='a',a[i+3]='c',a[i+4]='h';
}
else if(a[i]=='p' && a[i+1]=='e' && a[i+2]=='a' && a[i+3]=='c' && a[i+4]=='h'){
a[i]='a',a[i+1]='p',a[i+2]='p',a[i+3]='l',a[i+4]='e';
}
}
if(b==0){
printf("%s",a);
b++;
}
else{
printf(" %s",a);
}
}
printf("\n");
return 0;
}


Measured memory_bytes: 2072
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#define MAXN 200010 
using namespace std;
vector<int> E[MAXN];
int n,maxlen=-1,v;
void dfs(int u,int fa,int dep){
	if(dep>maxlen){
		maxlen=dep;
		v=u;
	}
	for(int i=0;i<E[u].size();i++){
		int to=E[u][i];
		if(to!=fa) dfs(to,u,dep+1);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		int u,v; scanf("%d%d",&u,&v);
		E[u].push_back(v);
		E[v].push_back(u);
	} 
	dfs(1,0,1);
	maxlen=-1;
	dfs(v,0,1);
	if(maxlen==0) puts("Second");
	else if(maxlen==1) puts("First");
	else if(maxlen==2) puts("Second");
	else puts(maxlen%3==2?"Second":"First");
	return 0;
}

Measured memory_bytes: 23680
#include<iostream>
using namespace std;
int main(void) {
  char c[3][3];
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      cin>>c[i][j];
    }
  }
  cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def is_prime(n):
        if n == 1:
            return False
        for k in range(2, int(pow(n, 0.5)) + 1):
            if n % k == 0:
                return False
        return True

    q = int(input())
    primes = set()
    nums = set()
    for i in range(2, 10 ** 5 + 1):
        if is_prime(i):
            primes.add(i)
            if (i + 1) // 2 in primes:
                nums.add(i)

    cnt = [0]
    for i in range(1, 10 ** 5 + 1):
        op = 1 if i in nums else 0
        cnt.append(cnt[-1] + op)

    for _ in range(q):
        l, r = map(int, input().split())
        res = cnt[r] - cnt[l - 1]
        print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;
using ll = long long;

const int N = 82;

int n, m;
int a[N][N], b[N][N];
const int M = 13000;

bitset<2*M> dp[2][N];

int main() {

	scanf("%d %d", &n, &m);

	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
		scanf("%d", &a[i][j]);
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
		scanf("%d", &b[i][j]);

	dp[n % 2][m - 1][M] = 1;
	// dp[(n - 1) % 2][m][M] = 1;
	for(int i = n - 1; i >= 0; i--) {
		int id = i % 2, id1 = (i + 1) % 2;
		for(int j = m - 1; j >= 0; j--) {
			int diff = abs(a[i][j] - b[i][j]);
			dp[id][j]  = dp[id1][j] >> diff;
			dp[id][j] |= dp[id1][j] << diff;
			dp[id][j] |= dp[id][j + 1] >> diff;
			dp[id][j] |= dp[id][j + 1] << diff;
		}
	}

	int ans = 1e9;

	for(int d = 0; d < 2 * M; d++) {
		if(dp[0][0][d]) {
			ans = min(ans, abs(d - M));
		}
	}

	assert(ans < M);

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
int dgts2(int n){return (n?dgts2(n>>1)+1:0);}
int dgts(int n, int k){return (n?dgts(n/k,k)+1:0);}
inline int v2(int n){return __builtin_ctzll(n);}
 
const int maxn=5005;
//i_am_noob

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int n;
    cin >> n;
  	print1((n+1)/2);
	return 0;
}


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

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)

typedef long long int llint;

int n, m;
int i, j;
llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

vector<int> v[200001];

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

int lcm(int a, int b)
{
  return a / gcd(a, b) * b;
}

int main()
{
  I >> n >> m;

  for(i = 0; i < m; i++) {
    int a, b;
    I >> a >> b;

    v[a].pb(b);
    v[b].pb(a);
  }

  bool flg = false;
  for(i = 0; i < v[1].size(); i++) {
    int tmp = v[1][i];
    for(j = 0; j < v[tmp].size(); j++) {
      if(v[tmp][j] == n) flg = true;
    }
  }

  if(flg) O << "POSSIBLE" << EN;
  else    O << "IMPOSSIBLE" << EN;

  return 0;
}


Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N;
  cin >> N;

  if(N%2==0){
    ll ans=0;
    ans+=(N/=10);
    for(int i=1;i<40;i++){
      ans+=N/5;
      N/=5;
    }
    cout << ans << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int sum = s[0] - '0';
  bool flag = true;
  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i] != '9')
      flag = false;
  }
  if (flag)
    cout << sum + 9 * (s.size() - 1) << endl;
  else
    cout << sum + 9 * (s.size() - 1) - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const [R, G, B, n] = input.split(" ").map(num => Number(num));
    const maxR = Math.ceil(n / R);
    // const maxG = Math.ceil(n / G);
    // const maxB = Math.ceil(n / B);
    let result = 0;
    for (let r = 0; r <= maxR; r++) {
        const sumR = r * R;
        const maxG = Math.ceil((n - sumR) / G);
        for (let g = 0; g <= maxG; g++) {
            const sumRG = sumR + g * G;
            const remain = n - sumRG;
            if (remain < 0) break;
            if (remain % B === 0) result++;
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int N,p[100000],v[100000];

	cin >> N;
	for(int i=0; i<N; i++)
	{
		cin>>p[i];
		v[i]=(1<<24);
	}

	queue<int> q;
	q.push(0); v[0]=0;
	
	
	while(!q.empty())
	{
		int t=q.front(); q.pop();

		if(t==N-1)
		{
			cout << v[t] << endl;
			break;
		}

		for(int d=1; d<=6; d++)
		{
			int nt=t+d;
			if(nt>=N) continue;

			while(v[t]+1 < v[nt])
			{
				v[nt]=v[t]+1;
				nt+=p[nt];
			}
			if(p[nt]==0 && v[nt]==v[t]+1)
			{
				q.push(nt);
			}
		}
	}
}

Measured memory_bytes: 1564
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  double n,m,d;
  cin>>n>>m>>d;
  if(d==0) cout<<(n-d)*(m-1)/(n*n)<<endl;
  else cout<<2*(n-d)*(m-1)/(n*n)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.nextLine();
		String a = sc.nextLine();
		
		char[] before = b.toCharArray();
		char[] after = a.toCharArray();
		
		String ans = "Yes";
		for (int i=0; i<before.length; i++) {
			if (!changeChar(before, after, i)) {
				ans = "No";
				break;
			}
		}

		System.out.println(ans);
	}
	
	private static boolean changeChar(char[] before, char[] after, int index) {
		char b = before[index];
		char a = after[index];

		if (b == a) {
			return true;
		}

		for (int i=0; i<before.length; i++) {
			if (before[i] == b) {
				before[i] = a;
			} else if (before[i] == a) {
				before[i] = b;
			} else {
				continue;
			}
			if (i < index) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 32804
n, m = map(int, input().split())
H = list(map(int, input().split()))
check = [1]*n

for _ in range(m):
    a, b = map(int, input().split())
    if H[a-1] >= H[b-1]:
        check[b-1] = 0
    if H[a-1] <= H[b-1]:
        check[a-1] = 0

print(sum(check))

Measured memory_bytes: 86320
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    char C; cin >> C;

    const char A[4] = {'A','C','T','G'};
    rep(i,4) {
        if (A[i]==C) {
            cout << A[(i+2)%4] << ln;
            return 0;
        }
    }
}

Measured memory_bytes: 256