akhauriyash/Code-Regression huggingface dataset:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B, K = ri_()
a = [i for i in range(A, B + 1) if i <= A + K - 1 or i >= B - K + 1]
for ai in a:
    print(ai)

Measured memory_bytes: 63596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 105;

int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<w*(double)h/2<<" ";
  bool f = (!(w&1))&&(!(h&1))&&(x==w/2)&&y==(h/2);
  cout<<f<<endl;
  return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
int r,g,b,res;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>r>>g>>b;
    res = b + 10*g + 100*r;
    if(res%4==0)cout<<"YES\n";
    else cout<<"NO\n";
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	ll N,X,ans=0;
	cin>>N>>X;
	VI a(N);
	REP(i,N){
		cin>>a[i];
		if(a[i]>X){
			ans+=a[i]-X;
			a[i]=X;
		}
		if(a[i]+a[i-1]>X && i-1>=0){
			ans+=a[i]+a[i-1]-X;
			a[i]-=a[i]+a[i-1]-X;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [1]+a
flg = [0] * (n + 1)

now = 0
i = 1
flg2 = 1
loop = 0
while (i < k+1):
    if (flg2 and flg[a[now]] != 0):
        flg2 = 0
        loop = i-flg[a[now]]
        i += ((k - i) // loop - 1) * loop
    now = a[now]
    flg[now] = i
    i += 1
print(a[now])


Measured memory_bytes: 32344
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
      cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
    low[v] = ord[v] = now_ord
    now_ord += 1
    visited[vis_i], vis_i = v, vis_i + 1
    for e in range(idx[v], idx[v + 1]):
        to = G[e, 1]
        if ord[to] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, to)
            low[v] = min(low[v], low[to])
        else:
            low[v] = min(low[v], ord[to])
    if low[v] == ord[v]:
        while True:
            u, vis_i = visited[vis_i - 1], vis_i - 1
            ord[u] = N
            ids[u] = group_num
            if u == v:
                break
        group_num += 1
    return now_ord, group_num, vis_i


@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
    idx = np.searchsorted(G[:, 0], np.arange(N + 1))
    low = np.zeros(N, np.int64)
    ord = np.zeros(N, np.int64) - 1
    now_ord = 0
    group_num = 0
    visited, vis_i = np.empty(N, np.int64), 0
    ids = np.zeros(N, np.int64)
    for v in range(N):
        if ord[v] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, v)
    return group_num, group_num - ids - 1

@njit((i8, i8, i8[:]), cache=True)
def main(N, D, XY):
    # X を True として、two sat に帰着する
    X, Y = XY[::2], XY[1::2]
    G, g = np.empty((4 * N * N, 2), np.int64), 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if abs(X[i] - X[j]) < D:
                # i True implies j False
                G[g], g = (i, j + N), g + 1
            if abs(X[i] - Y[j]) < D:
                # i True implies j True
                G[g], g = (i, j), g + 1
            if abs(Y[i] - X[j]) < D:
                # i False implies j False
                G[g], g = (i + N, j + N), g + 1
            if abs(Y[i] - Y[j]) < D:
                # i False implies j True
                G[g], g = (i + N, j), g + 1
    G = G[:g]
    G = G[np.argsort(G[:,0])]
    n_comp, comp = scc(N + N, G)
    ans = np.empty(N, np.int64)
    for i in range(N):
        if comp[i] < comp[i + N]:
            ans[i] = Y[i]
        elif comp[i] > comp[i + N]:
            ans[i] = X[i]
        else:
            print('No')
            return
    print('Yes')
    for x in ans:
        print(x)

N, D = map(int, readline().split())
XY = np.array(read().split(), np.int64)

main(N, D, XY)

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

using namespace std; 

int main(){ 
  string s;
  cin>>s;
  string l="abcdefghijklmnopqrstuvwxyz";
  map<char,int > z;
  for (int i=0;i<26;i++){
    z[l[i]]=0;
  }
  for(int i=0;i<s.size();i++){
    z[s[i]]+=1;
  }
  for(char i='a';i<='z';i++){
    if(z[i]==0){
      cout<<i;
      break;
    }
    if(i=='z') cout<<"None";
  }
}

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

int main() {
  int H, W;

  while (cin >> H >> W) {
    for (int i = 0; i < H; i++) {
      int pre = -1;

      for (int j = 0; j < W; j++) {
        if (j != 0) {
          cout << " ";
        }

        char ch;
        cin >> ch;

        if (ch == 'c') {
          pre = j;
        }

        if (pre == -1) {
          cout << -1;
        } else {
          cout << j - pre;
        }
      }

      cout << endl;
    }
  }
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
	long long int A,B,x,y,c,z,w;
	cin>>A>>B;
	x=(A*100)/8;
	y=(B*100)/10;
	z=min(x,y);
	w=max(x,y);
	c=-1;
	for(int i=z-1;i<w+2;i++)
	{
		if((i*8)/100 == A && (i*10)/100 == B)
		{
			c=1;
			cout<<i<<"\n";
			break;
		}
	}
	if(c==-1)
	cout<<-1<<"\n";
	
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-


class Dice(object):
    def __init__(self, one, two, thr, fou, fiv, six):
        self._one = one
        self._two = two
        self._thr = thr
        self._fou = fou
        self._fiv = fiv
        self._six = six

    def roll(self, direction):
        if direction == "W":
            dice = self._roll_west()
        elif direction == "N":
            dice = self._roll_noth()
        elif direction == "E":
            dice = self._roll_east()
        elif direction == "S":
            dice = self._roll_south()
        else:
            raise ValueError

        return dice

    def _roll_west(self):
        return Dice(self._thr, self._two, self._six,
                    self._one, self._fiv, self._fou)

    def _roll_noth(self):
        return Dice(self._two, self._six, self._thr,
                    self._fou, self._one, self._fiv)

    def _roll_east(self):
        return Dice(self._fou, self._two, self._one,
                    self._six, self._fiv, self._thr)

    def _roll_south(self):
        return Dice(self._fiv, self._one, self._thr,
                    self._fou, self._six, self._two)

    def get_sides(self):
        return [self._one, self._two, self._thr,
                self._fou, self._fiv, self._six]


if __name__ == "__main__":
    args = [int(n) for n in input().split()]
    dice = Dice(*args)
    for dire in input():
        dice = dice.roll(dire)

    print(dice.get_sides()[0])


Measured memory_bytes: 5616
#include <stdio.h>
int main()
{
    int p, b;
    scanf("%d %d", &p, &b);
    if( (p+b)%3==0 || p%3==0 || b%3==0 )
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }
    return 0;
}

Measured memory_bytes: 1696
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0)
            cnt++;
        if (cnt == k) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  bool pos=false;
  cin>>n;
  vector<pair<int,int>> d(n);
  for(auto &i:d){
    cin>>i.first>>i.second;
  }
  for(int i=0;i<d.size()-2;++i){
    if(d[i].first==d[i].second&&d[i+1].first==d[i+1].second&&d[i+2].first==d[i+2].second){
      pos=true;
    }
  }
  if(pos){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0;i<n;i++) cin >> x[i];
    y = x;
    sort(x.begin(),x.end());

    for(int i=0;i<n;i++){
        if(y[i] <= x[n/2-1]) cout << x[n/2] << endl;
        else cout << x[n/2-1] << endl;
    }



    return 0;
}

Measured memory_bytes: 3712
pair = {?[ => ?], ?( => ?)}
loop {
    s = gets.chomp
    break if s == ?.
    a = s.scan(/[()\[\]]/)
    stack = []
    a.each{|x|
        if stack.size > 0 && x == pair[stack[-1]]
            stack.pop 
        elsif pair.keys.include?(x)
            stack << x
        else
            stack << x
            break 
        end
    }
    puts stack.size == 0 ? 'yes' : 'no'
}   

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

int dp(int end,int arr[]){
	int result[end]={0};
	result[1] = abs(arr[1]-arr[0]);
	for(int i=2;i<end;i++){
	    result[i] = min((result[i-1]+abs(arr[i]-arr[i-1])),(result[i-2]+abs(arr[i]-arr[i-2])));
	}
	return result[end-1];
}

int main(){
  	int n;
  	cin >> n;
  	int arr[n];
  	for(int i=0;i<n;i++){
    	cin >> arr[i];
    }
  	cout << dp(n,arr);
	return 0;
}

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

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

int main(void) 
{
    ll n;
    cin >> n;
    ll ans = 0;
    vector<pair<ll,int>> fs;
    for (ll i = 2; i*i <= n; ++i) 
    {
        int x = 0;
        while (n%i == 0) {
        n /= i;
        ++x;
        }
        fs.emplace_back(i,x);
    }
    
    if (n != 1) fs.emplace_back(n,1);
    
    for (auto p : fs) 
    {
        int x = p.second;
        int b = 1;
        while (b <= x) 
        {
            x -= b;
            b++;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19768
n = int(input())
#x1y2 - x2y1 = s
y2 = n//(10**9)
if n%(10**9):
    y1 = 10**9 - n%(10**9)
    y2+=1
else:
    y1 = 0
print(0,0,10**9,y1,1,y2)

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N),Q(N);
    for(int i=0;i<N;i++) {
        cin >> P[i];
    }
    for(int i=0;i<N;i++) {
        cin >> Q[i];
    }

    vector<int> v;
    for(int i=1;i<=N;i++) {
        v.push_back(i);
    }
    int a=0,b=0,cnt=0;
    while(next_permutation(v.begin(),v.end())) { // if its the first one it will never check so value stays 0
        cnt++;
        bool check = true;
        for(int i=0;i<N;i++) {
            if(P[i] != v[i]) check = false;
        }
        if(check) a = cnt;
        check = true;
        for(int i=0;i<N;i++) {
            if(Q[i] != v[i]) check = false;
        }
        if(check) b = cnt;
    }
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int alpha[n]['z' - 'a' + 1];
    for (int x = 'a'; x <= 'z'; x++)
    {
        for (int j = 0; j < n; j++)
        {
            alpha[j][x - 'a'] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int x = 0; x < s.size(); x++)
        {
            for (int j = 'a'; j <= 'z'; j++)
            {
                if (s[x] == (char)j)
                {
                    alpha[i][j - (int)'a'] += 1;
                }
            }
        }
    }
    for (int i = 'a'; i <= 'z'; i++)
    {
        int min = 50;
        for (int j = 0; j < n; j++)
        {
            if (alpha[j][i - 'a'] < min)
            {
                min = alpha[j][i - 'a'];
            }
        }
        for (int j = 0; j < min; j++)
        {
            cout << (char)i;
        }
    }

    cout << endl;
    return 0;
}

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

int main() {
  string N;
  long ans=0;
  getline(cin,N);
  
  for (char c:N)
  switch (c) {
    case '1':ans+=1;break;
    case '2':ans+=2;break;
    case '3':ans+=3;break;
    case '4':ans+=4;break;
    case '5':ans+=5;break;
    case '6':ans+=6;break;
    case '7':ans+=7;break;
    case '8':ans+=8;break;
    case '9':ans+=9;break;
    default:break;
  }
  
  if (ans%9==0) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3732
#include<algorithm> 
#include<bitset> 
#include<memory.h> 
#include<cstdio> 
#include<cmath> 
#define maxn 200010
#define ll long long
#define pa pair<ll,ll> 
#define ld long double 
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
using namespace std; 
inline ll read(){   ll 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; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
ll ans,n;
int main(){
	ll x=read(),y=read(),z=read(),kkk=read();
	z=min(x<<2,min(y<<1,z));
	n=read();
	if (n&1)	ans+=z,--n;
	ans+=min(z*n,kkk*n/2);
	writeln(ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto& p_ : p) {
        cin >> p_;
    }

    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;

    return 0;
}


Measured memory_bytes: 3620
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  auto A = vect(N, vect(M, 0));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) { cin >> A[i][j]; }
  }
  int ans = INF;
  for (int S = 0; S < (1 << N); S++) {
    vector<int> ud(M, 0);
    int cost = 0;
    for (int i = 0; i < N; i++) {
      if ((S >> i) & 1) {
        for (int j = 0; j < M; j++) ud[j] += A[i][j];
        cost += C[i];
      }
    }
    bool judge = true;
    for (int j = 0; j < M; j++) {
      if (ud[j] < X) judge = false;
    }
    if (judge) chmin(ans, cost);
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define MAXN 105
int main()
{
      int sum=0,a,b,n;
      while(cin>>n){
      while(n--)
      {
          cin>>a>>b;
          sum=sum+b-a+1;
      }
      cout<<sum<<endl;
      }

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int n,m;
   cin >> n >> m;
  
  vector<long> p(m),y(m);
  vector<long> pre[n+1];
  
  rep(i,m) {
    cin >> p[i] >> y[i];
   pre[p[i]].push_back(y[i]);
  }

 rep(i,n) sort(pre[i+1].begin(),pre[i+1].end());
  
  rep(i,m) {
    string s="";
    string t;
    string u="00000";
    t=to_string(p[i]*1000000+int(lower_bound(pre[p[i]].begin(), pre[p[i]].end(), y[i])-pre[p[i]].begin()+1));
    s+=u.substr(0,12-t.length());
    s+=t;
    cout<< s << endl;
  
  }


}


Measured memory_bytes: 8576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  map<int, int> map;
  rep(i, n) {
    int a; cin >> a;
    if (map.find(a) == map.end()) map.insert(make_pair(a, 1));
    else map[a]++;
  }
  if (map.size() >= 4) No();
  else if (map.size() == 1) {
    if (map.find(0) != map.end()) Yes();
    else No();
  } else if (map.size() == 2) {
    if (n % 3 != 0) No();
    else if (map[0] == n / 3) Yes();
    else No();
  } else {
    if (n % 3 != 0) No();
    else {
      vector<int> m;
      for (auto it : map) {
        if (it.second != n / 3) {
          No();
          return;
        }
        m.push_back(it.first);
      }
      int a[3] = {0,0,1};
      int b[3] = {1,2,2};
      int c[3] = {2,1,0};
      for (int i = 0; i < 3; i++) {
        if ((m[a[i]] ^ m[b[i]]) == m[c[i]]) {
          Yes();
          return;
        }
      }
      No();
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main(){
    int n ,m , x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    ll ans = 1000000000000;

    for(int bit = 0; bit < (1 << n); bit++){
        vector<ll> check(m);
        ll sum = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                for(int j = 0; j < m; j++){
                    check[j] += a[i][j];
                }
                sum += c[i];
            }
        }
        bool flag = true;
        for(int i = 0; i < m; i++){
            if(check[i] < x){
                flag = false;
            }
        }
        if(flag){
            ans = min(ans, sum);
        }
    }
    if(ans == 1000000000000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()

    g = math.gcd(x, 360)

    return 360 // g


print(main())




Measured memory_bytes: 10896
#include <stdio.h>

#define MAX 30

int main(void)
{
    int i;

    int vert[MAX + 1];

    int vert_n;
    scanf("%d", &vert_n);
    for (i = 0; i < vert_n; i++) {
        vert[i] =  i + 1;
    }

    int horiz;
    scanf("%d", &horiz);

    int swap1, swap2;
    int tmp;
    while (horiz--) {
        scanf("%d, %d", &swap1, &swap2);
        tmp = vert[swap1 - 1];
        vert[swap1 - 1] = vert[swap2 - 1];
        vert[swap2 - 1] = tmp;
    }

    for (i = 0; i < vert_n; i++) {
        printf("%d\n", vert[i]);
    }

    return 0;
}

Measured memory_bytes: 596
n=int(input())
a=list(map(int,input().split()))
left=[0]*(2*n+1)
right=[0]*(2*n+1)
now_a=a[:n]
left[n]=sum(now_a)
now_a.sort()
from heapq import heapify,heappop,heappush
heapify(now_a)
for i in range(n,2*n):
  if a[i]>now_a[0]:
    left[i+1]=left[i]+a[i]-now_a[0]
    heappop(now_a)
    heappush(now_a,a[i])
  else:
    left[i+1]=left[i]
b=[-x for x in a]
now_b=b[-n:]
right[n]=sum(now_b)
now_b.sort()
heapify(now_b)
for i in range(n,2*n):
  if b[-i-1]>now_b[0]:
    right[i+1]=right[i]+b[-i-1]-now_b[0]
    heappop(now_b)
    heappush(now_b,b[-i-1])
  else:
    right[i+1]=right[i]
ans=-pow(10,14)
for i in range(n+1):
  ans=max(ans,left[n+i]+right[2*n-i])
print(ans)


Measured memory_bytes: 36692
n = gets.to_i
d,x = gets.split(" ").map(&:to_i)
a = []
n.times do |i|
  a[i] = gets.to_i
end

sum = 0
n.times do |i|
  if d % a[i] != 0
    sum += d / a[i] + 1
  else
    sum += d / a[i]
  end
end
print("#{sum+x}\n")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k,mn=INT_MAX,ans=0;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    int it=0;
    while(it<n-1){
        ans++;
        it+=k;
        it--;
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3932
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a==1)&&(b==1))
    cout<<"Draw"<<endl;
    else if(a==1)
    cout<<"Alice"<<endl;
    else if(b==1)
    cout<<"Bob"<<endl;
    else if(a==b)
    cout<<"Draw"<<endl;
    else if(a>b)
    cout<<"Alice"<<endl;
    else
    cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    char a;
    cin >> a;
    if((int)a <= 90) cout << "A" << endl;
    else cout << "a" << endl;


    return 0;
}



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

using namespace std;

int n;
int a[200001], ans[200001];

vector<int> tmp;
vector<int> adj[200001];

void dfs(int u, int p)
{       
	int pre = -1;
	int pos = lower_bound(tmp.begin(), tmp.end(), a[u]) - tmp.begin();
	if (pos == tmp.size())
		tmp.push_back(a[u]);
	else
	{
		pre = tmp[pos];
		tmp[pos] = a[u];
	}
	ans[u] = tmp.size();
	for (int v : adj[u])
		if (v != p)	
			dfs(v, u);

	if (pre != -1) tmp[pos] = pre;
	else tmp.pop_back();
}

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, -1);
	for (int i = 1; i <= n; i++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, Q;
  cin >> N >> Q;
  int a[N - 1], b[N - 1];
  vector<int> adj[N];
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);
  }
  int p[Q];
  ll x[Q];
  ll c[N]{};
  for (int i = 0; i < Q; i++) {
    cin >> p[i] >> x[i];
    p[i]--;
    c[p[i]] += x[i];
  }
  ll t = 0;
  deque<int> q;
  q.push_back(0);
  int vis[N]{};
  vis[0] = 1;
  while(!q.empty()) {
    int u = q.front();
    q.pop_front();
    for (int i : adj[u]) {
      if (vis[i] == 1) continue;
      vis[i] = 1; 
      c[i] += c[u];
      q.push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << c[i] << "\n";
    } else {
      cout << c[i] << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 20980
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f,g,h,i,j,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&f);
	scanf("%d",&g);
	scanf("%d",&h);
	scanf("%d",&i);
	scanf("%d",&j);
	x=a+b+c+d+e+f+g+h+i+j;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 2e18;
int main() {
	int n, W;
	cin >> n >> W;
	const int C = 123456;
	vector<ll> v(n), w(n), dp(C+1, inf);
	for (int i{}; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	// for(int i{};i<n;i++){
	// 	for(int j{C};j>0;j--){
	// 		dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
	// 	}
	// }
	dp[0] = 0;
	for (int i{}; i < n; i++) {
		for (int j{C}; j >= v[i]; j--) {
			dp[j] = min(dp[j - v[i]] + w[i], dp[j]);
		}
	}
	ll ans = 0;
	for(ll i = C;i>=0;i--){
		if(dp[i]<=W){
			ans = i;
			break;
		}
	}
	

	cout<<ans<<endl;
}

Measured memory_bytes: 4284
fun main(args: Array<String>) {
    fun read() = readLine()!!
    fun readInt() = read().toInt()
    fun readInts() = read().split(" ").map { it.toInt() }
    val n = readInt()
    val a = readInts()
    println(a.mapIndexed { index, i -> i to index + 1 }
        .sortedBy { it.first }
        .joinToString(" ") {
            it.second.toString()
        })
}

Measured memory_bytes: 80868
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>


using namespace std;


using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;


ll max_u(ll& m, ll v)
{
	if(m<v)
	{
		m=v;
		return 1;
	}
	return 0;
}


ll solve(int n, vi& a)
{
	priority_queue<int> back;
	priority_queue<int, vector<int>, greater<int> > front;
	vll f_sum, b_sum;
	ll ret;
	int i;

	f_sum.resize(n+1);
	b_sum.resize(n+1);
	for(i=0;i<n;i++)
	{
		front.push(a[i]);
		f_sum[0]+=a[i];
	}

	for(i=1;i<=n;i++)
	{
		front.push(a[n-1+i]);
		f_sum[i]=f_sum[i-1]-front.top()+a[n-1+i];
		front.pop();
	}

	reverse(a.begin(), a.end());
	for(i=0;i<n;i++)
	{
		back.push(a[i]);
		b_sum[0]+=a[i];
	}
	for(i=1;i<=n;i++)
	{
		back.push(a[n-1+i]);
		b_sum[i]=b_sum[i-1]-back.top()+a[n-1+i];
		back.pop();
	}

	ret=f_sum[0]-b_sum[n];
	for(i=1;i<=n;i++)
	{
		max_u(ret, f_sum[i]-b_sum[n-i]);
	}
	return ret;
}


int main(void)
{
	int n;
	vi a;

	while(scanf("%d", &n)==1)
	{
		a.resize(3*n);
		for(int i=0;i<3*n;i++)
		{
			scanf("%d", &a[i]);
		}
		printf("%lld\n", solve(n, a));
	}

	return 0;
}


Measured memory_bytes: 4088
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> L(N);
  set<int> s;
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  
  sort(L.begin(), L.end());
  
  ll ans = 0;
  for(int i=N-1; i>=0; i--){
    for(int j=i-1; j>=0; j--){
      ll tmp = (ll)distance(upper_bound(L.begin(), L.end(), L[i]-L[j]), L.end()) - (ll)(N-j);
      ans += max(0LL, tmp);
    }
  }

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

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

int main() 
{
    int N;
    cin>>N;
    vector<int> P;
    for (int i = 0; i < N; i++)
    {
        int p;
        cin>>p;
        P.push_back(p);
    }

    int ans=0,min=N;
    for (int i = 0; i < N; i++)
    {
        if(P[i]<=min)
        {
            ++ans;
            min = P[i];
        }
        if(min==1)
        {
            break;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var M = int.Parse(Console.ReadLine());
            var sum = T.Sum();
            var PX = new (int P, int X)[M];
            for (var i = 0; i < M; i++)
            {
                var px = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                PX[i] = (px[0], px[1]);
            }

            for (var i = 0; i < M; i++)
            {
                var (P, X) = PX[i];
                var answer = sum + X - T[P - 1];
                Console.WriteLine(answer);
            }
        }
    }
}


Measured memory_bytes: 28212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int h,w,n;
bool fall(vs &field){
	bool ret=false;
	REP(j,w){
		string aaa;
		FOR(i,0,h){
			if(field[i][j]!='.'){
				aaa.push_back(field[i][j]);
			}else{
				if(i>0&&field[i-1][j]!='.'){
					ret=true;
				}
			}
		}
		int pos=h-1;
		for(int k=aaa.size()-1;k>=0;k--){
			field[pos][j]=aaa[k];
			pos--;
		}
		for(;pos>=0;pos--){
			field[pos][j]='.';
		}
	}
	return ret;
}

bool dfs(vs &field){
	vvi change(h,vi(w));
	REP(i,h){
		int from=0;
		char curc=' ';
		REP(j,w+1){
			char c=(j<w?field[i][j]:'-');
			if(curc!=c){
				if(curc!='.'){
					if(j-from>=n){
						FOR(k,from,j){
							change[i][k]=1;
						}
					}
				}
				from=j;
			}
			curc=c;
		}
	}
	REP(i,w){
		int from=0;
		char curc=' ';
		REP(j,h+1){
			char c=(j<h?field[j][i]:'-');
			if(curc!=c){
				if(curc!='.'){
					if(j-from>=n){
						FOR(k,from,j){
							change[k][i]=1;
						}
					}
				}
				from=j;
			}
			curc=c;
		}
	}
	REP(i,h){
		REP(j,w){
			if(change[i][j]){
				field[i][j]='.';
			}
		}
	}
	bool flag=fall(field);
	if(flag){
		return dfs(field);
	}else{
		bool clear=true;
		REP(i,h){
			REP(j,w){
				if(field[i][j]!='.'){
					clear=false;
					break;
				}
			}
		}
		return clear;
	}
}

int main(){
	cin>>h>>w>>n;
	vs field(h);
	REP(i,h){
		cin>>field[i];
	}
	REP(i,h){
		REP(j,w-1){
			vs nfield(field);
			swap(nfield[i][j],nfield[i][j+1]);
			fall(nfield);
			if(dfs(nfield)){
				cout<<"YES"<<endl;
				exit(0);
			}
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 1372
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;


signed main() {
	int n;
	cin >> n;


	if (n <= 9) {
		cout << n % 10;
	}
	else if (n <= 99) {
		cout << "9";
	}

	else if (n < 999) {
		cout << 10 + n - 100;
	}

	else if (n <= 9999) {
		cout << 9 + 900;
	}

	else if (n <= 99999) {
		cout << 910 + n - 10000;
	}
	else {
		cout << 90909;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right){
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++){
		if (L[i].value <= R[j].value){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int left, int right){
	int mid;
	if (left + 1 < right){
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int partition(struct Card A[], int p, int r){
	int i, j;
	struct Card tmp, x=A[r];
	i = p - 1;
	for (j = p; j < r; j++){
		if (A[j].value <= x.value){
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i + 1;
}

void quickSort(struct Card A[], int p, int r){
	int q;
	if (p < r){
		q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q+1, r);
	}
}

int main(){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	mergeSort(A, 0, n);
	quickSort(B, 0, n - 1);
	for (i = 0; i < n; i++){
		if (A[i].suit != B[i].suit){
			stable = 0;
		}
	}
	if (stable == 1){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	for (i = 0; i < n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	return 0;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// ↓の最初のaから1ループごとにd%bだけ増えてって、
// cを超えたところでbぶん減った値に行ってまた同様のループが始まる
// この最中に区間(c,b)に入ってしまうと買えなくなって終わる
// c+1 <= (a+pk)%b (< b) が成り立つkが存在するとNo
// これもまたb<=pkを満たすkの最小値mについてpm%bだけずれるループになる
// この値がb-c以下ならNo


int q, a, b, c, d;

signed main() {
	cin >> q;
	while (q--) {
		cin >> a >> b >> c >> d;
		if (b>d || a<b) {
			cout << "No" << ln;
			continue;
		}
		int k = max((a-c+b-1)/b, 1ll);
		a -= b*k;
		if (a<0) {
			cout << "No" << ln;
			continue;
		}
		
		int p = d %b;
		if (p==0) {
			cout << "Yes" << ln;
			continue;
		}
		k = (b+p-1)/p;
		k = p*k %b;
		// pとkを数個ずつ足して作れる数のうちcを超える最小値がb未満ならNo
		int m = LONG_LONG_MAX;
		if (k!=0) chmin(m,k);
		if (p!=0) chmin(m,p);
		if (k!=0 && p!=0) chmin(m, __gcd(k,p));
		k = c/m + 1;
		k *= m;
		if (c<k && k<b) cout << "No" << ln;
		else cout << "Yes" << ln;
	}
}

Measured memory_bytes: 256
let partition (a : int array) p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    if i = 0 then print_int e
    else begin
      print_string " ";
      if i = k then (print_string "["; print_int e; print_string "]")
      else print_int e
    end) a;
  print_newline ()

Measured memory_bytes: 5344
#include <stdio.h>

int judge(int num){
	int i;
	for(i=2;i<num;i++){
		if(i*i > num)
			return 0;
		if(num % i == 0)
			return 1;
	}
	return 0;
}

int main(void){
	int n,i,sum=0;
	int  a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(judge(a) == 0)
			sum++;
	}
printf("%d\n",sum);
return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

const int MAX = 500000, MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

struct rolling_hash64 {
    int n;
    vector<long long> hs, pw;
    rolling_hash64(){}
    rolling_hash64(const string &s) {
        n = s.size();
        hs.assign(n+1,0);
        pw.assign(n+1,0);
        pw[0] = 1;
        for (int i = 0; i < n; i++) {
            hs[i+1] = hs[i]*base+s[i];
            pw[i+1] = pw[i]*base;
        }
    }

    long long hash(int l, int r) { return hs[r]-hs[l]*pw[r-l]; }
    bool match(int l1, int r1, int l2, int r2) { return hash(l1,r1) == hash(l2,r2); }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  string s; cin >> s;
  rolling_hash64 rh(s);

  set<ll> st;
  int l = 0, r = 0;
  for(int i=0;i<m;++i) {
    string q; cin >> q;
    if(q == "L++") {
      l++;
    } else if(q == "L--") {
      l--;
    } else if(q == "R++") {
      r++;
    } else {
      r--;
    }
    st.insert(rh.hash(l, r+1));
  }

  cout << st.size() << endl;
}


Measured memory_bytes: 21980