akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll r) {
  cout << r*r << endl;
}

int main() {
  ll r;
  cin >> r;
  solve(r);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String[] s = new String[100];
	for(int i=0; i<n; i++) {
		s[i] = sc.next();
	}
	int m = sc.nextInt();
	String[] t = new String[100];
	for(int i=0; i<m; i++) {
		t[i] = sc.next();
	}
	int counts = 1;
	int countt = 0;
	int answer = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			if(s[i].equals(String.valueOf(s[j]))) {
				counts++;
			}
		}
		for(int k=0; k<m; k++) {
			if(s[i].equals(String.valueOf(t[k]))) {
				countt++;
			}
		}
		if(answer < counts-countt) {
			answer = counts-countt;
		}
		counts = 1;
		countt = 0;
	}
	System.out.println(answer);
}
}


Measured memory_bytes: 21204
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
N -= 2
for i in range(1, N):
    if N >= 2:
        ans += A[i]*2
        N -= 2
    elif N  == 1:
        ans += A[i]
        N -= 1
    else:
        break
print(ans)





Measured memory_bytes: 31576
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

VV G;
V c, dp;
Vll ans;
int s = 0;

void dfs(int u, int p=-1) {
  int tmp = dp[c[u]] + s;
  for (auto v : G[u]) {
    if (v == p) continue;
    int tmp2 = dp[c[u]] + s;
    dfs(v, u);
    ll x = dp[c[u]] + s - tmp2;
    ans[c[u]] -= x*(x+1)/2;
  }
  ++s;
  dp[c[u]] = tmp - s;
}

int main() {
  ll n; cin >> n;
  G.assign(n, V());
  c.assign(n, 0);
  dp.assign(n, 0);
  ans.assign(n, n*(n+1)/2);

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);
  rep(i, n) {
    ll x = dp[i] + s;
    ans[i] -= x*(x+1)/2;
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 33020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {

    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x, 0);
    vector<ll> b(y, 0);
    vector<ll> c(z, 0);

    REP(i,x) cin >> a[i]; 
    REP(i,y) cin >> b[i]; 
    REP(i,z) cin >> c[i];

    vector<ll> ab(x*y, 0);
    int count = 0;
    REP(i,x) {
        REP(j,y) {
            ab[count] = a[i] + b[j];
            count += 1;
        } 
    }  

    sort(ab.begin(), ab.end(), greater<ll>());

    vector<ll> ans(k*z, 0);

    count = 0;
    REP(i, min(k, x*y)) {
        REP(j, z) {
            ans[count] = ab[i] + c[j];
            count += 1;
        } 
    } 

    sort(ans.begin(), ans.end(), greater<ll>());

    REP(i, k) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

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

const vector<int> vi = {-1, 0, 1, 0}, vj = {0, -1, 0, 1};

void update(int id, mat &dist, vector<vector<bool> > &people){
    //bool debug = id == 7;
    queue<P> pque;
    pque.emplace(dist[id/N][id%N], id);
    while(!pque.empty()){
        P p = pque.front(); pque.pop();
        int i = p.se/N, j = p.se%N;
        //if(debug) cout<<i<<' '<<j<<' '<<p.fi<<endl;
        rep(k, 4){
            int ni = i + vi[k], nj = j + vj[k];
            if(ni >= 0 && ni < N && nj >= 0 && nj < N){
                if(chmin(dist[ni][nj], p.fi + people[i][j])){
                    pque.emplace(dist[ni][nj], ni * N + nj);
                }
            }
        }
    }
}

int main() {
    cin>>N;
    vec ord(N * N);
    mat dist(N, vec(N));
    vector<vector<bool> > people(N, vector<bool>(N, true));
    rep(i,N) rep(j,N) dist[i][j] = min({(ll)i, (ll)j, N - 1 - i, N - 1 - j});
    ll res = 0;
    rep(q,N * N){
        cin>>ord[q];
        --ord[q];
        int i = ord[q] / N, j = ord[q] % N;
        res += dist[i][j];
        people[i][j] = false;
        update(ord[q], dist, people);
        /*
        cout<<q<<endl;
        rep(s,N) rep(t,N) cout<<dist[s][t]<<" \n"[t == N - 1];
         */
    }
    cout<<res<<endl;
}

Measured memory_bytes: 7216
/* ex 7_1
   B30095   */

#include <stdio.h>

/* a 2d point */
typedef struct{
    int x;
    int y;
}point;

/* get next point of a sqaure in counterclockwise */
point next_square_point(point p1, point p2){
    point p3, vect;

    // vector from p1 to p2
    vect.x = p2.x - p1.x;
    vect.y = p2.y - p1.y;

    // rotate the vector 90 degrees and add it to p2
    p3.x = p2.x - vect.y ;
    p3.y = p2.y + vect.x;

    return p3;
}

int main(void){

    point p1, p2, p3, p4;

    scanf("%d %d %d %d", &p1.x, &p1.y, &p2.x, &p2.y);
    
    p3 = next_square_point(p1, p2);
    p4 = next_square_point(p2, p3);

    printf("%d %d %d %d", p3.x, p3.y, p4.x, p4.y);

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size(); i++){
        /* cout << S.at(i) << S.at(S.size() - 1 -i)<< endl; */
        if (S.at(i) != S.at(S.size() - 1 -i)) {
            S.at(S.size() - 1 -i) = S.at(i);
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- forM [1..n] (\i -> (read::String -> Integer) <$> getLine)
  print $ foldl (\acc num -> let g = calcGcd acc num in acc * num `div` g) (arr !! 0) arr
  

calcGcd::Integer -> Integer -> Integer
calcGcd a b = if b == 0 then a else calcGcd b (a `mod` b)


Measured memory_bytes: 1020
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans,c[21],v[21],g[21];
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(register int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		g[i]=v[i]-c[i];
	}
	sort(g+1,g+1+n);
	for(register int i=n;i;i--)if(g[i]>0)ans+=g[i];
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    int i,j;
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0) break;
        VI a(m);
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                int x;
                cin>>x;
                a[j]+=x;
            }
        }
        vector<P> w;
        for(i=0;i<m;i++){
            w.pb(P(a[i],-i-1));
        }
        sort(w.begin(),w.end());
        reverse(w.begin(),w.end());
        for(i=0;i<m;i++) {
            cout<<-w[i].se;
            if(i!=m-1) cout<<" ";
        }
        cout<<endl;
    }


}


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

int main()
{
   ll n;
   cin >> n;
   ll Cou = 0;
   while(n)
   {
       Cou++;
       n /= 2;
   }
   ll ans = 1;
   for(ll i = 1; i <= Cou; i++)
   {
       ans *= 2;
   }
   cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dist(string &a,string &b)
{
    int n=a.length();
    int res=0;
    for(int i=0;i<n;i++) if(a[i]!=b[i]) res++;
    return res;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int ans = INT_MAX;
    int n=s.length(),m=t.length();
    for(int i=0;i+m-1<n;i++)
    {
        string temp = s.substr(i,m);
        ans = min(ans,dist(t,temp));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(std::string S){
  if (S=="SUN"){
    cout<<7<<endl;
  }else if(S=="MON"){
    cout<<6<<endl;
  }else if(S=="TUE"){
    cout<<5<<endl;
  }else if(S=="WED"){
    cout<<4<<endl;
  }else if(S=="THU"){
    cout<<3<<endl;
  }else if(S=="FRI"){
    cout<<2<<endl;
  }else if(S=="SAT"){
    cout<<1<<endl;
  }
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.3.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.14159265358979
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(18);
  int h,w;
  cin >> h >> w;
  Vs a(h);
  Vin(a);
  VVi ans(h,Vi(w));
  rep(i,0,w){
    if(a[0][i]=='#') break;
    ans[0][i] = 1;
  }
  rep(i,0,h){
    if(a[i][0]=='#') break;
    ans[i][0] = 1;
  }
  
  rep(i,1,h){
    rep(j,1,w){
      if(a[i][j]=='#') continue;
      ans[i][j] = ans[i-1][j] + ans[i][j-1];
      ans[i][j] %= MOD;
    }
  }
  VVerr(ans);
  cout << ans[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] sNumbers = sc.next().split("");

        int nearest = 1000;
        for (int i = 0; i <= sNumbers.length - 3; i++) {
            String sNumber = "";
            sNumber += sNumbers[i];
            sNumber += sNumbers[i + 1];
            sNumber += sNumbers[i + 2];

            int number = Integer.parseInt(sNumber);
            nearest = Math.min(Math.abs(753 - number), Math.abs(nearest));
        }
        System.out.println(nearest);
    }
}

Measured memory_bytes: 27024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

template<typename T>
void input(T &x) {
	x=0; T a=1;
	register char c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c==45) a=-1;
	for(;c>=48&&c<=57;c=getchar())
		x=x*10+c-48;
	x*=a;
	return;
}

#define MAXN 200010

struct Ball {
	
	int x,y;

	void Input() {
		input(x),input(y);
		if(x>y) swap(x,y);
		return;
	}

	bool operator < (const Ball &q) const {
		if(x!=q.x) return x<q.x;
		return y<q.y;
	}

};

Ball a[MAXN];

int main() {
	int n;
	input(n);
	if(n==1) {
		puts("0");
//		fclose(stdin),fclose(stdout);
		return 0;
    }
	for(int i=1;i<=n;i++) a[i].Input();
	sort(a+1,a+n+1);
	int Max=a[1].y,Min=a[1].x,_max=1,_min=1;
	for(int i=2;i<=n;i++) {
		if(a[i].x<Min) Min=a[_min=i].x;
		if(a[i].y>Max) Max=a[_max=i].y;
	}
	int Rmax=Max,Bmin=Min,Rmin=a[_min].y,Bmax=a[_max].x;
	for(int i=1;i<=n;i++){
		Rmin=min(Rmin,a[i].y);
		Bmax=max(Bmax,a[i].x);
	}
	ll ans=(ll)(Rmax-Rmin)*(Bmax-Bmin);
	if(_max!=_min) {
		Bmax=Max;
		Bmin=Min;
		Rmax=max(a[n].x,a[1].y);
		int premin=a[1].y;
		Rmin=min(a[1].y,a[2].x);
		ll ans0=Rmax-Rmin;
		for(int i=2;i<n;i++) {
			Rmax=max(a[i].y,Rmax);
			Rmin=min(min(premin,a[i].y),a[i+1].x);
			premin=min(premin,a[i].y);
			if(Rmax-Rmin<ans0)ans0=Rmax-Rmin;
		}
		ans0*=Bmax-Bmin;
		ans=min(ans,ans0);
	}
	printf("%lld\n",ans);
	return 0;
}


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

// K=0
// A B C -> A-B
//
// K=1
// B+C A+C A+B -> (B+C)-(A+C)=B-A
//
// K=2
// (2A+B+C) (A+2B+C) (A+B+2C) -> (2A+B+C)-(A+2B+C)=A-B
//
// K=3
// (2A+3B+3C) (3A+2B+3C) (3A+3B+2C) -> (2A+3B+3C)-(3A+2B+3C)=B-A
//
// K=4
// (6A+5B+5C) (5A+6B+5C) (5A+5B+6C) -> (
//
//
// f(0)=A
// g(0)=B
// h(0)=C
//
// f(1)=g(0)+h(0)
// g(1)=f(0)+h(0)
// h(1)=f(0)+g(0)
//
// f(x)=g(x-1)+h(x-1)
// g(x)=f(x-1)+h(x-1)
// h(x)=f(x-1)+g(x-1)
//
// w(x)=f(x)-g(x)=g(x-1)-f(x-1)=-(f(x-1)-g(x-1))=-w(x-1)
//
// w(0)=f(0)-g(0)=A-B
// w(1)=f(1)-g(1)=g(0)-f(0)=-(f(0)-g(0))=-w(0)=-(A-B)=B-A
// w(2)=f(2)-g(2)=g(1)-f(1)=-(f(1)-g(1))=-w(1)=-(B-A)=A-B
//

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 a = get!();
    let b = get!();
    let _ = get!();
    let k = get!();
    if k % 2 == 0 {
    	println!("{}", a - b);
    } else {
    	println!("{}", b - a);
    }
}

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

int main(int, char**) {
  int N;
  cin >> N;

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 0) continue;

    int num = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) {
        ++num;
      }
    }
    if (num == 8)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int A,B,x=0,i;
  cin >> A >> B;
  x = 0;
  for(i=0;i<2;i++){
    if(A>B){
      x += A;
      A--;
    }
    else {
      x += B;
      B--;
    }
  }
  cout << x << endl;
  return 0;
}

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

int main()
{
	string str;
	cin >> str;
	sort(str.begin(),str.end());
	char find = 'a';
	for(unsigned int i = 0 ; i < str.size() ; i++)
	{
		if(find == str[i] )
		{
			find++;
		}
		else if (find-1 != str[i])
		{
			cout<<find<<"\n";
			return 0;
		}
	}
	if(find<='z')
		cout<<find<<"\n";
	else
		cout<<"None\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D

int main()
{
    lli n;
    cin>>n;
    vector<lli> a(n);
    fori(n) cin>>a[i];
    lli sum=0;
    fori(n) sum+=a[i];
    map<lli,lli> m;
    fori(n){
        m[a[i]]++;
    }
    lli q;
    cin>>q;
    lli x,y;
    fori(q){
        cin>>x>>y;
        cout<<sum-m[x]*x + y*m[x]<<endl;
        sum=sum-m[x]*x + y*m[x];
        //print(m);
        m[y]+=m[x];
        m[x]=0;
    }
}

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

using namespace std;
#define ll long long int
#define pb push_back
#define rep(i, a, v) for(int i = a; i <= v; ++i)
#define vi vector<int>
#define vll vector<ll>
#define maxi 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const double pie = 3.1415926535;
const string spaces = "    ";

ll i, j, k;
ll temp;

int main(){
    cout.tie(0);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, w;
    cin >> n >> w;
    ll wt, val;
    // dp[i] = Maxmimum value for weight i
    vll dp(w + 1, 0);

    for(int i = 0; i < n; ++i){
        cin >> wt;
        cin >> val;
        for(int wt_red = w - wt; wt_red >= 0; --wt_red){
            dp[wt_red + wt] = max(dp[wt_red + wt], dp[wt_red] + val);
        }
    }

    cout << dp[w] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main()
{
  int a, b;
  cin >> a >> b;
  if (a > b){
    for (int i=0; i < a; i++){
      cout << b ;
    }
  }
  else{
    for (int i=0;i < b; i++){
      cout << a;
    }
  }
  return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int a[q], b[n];
  for(int i=0;i<n;++i) b[i]=0; //without this process, result will be WA
  string ans[n];
  for(int i=0; i<q; ++i){
    cin >> a[i];
    ++b[a[i]-1]; // b counts how many she won
  }
  for(int i=0;i<n;++i){
    if(k>(q-b[i])) ans[i]="Yes";
    else ans[i]="No";
    // q-b shows how many she lost
    // k-(q-b) is her point
    cout << ans[i] << endl;
  }
  return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        vector<string> str(n);
        for(int i=0;i<n;i++){
            cin>>str[i];
        }
        vector<string> res(n);
        for(int i=0;i<n;i++){
            res[i]=str[i];
            int dotcnt=0;
            for(int j=str[i].size()-1;j>=0;j--){
                if(str[i][j]=='.'){
                    if(dotcnt==0){
                        res[i][j]='+';
                    }
                    else{
                        res[i][j]=' ';
                    }
                    dotcnt++;
                }
                else{
                    res[i][j]=str[i][j];
                }
            }
        }

        for(int j=0;j<10000;j++){
            int tail=0;
            bool plus=false;
            for(int i=0;i<n;i++){
                if(j>=res[i].size()){
                    plus=false;
                    continue;
                }
                if(res[i][j]=='+'){
                   if(plus){
                       for(tail++;tail<i;tail++){
                           res[tail][j]='|';
                       }
                   } 
                   else{
                        plus=true;
                        tail=i;
                   }
                }
                else if(res[i][j]!=' '){
                    plus=false;
                }
                
            }
        }
        for(int i=0;i<n;i++) cout<<res[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a1(n);
    vector<int> a2(n);

    for(int i = 0; i < n; ++i){
        cin >> a1[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> a2[i];
    }
    int u = 0;
    int d = 0;
    for(int i = 0; i < n; ++i){
        u += a1[i];
        d = max(d + a2[i], u + a2[i]);
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
// #include <vector>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    string a;
    // vector<string> data(n);
    unordered_map<string, int> data;

    for(int i = 0; i < n; ++i){
        cin >> a;
        if(data.find(a) == data.end()){
            data[a] = 1;
        }
    }
    int ans = data.size();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17692
#include<bits/stdc++.h>
#define mems(a,x) memset(a,x,sizeof(a))
#define first fi
#define second se
using namespace std;
typedef long long ll;
const int mod=1e9+7,MS=105,N=66;
const double eps=1e-8;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll inv(ll x,ll mod){return x==1?x:(mod-mod/x)*inv(mod%x,mod)%mod;}
ll qpow(ll a,ll n){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
ll qpow(ll a,ll n,ll mod){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b,ll mod){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
struct vec
{
    double x,y;
    vec(double x=0,double y=0):x(x),y(y){}
    vec operator+(const vec&o)const{ return vec(x+o.x,y+o.y);}
    vec operator-(const vec&o)const{ return vec(x-o.x,y-o.y);}
    double operator*(const vec&o)const{ return x*o.x+y*o.y;}
    double operator^(const vec&o)const{ return x*o.y-y*o.x;}
    vec operator/(const double&o)const{ return vec(x/o,y/o);}
    vec operator*(const double&o)const{ return vec(x*o,y*o);}
    void sc(){scanf("%lf%lf",&x,&y);}
    double len(){return sqrt(x*x+y*y);}
};
struct Mat
{
    ll a[MS][MS];
    int n,m;
    Mat(int n=0,int m=0):n(n),m(m) { mems(a,0);}
    Mat operator*(const Mat&B)const
    {
        Mat C(n,B.m);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=B.m;j++)
                for(int k=1;k<=m;k++)
                C.a[i][j]=(C.a[i][j]+a[i][k]*B.a[k][j])%mod;
        return C;
    }
};
int n,k;
vec a[N];
double c[N];
vec s1,s2;
vec polar(double a,double r){return vec(cos(r)*a,sin(r)*a);}
bool intersect(vec c1,vec c2,double r1,double r2)
{
    double d=(c1-c2).len();
    if(d-eps>r1+r2||fabs(r1-r2)-d>eps) return false;
    double a=acos((r1*r1+d*d-r2*r2)/(2*r1*d));
    double t=atan2(c2.y-c1.y,c2.x-c1.x);
    s1=c1+polar(r1,t-a);
    s2=c1+polar(r1,t+a);
    return true;
}
bool judge(double T)
{
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(!intersect(a[i],a[j],T/c[i],T/c[j])) continue;
            int x=0,y=0;
            for(int k=1;k<=n;k++)
            {
                if(c[k]*(s1-a[k]).len()<=T+eps) x++;
                if(c[k]*(s2-a[k]).len()<=T+eps) y++;
            }
            if(x>=k||y>=k) return true;
        }
        int x=0;
        for(int j=1;j<=n;j++)
            if(c[j]*(a[i]-a[j]).len()<=T+eps) x++;
        if(x>=k) return true;
    }
    return false;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        a[i].sc(),scanf("%lf",&c[i]);
    double l=0,r=200000;
    for(int i=1;i<=50;i++)
    {
        double m=(l+r)/2;
        if(judge(m)) r=m;
        else l=m;
    }
    printf("%.10f\n",(l+r)/2);
}
/*
|? ?| * |f(x)  | == |f(x+1)|
|? ?|   |f(x-1)|    |f(x)  |
*/


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    string s = "abcdefghijklmnopqrstuvwxyz";
    char c;
    cin >> c;
    rep(i, 25){
        if (c == s[i]){
            cout << s[i+1] << endl;
            return 0;
        }
    }
}


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

bool check(string s){
	if(s.size()%2 == 1){
		return false;
	}
	if(s.substr(0,s.size()/2) == s.substr(s.size()/2,s.size()/2)){
		return true;
	}
	return false;
}

int main() {
	string s;
	cin >> s;
	for(int i=s.size();;i--){
		if(check(s.substr(0,i-1))){
			cout << i-1 <<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    int x;
    cin>>x;
    if(x<1200)
    cout<<"ABC";
    else
    cout<<"ARC";

    return 0;
}    

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = 200002, E = 200002;

vector <int> g[N], cvs;
vector <pair<int, int>> ces;
int up[N], h[N], from[E], to[E];
bool mark[N];

int cecvme(int v, int pare = -1) // With multiple edge
{
	up[v] = h[v];
	mark[v] = true;
	int children = 0;
	for(int e : g[v])
		if(e != pare)
		{
			int u = to[e] ^ from[e] ^ v;
			if(mark[u])
				up[v] = min(up[v], h[u]);
			else
			{
				h[u] = h[v] + 1;
				up[v] = min(up[v], cecvme(u, e));
				if(up[u] >= h[v] && pare != -1)
					cvs.push_back(v);
				children++;
			}
		}
	if(pare != -1 && up[v] == h[v])
		ces.push_back({from[pare] ^ to[pare] ^ v, v}); // pare
	if(pare == -1 && children > 1)
		cvs.push_back(v);
	return up[v];
}
 
int cecv(int v, int par) // Without multiple edge
{
	up[v] = h[v];
	mark[v] = true;
	int children = 0;
	for(int u : g[v])
	{
		if(mark[u] && u != par)
			up[v] = min(up[v], h[u]);
		if(!mark[u])
		{
			h[u] = h[v] + 1;
			up[v] = min(up[v], cecv(u, v));
			if(up[u] >= h[v] && h[v] > 0)
				cvs.push_back(v);
			children++;
		}
	}
	if(h[v] > 0 && up[v] == h[v])
		ces.push_back({par, v});
	if(h[v] == 0 && children > 1)
		cvs.push_back(v);
	return up[v];
}

int main()
{
	int n = in(), m = in();
	for(int i = 0; i < m; i++)
	{
		int u = in(), v = in();
		g[u].push_back(i);
		g[v].push_back(i);
		from[i] = u;
		to[i] = v;
	}
	h[0] = 0;
	cecvme(0, -1);
	for(auto &e : ces)
		if(e.first > e.second)
			swap(e.first, e.second);
	sort(ces.begin(), ces.end());
	for(auto e : ces)
		cout << e.first << " " << e.second << endl;
}



Measured memory_bytes: 9804
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let nab=readInts()
let n=nab[0]
let a=nab[1]
let b=nab[2]
if n*a<b {
  print(n*a)
}else{
  print(b)
}

Measured memory_bytes: 8212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, m;
llong a[100005];
MaxHeap<llong> p_que;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        p_que.push(a[i]);
    }

    for (int i= 0; i < m; i++) {
        llong p = p_que.top(); p_que.pop();
        p_que.push(p / 2);
    }

    llong sum = 0;
    while(!p_que.empty()) {
        sum += p_que.top(); p_que.pop();
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1912
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p + q, p + r, q + r}) << endl;
    return 0;
}


Measured memory_bytes: 888
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n, = map(int,readline().split())
s = input()

def next_index(N,s):
    D = [-1]*26
    E = [None]*(N+1)
    cA = ord('a')
    for i in range(N-1, -1, -1):
        E[i+1] = D[:]
        D[ord(s[i])-cA] = i
    E[0] = D
    return E

n = len(s)
nxt = next_index(n,s)

"""
for i in nxt:
    print(i[:4])
"""

#print(nxt)
dp = [0]*(n+1)
for i in range(n-1,-1,-1):
    idx = max(nxt[i])
    bad = min(nxt[i])
    dp[i] = dp[idx+1]+1 if bad != -1 else 0

#print(nxt[0])
#print(dp)

k = dp[0]+1
ans = [None]*k

v = 0
for i in range(k):
    #print(v)
    if v==n:
        ans[-1] = 0
        break

    for j in range(26):
        #print(nxt[v+1][j], dp[nxt[v+1][j]])
        if nxt[v][j]==-1 or dp[nxt[v][j] + 1] < dp[v]:
            ans[i] = j
            v = nxt[v][j]+1
            break

#print(ans)
def f(x):
    return chr(x+ord("a"))

a = "".join(map(f,ans))
print(a)



"""
x = [chr(ord("z")-i) for i in range(26)]
x = "".join(x)
print(x)
"""














Measured memory_bytes: 131968
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
typedef pair < pii , int > p3i;
const int mx=20;
int L;
vector < p3i > edges;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
	int i,j,k;
    scanf("%d",&L);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	int bt;
	for(bt=mx-1;bt>=0;--bt){
		if(!(L&(1<<bt))) break;
	}
	++bt;// fake bt
    for(i=1;i<mx-bt;++i){
		edges.push_back(mpr(mpr(i,i+1),1<<(mx-i-1)));
		edges.push_back(mpr(mpr(i,i+1),0));
	}
	// mx-i-1  ->  i
	// i-1  -> mx-(i-1)-1=mx-i
	// mx-bt is useless
	// mx-bt-1 => mx-bt (if mx-bt-1 exists)
	if(bt<mx){
		edges.push_back(mpr(mpr(mx-bt,mx-bt+1),0));
		edges.push_back(mpr(mpr(mx-bt,mx-bt+1),1<<(bt-1)));
		edges.push_back(mpr(mpr(mx-bt,mx-bt+1),1<<(bt-2)));
		edges.push_back(mpr(mpr(mx-bt,mx-bt+1),(1<<(bt-1))+(1<<(bt-2))));
	}
	for(i=mx-bt+1;i<mx-1;++i){
		edges.push_back(mpr(mpr(i,i+1),1<<(mx-i-2)));
		edges.push_back(mpr(mpr(i,i+1),0));
	}
	int cur=0,ptr=1;
	for(i=mx-1;i>=0;--i){
		if(L&(1<<i)){
			edges.push_back(mpr(mpr(0,ptr),cur));
			cur+=(1<<i);
		}
		if(i!=bt-1) ++ptr;
	}
	printf("%d %d\n",mx,(int)edges.size());
	for(i=0;i<(int)edges.size();++i){
		printf("%d %d %d\n",edges[i].first.first+1,edges[i].first.second+1,edges[i].second);
    }
	#ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,M;
  int p,S_AC=0,S_WA=0;
  char S[3];
  int ac[100002]={},wa[100002]={};
  scanf("%d %d\n",&N,&M);
  for(int i=1;i<=M;i++){
    scanf("%d %s\n",&p,S);
    if(ac[p]==1) continue;
    if(S[0]=='A'){
      S_AC++;
      ac[p]=1;
      S_WA+=wa[p];
    }else{
      wa[p]++;
    }
  }
  printf("%d %d\n",S_AC,S_WA);
  return 0;
}

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

template<typename OperatorMonoid>
struct SegmentTree {
    using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
    const H h;
    const OperatorMonoid OM0;
    int sz, height;
    vector<OperatorMonoid> lazy;
    SegmentTree(int n, const H h, const OperatorMonoid &OM0)
        : h(h), OM0(OM0), sz(1), height(0)
    {
        while (sz < n) sz <<= 1, height++;
        lazy.assign(sz * 2, OM0);
    }
    inline void propagate(int k) {
        if (lazy[k] == OM0) return ;
        lazy[k << 1 | 0] = h(lazy[k << 1 | 0], lazy[k]);
        lazy[k << 1 | 1] = h(lazy[k << 1 | 1], lazy[k]);
        lazy[k] = OM0;
    }
    inline void thrust(int k) {
        for (int i = height; i > 0; i--) propagate(k >> i);
    }
    void update(int a, int b, const OperatorMonoid &x) {
        thrust(a += sz);
        thrust(b += sz - 1);
        for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lazy[l] = h(lazy[l], x), ++l;
            if (r & 1) --r, lazy[r] = h(lazy[r], x);
        }
    }
    void set(int k, const OperatorMonoid &x) { thrust(k += sz); lazy[k] = x; }
    OperatorMonoid get(int k) { thrust(k += sz); return lazy[k]; }
    OperatorMonoid operator[](const int &k) { return get(k); }
};

int main() {
    int n, q; cin >> n >> q;
    SegmentTree<int> seg(n, [](int a, int b) { return a + b; }, 0);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int s, t, x; cin >> s >> t >> x; t++;
            seg.update(s, t, x);
        } else {
            int i; cin >> i;
            cout << seg[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

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

int main(){
    int H, W;
    cin >> H >> W;
    Graph g(H, vector<int>(W)), g2(H, vector<int>(W, 0));
    rep(i, H){
        rep(j, W){
            char c;
            cin >> c;
            if(c == '.') g[i][j] = 0;
            else g[i][j] = 1;
        }
    }

    rep(i, H){
        rep(j, W){
            if(g[i][j] == 1){
                rep(k, 4){
                    if(i + dy[k] >= 0 && i + dy[k] < H && j + dx[k] >= 0 && j + dx[k] < W){
                        if(g[i + dy[k]][j + dx[k]] == 1){
                            g2[i][j] = 1;
                            g2[i + dy[k]][j + dx[k]] = 1;
                        }
                    }
                }
            }
        }
    }
    bool ans = true;
    rep(i, H){
        rep(j, W){
            if(g[i][j] != g2[i][j])ans = false;
        }
    }
    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;

    for(int i=0; i<a; i++){
        if(s[i] == '-'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i=a+1; i<a+b+1; i++){
        if(s[i] == '-'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll x, k;
    cin>>k>>x;
    ll mmn = -1000000;
    ll l = max(mmn, x-k+1);
    ll r = min(1000000ll, x+k-1);
    loop(i,l, r+1){
        cout<<i<<" ";
    }
    cout<<endl;
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
   
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

string s, t,res;
int dp[3003][3003],len;

void trace(int i,int j){
	if (len==0) return ;
	if (s[i]==t[j]){
		res+=s[i];
		len--;
		trace (i-1,j-1);
	}
	else{
		if ( dp[i][j] == dp[i-1][j] )  trace (i-1,j);
		if ( dp[i][j] == dp[i][j-1] )  trace (i,j-1);
	}
}

int main (){
	
	//freopen("t.txt","r",stdin);
	
	cin>>s>>t;
	s="0"+s;
	t="0"+t;
	int n = s.length();
	int m = t.length();
	
	for (int i=1;i<n;i++){
		for (int j=1;j<m;j++){
			if (s[i]==t[j]) {
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else{
				dp[i][j] = max ( dp[i-1][j] , dp[i][j-1] );
			}
		}
	}
	
	len=dp[n-1][m-1];
	if (dp[n-1][m-1] == 0) cout<<' ';
	else {
		trace(n-1,m-1);
	}
	for (int i= res.length() -1 ; i>=0  ;i--) 
		cout<<res[i];
	return 0;
}

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

const int INF = 100000;

int h, w;
int cnt = 0;
int res; //答え = h*w - 1 - 最短手数 -　元からあった黒マスの数
char maze[51][51];
int dist[51][51];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int bfs(){
  queue<int> qx, qy;
  qx.push(0); qy.push(0);
  dist[0][0] = 0;
  
  while(qx.size()){
    int x = qx.front(); qx.pop();
    int y = qy.front(); qy.pop();
    if(x == w-1 && y == h-1){
      break;
    }
    rep(i, 4){
      int nx = x + dx[i], ny = y + dy[i];
      if(nx >= 0 && ny >= 0 && nx < w && ny < h &&  
         maze[nx][ny] != '#' && dist[nx][ny] == INF){
        qx.push(nx); qy.push(ny);
        dist[nx][ny] = dist[x][y] + 1;
      }
    }
  }
  //cout << dist[w-1][h-1] << " ";
  return dist[w-1][h-1];
}   

int main(){
  cin >> h >> w;
  rep(i, h){
    rep(j, w){
      cin >> maze[j][i];
      if(maze[j][i] == '#'){
        cnt++;
      }
    }
  }
  rep(i, h)rep(j, w)dist[j][i] = INF;
  //cout << cnt << " ";
  res = h * w - bfs() - cnt - 1;
  if(dist[w-1][h-1] == INF){
    res = -1;
  }
  //rep(i, h){rep(j, w){cout << maze[j][i];}cout << endl;}
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 2e6 + 10;
char s[maxn];
int main(){
	while(~scanf("%s",s)) {
		int i = 0;
		int sum = 0;
		while(s[i] != '\0') {
			sum += (s[i] - '0');
			i++;
		}
		if(sum % 9 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
} 

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, K, A[500], s, a[500], S[500];
vector<pair<int, int>>p;
vector<int>v;

void dfs(int x, int t) {
	if (x == p.size())v.push_back(t);
	else {
		for (int i = 0; i <= p[x].second; ++i) {
			dfs(x + 1, t);
			t *= p[x].first;
		}
	}
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		s += A[i];
	}
	for (int i = 2; i*i <= s; ++i) {
		if (s%i == 0) {
			p.push_back(mkp(i, 0));
			while (s%i == 0) {
				s /= i;
				++p.back().second;
			}
		}
	}
	if (s != 1) {
		p.push_back(mkp(s, 1));
	}
	dfs(0, 1);
	sort(v.rbegin(), v.rend());
	for (int i : v) {
		for (int j = 0; j < N; ++j) {
			a[j] = A[j] % i;
		}
		sort(a, a + N, greater<>());
		S[N - 1] = a[N - 1];
		for (int j = N - 2; j >= 0; --j) {
			S[j] = S[j+1] + a[j];
		}
		int cnt = 0;
		for (int j = 0; j < N - 1; ++j) {
			cnt += i - a[j];
			if (cnt == S[j + 1]) {
				if (cnt <= K) {
					cout << i << endl;
					return 0;
				}
				else {
					break;
				}
			}
		}
	}
	cout << 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
int main()
{
	std::vector<std::string>result;
	for (std::string s; std::getline(std::cin, s);)
	{
		int delta = 0;
		std::stringstream ss;
		ss << s;
		while (!ss.eof())
		{
			std::string temp;
			ss >> temp;
			if (temp.length() == 3 && temp[0] != '.' && temp[1] != '.' && temp[2] != '.')
			{
				int d1 = temp[0] - 't';
				int d2 = temp[1] - 'h';
				int d3 = temp[2] - 'e';
				for (auto i : { &d1,&d2,&d3 })
				{
					if (*i < 0)
					{
						*i += 26;
					}
				}
				if (d1 == d2 && d2 == d3)
				{
					delta = d1;
					break;
				}
			}
			else if (temp.length() == 4 && temp[0] != '.' && temp[1] != '.' && temp[2] != '.' && temp[3] != '.')
			{
				int d1 = temp[0] - 't';
				int d2 = temp[1] - 'h';
				int d3 = temp[2] - 'i';
				int d4 = temp[3] - 's';
				for (auto i : { &d1,&d2,&d3,&d4 })
				{
					if (*i < 0)
					{
						*i += 26;
					}
				}
				if (d1 == d2 && d2 == d3 && d3 == d4)
				{
					delta = d1;
					break;
				}
				d1 = temp[0] - 't';
				d2 = temp[1] - 'h';
				d3 = temp[2] - 'a';
				d4 = temp[3] - 't';
				for (auto i : { &d1,&d2,&d3,&d4 })
				{
					if (*i < 0)
					{
						*i += 26;
					}
				}
				if (d1 == d2 && d2 == d3 && d3 == d4)
				{
					delta = d1;
					break;
				}
			}
		}
		if (delta > 0)
		{
			delta -= 26;
		}
		result.push_back(std::string(s.length(), 'a'));
		for (int i = 0; i < s.length(); i++)
		{
			result.back()[i] = 'a' <= s[i] && s[i] <= 'z' ? (s[i] - 'a' - delta) % 26 + 'a' : s[i];
		}
	}
	for (auto i : result)
	{
		std::cout << i << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3128
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if a not in d or d[a] == 0:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  while True:
    if t not in d or d[t] == 0:
      break
    if a != t:
      i = min(d[a], d[t])
    else:
      i = d[a] // 2
    if i == 0:
      break
    result += i
    d[a] -= i
    d[t] -= i
    if a not in d or d[a] == 0:
      break
print(result)


Measured memory_bytes: 44560
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int s; cin >> s;
    set<int> set = {s};
    int cnt = 1;
    while (cnt != 1000000) {
        if (s%2 == 0) {
            if (set.find(s/2) != set.end()) {
                cout << cnt+1 << endl;
                return 0;
            }
            set.insert(s/2);
            s = s/2;
        }
        else {
            if (set.find(3*s + 1) != set.end()) {
                cout << cnt+1 << endl;
                return 0;
            }
            set.insert(3*s + 1);
            s = 3*s + 1;
        }
        cnt++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N;
	cin >> N;

	int sq = sqrt(N);


	ll kotae = 0;
	set<ll> yakusuu;
	rep1(i, sq + 1) {
		if (N % i == 0) {
			yakusuu.insert(i);
			yakusuu.insert(N / i);
		}
	}

	for (ll i : yakusuu) {
		if (N % i == 0) {
			if (N / i < i - 1) kotae += i - 1;
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;
int main(){
  int l,n;
  cin >> n;
  vector<int> a,b,c;

  for(int i=0;i<n;i++){
    cin >> l; a.push_back(l);
  }

  for(int i=0;i<n;i++){
    cin >> l; b.push_back(l);
  }

  for(int i=0;i<n;i++){
    cin >> l; c.push_back(l);
  }

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

  long long int ans = 0;

  for(int i=0;i<n;i++){
  vector<int>::iterator it1 = lower_bound(a.begin(), a.end(), b[i]);
  vector<int>::iterator it2 = upper_bound(c.begin(), c.end(), b[i]);
  ans += (it1-a.begin())*(n-(it2-c.begin()));
  }

  cout << ans << endl;

}


Measured memory_bytes: 1784