akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MN = 200200;
const int MM = MN*2;
int w[MM],x[MM];
vvi nx;
int bs[MM];
int main() {
	ios::sync_with_stdio(0);
	ll n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> w[i];
		w[i+n] = w[i];
	}
	nx.assign(MN,vi());
	for(int i=0;i<n*2;i++) {
		nx[w[i]].push_back(i);
	}
	for(int i=0;i<n;i++) {
		int val = w[i];
		int id = *upper_bound(nx[val].begin(),nx[val].end(),i);
		id++;
		bs[i] = id/n;
		id %= n;
		x[i] = id;
	}
	ll cl = bs[0];
	ll pt = x[0];
	while(pt != 0) {
		cl += bs[pt];
		pt = x[pt];
	}
	k %= cl;
	bitset<MM> bb;
	vi res;
	while(k) {
		if(bs[pt] >= k) {
			break;
		}
		k -= bs[pt];
		pt = x[pt];
	}
	while(k) {
		int val = w[pt];
		if(bb[val]) {
			while(bb[val]) {
				bb.reset(res.back());
				res.pop_back();
			}
		} else {
			bb.set(val);
			res.push_back(val);
		}
		pt++;
		if(pt >= n) {pt -= n;k--;}
	}
	for(int i=0;i<res.size();i++) {
		if(i > 0) {cout << " ";}
		cout << res[i];
	}
	cout << '\n';
}

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

using namespace std;

#define ll long long int
#define MOD 1000000007
#define mt make_tuple
#define eb emplace_back
#define error(args...){string _s = #args; replace(_s.begin(),_s.end(),',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args){cerr<<*it<<" = "<<a<<endl; err(++it,args...);}



int main()
{
	ll n;
	cin>>n;
	cout<<(n*2)/__gcd(n,2LL);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    std::cin >> a >> b >> c;
    bool x = true;
    int count = 0;
    while(true){
        if(x && c != 0){
            c--;
            count++;
            x = false;
            continue;
        }
        if(b != 0){
            b--;
            count++;
            x = true;
            continue;
        }
        if(b == 0 && c == 0){
            break;
        }
        if(a != 0){
            a--;
            x=true;
            continue;
        }
        break;
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

ans=remainder[0]
for i in range(2019):
  ans+=remainder[i]*(remainder[i]-1)//2
print(ans)


Measured memory_bytes: 9252
#include <cstdio>
#include <algorithm>
#include <vector>

int testcase() {
  unsigned N[8], C;
  for (int i=0; i<8; ++i)
    scanf("%x", &N[i]);

  scanf("%x", &C);

  unsigned K=0;
  for (int i=0; i<32; ++i) {
    unsigned cur=0;
    for (int j=0; j<8; ++j) {
      cur += N[j];
    }

    if ((cur>>i & 1) == (C>>i & 1)) continue;
    
    K |= 1u << i;
    for (int j=0; j<8; ++j) {
      N[j] ^= 1u << i;
    }
    C ^= 1u << i;
  }

  printf("%x\n", K);
  return 0;
}

int main() {
  int S;
  scanf("%d", &S);

  for (int i=0; i<S; ++i)
    testcase();

  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int K;
    cin >> K;

    queue<LL> Q;
    REP1 (i, 9)
    {
        Q.push(LL(i));
    }

    int cnt = 0;

    while (true)
    {
        cnt++;
        LL x = Q.front();
        Q.pop();

        if (cnt == K)
        {
            cout << x << endl;
            return;
        }

        if (x % 10 != 0)
            Q.push(10 * x + x % 10 - 1);

        Q.push(10 * x + x % 10);

        if (x % 10 != 9)
            Q.push(10 * x + x % 10 + 1);
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 1792
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y+=[c];X+=[a,b]
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X+=[a];Y+=[b,c]
def g(X):
 s=dict(enumerate(sorted(set(X))));K=len(s);h={s[i]:i for i in s}
 return s,K,h
s,K,h=g(X);t,L,w=g(Y);V=[[0]*(K+2)for i in r(L+2)];U=[i[:]for i in V];v=[i[:]for i in V]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L+1):
 for j in r(K+1):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

Measured memory_bytes: 551468
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k%2){
        cout << b-a << "\n";
    }else cout << a-b << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
int main()
{
    int s,w;
    scanf("%d %d",&s,&w);
    if(s>w)
    {
        printf("safe\n");
    }
    else
    {
        printf("unsafe\n");
    }
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

int main() {
    string s, t; cin >> s >> t;
    int n = s.size();
    if(s == t.substr(0,n)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long int
#define MO 1000000007

ll suum(ll a){
  ll ans=a*(a+1)/2;
  return ans;
}

int main(){
  ll n,k;
  scanf("%lld%lld",&n,&k);
  
  ll ans=0;
  for(int i=k;i<=n+1;i++){
    //ll mins = suum(i-1);
    //ll maxs = suum(n)-suum(n-k);
    //ll sa = maxs - mins;
    //sa +=1;
    //ans = (ans+sa)%MO;
    //printf("%lld %lld %lld\n",mins,maxs,sa);
    ans = (ans+(n+1-i)*i+1)%MO;
  }
  
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,i;
	long a[3];

	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[0];
		cin >> a[1];
		cin >> a[2];
		sort(a,a+3);
		if(a[2]*a[2] == a[1]*a[1]+a[0]*a[0])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		String ans ="";
		
		
		
		for (int i = 0; i < N; i++) {
			ans+="ACL";
		}
		
		System.out.println(ans);
 
		sc.close();
    }
}


Measured memory_bytes: 38684
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 1) {
			a = 14;
		}
		if (b == 1) {
			b = 14;
		}
		if (a > b) {
			System.out.println("Alice");
		}
		else {
			if (b > a) {
				System.out.println("Bob");
			}
			else {
				System.out.println("Draw");
			}
		}
	}
}
	

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

int main(){
  string s;
  cin >> s;
  int ans=1;
  int n=s.size();
  char c=s[0];
  for(int i=1;i<n;i++){
    if(s[i]==c||i==n-2&&s[i]==s[i+1]){
      i++; c='A';
    }
    else c=s[i];
    ans++;
    cerr << c << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

ll gcd(ll m, ll n){
    ll tmp;
    while(m%n){
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

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

    ll n, k;
    cin >> n >> k;
    
    ll g;
    cin >> g;
    ll mx = g;
    for(int i = 1; i < n; ++i){
        ll a;
        cin >> a;
        mx = max(mx, a);
        g = gcd(g, a);
    }

    if(k <= mx && k%g == 0) cout << "POSSIBLE" << endl;
    else  cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

int main()
{
    int n,k;
    string s;
    char ck;
    cin >> n >> s >> k;
    ck = s[k-1];
    for(int i=0;i<n;i++){
        if( s[i] != ck){
            s[i] = '*';
        }
    }
    cout << s;
}

Measured memory_bytes: 768
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << (a * 500 >= b ? "Yes": "No");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

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

	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	if (N == A.size())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll unsigned long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=1005;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll n,m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << E;
    r0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int a, b;
  vector<int> line(N);

  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    line.at(a - 1) += 1;
    line.at(b - 1) += 1;
  }

  for (int i = 0; i < line.size(); i++) cout << line.at(i) << endl;
}

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

int main(){
  int r=0,b=0,N; cin>>N;
  string s; cin>>s;
  for(int i=0;i<N;i++){
    if(s[i]=='R'){
      r++;
    }
    else{
      b++;
    }
  }
  if(r>b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
uint64_t gcd(uint64_t a, uint64_t b);
uint64_t lcm(uint64_t a, uint64_t b);

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  char C;
  cin >> C;

  cout << (char)(C + 1) << endl;

  return 0;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
//#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  int x,y; cin >> x >> y;
  int m = (x+y)/3;
  if((x+y)%3 != 0 || x < m || y < m){
    std::cout << 0 << '\n';
    return 0;
  }
  x -= m;
  COMinit();
  std::cout << COM(m,x) << '\n';
}


Measured memory_bytes: 25984
#include <iostream>
#include <cstdio>
#include <vector>

template <typename T> void in(T &_){
	char c=getchar(); _=0; int fl=1;
	while(c<'0'||c>'9') fl=c=='-'?-1:fl, c=getchar();
	while(c>='0'&&c<='9') _=_*10+c-'0', c=getchar(); _*=fl;
}
template <typename T, typename... A> void in(T &_, A &...a){in(_); in(a...);}

#define MOD 1000000007

int N, M, bit[1<<15], f[16][1<<15], g[16][1<<15], h[1<<15];
bool map[16][16];

int ksm(int x, int y){
	int z=1;
	for(; y; y>>=1, x=1LL*x*x%MOD) if(y&1) z=1LL*z*x%MOD;
	return z;
}

void print(int x){
	for(int i=0; i<N; i++)
		putchar('0'+((x>>i)&1)); 
}

int lowbit(int x){return (x&(-x));}

int main(){
	for(int i=0; i<15; i++) bit[1<<i]=i+1;
	in(N, M);
	for(int x, y, i=1; i<=M; i++){
		in(x); in(y);
		map[x][y]=true;
	}
	for(int i=1; i<=N; i++)
		for(int j=0; j<(1<<N); j++)
			f[i][j]=f[i][j-lowbit(j)]+map[i][bit[lowbit(j)]];
	for(int i=1; i<=N; i++)
		for(int j=0; j<(1<<N); j++)
			g[i][j]=ksm(2, f[i][j])-1;	
//			if(map[i][bit[lowbit(j)]]) g[i][j]=(g[i][j-lowbit(j)]<<1|1)%MOD;
//			else g[i][j]=g[i][j-lowbit(j)];
	for(int i=0; i<(1<<N); i++){
		h[i]=1;
		for(int j=i&(i-1); j; j=i&(j-1))
			if(((j&1)^((j&2)>>1))==0 && (((i^j)&1)^(((i^j)&2)>>1))==0){
				int tmp=h[i^j];
				for(int k=j; k; k-=lowbit(k)) 
					tmp=1LL*tmp*ksm(2, f[bit[lowbit(k)]][i^j])%MOD;
				for(int k=i^j; k; k-=lowbit(k))
					tmp=1LL*tmp*(ksm(2, f[bit[lowbit(k)]][j])-1)%MOD;
				h[i]=(h[i]+tmp)%MOD;
			}
	}
	printf("%d\n", (ksm(2, M)-h[(1<<N)-1]+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
const long long INF = __LONG_LONG_MAX__;

using namespace std;

bool is_second(int a, int x, int b) {
    if (a >= x && b <= x) {
        return true;
    } else if (a <= x && b >= x) {
        return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int count = 0;

    for (int i = 0; i < n-2; i++) {
        if(is_second(p[i], p[i+1], p[i+2])) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

int main(){
	int q;
	cin>>q;
	ll a[q],sum=0,sum1=0,sum2=0;
	for(int i=0;i<q;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll t=1000000000000,ans=0;
	
	for(int i=0;i<q-1;i++){
		sum1=sum1+a[i];
		ans=sum-sum1*2;
		ans=abs(ans);
		if(t>ans){
			t=ans;
		}
	}
	cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			int k = sc.nextInt();

			if (k == 1) {
				System.out.println(0);
			} else {
				System.out.println(n - k);
			}
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 1000000009;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  int ans = INF;
  // 横に切る方法を全探索
  for (int bit = 0; bit < (1 << (h-1)); bit++) {
    int cur = 0; // cur: 切った回数
    for (int i = 0; i < (h-1); i++) { if ((bit >> i) & 1) { cur++; } } // 立っているbitの数を数える
    int block_size = cur + 1;
    vector<int> block(block_size, 0); // 各ブロック内のホワイトチョコの数. ブロックの数は 切った回数+1
    // 横方向について全探索
    for (int i = 0; i < w; i++) {
      int block_id = 0;
      for (int j = 0; j < h; j++) {
        block[block_id] += (s[j][i] == '1');
        block_id += ( (bit >> j) & 1 );
      }
      bool is_ok = (*max_element(block.begin(), block.end()) <= k);
      if (!is_ok) {
        cur++;
        fill(block.begin(), block.end(), 0);
        block_id = 0;
        for (int j = 0; j < h; j++) {
          block[block_id] += (s[j][i] == '1');
          block_id += ( (bit >> j) & 1 );
        }
      }
      if (*max_element(block.begin(), block.end()) > k) { cur = INF; break; }
    }
    ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



const int max_comb=2000000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

char str[1000005];

void solve()
{
    pre_comb();
    int K;
    scanf("%d%s", &K, str);
    int n = strlen(str);
    ll ans = 0;
    int i;
    for (i = 0; i <= K; i++) {
        ll ans0 = mpow(26, i);
        ll ans1 = mpow(25, K - i) * comb(K - i + n - 1, n - 1) % MOD;
        ans0 = ans0 * ans1 %MOD;
        ans = (ans + ans0) % MOD;
    }
    printf("%lld\n", ans);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 35008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int c[100000] = {};
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        c[a]++;
        c[b]++;
    }

    for (int i = 0; i < n; i++) {
        if (c[i] % 2 != 0) {
            cout << "NO" << endl;
            quick_exit(0);
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
    int n,t,x,y,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

#define ll long long int

const int MAXK = 10005;
const int MAXD = 105;

ll d, dp[MAXK][MAXD][2][2], mod = 1e9 + 7;
string a, b;

ll rec(ll pos, ll rem, bool flag1, bool flag2)
{
	if(dp[pos][rem][flag1][flag2] != -1) return dp[pos][rem][flag1][flag2];
	if(pos == a.length()) return !rem;
	ll ans = 0, start1 = 0, end1 = 9;
	if(!flag1) start1 = a[pos] - '0';
	if(!flag2) end1 = b[pos] - '0';
	for(int i=start1;i<=end1;i++)
	{
		ans = (ans + rec(pos + 1, (rem + i) % d, (flag1 | i > start1), (flag2 | i < end1))) % mod;
	}
	return dp[pos][rem][flag1][flag2] = ans;
}

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

	cin >> b >> d;
	a = "";
	for(int i=0;i<b.length() - 1;i++) a += '0';
	a += '1'; 
	memset(dp, -1, sizeof(dp));
	cout << rec(0, 0, 0, 0) << endl;
    return 0;
}  

Measured memory_bytes: 34176
def main(): 
    
    N = int(input())

    SP = [input().split() for _ in range(N)]

    for i in range(N):
        SP[i][1] = int(SP[i][1])
        SP[i].append(i+1)

    SP.sort(key = lambda x:(x[0], -x[1]))

    for i in range(N):
        print(SP[i][2])
    


if __name__ == "__main__":
    main() 

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

int cnt,n,s;

void dfs(int i,int sum,int n){
  if( sum == s && n == 0 ){
    cnt++;
    return;
  } 
  if( i == 10 || n == 0 ) return;
  dfs(i+1 , sum , n);
  dfs(i+1, sum + i , n-1);
}

int main(){
  while( cin >> n >> s ){
    cnt = 0;
    if( n == 0 && s == 0 ) break;
    dfs(0,0,n);
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<queue>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;

//マクロ
#define H_M 62
#define W_M 13
#define NONE '.'
#define bp(x) block[(x)].h][block[(x)].w
#define bw(x) block[(x)].w
#define bh(x) block[(x)].h

struct P{ int h, w; };
bool judge(const P l, const P r){ return(l.w < r.w); }

//グローバル
int H, W;
char tower[H_M][W_M];
bool used[H_M][W_M];
const P dir[4] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };

//重心が両端の内側にあればfalse
bool calc_weight(int block[],int left,int right){
	double a=0,b = 0;
	rep(i, 0, W_M){
		double x = (double)i + 0.5;
		b += x*block[i];
		a += block[i];
	}
	//cout << b << '/' << a << "=";
	b /= a;
	//cout << b << endl;
	return !((double)left < b&&b < (double)right);
}

//同色判定したブロックをblockに格納 
void bfs(P s, char color,P *block){
	int n = 0;
	queue<P> que;
	que.push(s);
	while (!que.empty()){
		s = que.front(); que.pop();
		if (used[s.h][s.w] == true)continue;
		//cout << "n=" << n << endl;
		used[s.h][s.w] = true;
		block[n++] = s;
		rep(i, 0, 4){
			P p; p.h = s.h + dir[i].h, p.w = s.w + dir[i].w;
			//printf("p:%d,%d|%c\n", p.h, p.w,color);
			if (tower[p.h][p.w] == color&&used[p.h][p.w] == false)
				que.push(p);
		}
	}
	
	sort(block, block + 4, judge);
	return;
}

bool solve(P *block,int *b_num){
	char color = tower[bp(0)];
	char under;
	int left,right,tmp;
//	rep(j, 0, 4)printf("%d,%d|%c\n", bh(j), bw(j), color);
	rep(i, 0, 4)
	if (tower[bh(i) - 1][bw(i)] != color&&tower[bh(i) - 1][bw(i)] != NONE){
		under = tower[bh(i) - 1][bw(i)];
		left = bw(i);
		tmp = i;
		break;
	}
	rep(i, tmp, 4)
	if (tower[bh(i) - 1][bw(i)] == under)right = bw(i) + 1;
	//printf("l=%d,r=%d,now=%c,under=%c\n", left, right, color, under);

	//ここまでデッドライン決め
	P bk[4][4] = { { 0, 0 } };
	
	int block_size = 0;
	rep(i, 0, 4)if (used[bh(i) + 1][bw(i)] == false && tower[bh(i) + 1][bw(i)] != NONE){
		P p = { bh(i) + 1, bw(i) };
		bfs(p, tower[bh(i) + 1][bw(i)], bk[block_size]);
		int x[W_M] = { 0 };
		if (solve(bk[block_size], x))return true;
		block_size++;
		rep(j, 0, W_M)b_num[j] += x[j];
	}
	
	rep(i, 0, 4)b_num[bw(i)]++;
	return(calc_weight(b_num, left, right));

	
}

int main(void){
	while (true){
		cin >> W >> H;
		if (W == 0)return(0);
		memset(used, 0, sizeof(used));
		rep(i, 0, W + 2)tower[0][i] ='0', tower[H + 1][i] = NONE;
		rep(i, 0, H){
			tower[i+1][0] = tower[i + 1][W + 1] = NONE;
			rep(j, 0, W)cin >> tower[H - i][j + 1];
		}
		/*rep(i, 0, H + 2){
			rep(j, 0, W + 2)
				cout << tower[i][j];
				cout << endl;
		}*/
		rep(i, 0, W + 2)if (tower[1][i] != NONE){
			P s = { 1, i };
			P block[4] = { { 0, 0 } };
			bfs(s, tower[1][i], block);
			int x[W_M] = { 0 };
			if(solve(block,x))puts("UNSTABLE");
			else puts("STABLE");
		break;
		}
	}
}

Measured memory_bytes: 1180
using System;

public class Test
{
	static public void Main( )
	{
		String[] line = Console.ReadLine().Split( ' ' );
		var a = int.Parse( line[0] );
		var b = int.Parse( line[1] );
		Console.WriteLine( "{0} {1}", a*b, (a+b)*2 );
		
	}
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  ll n,k;  cin >> n >> k;
  vector<ll> v(k, 0);
  rep(i,1,n+1){
    v[i%k]++;
  }
  ll res=0;
  rep(a, 0, k){
    ll b = (k-a)%k;
    ll c = (k-a)%k;
    if((b+c)%k==0){
      res += v[a]*v[b]*v[c];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=0;
	if(k>=a)
	{
		sum+=a;
		k=k-a;
	}
	else
	{
		sum+=k;
		k=0;
	}
	if(k>=b)
	k=k-b;
	else
	k=0;
	if(k>=c)
	{
		sum-=c;
		k=k-c;
	}
	else
	{
		sum-=k;
		k=0;
	}
	
		cout<<sum<<endl;

}




Measured memory_bytes: 3636
s=input()

flag=True
KIHBR="KIHBR"
s_new=s.replace("A", "")
if len(s_new)!=5:
    flag=False
else:
    for i in range(5):
        if s_new[i]!=KIHBR[i]:
            flag=False
            break

if s.count("AA")>0 or s.count("KIH")!=1:
    flag=False

print("YES" if flag else "NO")


Measured memory_bytes: 9104
package main

import "fmt"

func main() {
	var N, cnt int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < N; i++ {
		if a[i] != (i + 1) {
			cnt++
		}
	}
	if cnt > 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
  	string s;
  	cin>>s;
  	int q,count=0;
  	cin>>q;
  	while(q--)
    {
      	int t;
      	cin>>t;
      	if(t==1)
          	count++;
     	else
        {
          int f;
          cin>>f;
          string c;
          cin>>c;
          if(f==1)
          {
            if(count%2==0)
                  s.insert(0,c);
            	else
                  s+=c;
          }
          else
          {
            	if(count%2==0)
              	s+=c;
            else
            	s.insert(0,c);
          }
        }
    }
  		if(count%2==0)
          cout<<s;
  		else
        {
          reverse(s.begin(),s.end());
  			cout<<s;
        }
}


Measured memory_bytes: 912
import sys
input=sys.stdin.readline

h,n=map(int,input().split())
inf=float("inf")

DP=[inf]*(h+1)
DP[0]=0
for i in range(n):
  a,b=map(int,input().split())
  for j in range(h+1):
    DP[min(h,j+a)]=min(DP[j]+b,DP[min(h,j+a)])
print(DP[h])


Measured memory_bytes: 50780
#include <cstdio>
#include <iostream>
#include <algorithm>


using namespace std;

int main(){
	int n, k, c = 0, an, i;
	char s[100005] = { '\0' };
	
	cin >> n >> k;
	for (i = 0; i < n; i++){
		cin >> s[i];
	}
	int count = 0;
	i = 0;
	if (s[i] == 'R'&&s[i + 1] == 'R') count++;
	for (i = 1; i < n - 1; i++){
		if (s[i] == 'L'&&s[i - 1] == 'L') count++;
		if (s[i] == 'R'&&s[i + 1] == 'R') count++;
	}
	if (s[i] == 'L'&&s[i - 1] == 'L') count++;
//	for(i = 0; i < n-1; i++){
//		if (s[i] != s[i + 1]) c++;
//	}
//	cout << count << endl;
	an = min((count + 2 * k), (n - 1));
	cout << an;
	system("pause");
	return 0;
}

Measured memory_bytes: 512
N, M, L = map(int, input().split())
INF = 10 ** 12

G = [[INF] * (N+1) for _ in range(N+1)]

for _ in range(M):
    a, b, c = map(int, input().split())
    G[a][b] = c
    G[b][a] = c


for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

GL = [[INF] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        if G[i][j] <= L:
            GL[i][j] = 1
            GL[j][i] = 1

for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            GL[i][j] = min(GL[i][j], GL[i][k] + GL[k][j])

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = GL[s][t]
    if ans == INF:
        print(-1)
    else:
        print(ans-1)




Measured memory_bytes: 60376
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 1000000;
  for(int i = 0; i < n; i++){
    int x = a[i], sum = 0;
    while(x % 2 == 0){
      x /= 2;
      sum++;
    }
    ans = min(sum, ans);
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int[] enn = {300000,200000,100000};
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		if(x == 1 && y == 1){
			System.out.println(1000000);
		} else if(x <= 3 && y <= 3){
			System.out.println(enn[x-1] + enn[y-1]);
		} else if(x <= 3 ){
			System.out.println(enn[x-1]);
		} else if(y <= 3){
			System.out.println(enn[y-1]);
		} else {
			System.out.println(0);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
#include <iostream>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<int, ll> pi;

#define maxN 100010

ll cache[maxN][3];
int n;
int a[maxN], b[maxN], c[maxN];

ll max(ll a, ll b, ll c) {
    return max(a, max(b, c));
}

ll dp(int i, int prev);

ll getValue(int i, int ci) {
    if (ci == 0) return a[i];
    if (ci == 1) return b[i];
    if (ci == 2) return c[i];
    return 0;
}

pi getMax(int i, int prev) {
    ll best = -1;
    int choice = -1;
    for (int c = 0; c<3; c++) {
        if (c == prev) continue;
        ll v = getValue(i, c) + dp(i+1, c);
        if (v > best) {
            best = v;
            choice = c;
        }
    }
    return make_pair(choice, best);
}

ll dp(int i, int prev) {
    if (i >= n) return 0;
    if (prev != -1 && cache[i][prev] != -1) return cache[i][prev];
    pi p = getMax(i, prev);
    return cache[i][prev] = p.second;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i<n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        cache[i][0] = -1;
        cache[i][1] = -1;
        cache[i][2] = -1;
    }
    cout << dp(0, -1) << endl;
    return 0;
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"
const int mod = (1e9) + 7;
vector<vector<int>> power(500, vector<int>(500, 1));

void preprocess() {
    for(int i = 1; i < 500; i ++) {
        for(int j = 1; j < 500; j ++) {
            power[i][j] = power[i][j-1] * i;
            power[i][j] %= mod;
        }
    }
    for(int i = 0; i < 500; i ++) {
        for(int j = 1; j < 500; j ++) {
            power[j][i] += power[j-1][i];
            power[j][i] %= mod;
        }
    }
}

void solve() {
    int n, c; cin >> n >> c;
    vector<int> arr(n, 0);
    vector<int> brr(n, 0);
    for(int i = 0; i < n; i ++)
        cin >> arr[i];
    for (int i = 0; i < n; i++)
        cin >> brr[i];
    preprocess();
    vector<vector<int>> dp(n+1, vector<int>(c + 1, 0));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i ++) {
        for(int j = 0; j <= c; j ++) {
            int ans = 0;
            for(int k = 0; k <= j; k ++) {
                ans += (dp[i-1][k] * (power[brr[i - 1]][j-k] - power[arr[i-1] - 1][j-k]))%mod;
                ans = ((ans%mod) + mod)%mod;
            }
            dp[i][j] = ans;
        }
    }
    // cout << dp << endl;
    cout << dp[n][c]%mod << endl;
}   


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;

int n, H, W;
vector<int> g[maxn];

int main() {
	scanf("%d%d%d", &H, &W, &n);
	for(int i = 1;i <= n;i ++) {
	  int x, y;
		scanf("%d%d", &x, &y);
    g[y].push_back(x);
	}
	for(int i = 1;i <= W;i ++) {
	  g[i].push_back(0);
		g[i].push_back(H + 1);
		sort(g[i].begin(),g[i].end());
	}
  //1
	int Ans = H, Sz, lst = -1;
	Sz = g[1].size();
	for(int i = 0;i < Sz;i ++) {
	  int x = g[1][i];
		if(x > 1) {
			Ans = min(Ans,x - 1);
			/*
			if(x - g[1][i - 1] > 1 && lst == -1) {
			  if(g[1][i - 1] > 1) lst = g[1][i - 1] + 1;
				else lst = 2;
			}
			*/
		}
	}
	lst = 2;
	for(int i = 2;i <= W;i ++) {
	  int Sz = g[i].size();
		for(int j = 0;j < Sz;j ++) {
		  int x = g[i][j];
			if(x <= i || x <= lst) continue;
      if(x - g[i][j - 1] > 1) {
				Ans = min(Ans,x - 1);
			  break;
			}
		}
		int flag = 0;
		for(int j = 0;j < Sz;j ++) {
		  int x = g[i][j];
			if(x <= lst + 1) continue;
      if(x - g[i][j - 1] > 1) {
			  int tmp = max(lst,g[i][j - 1] + 1);
				tmp ++; //tmp ++;
				lst = tmp;
//				cout << lst << ' ' << i << endl;
				flag = 1;
				break;
			}
		}
		if(!flag) lst = H + 5;
	}
	printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x>=400 && x<600)cout<<"8"<<endl;
    else if(x>=600 && x<800)cout<<"7"<<endl;
    else if(x>=800 && x<1000)cout<<"6"<<endl;
    else if(x>=1000 && x<1200)cout<<"5"<<endl;
    else if(x>=1200 && x<1400)cout<<"4"<<endl;
    else if(x>=1400 && x<1600)cout<<"3"<<endl;
    else if(x>=1600 && x<1800)cout<<"2"<<endl;
    else if(x>=1800 && x<2000)cout<<"1"<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a==b) cout<<"Yes"<<endl;
        else if((a==4 || a==6 || a==9 || a==11) && (a==b || b==6 || b==9 || b==11))
            cout<<"Yes"<<endl;
        else if((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12) && (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12))
            cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

int main()
{
  i64 h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (i64 i = 0; i < h; i++)
    cin >> s[i];
  vector<vector<i64>> ans(h, vector<i64>(w, -1));
  i64 cnt = 0;
  i64 b = -1;
  for (i64 i = 0; i < h; i++)
    for (i64 j = 0; j < w; j++)
      if (b == -1 && s[i][j] == '#')
        b = i;
  for (i64 i = 0; i < w; i++)
  {
    if (s[b][i] == '#')
      cnt++;
    ans[b][i] = (cnt == 0 ? cnt + 1 : cnt);
  }
  for (i64 i = b + 1; i < h; i++)
  {
    bool ok = true;
    for (i64 j = 0; j < w; j++)
      if (s[i][j] == '#')
        ok = false;
    if (ok)
    {
      for (i64 j = 0; j < w; j++)
        ans[i][j] = ans[i - 1][j];
    }
    else
    {
      i64 t = 0;
      for (i64 j = 0; j < w; j++)
      {
        if (s[i][j] == '#')
          t++;
        ans[i][j] = (t == 0 ? cnt + 1 : cnt + t);
      }
      cnt += t;
    }
  }
  for (i64 i = 0; i < b; i++)
    for (i64 j = 0; j < w; j++)
      cout << ans[b][j] << (j + 1 == w ? "\n" : " ");
  for (i64 i = b; i < h; i++)
    for (i64 j = 0; j < w; j++)
      cout << ans[i][j] << (j + 1 == w ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 1664
N,M = map(int, input().split())

islands = {}
for i in range(M):
    a,b = map(int, input().split())
    if a not in islands:
        islands[a] = {}
    if b not in islands:
        islands[b] = {}
    islands[a][b] = islands[b][a] = 1

if N not in islands:
    print('IMPOSSIBLE')
    exit()
for i in islands[1].keys():
    if i in islands[N]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 125052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    int k,n;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin>>p.at(i);
    }
    sort(p.begin(),p.end());
    int sum=0;
    rep(i,k){
        sum+=p.at(i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 200001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pb push_back
#define db double
#define pu puts(" ")
using namespace std;
const int p=998244353;
int read()
{
	int x=0,f=1;
	char ch=gc;
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%p;
		a=(ll)a*a%p;
		b>>=1;
	}
	return ans;
}
char s[15];
int ans,ok=1;
int main()
{
    cin>>s;
    int l=strlen(s);
    fo(i,0,l-1)
    {
    	if(s[i]=='x')ans++;
	}
	if(ans>7)ok=0;
	puts(ok?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b,c,d;


main(){
  cin>>a>>b>>c>>d;
  a--;
  
  int e=c*d/__gcd(c,d);

  int s=b/c+b/d-b/e;
  int t=a/c+a/d-a/e;
  b-=s;
  a-=t;
  //cout<<s<<' '<<t<<endl;

  cout<<b-a<<endl;
}


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

int main(){
    int N,K;
    cin>>N>>K;
    int h[N];
    for(int i=0;i<N;i++){
        cin>>h[i];
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(h[i]>=K)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

const long long INF = 1e18 + 5; 
int main() {
    int n,w;
    cin>>n>>w;
    long long val[n];
    long long  weight[n];
    long long sum  = 0;
    long long ans = 0;
    int i,j;
    for(i= 0 ;i < n; i++)
    {
        cin>>weight[i];
        cin>>val[i];
        sum = sum + val[i];
    }
         
    vector <long long> dp(sum+1, INF);
    dp[0] = 0;
    
    for(i= 1 ;i <= n; i++)
    {
        for(j= sum; j >= 0 ;j --)
        {
            if(val[i-1] <= j)
                dp[j] = min(weight[i-1] + dp[j - val[i-1]], dp[j]);
        }
    }
    for(j= sum; j >= 0 ;j --)
    {
        if(dp[j] <= w)
        {
            ans = j;
            break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long

char t[200005];
signed main() {
    int n; cin>>n;
    string s; cin>>s;
    int r=0, w=0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') r++;
        else    w++;
    }
    
    for(int i = 0; i < r; i++)  t[i] = 'R';
    for(int i = 0; i < w; i++)  t[r+i] = 'W';
    int unmatched = 0;
    for(int i = 0; i < n; i++)
        if(s[i] != t[i])    unmatched++;
    
    cout<<min((unmatched+1) / 2, min(r, w));
    return 0;
}

Measured memory_bytes: 3936
kn = list(map(int,input().split()))
k = kn[0]
n = kn[1]
A = list(map(int,input().split()))

def find_max(a,n,k):
    m = a[0] + (k-a[n-1])
    for i in range(1,n):
        if a[i]-a[i-1] > m:
            m = a[i]-a[i-1]
    return m

print(k-find_max(A,n,k))

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c;
    int s[3];
    while(cin>>a>>b>>c)
    {
        int cnt=0;
        s[0]=a;s[1]=b;s[2]=c;
        sort(s,s+3);
        //cout<<s[0]<<s[1]<<s[2]<<endl;
        if(s[1]-s[0]>=2)
        {
            while(s[0]<s[1])
            {
                    s[0]+=2;
                   // cout<<s[0]<<endl;
                    cnt++;
                   // cout<<"cnt1="<<cnt<<endl;
            }
                sort(s,s+3);
        }
        while(s[1]<s[2])
        {
            s[0]++;
            //cout<<s[1]<<endl;
            s[1]++;
            cnt++;
            //cout<<"cnt2="<<cnt<<endl;
        }
        if(s[0]==s[1]&&s[1]==s[2])
            cout<<cnt<<endl;
        else
            cout<<cnt+2<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
import math

k, s = map(int, input().split())

ans = 0
for i in range(min(s + 1, k + 1)):
    # y + z = s - x, x is substituted by i,
    if k < math.ceil((s - i) / 2):
        continue
    else:
        ans += 2 * (min(k, (s - i)) - (s - i) // 2)
        if (s - i) % 2 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define uLL unsigned long long
namespace io {
  template <typename T> inline void read(T &x) {
    bool flag = false;  char c = getchar();
    while ((c < '0' || c > '9') && c != '-')  c = getchar();
    c == '-' ? flag = true, x = 0 : x = c - '0';
    c = getchar();
    while (c >= '0' && c <= '9')  x = (x << 3) + (x << 1) + c - '0', c = getchar();
    if (flag)  x = -x;
  }
  template <typename T> inline void write(T x) {
    char st[10010];
    int cnt = 0;
    if (x < 0)  x = -x, putchar('-');
    if (x == 0)  putchar('0');
    while (x) { st[++cnt] = x % 10 + 48;  x /= 10; }
    while (cnt) { putchar(st[cnt--]); }
  }
}
using namespace io;
char s[100010];
int main() {
    cin >> s;
    int l = strlen(s);
    for (int i = 0, j; (i << 1) < l; ++i) {
        j = l - i - 1;
        if (s[i] == 'b') {
            if (s[j] != 'd') {
                puts("No");
                return 0;
            }
        } else if (s[i] == 'd') {
            if (s[j] != 'b') {
                puts("No");
                return 0;
            }
        } else if (s[i] == 'p') {
            if (s[j] != 'q') {
                puts("No");
                return 0;
            }
        } else if (s[i] == 'q') {
            if (s[j] != 'p') {
                puts("No");
                return 0;
            }
        } else {
            if (s[i] != s[j]) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}



 










Measured memory_bytes: 384