akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int N,M;
    cin >> N >> M;
    int a;
    int b;
    bool s[200010] = {false};
    bool t[200010] = {false};

    for( int i = 0; i < M; i++){
        cin >> a >> b;
        if( a == 1 ) s[b] = true;
        if( b == N ) t[a] = true;
    }

    for( int i = 0; i <= M; i++){
        if( s[i] == true && t[i] == true ){
            printf("POSSIBLE");
            return 0;
        }
    }
    printf("IMPOSSIBLE");
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define LL long long
int pos[maxn];
set<int>S;
int main(){
	int n,x;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&x),pos[x]=i;
	S.insert(0),S.insert(n+1);
	LL ans=0;
	for(int i=n;i;i--){
		S.insert(pos[i]);
		auto j=S.find(pos[i]),k=j;
		int l0=*(--j),l1=(j!=S.begin())?*(--j):-1,r0=*(++k),r1=(++k)!=S.end()?*k:-1,w=0,x=pos[i];
//		printf("%d %d %d %d\n",l0,l1,r0,r1);
		if(l1!=-1)w+=(r0-x)*(l0-l1);
		if(r1!=-1)w+=(x-l0)*(r1-r0);
		ans+=1ll*i*w;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    long long N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (int i = 0; i < N; i++)
        cin >> H[i];
    sort(H.begin(), H.end());
    long long counter = 0;
    for (int i = 0; i < N - K; i++)
        counter += H[i];
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

string s;
char c[] = "SW";
string check(string a, int now, int pre) {
  string res = a;
  rep(i, 1, s.size() - 1) {
    int nnow;
    if (s[i] == 'o') {
      if (c[now] == 'S') {
        nnow = pre;
      } else {
        nnow = 1 - pre;
      }
    } else {
      if (c[now] == 'S') {
        nnow = 1 - pre;
      } else {
        nnow = pre;
      }
    }
    res.push_back(c[nnow]);
    pre = now;
    now = nnow;
  }
  err(res);
  rep(i, s.size()) {
    auto check = [&](int i) {
      return (res[(i + s.size() - 1) % s.size()] == res[(i + 1) % s.size()]);
    };
    if (s[i] == 'o') {
      if (res[i] == 'S') {
        if (check(i) == false)return "";
      } else
        if (check(i) == true)return "";
    } else {
      if (res[i] == 'S') {
        if (check(i) == true)return "";
      } else if (check(i) == false)return "";

    }
  }
  return res;
}
void Calc() {
  int n = in;
  in, s;
  string res = check("SS", 0, 0);
  if (res.size()) {
    cout << (res) << endl;
    return;
  }
  res = check("SW", 1, 0);
  if (res.size()) {
    cout << (res) << endl;
    return;

  }
  res = check("WS", 0, 1);
  if (res.size()) {
    cout << (res) << endl;
    return;
  }
  res = check("WW", 1, 1);
  if (res.size()) {
    cout << (res) << endl;
    return;
  }
  cout << (-1) << endl;
}


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

int main() {
	
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 1000000000;
	for (int i = -100; i <= 100; i++) {
		int tmp = 0;
		for (int j = 0; j < n; j++) {
			tmp += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N,K;
    cin >> N;
    ll a[N];
    ll ans=0;
    ll sum=0;
    FOR(i,0,N-1){
      cin>>a[i];
    }
    ll c1=0;
    ll c2=0;
    ll c3=0;
    ll c4=0;
    ll c5=0;
    ll c6=0;
    ll c7=0;
    ll c8=0;
    ll c9=0;
    FOR(i,0,N-1){
      if(a[i]<400){
        c1=1;
      }else if(a[i]<800){
        c2=1;
      }else if(a[i]<1200){
        c3=1;
      }else if(a[i]<1600){
        c4=1;
      }else if(a[i]<2000){
        c5=1;
      }else if(a[i]<2400){
        c6=1;
      }else if(a[i]<2800){
        c7=1;
      }else if(a[i]<3200){
        c9=1;
      }else{
        c8++;
      }
    }

    ll ans1 =c1+c2+c3+c4+c5+c6+c7+c9;
    if(ans1==0){ans1=1;}
    ll ans2=c1+c2+c3+c4+c5+c6+c7+c8+c9;



  cout<<ans1<<" "<<ans2<<endl;

  return 0;
}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 20:04:25 2020

@author: k
"""

n = int(input())
a = input().split()
inf = 1000000000000000000
ans = 1
f = 1
for x in a:
    x = int(x)
    if x == 0:
        f = 0
    if ans == -1:
        continue
    ans = ans*x
    if ans > inf:
        ans = -1
print(ans*f)

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

int main() {
	int A, B;
	cin >> A >> B;

	int x;
	for (int i = 1; i < 4; i++) {
		if (i != A && i != B) {
			x = i;
		}
	}
	cout << x << endl;
}


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

using namespace std;


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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll a[7];

int main(){
    migmig
	for(int i = 0 ; i < 7 ; i ++ )
		cin >> a[i];
	ll ans = 0;
	ans+=a[0]/2*2;
	ans+=a[1];
	ans+=a[3]/2*2;
	ans+=a[4]/2*2;
	if(a[0]%2 and a[3]%2 and a[4]%2)ans+=3;
	ll ans2 = 0;
	ll boz = min(a[0] , a[3]);
	boz = min(boz , a[4]);
	ans2+=3*boz;
	a[0]-=boz , a[3]-=boz , a[4]-=boz;
	ans2+=a[0]/2*2;
	ans2+=a[1];
	ans2+=a[3]/2*2;
	ans2+=a[4]/2*2;
	a[0]+=boz , a[3]+=boz , a[4]+=boz;
	ll ans3 = 0;
	if(a[0] and a[3] and a[4]){
		ans3+=3;
		boz = 1;
		a[0]-=boz , a[3]-=boz , a[4]-=boz;
		ans3+=a[0]/2*2;
		ans3+=a[1];
		ans3+=a[3]/2*2;
		ans3+=a[4]/2*2;
	}
	cout << max(ans , max(ans3 , ans2));
    return(0);
}

Measured memory_bytes: 256
def main():
    N, K = map(int,input().split())
    A = list(map(int, input().split()))
    s = 0
    d = {}
    d[0] = {0}
    r = 0
    l = [0] * (N + 1)
    for i, v in enumerate(A, start=1):
        if i - K >= 0:
           x = l[i - K]
           d[x].remove(i-K)
        s += v % K
        s %= K
        t = (s - i) % K
        l[i] = t
        if t in d:
            r += len(d[t])
            d[t].add(i)
        else:
            d[t] = {i}
    return r
print(main())


Measured memory_bytes: 85144
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        int n;
        cin >> n;
        if (n >= 1000) cout << "ABD" << endl;
        else cout << "ABC" << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a = 0, b = 0;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll M = 1000000007;

int main () {
  ll N;
  cin >> N;
  ll ans = 1;
  for (ll i = 1; i <= N; ++i) {
    ans *= i;
    ans %= M;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    const ll p = 2019;
    
    vl rui(n+1);
    ll ten = 1;
    for(ll i = n-1; i >= 0; i--) {
        ll x = (s[i] - '0')*ten%p;
        rui[i] = (rui[i+1] + x)%p;
        ten *= 10;
        ten %= p;
    }
    
    vl cnt(p);
    ll ans = 0;
    for(ll i = n; i >= 0; i--) {
        ans += cnt[rui[i]];
        cnt[rui[i]]++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 5180
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h>
#include<queue>
using namespace std;
int a[102];
int main()
{int n,m=0,x,s=100000;cin>>n>>x;
for(int i=0;i<n;i++){
	cin>>a[i];m+=a[i];s=min(s,a[i]);
}
cout<<(x-m)/s+n;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, a, b; cin >> n >> a >> b;
  if(a + b > n + 1) {
    cout << -1 << endl;
    return 0;
  }
  if(a*b < n) {
    cout << -1 << endl;
    return 0;
  }
  vector<ll> v;
  ll s = n - a;
  ll cur = n;
  for(int i=0;i<a;++i) {
    int num = min(b-1, s) + 1;
    s -= num - 1;
    for(int j=0;j<num;++j) {
      v.push_back(cur - num + 1 + j);
    }
    cur -= num;
  }
  reverse(v.begin(), v.end());
  printv(v);
}


Measured memory_bytes: 6256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, Q = mapint()
query = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l, r = mapint()
    query[l][r] += 1

from itertools import accumulate
for i in range(N+1):
    query[i] = list(accumulate(query[i]))
for i in range(1, N+1):
    for j in range(N+1):
        query[i][j] += query[i-1][j]

for _ in range(Q):
    p, q = mapint()
    print(query[N][q]-query[p-1][q])

Measured memory_bytes: 81076
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (a+b>=c) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}



Measured memory_bytes: 1688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, N;
  cin >> H >> N;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    H -= x;
  }
  if(H > 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) {cout << b << endl;}
	if (a <= 12 && a >= 6) {cout << b / 2 << endl;}
	if (a <= 5) {cout << 0 << endl;} 
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T1BC2019_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine()) - 1;

            char change = s[k];

            char[] charArray = s.ToCharArray();

            for (int i = 0; i < n; ++i)
            {
                if (charArray[i] != change)
                {
                    charArray[i] = '*';
                }
            }

            Console.WriteLine("{0}", new string(charArray));

        }
    }
}


Measured memory_bytes: 13268
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = b[a[0]-1]
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i] - a[i-1] == 1:
        ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    int N,M;cin>>N>>M;
    vector<vector<pii> > G(N);
    for(int i=0;i<M;++i){
        int L,R,D;cin>>L>>R>>D;
        L--;R--;
        G[L].push_back(pii(R,D));
        G[R].push_back(pii(L,-D));
    }
    vector<int> dis(N,INF);
    queue<int> que;
    for(int i=0;i<N;++i)if(dis[i]==INF){
        dis[i]=0;
        que.push(i);
        while(!que.empty()){
            int u=que.front();que.pop();
            for(auto e:G[u]){
                if(dis[e.first]!=INF&&dis[e.first]!=dis[u]+e.second){
                    cout<<"No"<<endl;
                    return 0;
                }else if(dis[e.first]==INF){
                    dis[e.first]=dis[u]+e.second;
                    que.push(e.first);
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 12368
#include<iostream>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = k;i < n;i++) {
		if (a[i] > a[i - k])cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 3884
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	ll n;
	cin>>n;
	ll d,x;  // d days  x remain
	cin>>d>>x;
	ll *a=new ll[n];
	ll sum=0;
	sum+=x;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum++;
		sum+=(d-1)/a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<String, List<int[]>> map = new HashMap<>();
      for(int i = 1; i <= n; i++) {
        String city = sc.next();
        if(!map.containsKey(city))
            map.put(city, new ArrayList<>());
        map.get(city).add(new int[]{sc.nextInt(), i});
      }
      List<String> cities = new ArrayList<>(map.keySet());
      Collections.sort(cities, (c1, c2) -> c1.compareTo(c2));
      for(String city : cities) {
          List<int[]> res = map.get(city);
          Collections.sort(res, (r1, r2) -> r2[0] - r1[0]);
          for(int[] r : res)
            System.out.println(r[1]);
      }
      
  }
}

Measured memory_bytes: 27476
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let k = get!();
    let mut min = std::i64::MAX;
    let mut p = 0;
    for i in 0..n {
    	let x = get!();
        if x < min {
        	min = x;
            p = i;
        }
    }
    let mut ans = 0;
    if p < k {
    	ans += 1;
        ans += ((n-k)+((k-1)-1))/(k-1);
    } else if p > n-k {
    	ans += 1;
        ans += ((n-k)+((k-1)-1))/(k-1);
    } else {
    	ans = std::i64::MAX;
    	for i in p-(k-1)..p+1 {
        	let j = i+(k-1);
            let mut tmp = 1;
            tmp += (i+((k-1)-1))/(k-1);
            tmp += (n-(j+1)+((k-1)-1))/(k-1);
            if tmp < ans {
            	ans = tmp;
            }
        }
    }
    println!("{}", ans);
}

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

int dp[2010][2010];

main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n+1),b(m+1);
  rep(i,n){
    cin>>a[i+1];
  }
  rep(i,m){
    cin>>b[i+1];
  }

  rep(i,n+1){
    dp[i][0]=1;
  }
  rep(i,m+1){
    dp[0][i]=1;
  }
  
  FOR(i,1,n+1){
    FOR(j,1,m+1){
      int res=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
      if(a[i]==b[j]) res+=dp[i-1][j-1];
      dp[i][j]=res+M;
      dp[i][j]%=M;
    }
  }

  cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int main() {
	fastio; int a, b, c; cin >> a >> b >> c;
  cout << (a <= b*c ? "Yes" : "No");
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n>>k;
    ll a[n] = {0};
    for(i=0;i<k;i++){
        cin>>x;
        for(j=0;j<x;j++){
            cin>>y;
            a[y-1] = 1;
        }
    }
    for(i=0;i<n;i++){
        if(a[i] == 0)count++;
    }
    cout<<count;
}    
    

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



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


int main()
{
  vector<string> vec = {"AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABR","AKIHBAR","KIHABAR","AKIHBRA","KIHABRA","KIHBARA","AKIHBR","KIHBRA","KIHBAR","KIHABR","KIHBR"};
  string s ;
  cin >> s ;
  int n = SZ(vec) ;
  REP(i,n){
    if(vec.at(i)==s){
      cout <<"YES"<<endl ;
      return  0;
    }
  }
  
  cout <<"NO"<<endl ;

  return 0 ;
}




Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let n = read_i64() as usize;
    let xs = {
        let mut res = vec![];
        for _ in 0..n {
            let ys = read_vec_i64();
            res.push((ys[0], ys[1]));
        }
        res
    };
    let mut res = 0;
    for w in 0..2 {
        let mut left_heap = BinaryHeap::new();
        for i in 0..n {
            left_heap.push((xs[i].0, i));
        }
        let mut right_heap = BinaryHeap::new();
        for i in 0..n {
            right_heap.push((-xs[i].1, i));
        }
        let mut used = vec![false; n];
        let mut tres = 0;
        let mut pos = 0;
        for i in 0..n {
            while used[left_heap.peek().unwrap().1] {
                left_heap.pop();
            }
            while used[right_heap.peek().unwrap().1] {
                right_heap.pop();
            }
            if i % 2 == w {
                let (p,i) = left_heap.pop().unwrap();
                if ! (xs[i].0 <= pos && pos <= xs[i].1) {
                    tres += p - pos;
                    pos = p;
                }
                used[i] = true;
            }
            else {
                let (p,i) = right_heap.pop().unwrap();
                if ! (xs[i].0 <= pos && pos <= xs[i].1) {
                    tres += pos - -p;
                    pos = -p;
                }
                used[i] = true;
            }
            //println!("i={}, pos={}", i, pos);
        }
        tres += pos.abs();
        res = max(res, tres);
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//   fl();
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=6-(a+b);
	printf("%d\n",ans);
	return 0;
}


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

long long mod = 1000000007;
long long fact[1 << 19], inv[1 << 19];
long long val[1 << 19];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2LL == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 500000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 500000; i++) inv[i] = Div(1, fact[i], mod);

	val[0] = 1;
	for (int i = 1; i <= 500000; i++) {
		val[i] = (1LL * i * val[i - 1]);
		if (i % 2 == 1) val[i] -= 1LL;
		if (i % 2 == 0) val[i] += 1LL;
		val[i] = (val[i] + mod * mod) % mod;
	}
}

long long ncr(int n, int r) {
	if (n < r || r < 0) return 0;
	return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}

long long N, M;
long long Answer;

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

	int cx = M - N, cy = N;
	if (cx == 0) {
		Answer = val[N];
	}
	else {
		for (int i = 1; i <= cy; i++) {
			long long v1 = ncr((cx - 1) + (cy - i), cy - i);
			long long v2 = fact[cy];
			long long v3 = inv[i];
			long long v4 = val[i];
			Answer += (v1 * v2 % mod) * (v3 * v4 % mod) % mod;
			Answer %= mod;
		}
		for (int i = 1; i <= cx; i++) {
			long long v1 = ncr((cx - i) + (cy - 1), cy - 1);
			long long v2 = fact[cy];
			Answer += v1 * v2 % mod;
			Answer %= mod;
		}
	}

	long long F1 = fact[M];
	long long F2 = inv[M - N];
	long long F = F1 * F2 % mod;
	cout << Answer * F % mod << endl;
	return 0;
}

Measured memory_bytes: 15332
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string s, t;
	cin >> s >> t;
	int ans = t.size();
	for(int i = 0; i + t.size() <= s.size(); i++) {
		int cr = 0;
		for(int j = 0; j < t.size(); j++)
			if(t[j] != s[i + j]) cr++;
		ans = min(ans, cr);
	}
	cout << ans << '\n';
}



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

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	for(int i=0;i<s.length();i++){
		cnt+=(s[i]=='R'?1:0);
	}
	ll ans=0;
	for(int i=0;i<cnt;i++){
		ans+=(s[i]=='W'?1:0);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3732
#include<stdio.h>
int main(void)
{
	 int a,b,c;
	 scanf("%d %d %d",&a,&b,&c);
	 if(a<b && b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

int main() {
  int T;
  cin >> T;
  while(T--) {
    int x1,y1,x2,y2,x,y,n,ans=0;
    cin >> x1 >> y1 >> x2 >> y2 >> n;
    while(n--) {
      cin >> x >> y;
      if(x1<=x&&x<=x1+x2&&y1<=y&&y<=y1+y2) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3060
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=100000;
int n,mod;
vector<int> nei[N+1];
int dp[N+1];
vector<int> Prod[N+1],proD[N+1];
void dfs(int x=1,int fa=0){
	dp[x]=1;
	Prod[x].resize(nei[x].size()+1);Prod[x][0]=1;
	proD[x].resize(nei[x].size()+1);proD[x][nei[x].size()]=1;
	vector<int> son_dp(nei[x].size());
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y==fa)continue;
		dfs(y,x);
		son_dp[i]=dp[y];
	}
	for(int i=0;i<nei[x].size();i++)Prod[x][i+1]=1ll*Prod[x][i]*(son_dp[i]+1)%mod;
	for(int i=int(nei[x].size())-1;~i;i--)proD[x][i]=1ll*proD[x][i+1]*(son_dp[i]+1)%mod;
	dp[x]=Prod[x].back();
}
int ans[N+1];
void dfs0(int x=1,int fa=0){
	ans[x]=dp[x];
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y==fa)continue;
		int cpy_x=dp[x],cpy_y=dp[y];
		dp[x]=1ll*Prod[x][i]*proD[x][i+1]%mod*(fa?dp[fa]+1:1)%mod;
		dp[y]=1ll*dp[y]*(dp[x]+1)%mod;
		dfs0(y,x);
		dp[x]=cpy_x;
		dp[y]=cpy_y;
	}
}
int main(){
	cin>>n>>mod;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);nei[y].pb(x);
	}
	dfs();
	dfs0();
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}

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

#define ii pair<int, int>
#define LL long long int 
#define x first
#define y second
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define INF int(1e9)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vi originalA(n), originalB(n), A(n), B(n);

    for(int i=0; i<A.size(); i++)
        cin >> A[i];
    for(int i=0; i<B.size(); i++)
        cin >> B[i];

    originalA = A;
    originalB = B;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    vector<vi> permA = {A};
    vector<vi> permB = {B};
    while(next_permutation(A.begin(), A.end()))
        permA.pb(A);
    while(next_permutation(B.begin(), B.end()))
        permB.pb(B);

    int indexA = 0, indexB = 0;
    for(int j=0; j<permA.size(); j++){
        if(permA[j]==originalA){
            indexA = j;
        }
    }
    for(int j=0; j<permB.size(); j++){
        if(permB[j]==originalB)
            indexB = j;
    }
    cout << abs(indexA-indexB) << endl;
    return 0;
}

Measured memory_bytes: 6324
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,0,n){
		cin >> a[i];
		a[i] -= i+1;
	}
	sort(all(a));
	ll ans = 0;
	ll b = a[(n+1)/2-1];
	rep(i,0,n) ans += abs(a[i]-b);
	
	cout << ans << endl;
}


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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a[4][4];
  rep(i,3)rep(j,3){
    cin >> a[i][j];
  }
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  int ok[4][4] = {};
  rep(i,3)rep(j,3){
    rep(k,n){
      if(a[i][j] == b[k]) ok[i][j] = 1;
    }
  }

  rep(i,3){
    int ans = 1;
    rep(j,3){
      ans *= ok[i][j];
    }
    if(ans != 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i,3){
    int ans = 1;
    rep(j,3){
      ans *= ok[j][i];
    }
    if(ans != 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(ok[0][0]*ok[1][1]*ok[2][2] != 0){
    cout << "Yes" << endl;
    return 0;
  }
  if(ok[2][0]*ok[1][1]*ok[0][2] != 0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
} 







Measured memory_bytes: 256
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a


n, x = [ int(v) for v in input().split() ]
city_list = [ int(v) for v in input().split() ] + [x]
city_list.sort()

ans = 0

def_list = [ city_list[i+1] - city_list[i] for i in range(n)]


if n == 1:
	ans = def_list[0]
else:
	gcd_list = [ 0 for i in range(n-1)]
	gcd_list[0] = gcd(def_list[0],def_list[1])
	for i in range(1,n-1):
		gcd_list[i] = gcd(gcd_list[i-1], def_list[i+1])

	ans = gcd_list[-1]
print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int k, x; cin >> k >> x;

	FOR_LE(i, x - k + 1, x + k - 1) {
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
unsigned long long int n;
unsigned long long int a;
unsigned long long int b;

cin>>n>>a>>b;
if(n%(a+b)<a)
cout <<(n/(a+b))*a+(n%(a+b));
else 
cout <<(n/(a+b))*a+a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    ll ans;
    if (n == 1) {
        if (m == 1) ans = 1;
        else if (m == 2) ans = 0;
        else ans = m-2;
    } else if (n == 2) {
        ans = 0;
    } else {
        ans = max(n-2, 0ll) * max(m-2, 0ll);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  if (M < 2 * N) {
    ans = M/2;
  } else {
    ans += N;
    M -= 2 * N;
    ans += M/4; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
                if(n == 1){
                    System.out.println("Hello World");
                } else {
                    int a = sc.nextInt();
		    int b = sc.nextInt();
                    System.out.println(a + b);
                }
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

ll N;
string S;

void input() {
    cin >> N >> S;
}

bool solve() {
    ll def = 0;
    for (auto s : S) {
        if (s == 'R')
            def++;
        else
            def--;
    }
    return def > 0;
}

int main() {
    input();
    cout << (solve() ? "Yes" : "No") << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  ll a,b;
  cin>>a>>b;
  cout<<a+b/2<<endl;  
}
return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> price(N);
  for(int i = 0; i < N; i++) {
    cin >> price.at(i);
  }
  sort(price.begin(), price.end());
  int ans = 0;
  for(int i = 0; i < K; i++) {
    ans += price.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<int> v(n,-1);
    vector<int> tree[100005];
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    queue<int> q;
    v[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int now = q.front(); q.pop();
        rep(i,tree[now].size()) {
            int next = tree[now][i];
            if(v[next]==-1) {
                q.push(next);
                v[next] = now;
            }
        }
    }
    cout << "Yes" << endl;
    REP(i,1,n) {
        cout << v[i]+1 << endl;
    }
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int>h(n);
	vector<int> cost(n);
	rep(i,n)cin >> h[i];


	cost[0] = 0;
	cost[1] = abs(h[1]-h[0]);
	for(int i = 2; i< n; i++){
		cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),
					cost[i-2]+abs(h[i]-h[i-2]));
	}

	cout << cost[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_V 5000
#define INF 999999999
 
struct edge{int to,cost;};
vector<edge> G[MAX_V];
int d[MAX_V];
 
void dijkstra(int s,int V){
  priority_queue< pii,vector<pii>,greater<pii> > que;
  rep(i,V)d[i]=INF;
  d[s]=0;
  que.push(pii(0,s));
     
  while(que.size()){
    pii p=que.top();
    que.pop();
         
    int v=p.second;
    if(d[v]<p.first)continue;
         
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(pii(d[e.to],e.to));
      }
    }
  }
}
 
int main(){
  int n , k , o ;
  while(cin>>n>>k,n+k){
    rep(i,n)G[i].clear();;
    while(k--){
    cin>>o;
    //cout<<o<<" ";
    if(o){
      int a,b,c;
      cin>>a>>b>>c;
      --a,--b;
      G[a].push_back({b,c});
      G[b].push_back({a,c});
    }else{
      int a,b;
      cin>>a>>b;
      --a,--b;
      dijkstra(a,n);
      cout<<(d[b]!=INF?d[b]:-1)<<endl;
    }
    //    cout<<endl;
  }
  }

}

Measured memory_bytes: 1368