akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<deque>
using namespace std;

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

	deque<long long> table;
	for(int i=0; i<n; i++)
	{
		long long a;
		cin >> a;

		if(i%2 == 0)
			table.push_back(a);
		else
			table.push_front(a);
	}

	if(n%2 == 0)
	{
		auto it = table.begin();
		cout << *it;

		for(it++; it!=table.end(); it++)
			cout << " " << *it;
	}
	else
	{
		auto it = table.rbegin();
		cout << *it;

		for(it++; it!=table.rend(); it++)
			cout << " " << *it;
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int main(){
    int a,b;
    while( scanf("%d%d",&a,&b)!=EOF){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }

}



Measured memory_bytes: 3148
#include<stdio.h>
int main(void){
int S, h = 0, m = 0, s = 0;
scanf("%d", &S);
while(S >= 3600){
S = S - 3600;
h = h + 1;
}
while(S >= 60){
S = S - 60;
m = m + 1;
}
s = S;
printf("%d:%d:%d\n", h, m, s);
return 0;
}

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

using namespace std;
using pii = pair<int, int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, H;
  cin >> N >> H;
  priority_queue<pii> pq;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    pq.push(make_pair(a, 0));
    pq.push(make_pair(b, 1));
  }
  int res = 0;
  while (H > 0) {
    auto p = pq.top();
    pq.pop();

    int damage = p.first;
    int cnt = p.second == 0 ? (H + damage - 1) / damage : 1;
    res += cnt;
    H -= damage * cnt;
  }
  cout << res << '\n';
  return 0;
}


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

int main()
{   long long int n,sum=0;
    cin>>n;
    for(long long int i=1;i<=n;i++)
    {  if(i%3!=0&&i%5!=0)sum+=i;

    }
    cout<<sum;

    return 0;
}


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

#define sysp system("pause")

typedef long long ll;
ll a,b;

ll f(ll n){
	if(n==1)return n;
	else return (n*f(n-1))%1000000007;
}

int main(){
	cin>>a>>b;
	if(abs(a-b)>1){
		cout<<0<<endl;
			sysp;
		return 0;
	}
	if(abs(a-b)==1){
		cout<<(f(a)*f(b))%1000000007<<endl;
			sysp;
		return 0;
	}else{
		cout<<(f(a)*f(b)*2)%1000000007<<endl;
			sysp;
		return 0;
	}
	sysp;
} 

Measured memory_bytes: 2040
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b,i;
	char c[11];
	scanf("%d",&a);
	scanf("%s",c);
	scanf("%d",&b);
	for(i=0;i<a;i++){
		if(c[i]!=c[b-1]){
			c[i]='*';
		}
	}
	printf("%s\n",c);
	return 0;
}

Measured memory_bytes: 128
import math
A, B = list(map(int, input().split()))

A_min = math.ceil(A * 25 / 2)
A_max = ((A + 1) * 25 / 2)
if A_max > math.floor(A_max):
    A_max = math.floor(A_max) + 1
else:
    A_max = A_max
A_max = int(A_max)
B_min = B * 10
B_max = (B + 1) * 10
# print(B_min, B_max)
A_list = list(range(A_min, A_max))
B_list = list(range(B_min, B_max))
# print(A_list)
# print(B_list)

min_ans = -1
for num in A_list:
    if num in B_list:
        min_ans = num
        break
    else:
        continue

print(min_ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    string S; cin >> S;
    if (S.front() == S.back()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vi isprime(1000001,true);
	isprime[0]=isprime[1]=false;
	repi(i,2,isprime.size())
		if(isprime[i])
			for(int j=i+i;j<isprime.size();j+=i)
				isprime[j]=false;
	vi primes;
	rep(i,isprime.size())
		if(isprime[i])
			primes.push_back(i);
	
	for(int n;cin>>n,n;){
		int res=0;
		rep(i,primes.size()){
			int p=primes[i];
			int q=n-p;
			if(p<=q && binary_search(allof(primes),q))
				res++;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
	int key;
	struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	char com[16];
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
        scanf("%s",com);
		if(!strcmp(com,"insert")) {
			scanf("%d",&x);
			insert(x);
		} else if(!strcmp(com,"print")) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = INF;
    REP(i, N){
        ll a;
        cin >> a;

        ll temp = 0;
        while(a%2 == 0){
            a = a/2;
            temp++;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rem(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;


int main() {
	int N;
	cin >> N;
	N %= 10;
	if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon" << '\n';
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << '\n';
	}
	else {
		cout << "bon" << '\n';
	}

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

long max_value(int k, const vector<int> &as, const vector<int> &bs) {
  const long N = as.size();
  long ret = 0;
  for (int n = 0; n < N; n++) {
    const int a = as[n], b = bs[n];
    if ((a & ~k) == 0) {
      ret += b;
    }
  }
  return ret;
}

// read editorial
int main(int argc, char *argv[]) {
  // read inputs
  int N, K;
  vector<int> as, bs;
  scanf("%d %d", &N, &K);
  for (int n = 0; n < N; n++) {
    int a, b;
    scanf("%d %d", &a, &b);
    as.push_back(a);
    bs.push_back(b);
  }

  // solve
  long ans = max_value(K, as, bs);
  for (int k = 0; k < 30; k++) {
    if (K & (1 << k)) {
      ans = max(ans, max_value(((K & ~(1 << k)) | ((1 << k) - 1)), as, bs));
    }
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    char c[10]; cin >> c;
    int A, B, C, D;
    A = c[0] - '0';
    B = c[1] - '0';
    C = c[2] - '0';
    D = c[3] - '0';

    // int 型を string 型に変換
    string ans;
    int sum;

    // bit 全探索 2 の 3乗通り
    rep(i, 1 << 3) {
        ans = to_string(A);
        sum = A;
        if (i >> 0 & 1) {
            // 0 ビット目が立っている場合
            ans += "+" + to_string(B);
            sum += B;
        } else {
            // 0 ビット目が立っていない場合
            ans += "-" + to_string(B);
            sum -= B;
        }

        if (i >> 1 & 1) {
            // 1 ビット目が立っている場合
            ans += "+" + to_string(C);
            sum += C;
        } else {
            // 1 ビット目が立っていない場合
            ans += "-" + to_string(C);
            sum -= C;
        }

        if (i >> 2 & 1) {
            // 2 ビット目が立っている場合
            ans += "+" + to_string(D);
            sum += D;
        } else {
            // 2 ビット目が立っていない場合
            ans += "-" + to_string(D);
            sum -= D;
        }

        if (sum == 7) {
            ans += "=7";
            break;
        }
    }

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


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 
#define sq(a) ((a)*(a))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	char str[8];
	while(scanf("%s", str), str[0]!='0'){
		int v;
		sscanf(str+1, "%x", &v);
		int r = v / 0x10000;
		int g = (v % 0x10000) / 0x100;
		int b =  v % 0x100;
		
		const int rs[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};
		const int gs[] = {0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff};
		const int bs[] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff};
		
		int bestid = 0;
		int best = 1<<29;
		rep(i, 8){
			int d = sq(r-rs[i])+sq(g-gs[i])+sq(b-bs[i]);
			if(d < best){
				best = d;
				bestid = i;
			}
		}
		
		const char* name[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};
		puts(name[bestid]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#import <stdio.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main() {
    int x = 0, y = 0, z = 0, n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    rep(i, n) {
        int p;
        scanf("%d", &p);
        if (p <= a)
            x++;
        else if (p <= b)
            y++;
        else
            z++;
    }
    printf("%d\n", MIN(MIN(x, y), z));
}


Measured memory_bytes: 6612
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit(0)
else:
    p = [int(x) for x in input().split()]

p.sort()


ans1 = 300
ans2 = 300

flag = 1

for i in range(100):
    if x-i not in p:
        ans1 = x-i
        flag = 0
    if x+i not in p:
        ans2 = x+i
        flag = 0
    if flag == 0:
        break
    else:
        continue

print(min(ans1, ans2))

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define int long long
typedef struct{
	int parent;
	int jrcnt;
} node;
node t[101000];
vector<int> memo[101000];
signed main(){
	int n;
	cin>>n;
	lp(i,101000){
		t[i].parent=-1;
	}
	int id,c,k;
	lp(i,n){
		cin>>id>>k;
		lp(j,k){
			cin>>c;
			memo[id].push_back(c);
			t[id].jrcnt++;
			t[c].parent=id;
		}
	}
	lp(i,n){
		cout<<"node "<<i<<": parent = "<<t[i].parent<<", depth = ";
		int cnt=0;
		int now=i;
		while(1){
			if(t[now].parent==-1) break;
			now=t[now].parent;
			cnt++;
		}
		cout<<cnt<<", ";
		if(t[i].parent==-1) cout<<"root";
		else if(t[i].jrcnt==0) cout<<"leaf";
		else cout<<"internal node";
		cout<<", [";
		lp(j,memo[i].size()){
			if(j!=0){
				cout<<", ";
			}
			cout<<memo[i][j];
		}
		cout<<"]"<<endl;
	}
	return 0;
}



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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
  ll H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  } else if (H * W % 2){
    cout << H * W / 2 + 1 << endl;
  } else {
    cout << H * W / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   long long int N;
   cin>>N;
   bool flag=true;
   int X=0;
   int f=N;
  while (flag){
      int a=N%10;
      N=int(N/10);
      X+=a;
      if(N==0)
          flag=false;
  }
  if(f%X==0)
      cout<<"Yes"<<endl;
  else 
      cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String line=s.nextLine();
			for(int i=0;i<26;i++){
				String now="";
				for(int j=0;j<line.length();j++){
					if(line.charAt(j)>='a'&&line.charAt(j)<='z'){
						now+=(char)('a'+(line.charAt(j)-'a'+i)%26);
					}else now+=line.charAt(j);
				}
				boolean ok=false;
				for(int j=0;j<now.length()-2;j++){
					if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'&&now.charAt(j+2)=='e')ok=true;
				}
				for(int j=0;j<now.length()-3;j++){
					if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'){
						if(now.charAt(j+2)=='i'&&now.charAt(j+3)=='s')ok=true;
						if(now.charAt(j+2)=='a'&&now.charAt(j+3)=='t')ok=true;
					}
				}
				if(ok){
					System.out.println(now);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=200001;
int main()
{
  int n,i;
  long long res=0;
  long long a[N_MAX],c[N_MAX];
  cin >> n;
  fill(c,c+N_MAX,0);
  for(i=0;i<n;i++){
    cin >> a[i];
    c[a[i]]++;
  }
  for(i=1;i<N_MAX;i++)
    res+=c[i]*(c[i]-1)/2;
  for(i=0;i<n;i++)
    cout << res-c[a[i]]+1 << endl;
  return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// const int MAX = 510000;
const int MAX = 2000010;

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

void init_ncr() {
  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;
  }
}

ll ncr(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;
}
ll npr(ll val1, ll val2) {
  ll c = ncr(val1, val2);
  return c * fac[val2] % MOD;
}

int main() {
  init_ncr();

  ll S;
  scanf("%lld", &S);

  ll loop = S / 3;

  ll ans = 0;
  for (ll i = 1; i <= loop; i++) {
    ll n = S + i - 1;
    n -= (i * 3);
    ll r = i - 1;

    ll plus = ncr(n, r);

    ans += plus;
    ans %= MOD;

    // cout << "n:" << (n) << endl;
    // cout << "r:" << (r) << endl;
    // cout << "plus:" << (plus) << endl;
  }

  cout << (ans) << endl;
}


Measured memory_bytes: 50628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll int
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define llpvec vector<pair<ll,ll>>
////////////////////////////////////////////////////////////
ll n,x,y;
llvec g; 
llpvec pairs;
vector<ll> cnt;
map<pair<ll,ll>,ll> color;
ll mx=0;
void bfs(ll a,ll b,ll c){
 ll ed=g[a].size(),d=0;
 color[{b,a}]=c;
 for(int i=0;i<ed;++i){
  if(i+1==c)++d;
  bfs(g[a][i],a,i+d+1);
 }
}

int main(){
 cin>>n;
 g.resize(n+1);
 cnt.assign(n+1,0);
 for(int i=0;i<n-1;++i){
  cin>>x>>y;
  g[x].pb(y);
  pairs.pb(pair(x,y));
  ++cnt[x];++cnt[y];
  mx=max(cnt[x],mx);
 }
 cout<<mx<<endl;
 bfs(1,0,0);
 for(int i=0;i<n-1;++i){
  pair<ll,ll>p=pairs[i];
  cout<<color[p]<<endl;
 }
return 0;}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    char s;

    cin>> s;

    cout<<  ( (s >= 'a' && s <='z') ? 'a' : 'A' );
    nl;

    return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

vector<int> eratosthenes(int n){
    vector<int> arr(n,1);
	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(int j = 2; i * j < n; j++){
				arr[i*j] = 0;
			}
		}
	}
    return arr;
}


int main() {
    int n;
    cin >> n;
    int maxn = 55555;
    vector<int> prime = eratosthenes(maxn);
    vector<int> ans;
    for(int i = 2; i < maxn; i++){
        if(prime[i] && i%5 == 1){
            ans.push_back(i);
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
mod = 10**9 + 7
m = 10 ** 6
mod = 1000000007

fac = [1] * m
finv = [1] * m
inv = [1] * m


def COMinit():
    for i in range(2, m):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

# COMinit()
ans = 0
for i in range(k, n+1):
    ans += (i*(n+n-i+1)//2 - i*(i-1)//2+1) % mod
print((ans+1)%mod)


Measured memory_bytes: 32372
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(10000);
    rep(i,n) {
        int y;
        cin >> y;
        y--;
        p[y]++;
    }
    int sum,min=1000,ans;
    for(int i=-100; i<1000; ++i) {
        if (p[i]==1) continue; 
        sum=abs(x-i-1);
        if (min>sum) {
            min=sum;
            ans=i;
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 3264
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<long long> a(3 * N);
    for (int i = 0; i < 3 * N; i++)cin >> a[i];

    sort(a.begin(), a.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[3 * N - 2 - i * 2];
    }

    cout << ans << endl;

}


























































Measured memory_bytes: 2560
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int inf = 1e18;
const int maxN = 50 + 1;
const int maxMoney = maxN * 100 + 1234;

vector < pair<int, pair<int,int> > > g[maxN][maxMoney];

int convert(int i, int j) {
    return i * maxMoney + j;
}

pair<int,int> convert_back(int num) {
    return {num / maxMoney, num % maxMoney};
}

void solve() {
    int n, m, s;
    cin >> n >> m >> s;
    if(s > maxMoney) s = maxMoney - 1;
    for(int i = 0; i < m; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        for(int j = 0; j < maxMoney; ++j) {
            if(j >= a) {
                g[u][j].push_back({v, {a, b}});
                g[v][j].push_back({u, {a, b}});
            }
        }
    }
    vector <int> c(n), d(n);
    for(int i = 0; i < n; ++i) {
        cin >> c[i] >> d[i];
    }

    vector <int> D(10 * maxN * maxMoney, inf);
    set < pair<int,int> > S;
    vector <int> usd(10 * maxN * maxMoney, 0);
    int start = convert(0, s);
    D[start] = 0;
    S.insert({D[start], start});
    while(!S.empty()) {
        auto it = S.begin();
        int num = (*it).second;
        usd[num] = 1;
        S.erase(it);
        pair<int,int> con = convert_back(num);
        int v = con.first;
        int mon = con.second;
        // try to make more money...
        if(mon + c[v] < maxMoney) {
            if(D[num + c[v]] > D[num] + d[v]) {
                S.erase({D[num + c[v]], num + c[v]});
                D[num + c[v]] = D[num] + d[v];
                S.insert({D[num + c[v]], num + c[v]});
            }
        }
        // try to go somewhere...
        for(auto u : g[v][mon]) {
            int nv = u.first;
            int nm = mon - u.second.first;
            int delta = u.second.second;
            int nvert = convert(nv, nm);
            if(!usd[nvert] && D[nvert] > D[num] + delta) {
                S.erase({D[nvert], nvert});
                D[nvert] = D[num] + delta;
                S.insert({D[nvert], nvert});
            }
        }
    }
    for(int i = 1; i < n; ++i) {
        int ans = inf;
        for(int j = 0; j < maxMoney; ++j) {
            ans = min(ans, D[convert(i, j)]);
        }
        cout << ans << '\n';
    }
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 111272
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cassert>
using namespace std;

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

	string s;
	int k;
	cin >> s >> k;
	
	int n = s.length();
	set<string> small;
	for (int i = 0; i < n; i++) {
		for (int p = 1; p <= min(k, n-i); p++) {
			small.insert(s.substr(i, p));
		}
	}
	
	auto it = small.begin();
	for (int i = 1; i < k; i++) it++;
	cout << (*it) << endl;
}


Measured memory_bytes: 1664
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

if any([abs(A[i+1] - A[i] == 1) for i in range(len(A)-1)]):
  print(0)
  exit()

is_ok = [True] * (N+1)
for a in A:
  is_ok[a] = False

mod = pow(10, 9) + 7
dp = [0] * (N+1+2)
dp[0] = 1
if is_ok[1]:
  dp[1] = 1
  
for i in range(2, N+1):
  if is_ok[i]:
    if is_ok[i-1]:
      dp[i] = (dp[i] + dp[i-1]) % mod
    if is_ok[i-2]:
      dp[i] = (dp[i] + dp[i-2]) % mod

print(dp[N])

Measured memory_bytes: 8172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
    bool vis[100009]={};
    ll a[100009]={1,1,2};
    ll n,k,x;
    cin>>k>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        vis[x]=true;
    }
    for(int i=1;i<=k;i++)
    {
        if(vis[i]) a[i]=0;
        else a[i]=(a[i-1]%mod+(i>=2?a[i-2]:0)%mod)%mod;
    }
    cout<<a[k];
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
    int H,N;
    cin >> H >> N;
    int Skill[N];
    for(int i=0;i<N;i++){
        cin >> Skill[i];
    }
    
    for(int i=0;i<N&&H>0;i++){
        H-=Skill[i];
    }
    if(H>0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int x = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i + 1 < N; i++) {
                if (a[i] + a[i + 1] > x) {
                    int c = (a[i] + a[i + 1]) - x;
                    count += c;
                    a[i + 1] -= c;
                    if (a[i + 1] < 0) {
                        a[i] += a[i + 1];
                        a[i + 1] = 0;
                    }
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 49176
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}

int main(int argc, char* argv[])
{
    long a,b,k;
    scanf("%ld%ld%ld", &a, &b, &k);

    long count=0;
    long i;
    for(i=100; i>=1; i--) {
        if(a%i==0 && b%i==0) {
            count++;
            if(count==k) {
                printf("%ld\n", i);
                return 0;
            }
        }
    }



    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int d=a;
for(;;){
    if(d%b==c){printf("YES\n");return 0;}
    d=d+a;
    if(d==a*b){break;}
}
printf("NO\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N, K;

int main() {
  cin >> N >> K;
  int ans = 0;
  for (int j=N; j<=K; j++) {
    int i=j;
    int a = i%10;
    i/=10;
    int b = i%10;
    i/=100;
    int c = i%10;
    i/=10;
    int d = i%10;
    if (a==d && b==c) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for i in range(n)]

for i in range(1,n):
    if w[i-1][len(w[i-1])-1] != w[i][0]:
        ans = "No"
        break
else:
    if len(w) != len(set(w)):
        ans = "No"
    else:
        ans = "Yes"

print(ans)

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

using namespace std;

int n,k,i,j;

int main(){
	scanf("%d%d", &n, &k);
	
	int lim = n - 2;
	long long res = 0;
	
	for(i = 1; i < 6; i++){
		for(j = 0; j < 11; j++){
			int s = 9 * i + 9 + 8 * (j + 1);
			//printf(">> %d %d %d\n", i, j, s);
			if(s % 11 == k){
				if(lim >= j + 1){
					int num = (lim - j - 1) / 11 + 1;
					res += num;
				}
			}
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

const int MAX = 31;
ll dp[MAX];

ll pow(ll A, ll e){
  ll res = 1;
  while(e--) res*=A;
  return res;
}

int main(){
  ll d = 2;
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 5;
  dp[4] = 8;

  for(int i = 4; i < MAX; i+=2){
    ll add = pow(3,d++);
    dp[i+1] = dp[i]+add;
    dp[i+2] = dp[i+1]+add;
  }

  ll n;
  while(cin >> n && n) cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1156
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B, C int

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

	A, B, C = nextInt(), nextInt(), nextInt()

	ans := "NO"
	for i := 1; i <= B; i++ {
		s := i * A
		if s%B == C {
			ans = "YES"
			break
		}
	}

	fmt.Println(ans)
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll INF=1LL<<60;
const int MOD=998244353;
const int N=2e5+5;



int main(){
    int N, u, v; cin >> N >> u >> v;
    u--, v--;
    vector<vi> G(N);
    for(int i=0; i<N-1; i++){
        int A, B; cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    vector<vi> dist(2, vi(N, -1));
    for(int i=0; i<2; i++){
        queue<int> que;
        que.push(v+(u-v)*i);
        dist[i][v+(u-v)*i]=0;
        while(!que.empty()){
            int p=que.front();
            que.pop();
            for(auto &np : G[p]){
                if(dist[i][np] != -1) continue;
                dist[i][np]=dist[i][p]+1;
                que.push(np);
            }
        }
    }
    int res=0;
    for(int i=0; i<N; i++){
        if(dist[0][i] > dist[1][i]) res=max(res, dist[0][i]);
    }
    res--;
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

const int inf = 1e9+10;
vector<int> dp(100010,inf);
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];
	
	rep(i,n){
		// a[i] を入れる最適な場所 ak < a[i+1] < a[k+1] となるような k を見つける
		int it = lower_bound(dp.begin(), dp.end(), a[i]+1) - dp.begin();
		if(it == 0) {
			dp[it] = a[i];
		} else{
			if(dp[it-1] < a[i]){
				dp[it] = a[i];
			}
		}
	}
	int ans = 0;
	rep(i,100010){
		if(dp[i] != inf){
			ans ++;
		}
	}
	cout << ans << endl;
}



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

int main(){
    int a,c;
    char b;
    cin>>a>>b>>c;
    if(b=='+'){
        cout<<a+c;
    }else{
        cout<<a-c;
    }
cout<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string W,T;
    int count = 0;
    cin >> W;
    while(cin >> T){
        if (T == "END_OF_TEXT") break;
        else{
            for (int i = 0; i < T.size(); i++){
                T[i] = tolower(T[i]); 
            }
            if(T == W) count++;
        }
         
    }
    cout << count << endl;
    return 0;
}


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

long long n, t, a;

void solve();

int main() {
  cin >> n;
  solve();
  cout << t + a << endl;
  return 0;
}

void solve() {
  a = t = 1;
  for(long long i = 0; i < n; ++i) {
    long long nt, na, x, nextn;
    cin >> nt >> na;
    if(nt == na)
      t = a = max(a, t);
    else if(nt < na) {
      x = t % nt;
      if(x == 0) x = nt;
      t += nt - x;
      nextn = t;
      if(nextn / nt * na < a) {
        x = (a - nextn / nt * na);
        if(x % na != 0) x += na;
        nextn += x / na * nt;
      }
      t = nextn;
      a = nextn / nt * na;
    }
    else {
      x = a % na;
      if(x == 0) x = na;
      a += na - x;
      nextn = a;
      if(nextn / na * nt < t) {
        x = (t - nextn / na * nt);
        if(x % nt != 0) x += nt;
        nextn += x / nt * na;
      }
      a = nextn;
      t = nextn / na * nt;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

vector<int> num;
vector<int> l(8),g(3);
int ans = mod;

void SomeBit(int n,int k,const int m){
  if(k == 0){
    vector<int> result(n,0);
    vector<int> cnt(n,0);
    for(int i = 0; i < m; i++){
      for(int j = 0; j < n; j++){
        if(num[i] == j){
          result[j] += l[i];
          cnt[j]++;
        }
      }
    }
    int now = 0;
    for(int i = 0; i < n; i++){
      if(cnt[i] == 0){
        return;
      }
      now += abs(g[i]-result[i]);
      now += (cnt[i]-1)*10;
    }
    ans = min(ans,now);
    return;
  }

  for(int i = 0; i <= n; i++){
    num.push_back(i);
    SomeBit(n,k-1,m);
    num.pop_back();
  }

  return;
}


int main(){
  int n;
  cin >> n;
  for(int i = 0; i < 3; i++) cin >> g[i];
  for(int i = 0; i < n; i++) cin >> l[i];
  SomeBit(3,n,n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int a, b, v, w; int t;
	cin >> a >> v >> b >> w; cin >> t;
	int s = v - w;
	if (s * t >= abs(b - a))
		cout << "YES";
	else
		cout << "NO";



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

ll mod=998244353;
struct Mint {
    ll val;
    Mint inv() const{
        ll tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x):val(x>=0?x%mod:x%mod+mod){}
    int mtoi(){return this->val; }
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    bool operator==(const Mint& x) const{return val==x.val;}
    bool operator!=(const Mint& x) const{return val!=x.val;}
    bool operator<(const Mint& x) const{return val<x.val;}
    bool operator<=(const Mint& x) const{return val<=x.val;}
    bool operator>(const Mint& x) const{return val>x.val;}
    bool operator>=(const Mint& x) const{return val>=x.val;}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
    int n; scanf("%d",&n);
    factorial fact(10000010);
    Mint ans=Mint(3).pow(n);
    rep(i,n/2+1,n+1){
        ans-=fact.nCr(n,i)*Mint(2).pow(n-i)*2;
    }
    printf("%d\n",ans.val);
    return 0;
}

Measured memory_bytes: 156544
L, R = list(map(lambda x: int(x), input().split(" ")))

if R - L >= 2019:
  print(0)
else:
  A = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      A.append((i * j) % 2019)
  print(min(A))
    

Measured memory_bytes: 81272
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string a, b;
  cin >> a >> b;

  string c;
  for(char ch: a){
    c.push_back(ch);
  }
  for(char ch: b){
    c.push_back(ch);
  }

  int j = stoi(c);
  for(int i = 0; i <= 20000; i++){
    if(i * i == j){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
int main()
{

    int i,k,j,cn=0;
    char s[100];
    gets(s);
    i=strlen(s);
    if(i==6)
    {
        if(s[2]==s[3] && s[4]==s[5]) printf("Yes\n");
        else printf("No\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    int K;
    cin >> K;
    
    vector< vector<int> > nums;
    for (int digits = 0; digits < 10; digits++) {
        vector<int> num;
        for (int i = 0; i < 10; i++) {
            if (digits == 0) {
                num.push_back(1);
            } else {
                int temp = 0;
                for (int j = max(0, i - 1); j < min(10, i + 2); j++) {
                    temp += nums[digits - 1][j];
                }
                num.push_back(temp);
            }
        }
        nums.push_back(num);
    }
    
    int digit = 0;
    int count = 1;
    int num = 1;
    while (true) {
        if (count == K) {
            while (digit >= 0) {
                cout << num;
                num = max(0, num - 1);
                digit--;
            }
            break;
        }
        
        if (count + nums[digit][num] <= K) {
            count += nums[digit][num];
            num++;
        } else {
            cout << num;
            digit--;
            num = max(0, num - 1);
        }
        
        if (num == 10) {
            num = 1;
            digit++;
        }
    }
    
    return 0;
}


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

const int maxn=2e5;
const int INF=~0U>>2;

int n,k;
int A[maxn+10];
LL pre[maxn+10],ans;

void gao(int L,int R){
	if(L==R)ans+=A[L]>=0;
	else{
		int mid=(L+R)>>1;
		gao(L,mid);gao(mid+1,R);

		int cnt=0;
		pre[cnt]=0;
		for(int i=mid+1;i<=R;i++)pre[cnt]=pre[cnt++]+A[i];
		sort(pre+1,pre+cnt+1);
		LL sum=0;
		for(int i=mid;i>=L;i--){
			sum+=A[i];
			int t=lower_bound(pre+1,pre+cnt+1,-sum)-pre;
			ans+=max(0,cnt-t+1);
		}
	}
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		A[i]=t-k;
	}
	gao(1,n);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1920
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s


mx = 0
n = load()
H = load_list()
tmp = 0
for i in range(1, n):
    if H[i-1] >= H[i]:
        tmp += 1
        mx = max(tmp, mx)
    else:
        tmp = 0
print(mx)

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

int n,k;
int a[200005],cf[200005];

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	while (k--)
	{
		for (int i=1;i<=n;i++)  cf[i]=0;
		for (int i=1;i<=n;i++)
		{
			int l=max(i-a[i],1ll),r=min(i+a[i],n);
			cf[r+1]--,cf[l]++;
		}
		int now=0;
		for (int i=1;i<=n;i++)
		{
			now+=cf[i];
			a[i]=now;
		}
		int flag=1;
		for (int i=1;i<=n;i++)
		{
			if (a[i]!=n)
			{
				flag=0;
				break;
			}
		}
		if (flag==1)  break;
	}
	for (int i=1;i<=n;i++)  cout<<a[i]<<' ';
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 6720
#include<bits/stdc++.h>
#define MAX 200001
using namespace std;

long long n;
long long _xor[MAX],sum[MAX];

long long x;
long long ans;
long long l,r;
long long now;

int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		sum[i]=sum[i-1]+x;
		if(i>1)
			_xor[i]=_xor[i-1] xor x;
		else
			_xor[i]=x;
	}
	l=0,r=1;
	while(r<=n){
		while(l<=r && (_xor[r]^_xor[l])!=(sum[r]-sum[l])){
			l++;
		}
		ans+=r-l;
		r++;
	}
	printf("%lld",ans);
}

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

using namespace std;

struct Card {
    char suit;
    int value;
};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N - 1; ++i) {
        for (auto j = N - 1; j > i; j--) {
            if (A[j - 1].value > A[j].value) {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for (int i = 0; i < N - 1; ++i) {
        auto mini = i;
        for (auto j = i + 1; j < N; j++) {
            if (A[mini].value > A[j].value) {
                mini = j;
            }
        }
        if (mini != i) swap(A[i], A[mini]);
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i != 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card A[], struct Card B[], int N) {
    for (int i = 0; i < N; ++i) {
        if (A[i].suit != B[i].suit) return false;
    }
    return true;
}

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

    Card C1[36];
    for (int i = 0; i < N; ++i) {
        cin >> C1[i].suit >> C1[i].value;
    }

    Card C2[36];
    for (int i = 0; i < N; ++i) {
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;

    print(C2, N);
    cout << ((isStable(C1, C2, N)) ? "Stable" : "Not stable") << endl;
    return 0;
}


Measured memory_bytes: 3100