akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int part(vector<tuple<int,char,int>>&A,int L,int R){
	int x=L,i;
	for(i=L;i<R;i++){
		if(get<0>(A[i])<=get<0>(A[R])){
			swap(A[i],A[x]);
			x++;
		}
		
	}swap(A[x],A[R]);
	return x;
}
void quiso(vector<tuple<int,char,int>>&A,int L,int R){
	if(L>=R){return;}
	int mid=part(A,L,R);
	quiso(A,L,mid-1);
	quiso(A,mid+1,R);
}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<tuple<int,char,int>>A(n);
	for(i=0;i<n;i++){
		char c;int x;cin>>c>>x;
		A[i]=mt(x,c,i);
	}
	quiso(A,0,n-1);
	bool sta=1;
	for(i=0;i<n-1;i++){
		if(get<0>(A[i])==get<0>(A[i+1])&&get<2>(A[i])>get<2>(A[i+1])){sta=0;break;}
	}
	cout<<(sta?"Stable":"Not stable")<<endl;
	for(auto it:A){cout<<get<1>(it)<<" "<<get<0>(it)<<endl;}
	
	return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        if(i % 2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if(i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll r, g, b, n;
	cin >> r >> g >> b >> n;
	ll ans = 0;
	for (ll i = 0; i * r <= n; i++) {
		for (ll j = 0; j * g <= n - i * r; j++) {
			if ((n - i * r - j * g) % b == 0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stack>
#include<queue>
#include<map> 
#include<list>
#include<string>
#include<cstring>
#include<set>
#include<vector>
#define ll long long
#define memset(a,n) memset(a,n,sizeof(a))
#define mp make_pair 
#define pb push_back
using namespace std;
const int maxn = 1e6 + 100;

int main()
{
	int  a;cin >> a;
	cout << 3 * a * a << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

/*1 partition(A, p, r)
2   x = A[r]
3   i = p-1
4   for j = p to r-1
4     if A[j] <= x
5       i = i+1
6       A[i] と A[j] を交換
7   A[i+1] と A[r] を交換
8   return i+1*/
int partition(int A[], int p, int r){
  int x, i, j, tmp;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

int main(){
  int A[MAX], i, q, n;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  q = partition(A, 0, n-1);

  for(i = 0; i < n; i++){
    if(i) printf(" ");
    if(i == q) printf("[");

    printf("%d", A[i]);

    if(i == q) printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2132
n,a,b=int(input()),[],[]
m=n+(n%2==0)
for i in range(1,n):
  for j in range(i+1,n+1):
    if i+j!=m:a.append(i);b.append(j)
l=len(a)
print(l)
for i in range(l):print(a[i],b[i])


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repr(i,n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll A,B,m;
    cin >> A >> B >> m;
    vector<ll> a(A), b(B);
    rep(i,A) cin >> a[i];
    rep(i,B) cin >> b[i];
    vector<ll> x(m), y(m), c(m);
    rep(i,m) cin >> x[i] >> y[i] >> c[i];
    vector<ll> candi(m);
    rep(i,m) candi[i] = a[x[i]-1] + b[y[i]-1] - c[i];
    ll ans = min(*min_element(range(a)) + *min_element(range(b)),  *min_element(range(candi)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
g=1000000007

f2::Int->Int
f2 0=1
f2 n=n

f::Int->Int->Int->Int->String->Int
f a b c d []=c
f a b c d (x:xs)
    |x=='A'=f ((a+d) `mod` g) b c d xs
    |x=='B'=f a ((a+b) `mod` g) c d xs
    |x=='C'=f a b ((b+c) `mod` g) d xs
    |otherwise=f ((a*3+d) `mod` g) ((a+b*3) `mod` g) ((b+c*3) `mod` g) ((d*3) `mod` g)  xs

main = do
       a<-getLine
       putStrLn $ show $ f 0 0 0 1 a

Measured memory_bytes: 8700
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  map<int,int> mp;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans=0;
  for(auto m: mp){
    if(m.first <= m.second){
      ans += m.second - m.first;
    }else{
      ans += m.second;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	int A {in()}, B {in()}, C {in()}, D {in()}, E {in()};
	outl((min(0, B) - min(0, A)) * C + ((A < 0 && 0 < B) ? D : 0) + (max(0, B) - max(0, A)) * E);
}


Measured memory_bytes: 2536
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main() { 
    string s;
    REP(i,3)
    {
        cin >> s;
        cout << char(toupper(s[0]));
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
A = [0 for i in range(q)]
B = [0 for i in range(q)]
C = [0 for i in range(q)]
D = [0 for i in range(q)]

for i in range(q):
     A[i], B[i], C[i], D[i] = map(int, input().split())
     A[i] -= 1
     B[i] -= 1

ans = 0
for S in combinations_with_replacement(range(1, m + 1), n):
     pt = 0
     for i in range(q):
          if S[B[i]] - S[A[i]] == C[i]:
               pt += D[i]
          else:
               pass
     if ans < pt:
          ans = pt
     else:
          pass
print(ans)

Measured memory_bytes: 9220
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int i;
    cin>>i;
    if(i==1)
       cout<<"1.0000000000";
    else 
    {
        if((i%2)==0)
        {
            cout<<"0.5000000000";
        }
        else
        {
            double x=((i/2)+1);
            cout<<x/double(i);
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
X = [i for i in A if i % 2 == 0]
ans = 1
for p in X:
    if p % 3 == 0 or p % 5 == 0:
        pass
    else:
        ans *= 0

if ans == 0:
    print('DENIED')
if ans == 1:
    print('APPROVED')


Measured memory_bytes: 38256
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]

possibility=[False]*n
possibility[0]=True
count=[1]*n

for x,y in a:
    if possibility[x-1]==True and count[x-1]>1:
        possibility[y-1]=True
    elif possibility[x-1]==True and count[x-1]==1:
        possibility[x-1]=False
        possibility[y-1]=True
    count[x-1]-=1
    count[y-1]+=1

print(possibility.count(True))


Measured memory_bytes: 22692
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;
int main(){
  ll a,b,sum=0;
  cin>>a>>b;
  rep(i,0,b-a){
    sum+=i;
  }
  cout<<sum-a<<endl;
}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())


MOD = 10 ** 9 + 7
M = 200005
fact = [0] * M
fact[0] = 1
for i in range(1, M):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * M
rfact[M - 1] = pow(fact[M - 1], MOD - 2, MOD)
for i in range(M - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


ans = 0
for i in range(B + 1, W + 1):
        ans += comb(H - A + i - 2, i - 1) * comb(W - i + A - 1, A - 1)
        ans %= MOD

print(ans)


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

int main(){
 int n;
 double p[3],max=0,sum; 

 cin >> n ;
 double x[n],y[n];
 for(int i=0;i<n;i++){
  cin >> x[i] ;
 }
 for(int i=0;i<n;i++){
  cin >> y[i] ;
 }

 for(int j=1;j<4;j++){
  sum=0;
  for(int i=0;i<n;i++){
   sum+=pow(fabs(x[i]-y[i]),j) ;
  }
  p[j-1]=(double)pow(sum,1.0/j);
 }

 for(int i=0;i<n;i++){
  if(fabs(x[i]-y[i])>max) max=double(fabs(x[i]-y[i]));
 }

 cout << fixed << p[0] << endl << p[1] << endl << p[2] << endl << max << endl;

 return 0;
}

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

int main(){
 int N,e;
  cin>>N;
   int g=0,f=0,h=0,k=0;
  for(int i=0; i<N;i++){
    string S;
    cin>>S;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
   
    if(S=="P"){
      a++;
      if(a>0){
        f=1;
      }
      
    }else if(S=="W"){
      b++;
       if(b>0){
		g=1;
       }
      
    }else if(S=="G"){
      c++; 
      if(c>0){
        h=1;
      }
      
      
      
    }else if(S=="Y"){ 
      d++;
      if(d>0){
		k=1;
      }
    
    }
    e=f+g+h+k;
    
   
  }
  
   if(e==3){
	cout<<"Three"<<endl;
    }else if(e==4){
      cout<<"Four"<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
al = [list([0] * 2) for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    al[i][0] = a
    al[i][1] = b
al.sort(key=lambda x:(x[1], x[0]))
ans = 'Yes'
t = 0
for i in range(N):
    t += al[i][0]
    if t > al[i][1]:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 53908
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	string t = s;
	
	i64 ans = 0;
	i64 cnta = 0, cntbc = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A'){
			cnta++;
			int j = i+1;
			while(s[j] == 'A' || s[j] == 'B' && s[j+1] == 'C'){
				if(s[j] == 'A'){
					cnta++;
					j++;
				}
				else{
					ans += cnta;
					j += 2;
				}
			}
			cnta = 0;
			i = j;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 772
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#define INF 2000000
using namespace std;
typedef long long ll;//声明// 
int q1[4050];
int q2[4050];
int q3[4050];
int main()
{   ll n,sum=0,i,t=0,t1=0,t2=0,j,t3=0,t4=0,t5=0,k;
    char b[4050];
    cin>>n;
    cin>>b;
    
    for(i=0;i<n;i++)
    { if(b[i]=='R') t++;
       if(b[i]=='G') t1++;
        if(b[i]=='B')  t2++;
	}
	sum=t1*t2*t;
	if(sum==0)
	{ cout<<sum<<endl;
	  return 0; 
	}
	for(i=0;i<n;i++)
	{ for(j=0;j<n;j++)
	   {    k=2*j-i;
	        if(i<j&&j<k&&k<n&&b[i]!=b[j]&&b[j]!=b[k]&&b[k]!=b[i])
	               sum--;
	   }
	}
	cout<<sum<<endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int maxn = 505;

int p[maxn * maxn];
int dis[maxn][maxn];
bool vis[maxn][maxn];
int n;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

bool in(int x, int y){
    return x >= 0 and x < n and y >= 0 and y < n;
}

void dfs(int x, int y){
    int z = dis[x][y] + vis[x][y];
    for(int i = 0;i < 4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(in(nx, ny) and dis[nx][ny] > z){
            dis[nx][ny] = z;
            dfs(nx, ny);
        }
    }
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            dis[i][j] = min(min(i, n - 1 - i), min(j, n - 1 - j));
            vis[i][j] = true;
        }
    }
    ll ans = 0;
    for(int i = 1;i <= n * n;i++){
        cin >> p[i];
        p[i]--;
        int row = p[i] / n;
        int col = p[i] % n;
        vis[row][col] = false;
        ans += dis[row][col];
        dfs(row, col);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25088
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")

#define fi first
#define se second

const int N = 200200;

using namespace std;

int n;
int P;
char a[N];
int f[N];
int c[N];
int p10[N];

int pw(int x, int n)
{
        int res = 1;
        while(n > 0){
                if(n & 1) res = 1ll * res * x % P;
                x = 1ll * x * x % P;
                n /= 2;
        }
        return res;
}

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

        ios_base::sync_with_stdio(0);

        cin >> n >> P;

        p10[0] = 1;
        for(int i = 1; i < N; i++) p10[i] = 1ll * p10[i - 1] * 10 % P;

        //inverse
        for(int i = 0; i < N; i++) p10[i] = pw(p10[i], P - 2);

        long long res = 0;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                f[i] = (f[i - 1] * 10 + a[i] - '0') % P;

                if(P == 2 || P == 5){
                        if(f[i] == 0) res += i;
                } else{
                        c[1ll * f[i - 1] * p10[i - 1] % P] += 1;
                        res += c[1ll * f[i] * p10[i] % P];
                }

        }

        cout <<  res << "\n";
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

string s;

vector<ll> three_pow(int n){
    vector<ll> res(n);
    res.at(0) = 1;
    rp(i, 1, n)  res.at(i) = (res.at(i-1) * 3) % mod;
    return res;
}

vector<ll> two_pow(int n){
    vector<ll> res(n);
    res.at(0) = 1;
    rp(i, 1, n)  res.at(i) = (res.at(i-1) * 2) % mod;
    return res;
}

int main() {
    cin >> s;
    int n = s.size();
    vector<ll> three(n+10);
    three = three_pow(n+10);
    vector<ll> two(n+10);
    two = two_pow(n+10);

    ll res = 0;
    int count = 0;
    rp(i, 0, n){
        if(s[i] == '1'){
            res += (three.at(n - i - 1) * two.at(count))%mod;
            res %= mod;
            count ++;
        }
    }
    res += two.at(count);
    res %= mod;
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 2808
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<functional>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long long X[n], Y[n], Z[n], R[8][n], res[8];
  for (int i=0; i<n; i++) {
    scanf("%llu %llu %llu", &X[i], &Y[i], &Z[i]);
  }

  for (int i=0; i<n; i++) R[0][i] = X[i]+Y[i]+Z[i];
  for (int i=0; i<n; i++) R[1][i] = X[i]+Y[i]-Z[i];
  for (int i=0; i<n; i++) R[2][i] = X[i]-Y[i]+Z[i];
  for (int i=0; i<n; i++) R[3][i] = X[i]-Y[i]-Z[i];
  for (int i=0; i<n; i++) R[4][i] = -X[i]+Y[i]+Z[i];
  for (int i=0; i<n; i++) R[5][i] = -X[i]+Y[i]-Z[i];
  for (int i=0; i<n; i++) R[6][i] = -X[i]-Y[i]+Z[i];
  for (int i=0; i<n; i++) R[7][i] = -X[i]-Y[i]-Z[i];

  for (int i=0; i<8; i++) sort(R[i], R[i] + n, greater<long long>());
  for (int i=0; i<8; i++) {
    res[i] = 0;
    for (int j=0; j<m; j++) {
      res[i] += R[i][j];
    }
  }

  sort(res, res + 8, greater<long long>());

  printf("%llu\n", res[0]);

  return 0;
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int r,g,b,k;
		cin>>r>>g>>b>>k;
		while(k>0 and r>=g)
		{
			g*=2;
			--k;
		}
		while(k>0 and g>=b)
		{
			b*=2;
			--k;
		}
		if(b>g and g>r)
		{
			cout<<"Yes";
		}
		else
		cout<<"No";		
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}

#include <iostream>
using namespace std;
void fast();
long long arr[200005];
long long arr2[200005];


int main() {
fast();
int n;
string s;
cin >> n >> s;
int sum=1;
for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
        sum++;
    }
}

cout << sum;
}





void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    ll n, x;
    cin>>n>>x;
    ll a[n];
    rep(i, 0, n) cin>>a[i];
    ll ans, used;
    ans =  used = 0;
    rev(b, 60, 0) {
        ll msk = (1LL<<b);
        int cnt = 0;
        rep(i, 0, n)
            if(msk & a[i])
                cnt++;
        if(cnt >= n - cnt) {
            ans += cnt * msk;
        }
        else {
            if(used + msk <= x) {
                ans += (n-cnt) * msk;
                used += msk;
            }
            else
                ans += cnt * msk;
        }
    }
    cout<<ans<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4424
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]

#print(b)

#print('p',n//2)
for i in reversed(range(1,n//2 + 1)):
    j = 2
    b_sum = 0
    #print(i)
    while i * j <= n:
        #print(i,j)
        b_sum += b[i*j]
        j += 1
    if (b_sum % 2) == a[i-1]:
        b[i] = 0
    else:
        b[i] = 1

#print(b)

s = sum(b)

print(s)
if s > 0:
    sl = ''
    for i in range(len(b)):
        if b[i] == 1:
            sl += str(i) + ' '

    print(sl[:-1])


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

ll dp[2005];

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

    dp[0] = 1;
    for (int i = 3; i <= s; i++) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }

    cout << dp[s] << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n, k;
  string s;
  cin >> n >> k >> s;

  int cnt = 0;
  rep(i, n - 1) if(s[i] == s[i + 1]) cnt++;
  cout << min(n - 1, cnt + 2 * k) << endl;
  return 0;
}


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

const ll Q = 7 + 1e9;

int count_sumS( int s ){
    // length & sum
    vector<vector<int>> dp( s/3+1 ,vector<int>(s+1,0));
    for( int i = 3; i<=s; ++i ) dp[1][i] = 1;
    for( int i=1; i<s/3; ++i ){
        for( int j=3*i; j<=s; ++j ){
            for( int x=3; x<=s and j + x <= s ; ++x ){
                dp[i+1][j+x] += dp[i][j]%Q;
                dp[i+1][j+x] = dp[i+1][j+x]%Q;
            }
        }
    }
    /*rep(i,s+1) cout << i << " ";
    cout << endl;
    rep(i,s/3){
        rep(j,s+1) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    ll ans = 0;
    rep(j,s/3+1){
         ans += dp[j][s]%Q;
         ans = ans%Q;
    }
    return ans;
}

int main(){
    int S;
    cin >> S;
    cout << count_sumS( S ) << endl;
    return 0;
}
     

Measured memory_bytes: 8368
x, N = map(int, input().split(" "))
try:
  data = list(map(int, input().split(" ")))
except:
  data = []
point = 0
i = 0
while(1):
    if x not in data:
        print(x)
        break
    elif x+i not in data:
        print(x+i)
        break
    elif x+(-1*i) not in data:
        print(x+(-1*i))
        break
    else:
        i=i-1

Measured memory_bytes: 9228
n = int(input())
s = input()
dic = {}
for i in range(n):
  if s[i] in dic:
    dic[s[i]] += 1
  else:
    dic[s[i]] = 1
ans = 1
for v in dic.values():
  ans *= (1 + v)
  ans %= 10**9 + 7
ans -= 1
print(ans)

Measured memory_bytes: 3188
import collections
N=int(input())
V=list(map(int,input().split()))
l=N//2
V_odd=[]
V_eve=[]
for i in range(N):
  if i%2==0:
    V_odd.append(V[i])
  else:
    V_eve.append(V[i])

p_odd = list(collections.Counter(V_odd).most_common())
p_eve = list(collections.Counter(V_eve).most_common())
p_odd.append([0,0])
p_eve.append([0,0])

if p_odd[0][0]!=p_eve[0][0]:
  print(N-p_odd[0][1]-p_eve[0][1])
else:
  print(min(N-p_odd[0][1]-p_eve[1][1],N-p_odd[1][1]-p_eve[0][1]))


Measured memory_bytes: 21212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n,m;
  cin>>n>>m;
  vint a(n);
  repi(n)cin>>a[i];
  int res=0,dif=0;
  for(int i=1;i<n;++i){
    int sum=a[i]+a[i-1];
    dif=sum-m;
    dif=max(dif,0);
    if(dif>=a[i])a[i]=0;
    else a[i]-=dif;
    res+=dif;
  }
  out(res);

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int a;
string s;
int main(void){
    cin>>s;
    for(int i=0;i<s.size();i++)if(s[i]=='x')a++;
    if(a>=8)cout<<"NO\n";
    else cout<<"YES\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int N; cin >> N;
    int ans;
    ans = 1000 - N % 1000;
    if (ans == 1000) {
        ans = 0;
    }
    out(ans);







    return 0;
}









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

int main() {
  int n,m; cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];
  sort(x.begin() , x.end());

  priority_queue<int> diff;
  rep(i,m-1){
    diff.push(x[i+1] -x[i]);
  }

  bool flag = false;
  rep(i,n-1){
    if(diff.empty()){
      cout << 0 << endl;
      flag = true;
      break;
    }
    else diff.pop();
  }

  if(!flag){
  ll ans =0;
  while(!diff.empty()){
    ans += diff.top();
    diff.pop();
  }
  cout << ans << endl;
}
}


Measured memory_bytes: 1276
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0) System.out.printf(" %d", i);
            else {
                x = i;
                while (x != 0) {
                    if (x % 10 == 3) {
                        System.out.printf(" %d", i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.printf("\n");
    }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

vector<pair<ll, ll>> factorial(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0) continue;
        ll ex = 0;
        while(N % i == 0){
            ex++;
            N /= i;
        }
        res.push_back({i, ex});
    }
    if(N != 1) res.push_back({N, 1});
    return res;
}
int main(){

    string s;
    cin >> s;
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(i%2 == 0){
            if(s[i] == '0'){
              //  s[i] = 1;
              cnt1++;
            }
        }
        else{
            if(s[i] == '1'){
                // s[i] = 0;
                cnt1++;
            }
        }
        if(i%2 == 0){
            if(s[i] == '1'){
              //  s[i] = 1;
              cnt2++;
            }
        }
        else{
            if(s[i] == '0'){
                // s[i] = 0;
                cnt2++;
            }
        }
    }
    int ans = min(cnt1, cnt2);

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

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// }}} 1

int main() {

    char s[10];
    Scs(s);
    string ans;

    Rep( i,strlen(s)){
        if( s[i] == 'B' ){
            if( !ans.empty() )
            ans.pop_back();
        }else{
            ans.push_back(s[i]);
        }

    }

    printf ("%s\n", ans.c_str());

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  cout << (N*(N-1)/2)-N/2 << endl;
  if(N%2 == 0){
    for(int i = 1;i<=N;i++){
      for(int k = i+1;k<=N;k++){
        if((i+k)!=(N+1)){
          cout << i << " " << k << endl;
        }
      }
    }
  }
  else{
    for(int i = 1;i<=N;i++){
      for(int k = i+1;k<=N;k++){
        if((i+k)!=(N)){
          cout << i << " " << k << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int n,mod,dp_in[N],dp_out[N],pref[N],suf[N];
vector<int>adj[N];

void dfs1(int u,int p=0)
{
    dp_in[u]=1;
    for(auto&v:adj[u])
    {
        if(v==p) continue;
        dfs1(v,u);
        dp_in[u]=dp_in[u]*(dp_in[v]+1)%mod;
    }
}

void dfs2(int u,int p=0)
{
    for(int i=0;i<adj[u].size();i++)
    {
        int v=adj[u][i];
        if(i==0) pref[i]=1;
        else pref[i]=pref[i-1];
        if(v==p) continue;
        pref[i]=pref[i]*(dp_in[v]+1)%mod;
    }
    suf[adj[u].size()]=1;
    for(int i=adj[u].size()-1;i>=0;i--)
    {
        int v=adj[u][i];
        suf[i]=suf[i+1];
        if(v==p) continue;
        suf[i]=suf[i]*(dp_in[v]+1)%mod;
    }
    for(int i=0;i<adj[u].size();i++)
    {
        int v=adj[u][i];
        if(v==p) continue;
        int val=1;
        if(i>0) val=pref[i-1];
        dp_out[v]=(dp_out[u]*val%mod*suf[i+1]+1)%mod;
    }
    for(auto&v:adj[u]) if(v!=p) dfs2(v,u);
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>mod;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs1(1);
    dp_out[1]=1;
    dfs2(1);
    for(int i=1;i<=n;i++) cout<<dp_in[i]*dp_out[i]%mod<<'\n';
}


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

int n, m, k;
string a[10];

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

	cin >> n >> m >> k;

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

	int ans = 0;

	for (int mask_i = 0; mask_i < (1 << n); mask_i++) {
		for (int mask_j = 0; mask_j < (1 << m); mask_j++) {
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (mask_i & (1 << i)) continue;
					if (mask_j & (1 << j)) continue;

					cnt += a[i][j] == '#';
				}
			}

			ans += cnt == k;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    T=N+M
    T=((T*(T-1))/2)
    return print(int(T-M*N))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll l = 0, r = 0, d = 0;
  cin >> l >> r >> d;
  ll c = 0;
  for (ll i = l; i <= r; ++i) {
    if (i % d == 0) ++c;
  }
  cout << c;
}



Measured memory_bytes: 3612
using System;
using static System.Console;
using static MyUtil;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        int input = int.Parse(ReadLine());
        WriteLine(input * 2 * Math.PI);

#if DEBUG
        ReadKey();
#endif
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 18592
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    let ans = n- k + 1;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

#if 0
所用時間:

感想:

#endif

int N, W, v[1001], w[1001], Val[101][100001], ans = 0;//Val[y=i][x=c]

int solve(){

  for(int i = 0; i <= N; ++i){
    for(int c = 0; c <= W; ++c){
      if((i == 0) || (c == 0)) Val[i][c] = 0;
      else if(c - w[i] < 0) Val[i][c] = Val[i-1][c];
      else Val[i][c] = max(Val[i-1][c], max(Val[i-1][c-w[i]]+v[i],Val[i][c-w[i]]+v[i]));
    }
  }
  // //テーブルの確認
  // for(int i = 0; i <= N; ++i){
  //   for(int c = 0; c <= W; ++c)
  //     cout << Val[i][c];
  //   cout << endl;
  //   }

  return ans = Val[N][W];

}

int main(){
  cin >> N >> W;
  for(int i = 1; i <= N; ++i){
    cin >> v[i] >> w[i];
    //printf("v[%d]: %d, w[%d]: %d\n",i, v[i], i, w[i]);
  }
  cout << solve() << endl;
}



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

using namespace std;

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

  int N; cin>>N;
  vector<int> A(N), B(N), C(N-1);
  for (auto& a : A) cin>>a;
  for (auto& b : B) cin >> b;
  for (auto& c : C) cin >> c;

  int p = -1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a = A[i];
    ans += B[a-1];
    if (a == p+1)
      ans += C[p-1];
    p = a;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/8.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

const int N = 5e5 + 5; //N = Q

int n, q;
int c[N];

struct query{
    int l, r, id;
};
query que[N];
bool cmp(query qa, query qb){
    return qa.r < qb.r;
}
int fenwick[N];
int lowbit(int x){
    return x & (-x);
}
void init(){
    for(int x=1; x<=n; x++){
        fenwick[x] = c[x];
        int y = x-lowbit(x);
        for(int i=x-1; i>y; i-=lowbit(i))
            fenwick[x] += fenwick[i];
    }
}
void add(int val, int x){ //add val
    for(int i=x; i<=n; i+=lowbit(i)){
        fenwick[i] += val;
    }
}
int sum(int x){
    int s = 0;
    for(int i=x; i>0; i-=lowbit(i)){
        s += fenwick[i];
    }
    return s;
}

int book[N];
int ans[N];  //offline queries sadly

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> q;
    init();
    for(int i=1; i<=n; i++) cin >> c[i];
    for(int i=0; i<q; i++){
        int l, r; cin >> l >> r;
        que[i] = (query){l, r, i};
    }
    sort(que, que+q, cmp);
    
    int start = 1;
    for(int i=0; i<q; i++){
        for(int j=start; j<=que[i].r; j++){
            if(book[c[j]]) add(-1, book[c[j]]);
            add(1, j); book[c[j]] = j;
        }
        start = que[i].r+1;
        ans[que[i].id] = sum(que[i].r) - sum(que[i].l-1);
    }
    for(int i=0; i<q; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 17404
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

x = int(input())

if 400<=x<=599:
    print(8)
if 600<=x<=799:
    print(7)
if 800<=x<=999:
    print(6)
if 1000<=x<=1199:
    print(5)
if 1200<=x<=1399:
    print(4)
if 1400<=x<=1599:
    print(3)
if 1600<=x<=1799:
    print(2)
if 1800<=x<=1999:
    print(1)


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

int main(void) {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if (abs(a - b) > 1e18) {
        cout << "Unfair" << endl;
        return 0;
    }
    if (k % 2 == 0) {
        cout << a - b << endl;
    }
    else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll x;
	cin>>x;
	ll ans = x/11 * 2;
	x %= 11;
	if(0 < x) ++ans;
	if(6< x ) ++ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
$string = str_replace(array(" ", "\n"), "", fgets(STDIN));
$splited_string = str_split($string);
$counted_string = array_count_values($splited_string);
foreach ($counted_string as $count) {
  if ($count != 2) {
    echo "No";
    exit;
  }
}

echo "Yes";

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;

    vector<char> d(k);
    rep(i, k) {
        char c;
        cin >> c;
        d.push_back(c);
    }

    for (int i = n; i < 100000; ++i) {
        string tmp = to_string(i);
        bool check = true;
        rep(j, tmp.size()) rep(l, d.size()) {
            if (tmp[j] == d[l]) { check = false; break; }
        }
        if (check) { cout << i << endl; return 0; }
    }
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush as pu, heappop as po

n,m,s,t = map(int,input().split())
e = [[] for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    e[u].append((v,a,b))
    e[v].append((u,a,b))

def dik(s,v):
    S = [float("INF")]*(n)
    S[s] = 0
    h = []
    pu(h,[0,s])
    while h:
        d,now = po(h)
        for nex in e[now]:
            a,b = nex[0],nex[v]
            if d+b < S[a]:
                S[a] = d+b
                pu(h,[d+b,a])
    return S[::-1]
ans = []
cost = 10**15
now = 0
for i,j in zip(dik(s-1,1),dik(t-1,2)):
    now = max(now,cost-i-j)
    ans.append(now)
print(*ans[::-1],sep="\n")

Measured memory_bytes: 60120