akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   ll n,x;
   cin>>n>>x;
   ll a[n],pre[n];
   for(int i=0;i<n;i++)
    {
       cin>>a[i]; 
    } 
    sort(a,a+n);
    pre[0]=a[0];
    for(int i=1;i<n;i++)
    {
        pre[i]=a[i]+pre[i-1];
    }
    if(x<pre[0])
    {
        cout<<0<<endl;
    }
    else if(x>pre[n-1])
    {
        cout<<n-1<<endl;
    }
    else if(x==pre[n-1])
    {
        cout<<n<<endl;
    }
    else
    {ll idx=-1;
        for(int i=0;i<n;i++)
        {
            if(pre[i]<=x)
                continue;
            else
            {
                idx=i;
                break;
            }
        }
        cout<<idx<<endl;

    }
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

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

    int n,m,q;
    cin>>n>>m>>q;
    ll c_sum[n+1][n+1]={};
    for(int i=0,l,r;i<m;i++){
        cin>>l>>r;
        c_sum[l][r]++;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            c_sum[i+1][j+1]+=c_sum[i+1][j]+c_sum[i][j+1]-c_sum[i][j];
        }
    }
    for(int i=0,a,b;i<q;i++){
        cin>>a>>b;
        cout<<c_sum[b][b]-c_sum[b][a-1]-c_sum[a-1][b]+c_sum[a-1][a-1]<<endl;
    }
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

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);
}

void Main()
{
  ll n, m;
  cin >> n >> m;
  ll ans = lcm(n, m);
  str s, t;
  cin >> s >> t;
  map<ll, char> A;
  rep(i, s.size())
  {
    if (!A.count(i * (ans / n)))
      A[i * (ans / n)] = s[i];
  }
  rep(i, t.size())
  {
    if (A.count(i * (ans / m)))
    {
      if (A[i * (ans / m)] != t[i])
        fin(-1);
    }
    else
      A[i * (ans / m)] = t[i];
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 10880
#include <iostream>

using namespace std;

int main(){
	// input data
	// number of cards
	int n;
	cin >> n;
	
	// cards infos
	// spade ==> s, heart ==> h, club ==> c, dia ==> d
	int cardarrS[13] = {};
	int cardarrH[13] = {};
	int cardarrC[13] = {};
	int cardarrD[13] = {};
	for ( int i = 0; i < n; i++ ) {
		char tmpcardtype;
		int tmpcardnum;
		cin >> tmpcardtype >> tmpcardnum;
		if ( tmpcardtype == 'S' ) {
			cardarrS[tmpcardnum - 1] = 1;
		} else if ( tmpcardtype == 'H' ) {
			cardarrH[tmpcardnum - 1] = 1;
		} else if ( tmpcardtype == 'C' ) {
			cardarrC[tmpcardnum - 1] = 1;
		} else if ( tmpcardtype == 'D' ) {
			cardarrD[tmpcardnum - 1] = 1;
		}
	}

	// output results
	// print S
	for ( int i = 0; i < 13; i++ ) {
		if ( cardarrS[i] == 0 ) {
			cout << "S " << i + 1 << endl;
		}
	}
	// print H
	for ( int i = 0; i < 13; i++ ) {
		if ( cardarrH[i] == 0 ) {
			cout << "H " << i + 1 << endl;
		}
	}
	// print C
	for ( int i = 0; i < 13; i++ ) {
		if ( cardarrC[i] == 0 ) {
			cout << "C " << i + 1 << endl;
		}
	}
	// print D
	for ( int i = 0; i < 13; i++ ) {
		if ( cardarrD[i] == 0 ) {
			cout << "D " << i + 1 << endl;
		}
	}
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int n,ans,p=1,k;
signed main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i>=p) p*=10,k++;
        if(k&1) ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6;
int arr[maxn],n;
int main() {
  cin>>n;
  bool flag;
  int ans=1;
  int temp;
  cin>>arr[0];
  temp=arr[0];
  for(int i=1;i<n;i++)
  {
  	 cin>>arr[i];
	 if(arr[i]<temp)
  	 ans+=1;
  	 temp=min(arr[i],temp);
  }
 	cout<<ans;
      
}

Measured memory_bytes: 4364
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

void bubbleSort(int A[], unsigned short int N);//ソート関数
void trace(int A[], unsigned short int N);//配列の要素を順番に出力

int main()
{
	unsigned short int N;
	int A[100] = {};

	cin >> N;

	for (int i = 0;i<N;i++)
	{
		scanf("%d", &A[i]);
	}
	bubbleSort(A, N);

	return 0;
}

void bubbleSort(int A[], unsigned short int N)
{
	bool flag = 1;
	int v, c;
	c = 0;

	while (flag)
	{
		flag = 0;
		for (int j = N - 1;j > 0;j--)//数列最後尾から順に逆順要素の有無確認
		{
			if (A[j] < A[j - 1])//逆順要素入れ替え
			{
				v= A[j];
				A[j] = A[j-1];
				A[j - 1] = v;
				c = c + 1;
				flag = 1;//逆順要素入れ替えした場合、flag=1にする。
			}
		}
	}
	trace(A, N);
	cout << c << endl;
}

void trace(int A[], unsigned short int N)
{
	cout << A[0];
	for (int i = 1;i < N;i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
}


Measured memory_bytes: 3224
#include <iostream>

int main()
{
    unsigned long long X;
    std::cin >> X;
    unsigned long long y = 100;
    for(int i = 1; true; ++i){
        y += y / 100;
        if(y >= X) {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.



int main() {
  string s;
  cin >> s;
  int count = 0;
  
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
  {
    cout << 3 << endl;
  }
  else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
  {
    cout << 2 << endl;
  }
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
  {
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }

   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define INF 9999999;
using namespace std;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int n,m,z;
int main()
{
	n=read();
	m=read();
	z=read();
	n-=z;
	m+=z;
	cout<<n/m<<'\n';
	return 0;
}


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

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char s[4],t[4];

    scanf("%s %s",&s,&t);

    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i] == t[i])count++;
    }
    printf("%d",count);
}


Measured memory_bytes: 128
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

answer = 0
for i in range(N):
  if i != 0 and A[i] == A[i-1] + 1:
    answer+=C[A[i-1]-1]
  answer+=B[A[i]-1]

print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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, 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());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    ll s = 0;
    REP(i, n) s += a[i];
    vll b(n);
    ll res = 1e9, ans;
    REP(i, n){
        b[i] = abs(n * a[i] - s);
        if(b[i] < res){
            ans = i;
            res = b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
//const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R, X;
string S, T;

int main(){
  cin >> N >> M >> X;
  vi A(M);
  ll ans = 0;
  rep(i,M) {
    cin >> A[i];
    if(A[i]>X) ans++;
  }
  cout << min(ans, M-ans) << endl;  
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
	int pos;
	string s,t,r;
	cin >> s >> t;
	bool f=false;
    vector<string> vec;
	rep(i, s.length() - t.length()+1){
		
		pos = i;
		rep(j,t.length()){
			f=true;
			if(!(t[j] == s[j+i] || s[j+i] == '?')){
				f=false;
				break;
			}
		}
        
		if(f){
            r = "";
			rep(k,s.length()){
				if(k == pos){
					r += t;
					k += t.length() -1;
				}else if(s[k] == '?'){
					r += 'a';
				}else{
					r += s[k];
				}
			}
            vec.push_back(r);
		}
	}

    //for(auto e:vec)cout << e << endl;

	if(vec.size() == 0)
    	cout << "UNRESTORABLE" << endl;
    else
        cout << vec[vec.size()-1] << endl;
    return 0;
}


Measured memory_bytes: 256
abc = list(map(int,input().split()))
if abc[2] >= abc[1] and abc[1] >= abc[0]:
    print(2*abc[1]+min(abc[0]+1,abc[2]-abc[1]))
elif abc[2] >= abc[0] and abc[0] >= abc[1]:
    print(2*abc[1]+min(abc[0]+1,abc[2]-abc[1]))
elif abc[1] >= abc[0] and abc[0] >= abc[2]:
    print(abc[1]+abc[2])
elif abc[1] >= abc[2] and abc[2] >= abc[0]:
    print(abc[1]+abc[2])
elif abc[0] >= abc[1] and abc[1] >= abc[2]:
    print(abc[1]+abc[2])
elif abc[0] >= abc[2] and abc[2] >= abc[1]:
    print(abc[1]+abc[2])
 

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
int s[200005];
int main()
{
    int N,m;
    cin>>N;
    for(int i=0; i<N; i++)
    {
        cin>>s[i];
    }
    int h=s[0];
    int t=1;
    for(int i=1; i<N; i++)
    {
        if(s[i]<h)
        {
            t++;
            h=s[i];
        }

    }
    printf("%d",t);
    return 0;
}


Measured memory_bytes: 1024
import sys
def main():
    l= sys.stdin.readline()
    N, K = map(int, l.split())
    
    l = sys.stdin.readline()
    nums = list(map(lambda a:(int(a)+1)/2.0, l.split()))
    
    M = sum(nums[:K])
    mx = M
    for i in range(K, len(nums)):
        #print(nums[i-K], nums[i])
        M = M - nums[i-K] + nums[i]

        if M > mx:
            mx = M
        
    return mx
if __name__ == "__main__":
    print(main())

Measured memory_bytes: 23060
#include<cstdio>
#include<cstring>
using namespace std;
int gcd(int x,int y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
int main()
{
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				ans+=gcd(i,gcd(j,k));
			}
		}
	}
	printf("%d\n",ans);
	return 0;
} 


Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long calc(long N,long a,long A,long b,long B,long c,long C)
{
	vector<pair<long,long> >X;
	if(a<A)X.push_back(make_pair(a,A));
	if(b<B)X.push_back(make_pair(b,B));
	if(c<C)X.push_back(make_pair(c,C));
	if(X.size()==0)return N;
	else if(X.size()==1)
	{
		long t=N/X[0].first;
		return N+t*(X[0].second-X[0].first);
	}
	else if(X.size()==2)
	{
		long ret=N;
		a=X[0].first;
		A=X[0].second;
		b=X[1].first;
		B=X[1].second;
		for(long i=0;a*i<=N;i++)
		{
			long j=(N-a*i)/b;
			ret=max(ret,N-a*i+A*i-b*j+B*j);
		}
		return ret;
	}
	long ret=N;
	for(long i=0;a*i<=N;i++)for(long j=0;a*i+b*j<=N;j++)
	{
		long k=(N-a*i-b*j)/c;
		ret=max(ret,N-a*i+A*i-b*j+B*j-c*k+C*k);
		ret=max(ret,N-a*i+A*i-b*j+B*j);
	}
	return ret;
}
main()
{
	long N,a,A,b,B,c,C;
	cin>>N>>a>>b>>c>>A>>B>>C;
	cout<<calc(calc(N,a,A,b,B,c,C),A,a,B,b,C,c)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
int main(){
	int n;
	cin >> n;
	for(int rep=0; rep<n; rep++){
		VP v(4);
		for(int i=0; i<4; i++){
			double x,y;
			cin >> x >> y;
			v[i] = P(x, y);
		}
		if(isParallel(v[1]-v[0], v[3]-v[2])){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3184
(X,N) = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))
    for i in range(N+1):
        if (X - i) not in p:
            print(X-i)
            break
        elif(X+i) not in p:
            print(X+i)
            break

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

using ll = long long;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    bool visited[m];
    vector<ll> mods(m);
    for(int i = 0; i < m; i++) {
        mods[i] = ((ll)i*i)%m;
        visited[i] = false;
    }
    visited[x] = true;
    ll len = 1, cnum = x, start = -1;
    vector<ll> vals = {x};
    for(int i = 2; i <= n; i++) {
        cnum = ((ll)cnum*cnum)%m;
        if(!visited[cnum]) {
            visited[cnum] = true;
            vals.push_back(cnum);
            len++;
        }
        else {
            start = cnum;
            break;
        }
    }
    ll ans = 0;
    for(int i = 0; i < vals.size(); i++) {
        if(vals[i] == start) {
            len -= i;
            start = i;
            break;
        }
        else {
            ans += vals[i];
            n--;
        }
    }
    if(start != -1) {
        for(int i = start; i < vals.size(); i++) {
            ans += (ll)vals[i]*(n/len);
        }
        n %= len;
        for(int i = start; i < vals.size(), n > 0; i++, n--) {
            ans += vals[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4660
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int N;
	long long T,A,x,y;
	x=1;
	y=1;
	cin >> N;
	
	for(int i=1;i<=N;i++){
		cin >> T >> A;
		long long m = max((x+T-1)/T,(y+A-1)/A);
		x = m*T;
		y = m*A;	
	}
	
	cout << x+y << endl;
	
	return 0;	
};

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        mut xyh: [(i64, i64, i64); n],
    }

    xyh.sort_by_key(|&x| x.2);
    xyh.reverse();

    for xx in 0..101 {
        'outer: for yy in 0..101 {
            let mut hh: Option<i64> = None;
            for &(x, y, h) in &xyh {
                if hh.is_none() {
                    hh = Some(h + (xx - x).abs() + (yy - y).abs());
                } else {
                    if max(hh.unwrap() - (xx - x).abs() - (yy - y).abs(), 0) != h {
                        continue 'outer;
                    }
                }
            }
            println!("{} {} {}", xx, yy, hh.unwrap());
        }
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var K = cin.ReadLong;
			var A = cin.ReadIntArray(N);
			var order = Enumerable.Repeat(-1, N).ToArray();
			int cycle=0, loopTime=0;
			var taka = 0;
			var history = new List<int>() { taka };
			order[taka]=0;
			for(int i = 1; i<=N; i++) {
				var next = A[taka]-1;
				if(order[next]>=0) {
					cycle = i-order[next];
					loopTime=order[next];
					break;
				} else {
					history.Add(next);
					order[next]=i;
				}
				taka=next;
			}
			var essential = K<loopTime ? K : loopTime+(K-loopTime)%cycle;
			Console.WriteLine(history[(int)essential]+1);
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

Measured memory_bytes: 49008
#include<iostream>
using namespace std;
class Cube {
public:
	int f[6];
	Cube() {}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};
bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])return false;
	return true;
}
bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))return true;
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return false;
}
Cube C[100]; int n;
bool check() {
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (equal(C[i], C[j]))return false;			
		}	
	}
	return true;
}
int main() {
	cin >> n;
	for (int j = 0; j < n; j++)for (int i = 0; i < 6; i++)cin >> C[j].f[i];
	if (check())cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
using namespace std;

char ch[510][510];
bool b[510][510],r[510][510];
int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",ch[i]+1);
		for(int j=1;j<=w;j++)	if(ch[i][j]=='#')
			b[i][j] = r[i][j] = 1;
	}
	for(int i=1;i<=w;i++)	b[1][i]=1,r[h][i]=1;
	for(int i=2;i<h;i++)	for(int j=1;j<=w;j++)
	{
		if(j%2==1)	b[i][j]=1; else	r[i][j]=1;
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			printf("%c",b[i][j]?'#':'.');
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			printf("%c",r[i][j]?'#':'.');
		printf("\n");
	}
	return 0;
}

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

int m = 0;
int g[10000000];
int cnt;

void array_G(int n) {
  int number = 1;
  while (number <= n) {
    g[m] = number;
    number = 3 * number + 1;
    m++;
  }
}

void insertion_sort(int a[], int n, int g) {
  int v;
  int j;
  for (int i = g; i < n; i++) {
    v = a[i];
    j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
}

void shell_sort(int a[], int n) {
  cnt = 0;
  array_G(n);
  for (int i = m - 1; i >= 0; i--)
    insertion_sort(a, n, g[i]);
}

int main(void) {
  int n;
  int a[1000000];

  scanf("%d", &n);

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

  shell_sort(a, n);

  printf("%d\n", m);
  for (int i = m - 1; i >= 0; i--) {
    printf("%d", g[i]);
    if (i != 0)
      printf(" ");
  }
  printf("\n%d\n", cnt);

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



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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>p(n);
  rep(i,0,n)cin>>p[i];
  res=1;
  set<ll>st;
  rep(i,0,k)st.insert(p[i]);
  ll l=1,r=k;
  ll cnt=0;
  vector<ll>q(n-1);
  rep(i,0,n-1)if(p[i]>p[i+1])q[i]=1;
  rep(i,0,k-1)cnt+=q[i];
  bool judgebuf=true;
  if(cnt==0)judgebuf=false;
  while(1){
    if(r>=n)break;
    cnt+=q[r-1];cnt-=q[l-1];
    judge=false;
    if(*st.begin()!=p[l-1])judge=true;
    st.erase(st.find(p[l-1]));
    st.insert(p[r]);
    if(*--st.end()!=p[r])judge=true;
    if(judge){
      if(cnt==0){
        if(judgebuf)res++;
        judgebuf=false;
      }
      else res++;
    }
    //cout<<p[l] spa p[r] spa judge<<endl;
    l++;r++;
  }
  
  
  cout<<res<<endl;
  return 0;
}

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

const int mod=998244353;
long long dp[3001][3001]; //size,total
const int inv=998244353/2+1;

int main(void) {
    int n,s;
    scanf("%d %d",&n,&s);
    dp[0][0]=1;
    for(int i=1;i<=n;i++) {
        int x;
        scanf("%d",&x);
        for(int j=0;j<=s;j++) {
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
            if (j+x<=s) {
                dp[i][j+x]+=(inv*dp[i-1][j])%mod;
                dp[i][j+x]%=mod;
            }
        }
    }
    for(int i=0;i<n;i++) {
        dp[n][s]*=2;
        dp[n][s]%=mod;
    }
    printf("%lld",dp[n][s]);
}

Measured memory_bytes: 74056
#include <stdio.h>
#include <string.h>
int main(void){
    int ap,bp,cp,t;
    char a[999],b[999],c[82];
    scanf("%d",&t);
    while(~scanf("%s%s",&a,&b)){
        ap=strlen(a);
        bp=strlen(b);
        c[cp=(ap>80||bp>80)?0:81]='\0';
        t=0;
        while((t||ap||bp)&&cp>0){
            t+=(ap?a[--ap]-'0':0)+(bp?b[--bp]-'0':0);
            c[--cp]='0'+t%10;
            t/=10;
        }
        if(cp>0)puts(&c[cp]);
        else puts("overflow");
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

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


	ll LCM(ll a, ll b)
	{
		return a * b / GCD(a, b);
	}

}

void ABC131C()
{
	ll A, B;
	int C, D;
	cin >> A >> B >> C >> D;
	ll N = B - A + 1;
	ll E = LCM(C, D);

	ll c1 = A / C;
	ll c2 = B / C;
	ll nc = c2 - c1;
	if (c1 * C == A)
		++nc;
	ll d1 = A / D;
	ll d2 = B / D;
	ll nd = d2 - d1;
	if (d1 * D == A)
		++nd;
	ll e1 = A / E;
	ll e2 = B / E;
	ll ne = e2 - e1;
	if (e1 * E == A)
		++ne;
	ll ret = N - nc + ne - nd;
	cout << ret << endl;

}

int main()
{
	ABC131C();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5;
int n,a[N];pair<int,int>s[N];
bool check(int mid){
	for(int i=2,top=0;i<=n;++i)
		if(a[i]<=a[i-1]){
			if(mid==1)return false;
			while(top&&s[top].first>a[i])--top;
			if(top&&s[top].first==a[i])++s[top].second;
			else s[++top]={a[i],1};
			while(top&&s[top].second==mid){
				if(s[top].first==1)return false;
				if(top&&s[top-1].first==s[top].first-1)
					--top,++s[top].second;
				else s[top]={s[top].first-1,1};
			}
		}
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	int l=1,r=n-1,res=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))res=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    deque<ll> q;
    rep(i, 2) q.push_back(a[1]);
    ll ans = a[0];
    for(int i = 2; i < n; ++i){
        ans += q.front(); q.pop_front();
        rep(j, 2) q.push_back(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
import java.util.*;

public class Main {
	static Person[] arr;
	static int[][] dp;	//何人目、何人選択
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		arr = new Person[n];
		dp = new int[n + 1][n + 1];
		for (int i = 0; i < n; i++) {
			arr[i] = new Person(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(arr, new Comparator<Person>() {
		public int compare(Person p1, Person p2) {
			return p1.h + p1.p - p2.h - p2.p;
		}
		});
		for (int i = n; i >= 0; i--) {
			if (dfs(n, i) != Integer.MAX_VALUE) {
				System.out.println(i);
				return;
			}
		}
	}
	
	static int dfs(int x, int y) {
		if (y > x) {
			return Integer.MAX_VALUE;
		}
		if (y == 0) {
			return 0;
		}
		if (dp[x][y] != 0) {
			return dp[x][y];
		}
		int tmp = dfs(x - 1, y - 1);
		if (tmp > arr[x - 1].h) {
			tmp = Integer.MAX_VALUE;
		} else {
			tmp += arr[x - 1].p;
		}
		int ans = Math.min(dfs(x - 1, y), tmp);
		dp[x][y] = ans;
		return ans;
	}
	
	static class Person {
		int h;
		int p;
		public Person(int h, int p) {
			this.h = h;
			this.p = p;
		}
	}
}


Measured memory_bytes: 171576
#include<bits/stdc++.h>
using namespace std;
#define int long long
string x;
signed main(){
    cin>>x;
    int l=x.size();
    int s=0,t=0;
    for(int i=0;i<l;i++){
        if(x[i]=='S'){
            s++;
        }
        else{
            if(s>0){
                t++;
                s--;
            }
        }
    }
    int ans=l-t*2;
    cout<<ans<<endl;
    return 0;
}

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

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

  vector<int> a(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;

    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      //
      // ビット和代入 "|=" で、スイッチがどの電球につながっているかを
      // 2進数で管理する
      //
      // ### データ例
      // k s1 s2
      // 2  1  2
      // 1  1
      // 1  2
      //
      // ### スイッチの番号を 0-indexed に変換
      // k s1 s2
      // 2  0  1
      // 1  0
      // 1  1
      //
      // i=0
      //   a[0] |= 1 << 0;
      //     000 | 001 = 001
      //     a[0] = 001
      //   a[1] |= 1 << 0;
      //     000 | 001 = 001
      //     a[1] = 001
      // i=1
      //   a[0] |= 1 << 1;
      //     001 | 010 = 011
      //     a[0] = 011
      // i=2
      //   a[1] |= 1 << 2;
      //     001 | 100 = 101
      //     a[1] = 101
      //
      // ### 出来上がるデータ
      // a[0] = 011 // 0個目のスイッチは電球 0,1 につながっている
      // a[1] = 101 // 1個目のスイッチは電球 0,2 につながっている
      //
      a.at(s) |= 1 << i;
    }
  }

  int p = 0;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    // ### 処理の流れ
    //
    // p1 p2 p3
    // 0  0  1
    //
    // p = 000 | 0<<0 = 000
    // p = 000 | 0<<1 = 000
    // p = 000 | 1<<2 = 000 | 100 = 100
    //
    // 各電球につながっているスイッチについて、点灯条件が管理される。
    // 点灯条件は「スイッチが on になっている数の偶奇」である。
    //
    // 例えば2個目の電球の場合は on になっているスイッチの数が偶数であること。
    // つまり、onのスイッチの数が0個 or 2個の場合に点灯する。
    // しかし、2個目の電球は1つのスイッチと紐づいている。
    // そのため、onのスイッチが0個の場合に点灯する。
    //
    p |= x<<i;
  }

  int ans = 0;
  for (int s = 0; s < (1 << n); s++) {
    int t = 0; // どの電球がついているか

    // スイッチのon,offパターンのbit全探索
    //
    // * スイッチ0のみが on の場合
    //   * s = 1 = 2進数で表すと 01 となる
    // * a[0] との XOR で、0個目のスイッチにつながっている電球について、
    //   bitを立てることで、電球ごとに on になっているスイッチの数の偶奇がわかる
    //
    // * スイッチ0 と 1 が両方 on の場合
    // * a[0] a[1] との XOR で、電球ごとに on になっているスイッチの数の偶奇がわかる
    //
    // ### 処理の流れ
    //
    // s=0 (00)
    //   i=0 のスイッチ 00 >> 0 & 1 = 0
    //   i=1 のスイッチ 00 >> 1 & 1 = 0
    //   --> t=000
    //
    // s=1 (01)
    //   i=0 のスイッチ 01 >> 0 & 1 = 1
    //     t = 000 ^ a.at(0) = 000 ^ 011 = 011
    //   i=1 のスイッチ 01 >> 1 & 1 = 0
    //   --> t=011
    //
    // s=2 (10)
    //   i=0 のスイッチ 10 >> 0 & 1 = 0
    //   i=1 のスイッチ 10 >> 1 & 1 = 1
    //     t = 000 ^ a.at(1) = 000 ^ 101 = 101
    //   --> t=101
    //
    // s=3 (11)
    //   i=0 のスイッチ 11 >> 0 & 1 = 1
    //     t = 000 ^ a.at(0) = 000 ^ 011 = 011
    //   i=1 のスイッチ 11 >> 1 & 1 = 1
    //     t = 011 ^ a.at(1) = 011 ^ 101 = 110
    //   --> t=110
    //
    for (int i = 0; i < n; i++) {
      if (s >> i & 1) {
        // XOR演算子
        t ^= a.at(i);
      }
    }

    // p = 100 の場合、全ての電球が点灯する
    // 一方で t は bit 全探索した全てのパターンで 100 になることはない
    // そのため、ans がインクリメントされることはない
    if (t == p) {
      ans++;
    }
  }

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


Measured memory_bytes: 3628
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

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


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  set<ll> st;
  rep(i,3){
    ll a;cin>>a;
    st.insert(a);
  }
  if(st.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int N=100005,Mod=1e9+7;
int n,ans,f[N],g[N];
ll a[N],A,B;
int main()
{
	scanf("%d%lld%lld",&n,&A,&B);
    if(A>B)swap(A,B);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for(int i=3;i<=n;i++)if(a[i]-a[i-2]<A){printf("0\n");return 0;}
    f[0]=g[0]=1;
	int l=0,r=0;
    for(int i=1;i<=n;i++)
    {
        while(r<i-1&&a[i]-a[r+1]>=B)++r;
        if(l<=r)f[i]=(g[r]+Mod-(l?g[l-1]:0))%Mod;
        g[i]=(g[i-1]+f[i])%Mod;
        if(i>1&&a[i]-a[i-1]<A)l=i-1;
    }
    for(int i=n;i>=0;i--)
    {
        ans=(ans+f[i])%Mod;
        if(i<n&&a[i+1]-a[i]<A)break;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1664
import math
X = int(input())
XX = 2 * X
data = [i for i in range(2,XX+1)]
limit = math.sqrt(XX)
prime = []
while True:
    p = data[0]
    if limit <= p:
        prime = prime + data
        break
    prime.append(p)
    data = [e for e in data if e % p != 0]
lenp = len(prime)
for i in range(lenp):
    if prime[i] >= X:
        print(prime[i])
        break

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define UM unordered_map

int main()
{
  ll a,b;
  cin>>a>>b;
  if(a%b==0)cout<<a/b<<endl;
  else cout<<a/b+1<<endl;
  
}


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

int main(){
	int n,l;
	cin>>n>>l;
	
	int sum=0;
	int temp=999;
	int eaten=0;
	for(int i=1;i<=n;i++){
		sum+=l;
		if(abs(l)<temp){
			temp=abs(l);
			eaten=l;
		}
			
		l++;
	}
	cout<<sum-eaten;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin>>s;
  int flag=0;
  for(int i=0; i<s.size()-1; i++){
    if(s[i]==s[i+1])
      flag=1;
  }
  if(flag==0){
    cout<<"Good"<<endl;
  }else{
    cout<<"Bad"<<endl;
  }

  return 0;
}


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

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    priority_queue<ll> que;
    rep(i,x) que.push(p[i]);
    rep(i,y) que.push(q[i]);
    rep(i,c) que.push(r[i]);
    ll ans = 0;
    rep(i,x+y) {
        ans += que.top();
        que.pop();
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9816
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int siryoku[][] = new int [4][2];
 		while(true){
			try{
				double left = in.nextDouble();
				double right = in.nextDouble();
				if(left >= 1.1){
					siryoku[0][0]++;
				}else if(left >= 0.6 && left < 1.1){
					siryoku[1][0]++;
				}else if(left >= 0.2 && left < 0.6){
					siryoku[2][0]++;
				}else if(left < 0.2){
					siryoku[3][0]++;
				}
				if(right >= 1.1){
					siryoku[0][1]++;
				}else if(right >= 0.6 && right < 1.1){
					siryoku[1][1]++;
				}else if(right >= 0.2 && right < 0.6){
					siryoku[2][1]++;
				}else if(right < 0.2){
					siryoku[3][1]++;
				}
			}catch(Exception e){
				for(int i = 0;i < 4;i++){
					System.out.println(siryoku[i][0] + " " + siryoku[i][1]);
				}
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 20564
#include <iostream>
#include <fstream>

#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define pb push_back
#define mp make_pair


int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    // cout.setf(ios::fixed), cout.precision(20);

#ifdef LOCAL
    // ifstream cin("input.txt");
#endif

    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a,b) for(int i=a;i<b;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E cout<<"\n";
#define I(x) cin>>x;
#define O(x) cout<<x;
#define all(a) a.begin(),a.end()
const ll M=1000000007;

using namespace std;

//ll modexpo(ll a,ll b,ll p)
//{
//    ll ans=1;
//      a=a%p;  // update a if(a>=p)
//
//        if(a==0)
//            return 0;
//
//                while(b!=0)
//                {
//                    if(b%2==1)
//                        ans=(ans*a)%p;
//
//                    a=a*a;
//                    b=b/2;
//
//                }
//                return ans;
//}

//ll countbit(ll n)
//{
//    ll c=0,x=0;
//    while(n!=0)
//    {
//        c+=n&1;
//        n>>=1;
//        x++;
//    }
//    return c==x;
//}



/*  vector<int> prime1;
  int prime[10000001];

void sieve(int n)
{
       for(long long i=2;i<=n;i++)
       {
         if(prime[i]==0)
         {  prime[i]=i;
            prime1.pb(i);
         }

            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
            {

                   prime[i*prime1[j]]=prime1[j];


            }


      }

 return ;
}*/

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

}


int main()
{
    fastio();

    int n;
    cin>>n;
    if(n>=400 && n<=599)
        cout<<"8";
    else if(n>=600 && n<=799)
        cout<<"7";
    else if(n>=800 && n<=999)
        cout<<"6";
    else if(n>=1000 && n<=1199)
        cout<<"5";
    else if(n>=1200 && n<=1399)
        cout<<"4";
    else if(n>=1400 && n<=1599)
        cout<<"3";
    else if(n>=1600 && n<=1799)
        cout<<"2";
     else
         cout<<"1";

   return 0;
}


Measured memory_bytes: 3636