akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n+1);
    rep(i,n+1)cin>>in[i];
    rep(i,n+1){
      vector<int>tmp=in;
      tmp.erase(tmp.begin()+i);
      int sa=tmp[1]-tmp[0];
      bool h=true;
      rep(j,tmp.size()-1)if(sa!=tmp[j+1]-tmp[j]){
	h=false;
	break;
      }
      if(h){
	cout<<in[i]<<endl;
	break;
      }
    }
  }
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10, mod = 1e9 + 7;

int n;

int64 A, B, S[N];

int lf[N], f[N], g[N];

int t[N];

void add(int x, int v) { for (++x; x <= n + 1; x += x & -x) t[x] = (t[x] + v) % mod; }

int query(int x) { int v = 0; for (++x; x; x -= x & -x) v = (v + t[x]) % mod; return v; }

int main()
{
	gi(n);
	scanf("%lld%lld", &A, &B);
	if (A < B) swap(A, B);
	for (int i = 1; i <= n; ++i) scanf("%lld", S + i); S[0] = -A;
	++n; S[n] = S[n - 1] + A;
	lf[1] = 1;
	for (int i = 2; i <= n; ++i) if (S[i] >= S[i - 1] + B) lf[i] = lf[i - 1]; else lf[i] = i;
	f[0] = 1;
	add(0, f[0]);
	for (int i = 1; i <= n; ++i)
	{
		int k = upper_bound(S + 1, S + i + 1, S[i] - A) - S - 1;
		int j = lf[i - 1] - 1;
		if (S[i] - S[i - 1] >= A) f[i] = f[i - 1];
		if (i >= 2 && min(i - 2, k) >= j - 1) (f[i] += (query(min(i - 2, k)) - query(j - 1) + mod) % mod) %= mod;
		if (i < n && S[i + 1] - S[i - 1] >= B) add(i, f[i]);
	}
	printf("%d\n", f[n]);
	return 0;
}

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

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

    int ds[] = { 1, -1, n, -n };
    vector<int> dist(n * n);
    for (int x = 0; x < n; x++) {
        for (int y = 0; y < n; y++) {
            dist[x * n + y] = min({x, y, n - 1 - x, n - 1 - y});
        }
    }

    vector<int> exists(n * n, 1);
    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        int p;
        cin >> p; --p;
        ans += dist[p];
        exists[p] = 0;
        queue<int> q;
        q.push(p);
        while (!q.empty()) {
            int s = q.front(); q.pop();
            for (int d : ds) {
                int t = s + d;
                if (0 <= t && t < n * n && dist[t] > dist[s] + exists[s]) {
                    dist[t] = dist[s] + exists[s];
                    q.push(t);
                }
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5336
n = int(input())
ans = [0]*10**5
for i in range(1,int(n**0.5)):
	for j in range(1,int(n**0.5)):
		for k in range(1,int(n**0.5)):
			res = i**2 + j**2 + k**2 +i*j + j*k + k*i
			ans[res-1] += 1
for i in range(n):
	print(ans[i])

Measured memory_bytes: 10260
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

int main() {
    
    get2(n,m);
    vector<vector<pll>> adj(n, vector<pll>());

    unordered_map<ll,ll> idx;
    rep(i,m) {
        get2(a,b);
        adj[--a].pb({--b,i});
    }

    double res = INF;
    vector<double> val(n,0);
    val[n-1]=0;

    for(ll j=n-2;j>=0;j--) {

        bool flag = 0; double maxi = -1;
        for(auto k:adj[j]) {

            if(maxi<=-1+1e-9 || maxi+1e-9<val[k.fi]) {
                idx[j] = k.se;
                maxi = val[k.fi];
            }

            val[j] += (1+val[k.fi]);
        }
        val[j]/=(double)adj[j].size();

        if(flag)
            val[j] = INF;
    }

    res = min(res, val[0]);

    for(auto it:idx) {
        ll i = it.se;
        vector<double> val(n,INF);
        val[n-1]=0;

        for(ll j=n-2;j>=0;j--) {
            ll sz = adj[j].size();
            if(it.fi==j)
                sz--;

            if(sz>0) val[j] = 0.0;
            else continue;

            bool flag = 0;
            for(auto k:adj[j]) {
                if(val[k.fi]+1e-9>=INF) {
                    flag=1;
                    break;
                }

                if(k.se!=i)
                    val[j] += (1+val[k.fi]);
            }
            if(sz!=0)
                val[j]/=sz;

            if(flag)
                val[j] = INF;
        }

        res = min(res, val[0]);
    }

    printf("%0.10f\n", res);
    return 0;  
}

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

int main() {
	// your code goes here
	int n; cin >> n;
	for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++) 
			if (n == i * j) {
				cout << "Yes";
				return 0;
			}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
main=interact$f.lines
f[nkc,s]=unlines$map show r where
  [n,k,c]=map read.words$nkc
  [a,b]=map(g 1(-c)[])[s,reverse s]
  r = if length a/=k then [] else h a(reverse$map((n+1)-)b)[]
  g i p w (s:ss)=if i>p+c && s=='o' then g(i+1)i(i:w)ss else g(i+1)p w ss
  g _ _ w _=w
h(a:as)(b:bs)r
  |a>b=h as(b:bs)r
  |a<b=h(a:as)bs r
  |otherwise=h as bs(a:r)
h _ _ r=r

Measured memory_bytes: 50812
#include<stdio.h>
#include<algorithm>
using namespace std;
char ka[1100][10];
char kb[1100][10];
int t[1100];
char in[110];
char wa[1100][10];
char wb[1100][10];
char wn[1100][110];
int v[1100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		for(int i=0;i<a;i++){
			scanf("%s%s%s",in,ka[i],kb[i]);
			if(in[0]=='p')t[i]=1;
			else t[i]=0;
		}
		for(int i=0;i<b;i++)v[i]=0;
		for(int i=0;i<b;i++)scanf("%s%s%s",wa[i],wb[i],wn[i]);
		int ret=0;
		for(int i=0;i<b;i++){
			int c=0;
			for(int j=0;j<a;j++){
				bool ok1=true;
				bool ok2=true;
				for(int k=0;k<8;k++){
					if(ka[j][k]!='?'&&ka[j][k]!=wa[i][k])ok1=false;
					if(kb[j][k]!='?'&&kb[j][k]!=wb[i][k])ok2=false;
				}
				if(ok1&&ok2)c=t[j];
			}
			if(c){
				ret++;
				v[i]=1;
			}
		}
		printf("%d\n",ret);
		for(int i=0;i<b;i++)if(v[i])printf("%s %s %s\n",wa[i],wb[i],wn[i]);
	}
}

Measured memory_bytes: 1140
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int n;
char s[5001];

string get(string &s, int x) {
    int i;
    string t = "";
    
    for (i = x; i < n; i++) t += s[i];
    for (i = n - 1; i >= 0 && t.size() < n; i--) t += s[i];
    
    return t;
}

int main() {
    int k, i, j, l;
    char c = 'z';
    string ans;
    vector <string> v;
    
    scanf("%d %d", &n, &k);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) c = min(c, s[i]);
    
    k = min(k, 15);
    
    v.push_back(s);
    
    for (i = 0; i < k; i++) {
        vector <string> w;
        
        for (j = 0; j < v.size(); j++) {
            if (i == 0) {
                for (l = 0; l <= n; l++) w.push_back(get(v[j], l));
            } else if (i == k - 1) {
                int x = 0;
                
                for (l = n - 1; l >= 0; l--) {
                    if (v[j][l] != c) break;
                    x++;
                }
                
                w.push_back(get(v[j], n - x));
            } else {
                int x = 0;
                
                for (l = n - 1; l >= 0; l--) {
                    if (v[j][l] != c) break;
                    x++;
                }
                
                if (x > 0) w.push_back(get(v[j], min(x, n - x)));
            }
        }
        
        v = w;
    }
    
    ans = v[0];
    for (i = 1; i < v.size(); i++) ans = min(ans, v[i]);
    
    printf("%s\n", ans.c_str());
    
    return 0;
}


Measured memory_bytes: 79488
#include <stdio.h>

int main(void){
  double a[3][3];
  int i;

  for( ; ; ){
    for(i = 0; i < 6; ++i){
      if(scanf("%lf", &a[i / 3][i % 3]) == EOF){
          return 0;
      }
    }
    for(i=2; i >= 0; --i){
      a[0][i] /= a[0][0];
      a[1][i] -= a[0][i] * a[1][0];
    }
    for(i=2; i >= 1; --i){
      a[1][i] /= a[1][1];
      a[0][i] -= a[1][i] * a[0][1];
    }
    printf("%.3lf %.3lf\n", a[0][2], a[1][2]);
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

ll xorSum(const ll &a) {
     ll ret[] = { a, 1, a + 1, 0 };
	 
     return ret[a % 4];
}

ll xorSumRange(const ll &a, const ll &b) {
     return xorSum(b) ^ xorSum(a - 1);
}

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll a, b;

	cin >> a >> b;

	if (a == 0) Out(xorSum(b));
  	else Out(xorSumRange(a, b));
	
	return 0;
}


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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	int n;
	cin >> n;
	cout << 1000 * ((n + 1000 - 1) / 1000) - n << endl;
	return 0;
}

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

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

  string ans;
  int index_a = 200010, index_z = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A') {
      index_a = min(index_a, i);
    }

    if(s[i] == 'Z') {
      index_z = max(index_z, i);
    }
  }

  cout << index_z - index_a + 1 << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    string S;
    cin >> S;
    int N = S.size();
    int ori = 0;
    rep(i,N){
        if (S[i]=='p'){
            ori--;
        }
    }
    cout << ori + N / 2 << endl;
}


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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a;
	cin >> a;
	cout << a * 800 - a / 15 * 200 << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
	int n;
	ll t[100100];
	ll a[100100];
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> t[i] >> a[i];
	}

	for (int i = 1; i < n; ++i)
	 {
	 	ll tmp_t = t[i];
	 	ll tmp_a = a[i];
	 	if(t[i-1] > t[i] || a[i-1] > a[i]){
	 		ll tmp_mul = max( (t[i-1] - 1)/ t[i] + 1, (a[i-1] - 1) / a[i] + 1);
	 		// if( (tmp_mul * t[i] == t[i-1] && tmp_mul * a[i] > a[i-1] ) || (tmp_mul * a[i] == a[i-1] && tmp_mul * t[i] > t[i-1])  ){
	 		// 	tmp_mul--;
	 		// }

	 		// tmp_mul++;
	 		t[i] *= tmp_mul;
	 		a[i] *= tmp_mul;
	 		// cout << "tmp_mul " << tmp_mul << "  ";
	 	}
	 	// cout << t[i] << " " << a[i] << "　i番目 " << i <<endl;
	 }

	 cout << t[n-1] + a[n-1] << endl;

}


Measured memory_bytes: 256
using System;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var cost = 700;
            for (int i = 0; i < 3; i++)
            {
                if (input[i] == 'o')
                {
                    cost += 100;
                }
            }
            Console.WriteLine(cost);
        }
    }
}


Measured memory_bytes: 25900
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,w1="Sunny",w2="Cloudy",w3="Rainy";
	cin>>s;
	if(s==w1)
	{
		cout<<"Cloudy"<<endl;
	}
	else if(s==w2)
	{
		cout<<"Rainy"<<endl;
	}
	else if(s==w3)
	{
		cout<<"Sunny"<<endl;
	}
}

Measured memory_bytes: 768
#include <stdio.h>
#include<stdlib.h>

int main(void){
  int al=0;
   int bb=0;
  int n=0;
   int A[105];
  
  scanf("%d", &n);
  
  for(int i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  for(int j=0;j<n;j++){
    for(int l=j+1;l<n;l++){
      if(A[j]<A[l]){
        int temp = A[j];
        A[j] = A[l];
        A[l] = temp;
      }
    }
  }
  
  for(int i=0;i<n;i++){ 
      //printf("%d", A[i]);

    if(i%2==0){
      
      //a += A[i];
      al += A[i];
    }else bb += A[i];
  }
  
  printf("%d", (al-bb));
  return 0;
}
  
  
  

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int A, B;
  cin >> A >> B;
  if ((B/A) * A == B) cout << B + A << endl;
  else cout << B - A << endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;

  vector<string> vec(h);
  for (int i = 0; i < h; i++)
  {
    cin >> vec[i];
  }

  int dx[8] = {-1,-1,-1,0,0,1,1,1};
  int dy[8] = {-1,0,1,-1,1,-1,0,1};
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if(vec[i][j]=='.'){
        int cnt = 0;
        for (int k = 0; k < 8; k++)
        {
          int y = i+dy[k];
          int x = j+dx[k];

          if(y<0 || y>=h || x<0 || x>=w) continue;
          if(vec[y][x]=='#') cnt++;
        }
        vec[i][j]=cnt+'0';
      }
    }
  }

  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << vec[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(ll i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    bool used[1000001];
    fill(used,used+1000001,false);
    ll cnt[1000001];
    fill(cnt,cnt+1000001,0);
    vector<ll> v;
    rep(i,2,1000001){
        if(used[i])continue;
        v.push_back(i);
        for(ll j=i;j<=1000000;j+=i)used[j]=true;
    }
    rep(i,0,n){
        ll y=a[i];
        for(ll j=0;v[j]*v[j]<=y;j++){
            ll su=0;
            while(y%v[j]==0){
                su++;
                y/=v[j];
            }
            cnt[v[j]]=max(cnt[v[j]],su);
        }
        if(y!=1)cnt[y]=max(cnt[y],(ll)1);
    }
    ll ans=0;
    ll r=1;
    rep(i,0,v.size()){
        r*=beki(v[i],cnt[v[i]],mod);
        r%=mod;
    }
    rep(i,0,n){
        ll tt=r*gyaku(a[i],mod);
        tt%=mod;
        ans+=tt;
        ans%=mod;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 10360
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
const int MOD=1e9+7;
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;
const int MAX=500005;
ll ar[MAX],br[MAX];
const int M=1e4;
ll cnt[M];
int main()
{
    ll n;
    cin>>n;
    vector<int>pl(n),mn(n);
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        pl[i]=x+y;
        mn[i]=x-y;
    }
    sort(pl.begin(),pl.end());
    sort(mn.begin(),mn.end());
    cout<<max(pl[n-1]-pl[0],mn[n-1]-mn[0]);
}




Measured memory_bytes: 4840
from collections import OrderedDict

s = input()
t = input()

ds= OrderedDict()
dt= OrderedDict()

for i,(si,ti) in enumerate(zip(s,t)):
  if si in ds:
    ds[si].append(i)
  else:
    ds[si] = [i]
    
  if ti in dt:
    dt[ti].append(i)
  else:
    dt[ti] = [i]
    
ans = 'Yes'
for si,ti in zip(ds.values(),dt.values()):
  if si != ti:
    ans ='No'  
    
print(ans)     

Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
double dp[N][N];
int n;double d[N];
double ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>d[i];
	}
	dp[0][0]=1;
	dp[1][1]=d[1];
	dp[1][0]=(double)1-d[1];
	for(int i=2;i<=n;i++)
	{
		if(i!=1)dp[i][0]=dp[i-1][0]*(1-d[i]);
		for(int j=1;j<=i;j++)
		{
			if(i==1&&j==1)continue;
			dp[i][j]=dp[i-1][j]*((double)1-d[i])+dp[i-1][j-1]*d[i];
		}
	}
	double sum=0;
	for(int i=0;i<=n;i++)sum+=dp[n][i];
	for(int i=n/2+1;i<=n;i++)
	{
		ans+=dp[n][i];
	}
	printf("%.10f",ans);
	return 0;
}

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

#define printl(s) cout << s << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using vvs = vector<vector<string>>;

const ll modSeed = pow(10,9) + 7;
const int INF = 1'000'000'000;

template <typename T>
vector<T> getVector(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
ll N,ans;

int main(){
  ans = 0;
  cin >> N;
  vvs names(5);
  string tgt = "MARCH";
  rep(i,N){
    string name;
    cin >> name;
    rep(j,5){
      if(name[0]==tgt[j]){
        names[j].push_back(name);
      }
    }
  }

  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int h=j+1;h<5;h++){
        ans += names[i].size()*names[j].size()*names[h].size();
      }
    }
  }
  printl(ans);
}


Measured memory_bytes: 7332
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
#define w(x) int x; cin>>x; while(x--)

#include "bits/stdc++.h" 
using namespace std; 
  
#define MAXN   1000001 
  
int spf[MAXN]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 

        spf[i] = i; 

    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

long long int getFactorization(int x) 
{ 
    map<int , int> map;
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        map[spf[x]]++;
        x = x / spf[x]; 
    } 
    long long int ans=1; 
    for(auto i: map)
    {
        int x=i.first;
        int y=i.second;
        //cout<<x<<" "<<y<<" "
        ans*=(y+1);
    }
    return ans;
} 

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
long long int n,ans=0;
cin>>n;
for(int i=1;i<=n-1;i++)
{
    if(i==n-1)
        ans++;
    else
    {    
        int x=getFactorization(n-i);
        // if(x%2==1)
        // {
        //     ans--;
        // }
        ans+=x;
    }
}
cout<<ans;
}

Measured memory_bytes: 7552
#include<stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int main() {
  int i, k;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }

  int right;
  int sum[MAX_V+1] = {0};
  sum[1] = 0;
  for(i = 1; i < MAX_V+1; i++){
    if(prime[i] == 1){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  while(scanf("%d", &right) != EOF){
    printf("%d\n", sum[right + 1]);
  }
  return 0;
}

Measured memory_bytes: 8840
# coding: utf-8
# Your code here!

try:
   while True:
      cards = input()
      if cards == "-": break
      m = int(input()) #シャッフルの回数
      
      for i in range(m):
         h = int(input()) #シャッフルするカードの枚数
         neworder = cards[h:len(cards)]
         #print("#1", neworder)
         for j in range(h):
            #print("+", cards[j])
            neworder += cards[j]
            #print("#", neworder)
         cards = neworder
         #print("#2", cards)
   
      print(cards)

except EOFError:
   pass



Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int xi = sc.nextInt();

		for (int i = 1; i <= 10; i++) {
			System.out.println(xi = r * xi - D);
		}
	}
}

Measured memory_bytes: 21716
N = int(input())
list = []
for i in range(N):
    input_list = input()
    S = input_list.split(" ")[0]
    P = int(input_list.split(" ")[1])
    list.append([i, S, P])

#from operator import itemgetter

list.sort(key=lambda x: x[2] ,reverse=True)
list.sort(key=lambda x: x[1])
for i in range(N):
    print(list[i][0]+1)


Measured memory_bytes: 3060
class DisjointSet:
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if self.rank[xRoot] > self.rank[yRoot]:
            self.parent[yRoot] = xRoot
        elif self.rank[xRoot] < self.rank[yRoot]:
            self.parent[xRoot] = yRoot
        elif xRoot != yRoot:
            self.parent[yRoot] = xRoot
            self.rank[xRoot] += 1
        # print(x, y, xRoot, yRoot, self.parent)

    def num_disjoint_set(self):
        return len(set([self.find(i) for i in range(n)]))


n, m = map(int, input().split())
g = [(map(int, input().split())) for _ in range(m)]

dset = DisjointSet(n)

for x, y, _ in g:
    dset.union(x - 1, y - 1)

print(dset.num_disjoint_set())


Measured memory_bytes: 58664
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = getInt()
	}
	ans := 0
	for i := 0; i < N; i++ {
		d0 := asub(x[i], K)
		d1 := x[i]
		if d0 > d1 {
			ans += d1 * 2
		} else {
			ans += d0 * 2
		}
	}
	out(ans)
}


Measured memory_bytes: 640
require 'pp'

n = gets.to_i
chs = gets.chomp!.chars

head = 0
tail = chs.length - 1
count = 0
while head < tail
    # 左からwを探す
    while head < tail
        if chs[head] == "W"
            break
        end
        head += 1
        #pp head
    end

    while tail > head
        if chs[tail] == "R"
            break
        end
        tail -= 1

        #pp tail
    end

    #pp "======"
    #pp head
    #pp tail 

    break if head >= tail

    chs[head] = "R"
    chs[tail] = "W"
    #pp chs
    #head += 1
    #tail -= 1
    count += 1
end

puts count


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e7+5,mod=998244353;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
int fac[N*3],inv[N*3];
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=0;--i)
		inv[i]=inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	int n,A,B,ans=0,res;
	cin>>n>>A>>B;
	if(A==0 && B==0) return cout<<1,0;
	init(n+A+B);
	for(int k=0;k<=A && k+B<=n;++k){
		res=C(B+k-1,k)+(mod-C(B+k-1,k-1))%mod; res%=mod;
		if(k+B==n){
			if(k==A) add(ans,res);
		}
		else add(ans,res*C(n-B-k-1+A-k,A-k)%mod);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 406932
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

void TorT()
{
  int N, A, B;
  cin >> N >> A >> B;
  if (N * A > B) cout << B << endl;
  else           cout << N * A << endl;
}

int main()
{
  TorT();
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]
dekai = 1000000007
"""
import sympy as sym

def Fib(n):
	x = sym.symbols('x',nonnegative=True,integer=True)
	Fib=1/sym.sqrt(5)*(((1+sym.sqrt(5))/2)**(n-1)-((1-sym.sqrt(5))/2)**(n-1))
	result=Fib.subs(x,n)
	result=result.evalf(int(n*3/14)+1)
	return int(result)


"""
def Fib(n):
	a,b = 0,1
	if n == 1:
		return a
	elif n == 2:
		return b
	else:
		for i in range(n-2):
			a,b = b,a+b
		return b
ans = 1

if M == 0:
	print(Fib(N+1-(-1))%dekai)
	exit()

for i in range(M+1):
	if i == 0:
		ans = (ans*(Fib(a[0]-(-1))%dekai))%dekai
	elif i == M:
		ans = (ans*(Fib(N+1-a[M-1])%dekai))%dekai
	else:
		ans = (ans*(Fib(a[i]-a[i-1])%dekai))%dekai
print(ans)

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    string s;
    cin >> s;
    ll f1 = 0, f2 = 0, f3 = 0, f4 = 0;
    if (s.size() >= 6) f1++;
    rep(i, s.size()) {
        ll a = s.at(i)-'0', b = s.at(i)-'A', c = s.at(i)-'a';
        if (0<=a && a<10) f2++;
        if (0<=b && b<26) f3++;
        if (0<=c && c<26) f4++;
    }
    if (f1*f2*f3*f4 > 0) {
        cout << "VALID" << endl;
    } else {
        cout << "INVALID" << endl;
    }
}


Measured memory_bytes: 3216
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
    int cur = 0;
    F0R(i, N) {
        int X; cin >> X;
        if (X == cur+1) cur++;
    }
    if (cur == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << N-cur << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    A=LI()
    ans = 0
    need = sum(A)
    for a in A:
        if(need<=4*M*a):
            ans += 1
    if(ans>=M):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

int main() {
    int ans;
    rep(i, 5) {
        int x;
        cin >> x;
        if (x != i+1) ans = i+1;
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;
pair < int, pair < int, int > > a[400000];
int t[400000];
int m;
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += t[r];
	return result;
}

void inc (int i, int delta)
{
	for (; i < m + 1; i = (i | (i+1)))
		t[i] += delta;
}

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //  freopen("input.txt", "r", stdin);
    int n;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> a[i].S.F >> a[i].S.S;
        a[i].F = a[i].S.S - a[i].S.F + 1;
    }
    sort(a, a + n);
    int l = 0;
    for (int i = 1; i <= m; i++){
        while(l < n && a[l].F < i){
            inc(a[l].S.S + 1, -1);
            inc(a[l].S.F, 1);
            l++;
        }
        int ans = 0;
        for (int j = 0; j <= m; j += i){
            ans += sum(j);
        }
        ans += n - l;
        cout << ans << endl;
    }
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define endl '\n'
using namespace std;
bool sv[1000002];
int f[1000002];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector<int> vec(n+1);
    int g;
    for(int i = 1; i <= n; i++){
        cin >> vec[i]; f[vec[i]]++;
        if(i == 1){
            g = vec[i]; continue;
        }
        g = __gcd(g, vec[i]);
    }
    if(g == 1){
        //int cnt = 0;
        bool ok = 1;
        for(int i = 2; i <= 1000000; i++){
            if(!sv[i]){
                int cnt = f[i];
                sv[i] = 1;
                for(int j = i+i; j <= 1000000; j += i){
                    sv[j] = 1; cnt += f[j];
                }
                if(cnt <= 1)continue;
                ok = 0; break;
            }
        }
        if(ok){
            cout << "pairwise coprime" << endl;
        }
        else{
            cout << "setwise coprime" << endl;
        }
    }
    else{
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 11848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll l,r,d;
  cin >> l >> r>>d;
  ll count = 0;
  for (ll i = l; i <= r; i++){
    if(i%d==0){
      count++;
    }
  }
  print(count);
}

Measured memory_bytes: 3628
import bisect
from collections import deque

N = int(input())

ans = deque([-1])
for _ in range(N):
    a = int(input())
    i = bisect.bisect_left(ans, a)
    if i == 0:
        ans.appendleft(a)
    else:
        ans[i-1] = a
print(len(ans))


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] AV = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long A = AV[0];
            long V = AV[1];
            long[] BW = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long B = BW[0];
            long W = BW[1];
            long T = long.Parse(Console.ReadLine());
            bool flag = false;
            if(A>B){
                if(-A+V*T>=-B+W*T){
                    flag = true;
                }
            }else{
                if(A+V*T>=B+W*T){
                    flag = true;
                }
            }
            Console.WriteLine(flag?"YES":"NO");
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27492
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,x,y;
    cin >> n >> k>>x>>y;
    ll ans=0;
    for (int i = 0; i < n; i++)
    {
        if(i<k){
            ans+=x;
        }
        else ans+=y;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(A) A.begin(),A.end()
using namespace std;
typedef long long ll;

int n;
vector<string> card;
vector<string> check;

string check_array(){
	string x[10],y[10];
	rep(i,10) x[i]=y[i]="";
	rep(i,n){
		x[check[i][1] - '0'] += check[i][0];
		y[card[i][1] - '0'] += card[i][0];
	}
	int ans = 1;
	rep(i,10) ans&=x[i]==y[i];
	string res = ans?"Stable":"Not stable";
	return res;
}

int main() {
	cin >> n;
	card.resize(n);
	rep(i,n) cin >> card[i];
	check.resize(n);
	rep(i,n) check[i] = card[i];
	
	
	rep(i,n){
		for(int j = n - 1; j >= i + 1; --j){
			if(card[j][1] < card[j - 1][1]){
				swap(card[j], card[j - 1]);
			}
		}
	}
	
	rep(i,n){
		if(i != n - 1) cout << card[i] << ' ';
		else cout << card[i] << endl;
	}
	cout << check_array() << endl;
	
	rep(i,n) card[i] = check[i];
	rep(i,n){
		int minj = i;
		for(int j = i;j < n; ++j){
			if(card[j][1] < card[minj][1]){
				minj = j;
			}
		}
		swap(card[i], card[minj]);
	}
	
	rep(i,n){
		if(i != n - 1) cout << card[i] << ' ';
		else cout << card[i] << endl;
	}
	cout << check_array() << endl;
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,n=0;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i < N; i++)
  {
    cin >> a.at(i);
  }
  for(int i=1; i <= N; i++)
  {
    if(i % 2 != 0 && a.at(i-1) % 2 != 0)
      n++;
  }
  cout << n;
  return 0;
}


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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : number( 0 ), count( 0 ), prev( NULL ), next( NULL ){}

	int number, count;
	tCell *prev, *next;
};

class Database{
public:
	Database() : size( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~Database(){
		init();
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = size; i > 0; --i ){
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
	}
	void store( int n ){
		bool stored = false;
		tCell* cell = head;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( cell->number == n ){
				++cell->count;
				stored = true;
				break;
			}
		}
		if ( !stored ){
			pushBack( n );
		}
	}
	void sort(){
		for ( int i = 0; i < size - 1; ++i ){
			tCell* cell = head;
			tCell* celln = head->next;
			for ( int j = 0; j < size - 1 - i; ++j ){
				cell = celln;
				celln = celln->next;
				if ( cell->number > celln->number ){
					int tn = cell->number;
					int tc = cell->count;
					cell->number = celln->number;
					cell->count = celln->count;
					celln->number = tn;
					celln->count = tc;
				}
			}
		}
	}
	void maxCount( Database& db ){
		int c = 0;
		tCell* cell = head;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( c < cell->count ) c = cell->count;
		}
		db.init();
		cell = head;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( cell->count == c ){
				db.store( cell->number );
			}
		}
	}
	int getSize(){ return size; }
	
	tCell operator[]( int n ){
		tCell* cell = head->next;
		if ( n >= size ){ cell = NULL; return *cell; }
		for ( int i = 0; i < n; ++i ){
			cell = cell->next;
		}
		return *cell;
	}

private:
	void pushBack( int n ){
		++size;
		tCell* cell = new tCell;
		cell->number = n;
		++cell->count;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}

	int size;
	tCell *head, *tail;
};

int main(){
	int n;
	Database db, result;

	while ( cin >> n ){
		db.store( n );
	}

	db.sort();
	db.maxCount( result );
	for ( int i = 0; i < result.getSize(); ++i ){
		cout << result[ i ].number << endl;
	}

	return 0;
}

Measured memory_bytes: 0