akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative( (<$>))
import Data.List( foldl1')
import Data.Word( Word32)

main = do
    [n_, m_] <- map read . words <$> getLine
    let
	mn, mx::Word32
	mn = min n_ m_
	mx = max n_ m_
	v = product' [1..mn]
	magicnumber = toInteger 1000000007
	product' = foldl1' mul 
	  where
	    mul a b = fromInteger $
			(toInteger a*toInteger b) `rem` magicnumber
    print $ if n_==m_
		then (2*(toInteger v)^2) `rem` magicnumber
		else if 1 == abs (mx - mn)
		    then ((toInteger $ mn+1)*(toInteger v)^2) `rem` magicnumber
		    else 0

Measured memory_bytes: 1020
n = int(input())

ans = 0
for i in range(0, 6, 2):
  if i == 0:
    low = 1
  else:
    low = 10 ** i
  up = 10 ** (i + 1 ) - 1
  
  if up <= n:
    ans += up - low + 1
  else:
    if low <= n:
      ans += n - low + 1
    break
    
print(ans)    
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ll sum=0;
    vector<ll> a(n);
    For(i,0,n) {
        cin>>a[i];
        sum+=a[i];
    }
    ll cnt=0;
    ll border=(4*m-1+sum)/(4*m);
    For(i,0,n){
        if(a[i]>=border) cnt++; 
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#define SIZE 200

void push(int);
int pop(void);

int top = 0;
int s[SIZE];

int main(void){
	int c, a, op1, op2;
	while((c = getchar()) != EOF){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &a);
			push(a);
		}else{
			switch(c){
			case '+':
					op2 = pop();
					op1 = pop();
					push(op1 + op2);
					break;
			case '*':
					op2 = pop();
					op1 = pop();
					push(op1 * op2);
					break;
			case '-':
					op2 = pop();
					op1 = pop();
					push(op1 - op2);
					break;
			case '\n':
					printf("%d\n", pop());
					break;
			case ' ':
					break;
			default:
					break;
			}
		}
	}

	return 0;
}

void push(int x){
	if(top < SIZE){
		top++;
		s[top] = x;
	}else{
		printf("error: Stack full\n");
	}
}

int pop(void){
	if(top > 0){
		top--;
		return s[top + 1];
	}else{
		printf("error: Stack empty\n");
	}
}

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

int main()
{
    int n, ans = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        int l, r;
        scanf("%d%d",&l,&r);
        ans += (r - l + 1);
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e3 + 1;

struct Eratosthenes {
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }

  void init(int n) {
    prime.resize(n + 1);
    REP(i, prime.size()) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i < sqrt(n); i++) {
      if (prime[i]) {
        for (int j = 0; i * (j + 2) < n; j++) {
	  prime[i * (j + 2)] = false;
	}
      }
    }
  }
};

int N;
int memo[MAX_N];

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

  Eratosthenes e(MAX_N);
  cin >> N;

  REP(i, N + 1) {
    if (e.prime[i]) {
      (++memo[i]) %= MOD;
    } else {
      int tmp = i;
      FOR(j, 2, i + 1) {
	while (tmp % j == 0) {
	  tmp /= j;
	  ++memo[j] %= MOD;
	}
      }
    }
  }

  ll ans = 1ll;
  REP(i, N + 1) {
    if (!e.prime[i]) continue;
    (ans *= (memo[i] + 1)) %= MOD;
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vi p(n);
  rep(i, n) cin >> p[i];
  rep(i, n) p[i]++;
  int mx = 0;
  int s = 0;
  queue<int> q;
  rep(i, n){
    s += p[i];
    q.push(p[i]);
    if(q.size() > k){
      s -= q.front();
      q.pop();
    }
    if(q.size() == k){
      mx = max(mx, s);
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%lf\n", ans);
}

Measured memory_bytes: 1792
INF = pow(10, 18)

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(INF)
    R.append(INF)

    i = 0
    j = 0
    cnt = 0
    n1 = mid - left
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i # 反転したときだけ反点数を足し込んでいく
    return cnt

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = merge_sort(A, left, mid)
        cnt2 = merge_sort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0

n = int(input())
a = list(map(int, input().split()))
cnt = merge_sort(a, 0, n)
print(cnt)


Measured memory_bytes: 27480
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int x;
	cin >> x;
	if (x == 1) {
		cout << 1 << endl;
		return 0;
	}
	map<int, int> a;
	rep(j,2,x+1){
		int n = j;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			int sum = 0;
			while (n % i == 0) {
				sum++;
				n /= i;
			}
			a[i] += sum;
		}
	}
	if (n > 1)a[n]++;
}
		llint ans = 1;
		rep(i, 1, x + 1) {
			ans *= (1 + a[i]);
			ans %= mod;
		}
		cout << ans << endl;
		return 0;
	}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int K, S; scanf("%d %d", &K, &S);
  int ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - x - y;
      if (0 <= z and z <= K) { ++ans; }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
def ok():
    print("YES")
    exit(0)
    
def ng():
    print("NO")
    exit(0)

n = int(input())
sorted_p = list(range(1, n + 1))
p = list(map(int,input().split()))

for i in range(n):
    for j in range(i+1, n):
        p[i], p[j] = p[j], p[i]
        if p == sorted_p:
            ok()
        p[i], p[j] = p[j], p[i]

if p == sorted_p:ok()
else: ng()
        

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	vector<T> data;

	BinaryIndexTree(int siz)
	{
		//1-indexなので配列は1つ多めに用意する
		data.resize(siz + 1, 0);
	}
	T sum(int k)
	{
		//a_1～a_kまでの和を計算
		T ret = 0;
		for (int i = k; i > 0; i -= (i & -i))
		{
			ret += data[i];
		}
		return ret;
	}

	void add(int k, int x)
	{
		//a_kにxを加算する
		for (int i = k; i < data.size(); i += (i & -i))
		{
			data[i] += x;
		}
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n+10);

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

	ll sum = 0;
	vector<pll> b;
	for (int i = 0; i <= n; i++)
	{
		sum += a[i];
		b.push_back(pll(sum - ((ll)i) * k, i));

	}
	
	sort(b.begin(), b.end());
	
	BinaryIndexTree<ll> BIT(n+10);
		
	ll ans = 0;
	for (int i = 0; i <= n; i++)
	{
		ans += BIT.sum(b[i].second+1);
		BIT.add(b[i].second+1, 1LL);
	}
	
	cout << ans << endl;

}


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

using namespace std;

int main(){
    //入力 N, M
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M, 0);//長さMの配列を用意

    for (int i = 0; i < N; i++){
        int K;
        cin >> K;

        for (int j = 0; j < K; j++){
            int A;
            cin >> A;
            A--;//0-indentとの差を埋める
            cnt[A]++;
        }
    }
    int ans = 0;//人数
    for (int i = 0; i < M; i++){
        if (cnt[i] == N){//各配列のi番目がNになっていた時
            ans++;//ansをインクリメント
        }
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
typedef pair<int, int> P;

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

  cin >> N;
  vector<P> A(N);
  int x,l;
  rep(i, N) {
    cin >> x >> l;
    A[i] = P(x+l, x-l);
  }
  sort(ALL(A));
  int cnt = 0;
  int left = -INF;
  rep(i, N) {
    P p = A[i];
    if (left <= A[i].second) {
      left = A[i].first;
      cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll root(ll i,ll ar[])
{
    while(i!=ar[i])
    {
        i=ar[i];
    }
    return i;
}

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

	ll n,m,k;
	cin>>n>>m>>k;

	ll dsu[n+1],size[n+1];
	for(ll i=0;i<=n;++i)
    {
        dsu[i]=i;
        size[i]=1;
    }

    vector<ll> f[n+1],b[n+1];

    for(ll i=0;i<m;++i)
    {
        ll a,bb;
        cin>>a>>bb;
        f[a].pb(bb);
        f[bb].pb(a);
        ll rx=root(a,dsu);
        ll ry=root(bb,dsu);
        if(rx!=ry)
        {
            if(size[rx]>size[ry]){
                size[rx]+=size[ry];
                dsu[ry]=rx;
            }
            else{
                size[ry]+=size[rx];
                dsu[rx]=ry;
            }
        }
    }

    for(ll i=0;i<k;++i)
    {
        ll x,y;
        cin>>x>>y;
        b[x].pb(y);
        b[y].pb(x);
    }

    ll ans[n+1]={0};

    for(ll i=1;i<=n;++i)
    {
        ll rx=root(i,dsu);
        ans[i]=size[rx]-f[i].size()-1;
        for(ll j=0;j<b[i].size();++j)
        {
            ll y=b[i][j];
            ll ry=root(y,dsu);
            if(rx==ry){--ans[i];}
        }
        cout<<ans[i]<<" ";
    }

	return(0);
}


Measured memory_bytes: 15348
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,l;
    cin >> a >> b >> c >> l;
    int i=0,j=0;
    while(b<=a){
        b*=2;
        i++;
    }
    while(c<=b){
        c*=2;
        j++;
    }
    if(i+j<=l) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
#define F first
#define S second
#define MP make_pair
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>PP;
typedef long long int ll;
int  main(){
  ll a,m;
  int n;
  cin>>a>>n>>m;
  int ac=0;
  ll i=1;
  while(1){
    ll bs=a+i;
    ll work=bs;
    for(int j=1;j<n;j++){
      work=work*bs;
    }
    if(work>m){
      break;
    }
    bs=work;
    ll ch=0;
    while(work!=0){
      ch+=(work%10);
      work=work/10;
    }
    if(ch==i){
      ac++;
    }
    i++;
  }
  cout<<ac<<endl;
  return(0);
}



Measured memory_bytes: 3124
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[,\n]");
		
		int sum = 0;
		int n = 0;
		int total = 0;
		while (true)
		{
			try
			{
				int value = sc.nextInt();
				int amount = sc.nextInt();
				sum += value * amount;
				total += amount;
				n++;
			}
			catch (Exception e)
			{
				break;
			}
		}
		System.out.println(sum);
		System.out.println(Math.round((double) total / n));
	}
}

Measured memory_bytes: 12000
function main()
  X,Y,A,B,C=map(x->parse(Int,x),split(readline()))
  p=sort(map(x->-parse(Int,x),split(readline())))
  q=sort(map(x->-parse(Int,x),split(readline())))
  r=map(x->-parse(Int,x),split(readline()))
  for i=1:X
    push!(r,p[i])
  end
  for i=1:Y
    push!(r,q[i])
  end
  sort!(r)
  println(-sum(r[1:X+Y]))
end
main()

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

/*int main(void)
{
    double a, b, c;
    cin >> a >> b >> c;

    if (sqrt(c) > (sqrt(a) + sqrt(b)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

}*/

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

    long long int d = c - a - b;
    if (d > 0 && 4*a*b < d*d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 764
List = [list(map(int,input().split())) for i in range (3)]
N = int(input())
Number = [int(input()) for i in range (N)]
a = 'No'
for k in range(0,3):
    for j in range(0,3):
        for i in range(0,N):
            if Number[i]== List[k][j]:
                List[k][j]=0
            
if List[0] == [0,0,0] or List[1] == [0,0,0] or List[2]== [0,0,0]:
    a = 'Yes'
for m in range(0,3):
    if List[0][m] == 0 and List[1][m] == 0 and List[2][m]==0:
        a ='Yes'
if List[0][0]==0 and List[1][1] == 0 and List[2][2]==0:
    a = 'Yes'
if List[0][2]==0 and List[1][1] == 0 and List[2][0]==0:
    a = 'Yes'
print (a)    
    

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){

	int a, b, c, d;
	
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(a+b > c+d)
		printf("Left");
	else if(a+b == c+d)
		printf("Balanced");
	else
		printf("Right");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int arr[100002]={0};
long long mode=1000000007;
long long Mode(long long a, long long b)
{
    long long sum = 1;
    while (b) {
        if (b & 1) {
            sum = (sum * a) % mode;
            b--;
        }
        b /= 2;
        a = a * a % mode;
    }
    return sum;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int p;
		cin>>p;
		arr[p]++;
	}
	for(int i=1;i<n;i++)
	{
		if(arr[i]!=2&&arr[i]!=0)
		{
			cout<<0<<endl;
			return 0;
			}	
	}
	if(n%2==1&&arr[0]==1)
	{
		cout<<Mode(2,(long long)(n/2))<<endl;
	}
	else if(n%2==0&&arr[0]==0)
	{
		cout<<Mode(2,(long long)(n/2))<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 640
from fractions import gcd
import math

mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def cnt(s, k):
    s = s * k
    ans = 0
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] = ' '
            ans += 1
    return ans


def main():
    s = [i for i in input()]
    k = int(input())
    if len(set(s)) == 1:
        print(k * len(s) // 2)
        return
    if k <= 100:
        ans = cnt(s, k)
        print(ans)
        return
    cnt50 = cnt(s, 50)
    cnt51 = cnt(s, 51)
    dif = cnt51 - cnt50
    print(cnt50 + (k - 50) * dif)

main()


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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll h,a;
    cin >> h>>a;

    if(h%a==0)
    {
      cout << h/a << endl;
    }else
    {
      cout << h/a+1 << endl;
    }
  
}


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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

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

    string s;
    cin >> s;

    sort(all(s));

    puts(s == "abc" ? "Yes" : "No");
    
    return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int count =0;
		for (int i =l; i<=r;i++) {
			if (i%d==0) {
				count++;}}
		System.out.println(count);
	}

}


Measured memory_bytes: 35604
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    map<int,int> z;
    int i;
    for(i=0; i<n; i++) {
        int a;
        scanf("%d", &a);
        z[a]++;
    }

    int num = (int)z.size();
    if(n%3!=0) {
        if(num==1 && z.begin()->first==0) {
            printf("Yes\n"); return 0;
        }
        printf("No\n"); return 0;
    }

    if(num>3) {
        printf("No\n"); return 0;
    }
    if(num==1) {
        auto it=z.begin();
        int p = it->first;
        if(p==0) {
            printf("Yes\n"); return 0;
        }
        else {
            printf("No\n"); return 0;
        }
    }

    int aa,bb,cc;
    if(num==2) {
        auto it=z.begin();
        int p = it->first;
        int p2 = it->second;
        it++;
        int q = it->first;
        int q2 = it->second;
        if(p2==n/3*2 && q2==n/3) {
            aa=p; bb=p; cc=q;
        }
        else if(p2==n/3 && q2==n/3*2) {
            aa=p; bb=q; cc=q;
        }
        else {
            printf("No\n"); return 0;
        }
    }
    else if(num==3) {
        auto it=z.begin();
        int p = it->first;
        int p2 = it->second;
        it++;
        int q = it->first;
        int q2 = it->second;
        it++;
        int r = it->first;
        int r2 = it->second;
        if(p2==n/3 && q2==n/3 && r2==n/3) {
            aa=p; bb=q; cc=r;
        }
        else {
            printf("No\n"); return 0;
        }        
    }
    if(aa==(bb^cc) && bb==(cc^aa) && cc==(aa^bb)) {
        printf("Yes\n"); return 0;
    }
    printf("No\n");

    return 0;
}



Measured memory_bytes: 3840
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll n;
ll a[300000];
map<ll,ll>m;
ll p(ll x){
    return x*(x-1)/2;
}
int main(){
    cin>>n;
    rep(i,0,300000){
        a[i]=0;
    }
    rep(i,0,n){
        cin>>a[i];//a[i]<=n
        m[a[i]]++;
    }
    ll ans=0;
    rep(i,1,n+1){
        ans+=p(m[i]);
    }
    rep(i,0,n){
        ll x=ans-p(m[a[i]]);
        x+=p(m[a[i]]-1);
        if(x<0)x=0;
        puts(x);
    }
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
void close(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
}
int a,b,c;
int main(){
	close();
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust";
	else cout<<"win";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=505;
int H,W,h,w;
int main(){
	cin >> H >> W >> h >> w;
	if (H%h==0&&W%w==0)
		return puts("No"),0;
	puts("Yes");
	int v1=N,v2=N*(w*h-1)+1;
	for (int i=1;i<=H;i++,puts(""))
		for (int j=1;j<=W;j++)
			if (i%h==0&&j%w==0)
				printf("%d ",-v2);
			else
				printf("%d ",v1);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>
#include <sstream> 
 
using namespace std;


int main(){
    long int a,b,k;
    cin>>a>>b>>k;
    long int sa=(a+k-1);
    for(long int i=a;i<=sa;i++){
        if(i<=b){
            cout<<i<<endl;
        }else{
            return 0;
        }
    }
    
    long int su=(b-k+1);
    for(long int i=su;i<=b;i++){
        if(i>sa){
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//package atCoderBeginnerContest166;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        String S = scan.next();
       // String R;


        if(S.equals("ABC")) {
        	System.out.println("ARC");
        }else if(S.equals("ARC")){
        	System.out.println("ABC");

        }
	}

}


Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll prime[100000];
vector<ll> prime1;
bool is_prime[100000];

ll sieve(ll n) {
  ll p = 0;
  for (ll i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i <= n; i++) {
    if (is_prime[i]) {
      if (i%10==1) {prime1.push_back(i);}
      prime[p++] = i;
      for (ll j = 2*i; j <= n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

int main() {
  ll N; cin >> N;
  sieve(55555);
  for (ll i = 0; i < N; i++) {
    cout << prime1[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 200050;
int N, A, B, C, D;
std::string S_in;
char S[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> A >> B >> C >> D;
    std::cin >> S_in;

    for (int i = 1; i <= N; i++) {
        S[i] = S_in[i-1];
    }

    for (int i = B + 1; i <= D - 1; i++) {
        if (S[i] == '#' && S[i+1] == '#') {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    for (int i = A + 1; i <= C - 1; i++) {
        if (S[i] == '#' && S[i+1] == '#') {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    if (C < D) {
        std::cout << "Yes" << std::endl;
        return 0;
    } else {
        assert(A < B && D < C);
        for (int i = B; i <= D; i++) {
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
        std::cout << "No" << std::endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 772
N = int(input())
A = str(input())
B = str(input())
C = str(input())

ans = []
for i in range(N):
     L = [A[i],B[i],C[i]]
     if len(set(L)) == 2:
            ans.append(1)
     elif len(set(L)) == 3:
            ans.append(2)
     else:
            ans.append(0)
print(sum(ans))

Measured memory_bytes: 3064
from itertools import combinations
n, m, q = map(int, input().split())
abcd = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    abcd.append((a, b, c, d))

ans = 0
for i in combinations(list(range(1,n+m)), m-1):
    tmp = 1
    li = []
    for j in range(1, n+m):
        if j in i:
            tmp += 1
        else:
            li.append(tmp)
    score = 0
    for a, b, c, d in abcd:
        if li[b-1]-li[a-1]==c:
            score += d
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 9228
#include <stdio.h>
int fibonatchi(int a,int b,int m){
	int c,l;
	c=a+b;
	l=m-1;
	if(l!=0)
		return (fibonatchi(c,a,l));
	else
		return a;
}
int main(void)
{
	int n,x,y;
	scanf("%d",&n);
	x=1;
	y=1;
	printf("%d\n",fibonatchi(x,y,n));
	return 0;
}


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

using namespace std;

const int maxn = 1e5 + 7;

struct Edge{
	int to,last;
}E[maxn << 1];
struct Que{
	int s,c,d;
}q[maxn];
int n,m,Q;
int cnt;
int col[maxn];
int Max[maxn];
int head[maxn];
int Read(char c = 0,int re = 0){
	while(!isdigit(c = getchar()));
	re = c - '0';
	while(isdigit(c = getchar()))
		re = ((re << 2) + re << 1) + c - '0';
	return re;
}
void Adde(int x,int y){
	E[++cnt] = (Edge){y,head[x]};
	head[x] = cnt;
}
void Dfs(int x,int d,int c){
	if(Max[x] >= d)return;
	if(!col[x])col[x] = c;
	Max[x] = d;
	if(!d)return;
	for(int i = head[x],y; y = E[i].to,i; i = E[i].last){
		Dfs(y,d - 1,c);
	}
}
int main(){
#ifdef Hermione
	freopen("in","r",stdin);
#endif
	n = Read();m = Read();
	for(int i = 1; i <= m; ++i){
		int x = Read(),y = Read();
		Adde(x,y);Adde(y,x);
	}
	Q = Read();
	for(int i = 1; i <= Q; ++i){
		q[i].s = Read();
		q[i].d = Read();
		q[i].c = Read();
	}
	memset(Max,-1,sizeof Max);
	for(int i = Q; i; --i){
		Dfs(q[i].s,q[i].d,q[i].c);
	}
	for(int i = 1; i <= n; ++i)
		printf("%d\n",col[i]);
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m; 
    cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i,m){
        int a, b; 
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n, -1);
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto nv : G[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            q.push(nv);
        }
    }
    //for(auto p : dist) cout << p << endl;
    if(dist[n-1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl; 
}

Measured memory_bytes: 16148
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){ 
    int a,b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) puts("Possible");
    else puts("Impossible");

}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.util.*;

public class Main {
	static int INF = 2 << 27;
	static int[] vx = {1,0,-1,0};
	static int[] vy = {0,1,0,-1};
	static int[] vd = {0,1,2,3};
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int W = sc.nextInt();
			int H = sc.nextInt();
			if(W == 0 && H == 0) break;
			int[][] map = new int[H][W];
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					map[i][j] = sc.nextInt();
				}
			}
			int[] cost = new int[4];
			for(int i = 0; i < 4; i++) {
				cost[i] = sc.nextInt();
			}
			int[][][] memo = new int[H][W][4];
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++)
				Arrays.fill(memo[i][j], 2 << 28);
			}
			PriorityQueue<Data> q = new PriorityQueue<Data>();
			q.add(new Data(0,0,0,0));
			while(!q.isEmpty()) {
				Data p = q.poll();
				int h = p.h;
				int w = p.w;
				if(memo[h][w][p.dir%4] <= p.cost) continue;
				memo[h][w][p.dir%4] = p.cost;
				for(int i = 0; i < 4; i++) {
					int td = (p.dir + vd[i]) % 4;
					int th = h + vy[td];
					int tw = w + vx[td];
					if(th < 0 || tw < 0 || th >= H || tw >= W) continue;
					if(map[h][w] == i) {
						q.add(new Data(th,tw,td,p.cost));
					}
					else {
						q.add(new Data(th,tw,td,p.cost + cost[i]));
					}
				}
			}
			int MIN = 2 << 28;
			for(int k = 0; k < 4; k++) MIN = Math.min(MIN, memo[H-1][W-1][k]);

			System.out.println(MIN);
			
		}
	}
	static class Data implements Comparable<Data> {
		
		int h;
		int w;
		int dir;
		int cost;
		Data(int a, int b, int c, int e) {
			h = a;
			w = b;
			dir = c;
			cost = e;
		}
		@Override
		public int compareTo(Data o) {
			return this.cost - o.cost;
		}
	}
}

Measured memory_bytes: 75176
import java.util.Scanner;

public class Main {
	static long solve(long a , long b , long c , long d){
		long arr[] = {a , b , c , d};
		long ret = b * d;
		for(int i = 0 ; i < 2 ; ++i){
			for(int j = 2 ; j < 4 ; ++j){
				long x = arr[i] * arr[j];
				ret = Math.max(ret, x);
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		System.out.println(solve(a, b, c, d));
	}
}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll a,b; cin>>a>>b;
    vector<vector<char>> res(100, vector<char>(99));
    rep(i,100){
        rep(j,99){
            if(i<50) res[i][j]='#';
            else res[i][j]='.';
        }
    }
    rep(i, a-1){
        ll tmp=2*i;
        res[2 * (tmp/99)][tmp%99]='.';
    }
    rep(i, b-1){
        ll tmp=2*i;
        res[51 + 2 * (tmp/99)][tmp%99]='#';
    }
    cout<< 100 << ' ' << 99 <<endl;
    rep(i,100){
        rep(j,99) cout<<res[i][j];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

ll cnt;
Graph G(200000);
vector<int> mem;
vector<int> seen(200000);

ll s, e;
void dfs(int v){
    cnt++;
    if(seen[v] > 0){
        s = seen[v];
        e = cnt;
        return;
    }
    seen[v] = cnt;
    mem.push_back(v);
    dfs(G[v][0]);
}

int main(){
    ll n, k;
    cin >> n >> k;
    rep(i, n){
        int a;
        cin >> a;
        a--;
        G[i].push_back(a);
    }
    dfs(0);
    s--;
  	k -= s;
    if(k < 0){
        k += s;
        cout << mem[k] + 1;
        return 0;
    }
  	k %= (e - s - 1);
  	cout << mem[s + k] + 1; 
}



Measured memory_bytes: 15628
n = int(input())
root = set(range(n))
binary_tree = [0 for i in range(n)]
#out = [0 for i in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    binary_tree[l[0]] = l
    s = set(l[1:3])
    root -= s

def binary(id, parent, depth, sibling, height):
    output = {}
    hline = []
    hline.append(height)
    output['node'] = id
    output['parent'] = parent
    output['sibling'] = sibling
    output['depth'] = depth
    left = binary_tree[id][1]
    right = binary_tree[id][2]
    degree = 0
    if(parent == -1):
        output['type'] = 'root'
    elif(left == -1 and right == -1):
        output['type'] = 'leaf'
    else:
        output['type'] = 'internal node'
    if(left != -1):
        degree += 1
        hline.append(binary(left, id, depth+1, right, height))
    if(right != -1):
        degree += 1
        hline.append(binary(right, id, depth+1, left, height))
    max_height = max(hline)
    output['degree'] = degree
    output['height'] = max_height
    binary_tree[id] = output
    return max_height + 1

binary(list(root)[0], -1, 0, -1, 0)
for line in binary_tree:
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(line['node'], line['parent'], line['sibling'], line['degree'], line['depth'], line['height'], line['type']))



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int dp[N];
int n;
vector<int> v(N);
int res(int id){
		if(id == n){
    	return 0;
    }
    int &ans = dp[id];
    if(ans != -1)
    	return ans;
  	if(id < n)
    	ans = abs(v[id + 1] - v[id]) + res(id + 1);
    if(id < n - 1)
    	ans = min(ans, abs(v[id + 2] - v[id]) + res(id + 2));
    return ans;
}
int32_t main() {
	memset(dp, -1, sizeof(dp));
	cin >> n;
  for(int i = 1; i <= n; i++)
  	cin >> v[i];
  cout << res(1);
}


Measured memory_bytes: 7948
#include <cstdio>
using namespace std;
int n,m,cnt,p,o;
char a[10][10];
int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=n;++i){
		scanf("%s",a[i]+1);
	}
	for(int i=0;i<(1<<n);++i){
		for(int j=0;j<(1<<m);++j){
			bool b[10][10]={false};
			o=i;
			for(int k=1;k<=n;++k){
				if(o&1){
					for(int l=1;l<=m;++l){
						b[k][l]=true;
					}
				}
				o/=2;
			}
			o=j;
			for(int k=1;k<=m;++k){
				if(o&1){
					for(int l=1;l<=n;++l){
						b[l][k]=true;
					}
				}
				o/=2;
			}
			int sum=0;
			for(int k=1;k<=n;++k){
				for(int l=1;l<=m;++l){
					if(b[k][l]==false&&a[k][l]=='#'){
						++sum;
					}
				}
			}
			if(sum==p)++cnt;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>

int main(void){

int a,b,c;

int count=0;

int i;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){

if(c%i==0){

count++; }

}

printf("%d\n",count);

return 0; }

Measured memory_bytes: 596
#include<stdio.h>

int main(){
		long long a,b,x,ans1,ans2;
		scanf("%lld%lld%lld",&a,&b,&x);
		ans1=(a-1)/x;
		ans2=b/x;
		if(b<x){
				if(a==0)puts("1");
				else puts("0");
				return 0;
		}else if(a==0&&x!=1)ans2++;
		printf("%lld\n",ans2-ans1);
		return 0;
}


Measured memory_bytes: 128
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	int X,Y,Z,n=0;
	scanf("%d %d %d",&X,&Y,&Z);
	X=X-Z;
        n=X/(Y+Z);
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[210000];
vector<int>v[210000];
int jm[210000];
long long vis[210000];

int rev[210000];
int ans[210000];
int main(){
	int a;
	long long b;scanf("%d%lld",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	
	}
	for(int i=0;i<a;i++)v[p[i]].push_back(i);
	for(int i=0;i<a;i++){
		int at=p[i];
		if(v[at].size()==1){
			jm[i]=a+1;
		}else{
			int ind=lower_bound(v[at].begin(),v[at].end(),i)-v[at].begin();
			if(ind==v[at].size()-1){
				jm[i]=(a+v[at][0]+1)-i;
			}else{
				jm[i]=(v[at][ind+1]+1)-i;
			}
		}
	}
	for(int i=0;i<a;i++)vis[i]=-1;
	long long now=0;
	int st=-1;
	int rem=0;
	do{
		vis[now%a]=now;
		if(now+jm[now%a]>=a*b){
			st=now%a;
			rem=a*b-now;break;
		}
		now+=jm[now%a];
	}while(vis[now%a]==-1);

	if(st==-1){
		long long is=now-vis[now%a];
		long long S=a*b;
		S-=now;
		S%=is;
		S+=now;
		long long now2=now;
		do{
			if(now2+jm[now2%a]>=S){
				st=now2%a;
				rem=S-now2;break;
			}
			now2+=jm[now2%a];
		}while(1);
	}
	//printf("%d %d\n",st,rem);
	for(int i=0;i<210000;i++)rev[i]=-1;
	int sz=0;
	for(int i=0;i<rem;i++){
		int I=p[(i+st)%a];
		if(rev[I]==-1){
			rev[I]=sz;
			ans[sz]=I;
			sz++;
		}else{
			int tmp=rev[I];
			for(int j=rev[I];j<sz;j++){
				rev[ans[j]]=-1;
			}
			sz=tmp;
		}
	}

	for(int i=0;i<sz;i++){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}printf("\n");
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, m, Q; cin >> n >> m >> Q;

    vector<vector<int>> c(n, vector<int>(n, 0));
    for (int i = 0; i < m; ++i) {
        int l, r; cin >> l >> r;
        --l; --r;

        c[l][r]++;
    }

    vector<vector<int>> sum(n, vector<int>(n + 1, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            sum[i][j + 1] = sum[i][j] + c[i][j];
        }
    }

    for (int i = 0; i < Q; ++i) {
        int p, q; cin >> p >> q;
        --p; --q;

        int ans = 0;
        for (int j = p; j <= q; ++j) {
            ans += sum[j][q + 1] - sum[j][p];
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 5600
// By Hacheylight

#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef long double ld ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef pair <ll, int> pli ;
typedef pair<int, pii> tri ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef vector <vi> vvi ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int mod = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
void add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod ; }
void sub(int &a, int b) { a = (a - b + mod) % mod ; }
void mul(int &a, int b) { a = (ll) a * b % mod ; }
int addv(int a, int b) { return (a += b) >= mod ? a -= mod : a ; }
int subv(int a, int b) { return (a -= b) < 0 ? a += mod : a ; }
int mulv(int a, int b) { return (ll) a * b % mod ; }
int read() {
    int f = 1, x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}
int pw(int a, int b) {
    int s = 1 ;
    for (; b; b >>= 1, a = (ll) a * a % mod)
    if (b & 1) s = (ll) s * a % mod ;
    return s ;
}


string s ; 
int dp[N][13] ;

signed main() {
	cin >> s ;
	dp[0][0] = 1 ;
	rep(i, 0, siz(s) - 1) {
		if (s[i] == '?') {
			rep(j, 0, 12) 
			rep(k, 0, 9) add(dp[i + 1][(j * 10 + k) % 13], dp[i][j]) ;
		} else {
			int k = s[i] - '0' ;
			rep(j, 0, 12) add(dp[i + 1][(j * 10 + k) % 13], dp[i][j]) ;
		}
	}
	printf("%d\n", dp[siz(s)][5]) ;
	return 0 ;
}

Measured memory_bytes: 5504
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

#define MAX 200000
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  GI(N);
  int left, right;
  map<int, int> list;
  FOR(i, N + 1) {
    GI(a);
    if (list.count(a)) {
      left = list[a];
      right = i;
    } else {
      list[a] = i;
    }
  }
  int padding = left + N - right;
  COMinit();
  FOR(i, N + 1) { print((MOD + COM(N + 1, i + 1) - COM(padding, i)) % MOD); }
  return 0;
}

Measured memory_bytes: 10624
#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%3 !=0 && i%5 !=0 && i%15 != 0)sum += i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3616
#n=int(input())
n,m=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

total=sum(al)

thre=total/(4*m)
count=0
for i in range(n):
    if al[i]>=thre:
        count+=1

if count>=m:
    print("Yes")
else:
    print("No")


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

int main(){
  string T;
  cin >> T;
  int length = T.size();
  
  for(int i=0 ; i<length ; i++){
    if (T.at(i)=='?')
      T.at(i)='D';
  }
  
  cout << T << endl;
}

Measured memory_bytes: 3760
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e18+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
   	string s, t;
   	cin >> s >> t;
   	assert(s.size() >= t.size());
   	int ans = 1000000;
   	int n = s.size();
   	int m = t.size();
   	for(int i = 0; i < n - m + 1; i++)
   	{
   		string tt = s.substr(i, m);
   		int curr = 0;
   		for(int j = 0; j < m; j++)
   		{
   			if(t[j] != tt[j])
   				curr++;
   		}
   		if(curr < ans)
   			ans = curr;
   	}
   	cout << ans << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3656