akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

vector<ll> factinv(200010,0LL), fact(200010,0LL), p;

ll pow(ll b, ll e) {
    ll res = 1;
    while (e) {
        if (e&1) res *= b;
        e >>= 1;
        b *= b;
        b %= MOD;
        res %= MOD;
    }
    return res;
}

void init() {
    fact[0] = 1, fact[1] = 1;
    for (int i=2;i<=200000;i++) fact[i] = fact[i-1] * i % MOD;
    factinv[0] = 1, factinv[1] = 1;
    for (int i=2;i<=200000;i++) factinv[i] = pow(fact[i],MOD-2);

    for (int i=2;i<=100000;i++) {
        bool flag = true;
        for (int j=2;j*j<=i;j++) {
            if (i%j == 0) {
                flag = false; break;
            }
        }
        if (flag) p.push_back(i);
    }
}

map<ll,int> prime(ll X) {
    map<ll,int> res;
    for (auto itr: p) {
        if (X == 1) break;
        ll Y = itr;
        int j = 0;
        while (X%Y == 0) {
            Y *= itr; j++;
        }
        res[itr] = j;
        X = X*itr / Y;
    }
    if (X>1) res[X] = 1;
    return res;
}

int main(void) {
    int N;
    ll M;
    cin >> N >> M;
    init();

    map<ll,int> V = prime(M);
    ll res = 1;
    for (auto itr: V) {
        res = res * fact[N+itr.second-1] % MOD * factinv[N-1] % MOD * factinv[itr.second] % MOD;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4096
N, M = map(int, input().split())
left = 0
right = 10 ** 5
for _ in range(M):
  l, r = map(int, input().split())
  left = max(left, l)
  right = min(right, r)
ans = right - left + 1
print(ans if ans > 0 else 0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  int n;
  P team[1000010];
  while(cin >> n , n){
    for(int i=0;i<n;i++){
      scanf("%d",&team[i].second);
      team[i].first = 0;
      for(int j=0;j<8;j++){
	int a; scanf("%d",&a);
	if(j % 2 == 0) team[i].first += a*60;
	else team[i].first += a;
      }
    }
    sort(team,team+n);
    cout << team[0].second << endl;
    cout << team[1].second << endl;
    cout << team[n-2].second << endl;
  }  
}

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
const int YYQ=1e9+7;
int n,dp[1<<21+5],a[25][25];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)	for(int j=0;j<n;j++)	cin>>a[i][j];
	dp[0]=1;
	for(int i=0;i<n;i++)	for(int j=0;j<(1<<n);j++){
		if(__builtin_popcount(j)!=i)	continue;
		for(int s=0;s<n;s++)
			if(a[i][s]&&(j>>s)&1^1)
				dp[j|(1<<s)]=(dp[j]+dp[j|(1<<s)])%YYQ;
	}
	cout<<dp[(1<<n)-1]%YYQ<<endl;
}

Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

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

    if(r < 1200){
        cout << "ABC" << endl;
    } 
    else if (r < 2800){
        cout << "ARC" << endl;
    } 
    else cout << "AGC" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
	double n, d1, x, ans = 0;
	cin >> n >> d1 >> x;
    d1 = d1 + d1 + x;
    x*= 4;
    while(n){
        ans += (d1 * n + x * n * (n - 1) / 2) / 2 / n;
        d1 += d1 / n + 3 * x / 2 / n;
        x += 2 * x / n;
        n--;
    }
    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long ll;
bool valid(ll a, ll b, ll c) {
	return a % 2 == 1 || b % 2 == 1 || c % 2 == 1;
}
set<pair<int, int> > s;
bool ex(ll a, ll b, ll c){
	set<pair<int, int> > :: iterator ite = s.find(MP(a, b));
	if (ite != s.end()) {
		return true;
	}
	ite = s.find(MP(a, c));
	if (ite != s.end()) {
		return true;
	}
	ite = s.find(MP(c, b));
	if (ite != s.end()) {
		return true;
	}
	
	ite = s.find(MP(b, c));
	if (ite != s.end()) {
		return true;
	}
	ite = s.find(MP(c, a));
	if (ite != s.end()) {
		return true;
	}
	ite = s.find(MP(b, a));
	if (ite != s.end()) {
		return true;
	}
	return false;
}

int main(){
  ll a, b, c; 
  cin >> a >> b >> c;
  
  s.insert(MP(a, b));
  s.insert(MP(a, c));
  s.insert(MP(c, b));
  ll ans = 0;
  while (!valid(a, b, c)) {
  	
  	ll temp = (b + c) / 2;
  	ll temp2 = (a + c) / 2;
  	c = (a + b) / 2;
  	a = temp;
  	b = temp2;
  	ans++;
  	if (ex(a, b, c)) {
	  	cout << -1 << "\n";
	  	return 0;
  	}
  	s.insert(MP(a, b));
  	s.insert(MP(a, c));
  	s.insert(MP(c, b));
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import heapq
# n,m=map(int,input().split())
n=int(input())
def deka(a,b,c):
    return a*10**12+b*10**6+c
parents=[-1 for i in range(n)] #ひとつ親、自分が根の場合はその木のサイズ*(-1)
HEN=[] #距離が小さいものが、一番ちっちゃい数になってる
MST=[[] for i in range(n)] #答えである最小全域木
A=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append([i,a,b])
A=sorted(A,key=lambda x:x[1])
for i in range(1,n):
    heapq.heappush(HEN, deka(A[i][1]-A[i-1][1],A[i][0],A[i-1][0]))
A=sorted(A,key=lambda x:x[2])
for i in range(1,n):
    heapq.heappush(HEN, deka(A[i][2]-A[i-1][2],A[i][0],A[i-1][0]))
# for i in range(m):
#     a,b,d=map(int,input().split())
#     heapq.heappush(HEN, deka(d,a,b))

def find(x): #xの最親(根)はなに？
    if parents[x] <0 : return x  #自分自身が根
    parents[x]=find(parents[x])
    return parents[x]
def union(x,y): #くっつける
    xx=find(x) ; yy=find(y)
    if xx==yy: return #xとyの根が同じ(同じグループ)ならなにもしない
    size_xx=abs(parents[xx])
    size_yy=abs(parents[yy]) #xやyの属する木のサイズ
    if size_xx>size_yy: xx,yy=yy,xx #yyの方が大きい
    parents[yy]+=parents[xx]
    parents[xx]=yy  #サイズが小さい木を大きい木に接ぐ

ans=0
while HEN:
    dd= heapq.heappop(HEN)
    d=dd//(10**12) ; a=(dd-d*10**12)//(10**6) ; b=dd%(10**6)
    if find(a)==find(b):continue
    union(a,b) #ループができるようなやつは勝手に飛ばしてくれる
    # MST[a].append(b)
    # MST[b].append(a)
    ans+=d
    #parentsは同じグループかどうかの判定用。だから経路圧縮してもよい。

print(ans)

Measured memory_bytes: 117228
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){

    ll n,k;
    cin >> n >> k;

    ll cnt = 0;
    while(n > 0){
	n /= k;
	cnt++;
    }
    P(cnt);
    return  0;
}


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll x[100005];
int main(){
	std::ios::sync_with_stdio(false);
	ll n,i,j,k,ans=inf,val=0;
	cin>>n>>k;
	rep(i,n){
		cin>>x[i];
	}
	if(k==0){
		cout<<0<<endl;
		return 0;
	}
	i=0;
	while(1){
		j=i+k-1;
		if(j>=n){
			break;
		}
		val=x[j]-x[i];
		if(x[j]<=0){
			val-=x[j];
		}
		else{
			if(x[i]>=0){
				val+=x[i];
			}
			else{
				val+=min(x[j],-1*x[i]);
			}
		}
		i++;
		ans=min(ans,val);
	}
	cout<<ans<<endl;
} 
	

Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))
count = 1
while count>0:
    count=0
    mod = min(A)
    for i in range(n):
        if A[i]==mod:
            continue
        elif A[i]%mod ==0:
            A[i]=mod
            count +=1
        else:
            A[i] = A[i]%mod
            count +=1
print(A[0])

Measured memory_bytes: 14252
// (c) 2020, redotter
// The grass was greener...

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:200000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int (i) = 0; (i) < (n); (i)++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i64 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

const i64 MAXN = 1e6 + 1;

i64 n;
v64 a;
a64<MAXN> np;

void Problem::solve() {
	sort(the(a));
	for (i64 i = 0; i < n; i++) {
		if (np[a[i]]) continue;
		if (i && a[i] == a[i - 1]) continue;
		for (i64 j = 2 * a[i]; j < MAXN; j += a[i]) {
			np[j] = 1;
		}
	}
	i64 ans = 0;
	for (i64 i = 0; i < n; i++) {
		if (i && a[i] == a[i - 1]) continue;
		if (i != n - 1 && a[i] == a[i + 1]) continue;
		ans += !np[a[i]];
	}
	println(ans);
}

void Problem::input() {
	read(n);
	a.resize(n);
	forn(i, n) read(a[i]);
}


Measured memory_bytes: 12680
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    int N;
    long ret = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ret += i;
    }
    cout << ret << endl;
}

Measured memory_bytes: 3636
#define  _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

bool ok(vector<int>& v) {
	for (int i = 0; i < v.size() - 1; i++) {
		if (v[i] > v[i + 1]) return false;
	}
	return true;
}

int main() {
	int n; cin >> n;
	vector<int> v; v.resize(n);
	for (int i = 0; i < n; i++)cin >> v[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int temp = v[i];
			v[i] = v[j];
			v[j] = temp;

			if (ok(v)) {
				printf("YES");
				return 0;
			}

			temp = v[i];
			v[i] = v[j];
			v[j] = temp;

		}
	}
	printf("NO");
	return 0;
}

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

int main(){
    int N;  cin >> N;
    vector<double> p(N+1);
    for(int i=1; i<=N; i++) cin >> p[i];

    vector<vector<double>> dp;
    dp = vector<vector<double>>(N+1, vector<double>(N+1, 0));
    dp[0][0] = 1;

    for(int i=1; i<=N; i++){
        for(int j=0; j<=N; j++){
            dp[i][j] = (1-p[i])*dp[i-1][j] + p[i]*dp[i-1][j-1];
        }
    }
    
    double ans = 0;
    for(int i=N/2+1; i<=N; i++){
        ans += dp[N][i];
    }
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxm=2e6+5;
char s[maxm];
int n;
struct SAM{
    int ch[maxm][26];
    int fa[maxm],l[maxm];//l[]是等价类的最长字符串长度len
    int last=1,tot=1;//tot是节点数量
    //
    int lc[maxm],rc[maxm];
    int cnt[maxm];
    int idx[maxm];
    int solve(){
        for(int i=0;i<=tot;i++)cnt[i]=0;
        for(int i=1;i<=tot;i++)cnt[l[i]]++;
        for(int i=1;i<=tot;i++)cnt[i]+=cnt[i-1];
        for(int i=1;i<=tot;i++)idx[cnt[l[i]]--]=i;
        //
        for(int i=tot;i>=1;i--){
            int x=idx[i];
            if(!lc[fa[x]]||lc[x]<lc[fa[x]]){
                lc[fa[x]]=lc[x];
            }
            if(!rc[fa[x]]||rc[x]>rc[fa[x]]){
                rc[fa[x]]=rc[x];
            }
        }
        int ans=0;
        for(int i=1;i<=tot;i++){
            if(rc[i]-lc[i]>=l[i]){
                ans=max(ans,l[i]);
            }else{
                ans=max(ans,rc[i]-lc[i]);
            }
        }
        return ans;
    }
    //
    void add(int c,int pos){//传入s[i]-'a'而不是s[i]
        int p=last,np=++tot;last=np;l[np]=l[p]+1;
        for(;p&&!ch[p][c];p=fa[p])ch[p][c]=np;
        if(!p)fa[np]=1;
        else{
            int q=ch[p][c];
            if(l[p]+1==l[q])fa[np]=q;
            else{
                int nq=++tot;l[nq]=l[p]+1;
                memcpy(ch[nq],ch[q],sizeof ch[q]);
                fa[nq]=fa[q];fa[q]=fa[np]=nq;
                for(;ch[p][c]==q;p=fa[p])ch[p][c]=nq;
            }
        }
        //记录最左和最右位置
        lc[np]=rc[np]=pos;
    }
    void init(){
        for(int i=1;i<=tot;i++){
            memset(ch[i],0,sizeof ch[i]);
            fa[i]=l[i]=0;
        }
        last=tot=1;
    }
}S;
signed main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    S.init();
    for(int i=1;i<=n;i++){
        S.add(s[i]-'a',i);
    }
    int ans=S.solve();
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> field(H);
    for (int i = 0; i < H; i++) cin >> field[i];

    int res = 1<<29;
    for (int bit = 0; bit < (1<<(H-1)); bit++) {
        bool gok = true;
        int N = 0;
        vector<int> ord(H, 0);
        for (int i = 0; i < H-1; ++i) {
            if (!(bit & (1<<i))) {
                ord[i+1] = ord[i]+1;
                N++;
            }
            else {
                ord[i+1] = ord[i];
            }
        }
        int add = 0;
        vector<int> nums(N+1, 0);
        for (int w = 0; w < W; w++) {
            vector<int> one(N+1, 0);
            bool ok = true;
            for (int h = 0; h < H; h++) {
                one[ord[h]] += field[h][w] - '0';
                nums[ord[h]] += field[h][w] - '0';
                if (one[ord[h]] > K) gok = false;
                if (nums[ord[h]] > K) ok = false;
            }
            if (!ok) {
                add++;
                nums = one;
            }
        }
        if (gok) res = min(res, N+add);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to, cor; };

int dp[3005][3005];
signed main() {
	string s, t; cin >> s >> t;
	rep(i, s.size()) {
		rep(j, t.size()) {
			if (s[i] == t[j])dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}

	int lcs = dp[s.size()][t.size()];
	string ans;
	for (int i = s.size(); i > 0; i--) {
		for (int j = t.size(); j > 0; j--) {
			if (dp[i][j] == lcs&&dp[i][j - 1] == lcs - 1 && dp[i - 1][j] == lcs-1) {
				ans.push_back(s[i - 1]);
				lcs--;
				goto E;
			}
		}
	E:;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
const int MAX=2e5+7,MOD=1e9 + 7;
typedef long long int ll;
map<int,int>cnt_i;
void solve(){
    int n;cin>>n;
    int A[n+5];
    for(int i=1;i<=n;i++){
            cin >> A[i];
            cnt_i[A[i] + i]++;
    }
    ll res=0;
    for(int i=1;i<=n;i++){
            res+= cnt_i[i - A[i]];
    }
    cout<<res<<endl;

}
int main (){
    int t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 21468
#include<iostream>

using namespace std;

int main(){
    int input[3];
    cin >> input[0] >> input[1] >> input[2];

    int num = 0;
    for(int i=0;i<3;i++){
        if(input[i]==5)num++;
        if(input[i]==7)num += 3;
    }
    if(num==5)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
from collections import deque
from math import ceil
import sys
input = sys.stdin.readline

def main():
    N,D,A = map(int,input().split())
    XH = sorted([[int(i) for i in input().split()] for _ in range(N)],key=lambda x: x[0])

    ans = 0
    index = deque()
    damage = 0
    for i in range(N):
        # 爆弾が届かない場合
        while index:
            if index[0][0] + 2*D < XH[i][0]:
                _,c = index.popleft()
                damage -= A * c
            else:
                break
        
        # 爆弾投下
        XH[i][1] -= damage

        # 生き残り
        if XH[i][1] > 0:
            count = ceil(XH[i][1]/A)
            damage += count * A
            index.append([XH[i][0],count])
            ans += count

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 120988
#include <bits/stdc++.h>
using namespace std;
int father(vector<int>& f, int x){
    return (f[x] == x) ? x : (f[x] = father(f, f[x]));
}
int merge(vector<int>& f, int x, int y){
    x = father(f, x);
    y = father(f, y);
    if (x == y)
        return 0;
    f[x] = y;
    return 1;
}
int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int> f(n + 1, 0);
    for (int i = 1; i <= n; i++)
        f[i] = i;
    int ans = n - 1;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if (merge(f, x, y))
            ans --;
    }
    cout << ans << endl;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  cout << max(0, C - (A-B)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
struct dice {
    int face1;
    int face2;
    int face3;
    int face4;
    int face5;
    int face6;
};
 
int check(struct dice d1, struct dice d2, struct dice d1_origin);
struct dice move_W(struct dice d); 
struct dice move_S(struct dice d); 
struct dice move_E(struct dice d); 
struct dice move_N(struct dice d);
 

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

    struct dice d[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d %d %d %d",
                &d[i].face1, &d[i].face2, &d[i].face3, &d[i].face4, &d[i].face5, &d[i].face6);
    }
 
    struct dice d_origin[n];
    for (int i = 0; i < n; i++) {
        d_origin[i].face1 = d[i].face1;
        d_origin[i].face2 = d[i].face2;
        d_origin[i].face3 = d[i].face3;
        d_origin[i].face4 = d[i].face4;
        d_origin[i].face5 = d[i].face5;
        d_origin[i].face6 = d[i].face6;
    }

    int answer = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            answer += check(d[i], d[j], d_origin[i]);
        }
    }
 
    if (answer == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
 
    return 0;
}
 


int check(struct dice d1, struct dice d2, struct dice d1_origin) {
    char command[24][7] = {"",   "SEN",   "SWN",  "SSEE",
                           "N",  "NSEN",  "NSWN", "NSSEE",
                           "W",  "WSEN",  "WSWN", "WSSEE",
                           "E",  "ESEN",  "ESWN", "ESSEE",
                           "S",  "SSEN",  "SSWN", "SSSEE",
                           "SS", "SSSEN", "SSSWN","SSSSEE"};
    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 7; j++) {
            switch (command[i][j]) {
                case 'W':
                    d1 = move_W(d1);
                    break;
                case 'S':
                    d1 = move_S(d1);
                    break;
                case 'E':
                    d1 = move_E(d1);
                    break;
                case 'N':
                    d1 = move_N(d1);
                    break;
                default:
                    break;
            }
        }
        if ((d1.face1 == d2.face1)&&(d1.face2 == d2.face2)&&(d1.face3 == d2.face3)
                 &&(d1.face4 == d2.face4)&&(d1.face5 == d2.face5)&&(d1.face6 == d2.face6)) {
            return 1;
        } else {
            d1 = d1_origin;
        }
    }
    return 0;
}

struct dice move_W(struct dice d) {
    struct dice d_tmp = {d.face3, d.face2, d.face6, d.face1, d.face5, d.face4};
    return d_tmp;
}
 
struct dice move_S(struct dice d) {
    struct dice d_tmp = {d.face5, d.face1, d.face3, d.face4, d.face6, d.face2};
    return d_tmp;
}
 
struct dice move_E(struct dice d) {
    struct dice d_tmp = {d.face4, d.face2, d.face1, d.face6, d.face5, d.face3};
    return d_tmp;
}
 
struct dice move_N(struct dice d) {
    struct dice d_tmp = {d.face2, d.face6, d.face3, d.face4, d.face1, d.face5};
    return d_tmp;
}


Measured memory_bytes: 2120
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            while((line=br.readLine())!=null){  if(line.equals(""))break;
                String[] splited = line.split(",");
                double xa=Double.parseDouble(splited[0]),ya=Double.parseDouble(splited[1]);
                double xb=Double.parseDouble(splited[2]),yb=Double.parseDouble(splited[3]);
                double xc=Double.parseDouble(splited[4]),yc=Double.parseDouble(splited[5]);
                double xd=Double.parseDouble(splited[6]),yd=Double.parseDouble(splited[7]);
                gra=(yc-ya)/(xc-xa);y0=ya;x0=xa;
                boolean check1;
                check1=linemaker(xb,yb)*linemaker(xd,yd)<0;
      if(!check1){System.out.println("NO");continue;}
      gra=(yd-yb)/(xd-xb);y0=yb;x0=xb;
                boolean check2=linemaker(xa,ya)*linemaker(xc,yc)<0;
                if(check2)System.out.println("YES");else System.out.println("NO");
                
            }         
        }catch(Exception e){e.printStackTrace();}        
    }
    static double gra=0,y0=0,x0=0;
    static double linemaker(double x1, double y1){
        return y1-y0-(gra*(x1-x0));
    }
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << "2018/01/" << s[8] << s[9] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll s;
  cin>>s;
  ll res=1000;
  while(s>=100)
  {
    chmin(res,abs(753-s%1000));
    s/=10;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	ruisekiwa := make([]int, n)
	ruisekiwa[0] = getInt()
	for i := 1; i < n; i++ {
		ruisekiwa[i] = ruisekiwa[i-1] + getInt()
	}

	ans := 99999
	for i := 0; i < n-1; i++ {
		ans = min(ans, abs(ruisekiwa[n-1]-ruisekiwa[i]*2))
	}

	fmt.Println(ans)
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
  int w[10],k[10];
  int i,j;
  int sw,sk,t;
  for(i=0;i<10;i++)
    scanf("%d",&w[i]);
  for(i=0;i<10;i++)
    scanf("%d",&k[i]);
  for(i=0;i<9;i++){
    for(j=9;j>i;j--){
      if(w[j-1]<w[j]){
	t=w[j-1];
	w[j-1]=w[j];
	w[j]=t;
      }
      if(k[j-1]<k[j]){
	t=k[j-1];
	k[j-1]=k[j];
	k[j]=t;
      }
    }
  }
  sw=w[0]+w[1]+w[2];
  sk=k[0]+k[1]+k[2];
  printf("%d %d\n",sw,sk);

  return 0;
}

Measured memory_bytes: 596
import math

a, b, x = list(map(int, input().split()))
c = 2 * x / a / b
if c > a:
    bt = 2 * (b - x / a / a)
    print(math.degrees(math.atan2(bt, a)))
else:
    print(math.degrees(math.atan2(b, c)))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAX_N 100000
using namespace std;

int N;
int A[MAX_N], B[MAX_N], C[MAX_N];

int main(){
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        scanf("%d", A + i);
    }
    for(int i = 0; i < N; ++i){
        scanf("%d", B + i);
    }
    for(int i = 0; i < N; ++i){
        scanf("%d", C + i);
    }

    long long ans = 0;
    sort(A, A + N);
    sort(C, C + N);
    for(int j = 0; j < N; ++j){
        int numA = lower_bound(A, A + N, B[j]) - A;
        int numC = upper_bound(C, C + N, B[j]) - C;
        ans += 1LL * numA * (N - numC);
    }

    cout << ans << endl;

    return 0;
}


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

n = int(input())
g = [[] for _ in range(n)]
e = []
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
    e.append((a, b))

# topological順序の計算
s = []
s.append(0)
parent = [-1]*n
order = []
while s:
    x = s.pop()
    order.append(x)
    for nx in g[x]:
        if nx == parent[x]:
            continue
        parent[nx] = x
        s.append(nx)

color = [0]*n
for v in order:
    ng = color[v]
    c = 1
    for u in g[v]:
        if u == parent[v]:
            continue
        if c == ng:
            c += 1
        color[u] = c
        c += 1

ans = []
for a, b in e:
    if parent[a] == b:
        ans.append(color[a])
    else:
        ans.append(color[b])

print(len(set(ans)))
print('\n'.join(map(str,ans)))

Measured memory_bytes: 38196
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll s;
  cin >> s;
  ll a = s;
  set<ll> searched;
  searched.insert(s);
  ll ans = INF;
  int i = 2;
  while (i < 1000005) {
    if (a % 2 == 0) {
      a = a / 2;
    } else {
      a = 3 * a + 1;
    }
    if (searched.find(a) != searched.end()) {
      ans = i;
      break;
    }
    i++;
    searched.insert(a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 10000000
using namespace std;
int main(){
    int T,P,R;
    while(1){
        cin >> T >> P >> R;
        if(T == 0 && P == 0 && R == 0) break;
        int time_table[T][P] = {};
        int flag_table[T][P] = {};
        rep(i,R){
            int team,program,t;
            string flag;
            cin >> team >> program >> t >> flag;
            team--; program--;
            if(flag == "CORRECT"){
                time_table[team][program] = flag_table[team][program]*1200+t;
            }
            else if(flag == "WRONG"){
                flag_table[team][program]++;
            }
        }
        int top = -1;
        vector<pair<pair<int,int> , int> > ans(T);
        rep(i,T){
            int correct = 0;
            int fail = 0;
            rep(j,P){
                if(time_table[i][j] != 0) correct++;
                fail += time_table[i][j];
            }
            ans[i].first.first = -correct;
            ans[i].first.second = fail;
            ans[i].second = i+1;
        }
        sort(ans.begin(),ans.end());
        rep(i,ans.size()){
            cout << ans[i].second << " " << -ans[i].first.first << " " << ans[i].first.second << endl;
        }
        /*rep(i,T){
            rep(j,P){
                cout << time_table[i][j] << " ";
            }
            cout << endl;
        }
        rep(i,T){
            rep(j,P){
                cout << flag_table[i][j] << " ";
            }
            cout << endl;
        }*/
    }
    return 0;
}


Measured memory_bytes: 3120
N,K = map(int,input().split())
S = input()
prev = "1"
count = 0
blocks = []
for i,s in enumerate(S):
    if s != prev:
        blocks.append(count)
        prev = s
        count = 1
    else:
        count += 1
blocks.append(count)
if len(blocks) % 2 == 0:
    blocks.append(0)
if len(blocks) // 2 <= K:
    print(sum(blocks))
else:
    ps = sum(blocks[:2*K+1])
    cur_max = ps
    for i in range(2*(K+1),len(blocks),2):
        ps += blocks[i-1] + blocks[i]
        ps -= blocks[i-2-2*K] + blocks[i-1-2*K]
        cur_max = max(cur_max,ps)
    print(cur_max)

Measured memory_bytes: 46192
#include <stdio.h>

#define n 10000
#define q 500

int main(){

  int a,b,i,j,status;

  int count = 0;
  
  int S[n],T[q];
  
  scanf("%d",&a);

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

  scanf("%d",&b);

  for(i=0;i<b;i++){
    scanf("%d",&T[i]);
    j = 0;
    while(j<a){
      if(S[j] == T[i]){
	count++;
	break;
      }
      j++;
    }
  }

  printf("%d\n",count);



  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int n,s=0,i;
	cin>>n;
	int a[n+1];
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i]-1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void calculate(int a, int b, char op) {
	int res;
	if (op == '+') {
		res = a + b;
	} else if (op == '-' ) {
		res = a - b;
	} else if (op == '*' ) {
		res = a * b;
	} else {
		res = a / b;
	}
	cout << res << endl;
}

int main() {
	while (1) {
		int a, b;
		char op;
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		calculate(a, b, op);
	}
	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int N, K;
int arr[505];
int rem[505];
int psa[505];
vector <int> factors;

void findFactors(int tot){
    int p = (int) sqrt(tot)+1;
    for (int i=1; i<=p; i++) {
        if (tot % i == 0) {
            factors.push_back(i);
            factors.push_back(tot/i);
        }
    }
    sort(factors.begin(), factors.end(), greater<>());
}

int main() {
    cin >> N >> K;
    int tot = 0;
    for (int i=1; i<=N; i++){
        scanf("%d", &arr[i]);
        tot += arr[i];
    }
    findFactors(tot);
    int ans;
    for (int f: factors){
        int idx = 1;
        for (int i=1; i<=N; i++){
            if (arr[i] % f != 0) {
                rem[idx] = arr[i] % f;
                idx++;
            }
        }
        idx--;
        memset(psa, 0, sizeof(psa));
        sort(rem+1, rem+idx+1);
        for (int i=1; i<=idx; i++) psa[i] = psa[i-1]+rem[i];
        int best = INT_MAX;
        if (idx == 0) best = 0;
        for (int i=1; i<idx; i++){
            if (psa[i]-psa[0] == (idx-i)*f-(psa[idx]-psa[i])) best = psa[i]-psa[0];
        }
        if (best <= K) {
            ans = f;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    BY - Darkworld1 ( Tanu kumar )
    college - AIT
    Problem - contest ( div 3 )
*/
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define rep(i,a,n) for( int i = a ; i < n ; i++ )
#define prep( i, a , n ) for ( int i = a ; i>= n ; i--)
#define   pr pair<int,int>
const int N = 13 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
ll ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){

        ll n  ,  m ;
        cin >> n >> m ;
        string s , t ;
        cin >> s >> t ;
        ll l = (n*m) / (__gcd(n,m)) ;
        map < int , char > mp ;
        for( int i = 0 ; i < n ; i++){
            mp[(i*(l/n))+1] = s[i];
        }
        for( int i = 0 ; i < m  ; i++){
            int k = ( i *(l/m) ) + 1 ;
            if ( mp.find(k)!=mp.end() && mp[k] != t[i] ){
                cout << -1;
                return ;
            }
        }
        cout << l ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    ---------------- lemmas-----------------------------------
   1)
   2)
   3)

*/


Measured memory_bytes: 4736
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto T = s[1];
    auto A = iota(N).map!(_ => readln.split.map!(to!int).array).array;
    A.sort!"a[0] < b[0]";

    auto dp = new int[][](N+1, T+1);

    foreach (i; 0..N) {
        foreach (j; 0..T+1) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j != T) dp[i+1][min(T, j + A[i][0])] = max(dp[i+1][min(T, j + A[i][0])], dp[i][j] + A[i][1]);
        }
    }

    dp[N].reduce!max.writeln;
}

Measured memory_bytes: 38780
#ABC088-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
C=[IL() for i in range(3)]
A=[0,0,0]
B=[0,0,0]
for i in range(3):
    B[i]=C[0][i]-A[0]
for i in range(1,3):
    A[i]=C[i][0]-B[0]
flag=True
for i in range(3):
    for j in range(3):
        if A[i]+B[j]!=C[i][j]:
            flag=False
if flag:
    print("Yes")
else:
    print("No")

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

int main() {
  int K, X; cin >> K >> X;

  // range -1,000,000 - 1,000,000

  int start_point = max(X-(K-1), -1000000);
  int end_point = min(X+(K-1), 1000000);
  for (int i = start_point; i < end_point; ++i) {
    cout << i << " ";
  }
  cout << end_point << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    vector<pair<ll, ll>> A;
    while(true){
        ll H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        A.pb(make_pair(H, W));
    }

    rep(i, 0, A.size()){
        rep(y, 0, A[i].first){
            rep(x, 0, A[i].second){
                if(y & 1){
                    if(x & 1) cout << "#";
                    else cout << ".";
                }else{
                    if(~x & 1) cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 2992
package main

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

type node struct {
	key   int
	left  *node
	right *node
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextOperation() int {
	sc.Scan()
	text := sc.Text()
	if text == "insert" {
		return 1
	} else if text == "print" {
		return 0
	} else {
		return 2
	}
}
func Print(nodes []int) {
	// 木の走査によって得られたint型スライスを引数に、
	// 指定されたフォーマットに出力する関数
	writer := bufio.NewWriter(os.Stdout)
	for _, v := range nodes {
		writer.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	writer.Write([]byte("\n"))
	writer.Flush()
}
func Insert(root *node, value int) *node {

	if root == nil {
		return &node{value, nil, nil}
	}

	var parent *node
	anode := root
	for anode != nil {
		parent = anode
		if anode.key > value {
			anode = anode.left
		} else {
			anode = anode.right
		}
	}

	if parent.key > value {
		parent.left = &node{value, nil, nil}
	} else {
		parent.right = &node{value, nil, nil}
	}
	return root
}
func Inorder(root *node, store []int) []int {
	if root != nil {
		store = Inorder(root.left, store)
		store = append(store, root.key)
		store = Inorder(root.right, store)
	}
	return store
}
func Preorder(root *node, store []int) []int {
	if root != nil {
		store = append(store, root.key)
		store = Preorder(root.left, store)
		store = Preorder(root.right, store)
	}
	return store
}
func Find(root *node, value int) bool {
	if root == nil {
		return false
	}
	if root.key == value {
		return true
	}
	if root.key > value {
		return Find(root.left, value)
	}
	return Find(root.right, value)
}
func main() {
	sc.Split(bufio.ScanWords)
	var root *node
	n := nextInt()
	for i := 0; i < n; i++ {
		ope := nextOperation()
		if ope == 1 {
			key := nextInt()
			root = Insert(root, key)
		} else if ope == 0 {
			Print(Inorder(root, []int{}))
			Print(Preorder(root, []int{}))
		} else {
			k := nextInt()
			if Find(root, k) == true {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		}
	}
}



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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


ll mod = 1e9 + 7;

ll powmod(ll b){
    ll r = 1;
    ll c = mod-2;
    for (; c>0; c>>=1, b=b*b%mod){
        if (c&1)    r = r*b%mod;
    }
    return r;
}

ll powdiv(ll a, ll b){
    return a * powmod(b) % mod;
}

ll solve(ll n, ll k){
  ll allSum = 0;
  rep(d, n) allSum += d*(n-d), allSum %= mod;

  return allSum;
}

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

  ll pat = n*m;

  ll c = 1;
  rep(i, k-2){
    c *= (pat-i-2) % mod;
    c %= mod;
    c = powdiv(c, i+1);
  }

  ll allSum = 0;
  ll nSum = solve(n, k);
  allSum += pow(m, 2) * nSum;
  allSum %= mod;

  ll mSum = solve(m, k);
  allSum += pow(n, 2) * mSum;
  allSum %= mod;

  allSum *= c;
  allSum %= mod;

  cout << allSum << endl;
  


  return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  int t = stoi(a+b);
  for(int i=0;i<400;i++){
    if(t == i*i){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>


int main(void) {
	int w, h, x, y, r;
	while (1) {
		scanf("%d", &w);
		scanf("%d", &h);
		if (w == 0 && h == 0)
			break;
		if (w > h) {
			printf("%d %d\n", h, w);
		}
		else {
			printf("%d %d\n", w, h);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

// 重み付きグラフ

void dfs(int cur, vector<vector<pair<int, int> > > &g, vector<int> &color, int c){
    color[cur] = c;
    for(auto x : g[cur]){
        if(color[x.second] != -1) continue;
        int nxt = x.second;
        int val = x.first;
        int nc = c;
        if(val % 2 == 1) nc = (nc + 1) % 2;
        dfs(nxt, g, color, nc);
    }
}

signed main(){

    int n; cin >> n;
    int m = n - 1;
    vector<vector<pair<int, int> > > g(n);
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c; a--; b--;
        g[a].push_back({c, b});
        g[b].push_back({c, a});
    }


    vector<int> color(n, -1);
    dfs(0, g, color, 0);
    for(int i = 0; i < n; i++) cout << color[i] << endl;
    return 0;
}




Measured memory_bytes: 12672