akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
 
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll k,n;
    cin >> k >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=-1;
    rep(i,n){
        if(i==n-1){
            b[i]=k-a[i]+a[0];
            ans=max(ans,b[i]);
            continue;
        }
        b[i]=a[i+1]-a[i];
        ans=max(ans,b[i]);
    }
    cout << k-ans << endl;
    return 0;
} 

Measured memory_bytes: 3328
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, a[128], r;
double b, v, e, f;
double co[20000], dp[128];

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) scanf("%d", a+i+1);
        scanf("%lf%d%lf%lf%lf", &b, &r, &v, &e, &f);
        rep (x, 15000) {
            double t = x >= r ? 1.0/(v-e*(x-r)) : 1.0/(v-f*(r-x));
            co[x+1] = co[x] + t;
        }
        dp[0] = 0;
        rep (i, n) {
            dp[i+1] = 1e100;
            rep (j, i+1) {
                dp[i+1] = min(dp[i+1], dp[j]+co[a[i+1]-a[j]]+b);
            }
        }
        printf("%.9f\n", dp[n]-b);
    }
}

Measured memory_bytes: 1208
S=input()
T=input()
lens=len(S)
lent=len(T)
ans=[]
for i in range(lens-lent+1):
    SS=S[i:i+lent]
    for j in range(len(SS)):
        if SS[j]!=T[j] and SS[j]!="?":
            break
    else:
        SSS=S[:i]+T+S[lent+i:]
        ans.append(SSS.replace("?","a"))
ans.sort()
if ans==[]:
    print("UNRESTORABLE")
else:
    print(ans[0])

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

typedef long long int ll;
typedef string str;

int main ()
{
	ll t,n,m,k,i,j,a,b;
	cin >> n >> k;
	ll hash[n+2]={0};
	for(i=0;i<k;i++)
	{
		cin >> a;
		for(j=0;j<a;j++)
		{
			cin >> b;
			hash[b]++;
		}
	}
	k=0;
	for(i=1;i<n+1;i++)
	{
		if(!hash[i])
			k++;
	}
	cout << k << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S;
  cin >> S;
  int s=0,ans=0;
  for (int i = 0; i < (int)S.size(); i++){
    if(s == 0 && S[i] == 'T'){
      ans++;
    }else if(S[i] == 'S'){
      s++;
    }else if(S[i] == 'T'){
      s--;
    }
  }

  printf("%d\n", ans + s);
  
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N, X;
  cin >> N >> X;
  int l[N];
  for (int i = 0; i < N; i++) cin >> l[i];

  int d = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (d <= X) ans++;
    d = d + l[i];
  }
  if (d <= X) ans++;

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


Measured memory_bytes: 256
n=int(input())
a=list(map(int , input().split()))
res_o=[0]*n
res_e=[0]*n
res_o[0]=a[0]
res_e[0]=a[0]

o=0
e=0

if res_o[0]<=0:
    o+=1-res_o[0]
    res_o[0]=1
if res_e[0]>=0:
    e+=res_e[0]+1
    res_e[0]=-1

for i in range(1,n):
    res_o[i]=res_o[i-1]+a[i]
    res_e[i]=res_e[i-1]+a[i]
    if i%2==0 and res_o[i]<=0:
        o+=(1-res_o[i])
        res_o[i]=1
    elif i%2==1 and res_o[i]>=0:
        o+=(res_o[i]+1)
        res_o[i]=-1
    if i%2==0 and res_e[i]>=0:
        e+=(1+res_e[i])
        res_e[i]=-1
    elif i%2==1 and res_e[i]<=0:
        e+=(1-res_e[i])
        res_e[i]=1
print(min(e,o))

Measured memory_bytes: 63728
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;

class DandA {
    static void Main(string[] args) {
        long n = ReadLineLong();
        long i = 1;
        long rtn_a = 0;
        long rtn_b = 0;
        while (i * i <= n) {
            if (n % i == 0) {
                rtn_a = n / i;
                rtn_b = i;
            }
            i++;
        }
        Console.WriteLine((rtn_a + rtn_b) - 2);
    }

    static string[] ary = new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    ll X, Y;
    cin >> X >> Y;

    ll cnt = 0;
    while (X <= Y) {
        cnt++;
        X *= 2;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//--------O&Oo&oO&O---------------

#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

using in=long long int;

void SOLVE()
{
	
   int n,x,y;
   cin>>n>>x>>y;
   map<int,int> MPP;
   int dis[n+1]={0};
  // dis[1]=0;
   for(int i=2;i<=n;i++)
   {
   		dis[i]=1+dis[i-1];
   		//MPP[dis[i]]++;
   		//cout<<dis[i]<<" ";
   }
   

   dis[y]=dis[x]+1;
   for(int i=y+1;i<=n;i++)
   	dis[i]=dis[i-1]+1;


  
  
   for(int i=2;i<=n;i++)
   {
   	for(int j=1;j<i;j++)
   	{
   		
   			MPP[min(abs(x-j)+1+abs(i-y),min(abs(i-j),abs(y-i)+abs(j-x)+1))]++;
   		
   	}
   }
   for(int i=1;i<=n-1;i++)
   {
   	cout<<MPP[i]<<"\n";
   	
   }





}

int main()
{
	FAST_IO
	
	SOLVE();

	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <functional>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

int calc(int x, int y) {
    if (x > y) return INF;
    return y - x;
}

signed main() {
    int x, y; cin >> x >> y;
    int ans = INF;
    chmin(ans, calc(x, y));
    chmin(ans, calc(-x, y) + 1);
    chmin(ans, calc(x, -y) + 1);
    chmin(ans, calc(-x, -y) + 2);
    cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  //道路数え上げ
  vector<int> roads(N);
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    roads.at(a - 1)++;
    roads.at(b - 1)++;
  }
  
  //表示
  for (int i = 0; i < N; i++) {
    cout << roads.at(i) << endl;
  }
}

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

int main() {
  string N;
  cin >> N;
  if (N.at(0) == '7') {
    cout << "Yes" << endl;
  }else if (N.at(1) == '7'){
    cout << "Yes" << endl;
  }else if(N.at(2) == '7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = -1;
    int b = -1;
    for(int i = 0; i < s.length() - 1; i++) {
      if(s.charAt(i) == s.charAt(i + 1)) {
        a = i + 1;
        b = i + 2;
      }
    }
    for(int i = 0; i < s.length() - 2; i++) {
      if(s.charAt(i) == s.charAt(i + 2)) {
        a = i + 1;
        b = i + 3;
      }
    }
    System.out.println(a + " " + b);
  }
}


Measured memory_bytes: 25764
#include <bits/stdc++.h>
using namespace std;
// g++ -std=c++17 -Wshadow -Wall sol.cpp -o  s -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vvi = vector< vi > ;
using ld = long double;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }

void solve(int tc) {
  long long n, m, x;
  cin >> n >> m;
  long long sum = 0;
  for(int i = 0; i < m; ++i){
    cin >> x;
    sum+=x;
  }
  cout << max(-1LL, n - sum) << endl;
 }

int main() {
  int tc = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin >> tc;
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

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

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

    int d;
    cin >> d;

    if(d==25) puts("Christmas");
    if(d==24) puts("Christmas Eve");
    if(d==23) puts("Christmas Eve Eve");
    if(d==22) puts("Christmas Eve Eve Eve");
}

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

using namespace std;

const int DIM = 1e5 + 7;

int v[DIM];

vector <int> t;

main()
{
	int n, k;
	cin >> n >> k;
	
	int sum = 0;
	
	for(int i = 1; i <= n; i++)
	{
		char c;
		cin >> c;
		
		if(c == 'L')
			v[i] = 1;
		else
			v[i] = 2;
		
		if(v[i] == v[i - 1])
			sum++;
		else
			t.push_back(i);
	}
	
	while(t.size() > 3 && k)
	{
		k--;
		sum += 2;
		t.pop_back();
		t.pop_back();
	}
	
	if(k != 0 && t.size() == 3)
	{
		t.pop_back();
		t.pop_back();
		
		k--;
		sum += 2;
	}
	
	if(k != 0  && t.size() == 2)
	{
		t.pop_back();
		
		k--;
		sum++;
	}
	
	cout << sum;
}

Measured memory_bytes: 1148
H=int(input())-1
K = [list(map(int, input().split())) for i in range(H)]
total_total=[]
for j in range(H):
    total=K[j][0]+K[j][1]
    for i in range(j,H-1):
        c1=K[i][0]
        s1=K[i][1]
        f1=K[i][2]
        c2=K[i+1][0]
        s2=K[i+1][1]
        f2=K[i+1][2]
        if total>s2:
            if (total-s2)%f2==0:
                total=total+c2
            else:
                total=((total-s2)//f2+1)*f2+s2+c2
        else:
            total=s2+c2
    print(total)
print(0)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m-1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
//#define int long long
#define al(s) s.begin(),s.end()
#define INT_MAX 2147483647
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;
typedef pair<int, pi> pip;
typedef pair<long long, pi> llpi;

struct SegTree
{
	int N;
	vector<int> Seg;
	void init(int n)
	{
		N = 1;
		while (N < n)N *= 2;
		for (int i = 0; i < N * 2; i++)
		{
			Seg.push_back(INT_MAX);
		}

	}

	void update(int k, int a)
	{
		k = k - 1 + N;
		Seg[k] = a;
		while (k > 0)
		{
			k = (k - 1) / 2;
			Seg[k] = min(Seg[2 * k + 1], Seg[2 * k + 2]);
		}
	}
	int find_min(int a, int b)
	{
		return query(a, b, 0, 0, N);
	}

	int query(int a, int b, int k, int l, int r)
	{
		if (r <= a || l >= b)return INT_MAX;
		if (l >= a&&r <= b)
		{
			return Seg[k];
		}
		else
		{
			return min(query(a, b, k * 2 + 1, l, (r + l) / 2),
				query(a, b, k * 2 + 2, (r + l) / 2, r));
		}
	}
};

SegTree ss[4];//min,max

vector<llpi> s;
vector<long long > a;
int  main()
{
	long long ans = 0;
	long long n, d;
	cin >> n >> d;
	rei(4)ss[i].init(n);
	for (int i = 0; i < n; i++)
	{
		long long b;
		int x, y;
		cin >> x >> y >> b;
		s.push_back(llpi(b, pi(x, y)));
	}
	sort(al(s));
	for (int i = 0; i < s.size(); i++)a.push_back(s[i].first);
	for (int i = 0; i < n; i++)
	{
		ss[0].update(i, s[i].second.first);
		ss[2].update(i, s[i].second.first*(-1));

		ss[1].update(i, s[i].second.second);
		ss[3].update(i, s[i].second.second*(-1));
	}
	//bool end = false;
	for (vector<long long >::iterator i = a.begin();;)
	{
		vector<long long>::iterator E;
		E = upper_bound(al(a), (long long)(*i + d));
		int AA, BB;
		AA = i - a.begin();
		BB = E - a.begin();
		i = upper_bound(al(a),(long long)(*i));
		//cout << AA << " " << BB << endl;
		ans = max(ans,
			(long long)((-1)*ss[2].find_min(AA, BB) - ss[0].find_min(AA, BB))
			*(long long)((-1)*ss[3].find_min(AA, BB) - ss[1].find_min(AA, BB)));
		if (E == a.end())break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 16884
package main

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

var IntMapCapForInt2DMap = 0

type Int2DMap map[ // IntMap は、map[Int][Int]に便利メソッドを追加します.
int]IntMap

type IntMap map[ // IntMap は、map[Int][Int]に便利メソッドを追加します.
int]int

func lib_MaxInt(values ...int) (max int, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	max = values[0]
	for _, value := range values {
		if max < value {
			max = value
		}
	}
	return
}
func lib_MinInt(values ...int) (min int, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	min = values[0]
	for _, value := range values {
		if min > value {
			min = value
		}
	}
	return
}
func lib_MustMaxInt(values ...int) (max int) {
	max, err := lib_MaxInt(values...)
	if err != nil {
		panic(err)
	}
	return max
}
func lib_NewInt2DMap(cap, cap2 int) Int2DMap {
	IntMapCapForInt2DMap = cap2
	return make(map[int]IntMap, cap)
}
func lib_NewIntMap(cap int) IntMap {
	return make(map[int]int, cap)
}
func (m Int2DMap) ChMin(key1, key2, value int, values ...int) (replaced bool, valueAlreadyExist bool) {
	min, _ := lib_MinInt(append(values, value)...)
	if v, ok := m.Get(key1, key2); ok {
		if v > min {
			m.Set(key1, key2, min)
			return true, true
		} else {
			return false, true
		}
	}
	m.Set(key1, key2, min)
	return true, false
}
func (m Int2DMap) Get(key1, key2 int) (int, bool) {
	v1, ok := m[key1]
	if !ok {
		return 0, false
	}
	v2, ok := v1[key2]
	if !ok {
		return 0, false
	}
	return v2, true
}
func (m IntMap) Keys() (keys []int) {
	keys = make([]int, 0, len(m))
	for k, _ := range m {
		keys = append(keys, k)
	}
	return
}
func (m Int2DMap) Set(key1, key2, value int) (isNewValue bool) {
	v1, ok := m[key1]
	if !ok {
		m[key1] = lib_NewIntMap(IntMapCapForInt2DMap)
		v1 = m[key1]
	}
	_, ok = v1[key2]
	v1[key2] = value
	return !ok
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var W int
	scanner.Scan()
	W, _ = strconv.Atoi(scanner.Text())
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		w[i], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		v[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, W, w, v))
}
func solve(N int, W int, w []int, v []int) int {
	m := lib_NewInt2DMap(N, 1000*N)
	m.Set(0, 0, 0)
	for i, curV := range v {
		curW := w[i]
		for bV, bW := range m[i] {
			m.ChMin(i+1, bV, bW)
			if newW := bW + curW; newW <= W {
				m.ChMin(i+1, bV+curV, newW)
			}
		}
	}
	return lib_MustMaxInt(m[N].Keys()...)
}


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

int main()
{
	int N, A;
	cin>>N>>A;
	int tmp=N/500;
	tmp*=500;
	if(N-tmp <=A)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>): Unit {
    val sc = java.util.Scanner(System.`in`)
    val r = sc.nextInt()
    val d = sc.nextInt()
    val x2000 = sc.nextInt()

    var x = x2000
    (1..10).forEach {
        x = r * x - d
        println(x)
    }
}

Measured memory_bytes: 31128
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// メモ用の DP テーブル
long long dp[100010];

long long rec(int i) {
    // DP の値が更新されていたらそのままリターン
    if (dp[i] < INF) return dp[i];
    
    // 足湯 0 のコストは 0
    if (i == 0) return 0;
    
    // i-1, i-2 それぞれ試す
    long long res = INF;
    chmin(res, rec(i-1) + abs(h[i] - h[i - 1])); // 足湯 i-1 から来た場合
    if (i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i - 2])); // 足湯 i-2 から来た場合
    
    // 結果をメモしながら、返す
    return dp[i] = res;
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;
    
    // 答え
    cout << rec(N-1) << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	cin >> n;
	map<string, int> cnt;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		cnt[s]++;
	}
	long long ans = 0;
	for (auto p : cnt) {
		long long x = p.second;
		ans += x * (x - 1) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11136
n = int(input())

abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2])

print(max(dp[n-1]))

Measured memory_bytes: 47368
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> vec(n);
  iota(vec.begin(),vec.end(),1);
  int i=1;
  int n1,n2;
  do{
    if(p==vec){
      n1=i;
    }
    if(q==vec){
      n2=i;
    }
    i++;
  }while(next_permutation(vec.begin(),vec.end()));
  cout<<abs(n1-n2)<<endl;
  return 0;
}

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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll mod = n % (a + b);
    ll q = n / (a + b);
    ll ans = a * q + min(a, mod);
    cout << ans << endl;
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,temp1,temp2,t,x,y,m,k,b,temp,q,d,p;
	char c;
	cin>>c;
	
	if(isupper(c))
	{
		cout<<"A"<<endl;
	}
	else
	{
		cout<<"a"<<endl;
	}
}

	
	


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;


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

    vector<pair<int, int >> E;

    if(N % 2 == 0) {
        cout << N * (N - 2) / 2 << endl;
        for(int i = 1; i < N + 1; i++) {
            for(int j = i + 1; j < N + 1; j++) {
                if(j != (N + 1) - i) {
                    cout << i << " " << j << endl;
                }
            }
        }
    } else {
        cout << pow(N - 1, 2) / 2 << endl;
        for(int i = 1; i < N + 1; i++) {
            for(int j = i + 1; j < N + 1; j++) {
                if(j != N - i) {
                    cout << i << " " << j << endl;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll N,K;
	cin >> N >> K; 
	map<ll, ll> num;
	ll n = 0;
	for (int i = 0; i < N; i++) {
		cin >> n;
		num[n]++;
	}
	vector<ll> ball;
	ll size = num.size();
	if (size <= K)cout << "0" << endl;
	else {
		ll ans = 0;
		for (auto x : num) {
			ball.push_back(x.second);
		}
		sort(all(ball));
		for (int i = 0; i < size - K; i++) {
			ans += ball[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()

#define naman                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const ll INF=1e18;
const double PI=4*atan(1);


void solve(){
    ll k,x;
    cin >> k >> x;
    if(500*k>=x) cout << "Yes";
    else cout << "No";
    cout << endl;

}

int32_t main(){
    naman
    ll i = 0,j = 0;
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
*/
    //cout << fixed << setprecision(10);

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

    }

}

Measured memory_bytes: 256
N = int(input())
a = []
for i in range(N):
	X, L = map(int, input().split())
	a.append((X + L, X - L))
a.sort()
b = [a[0][0]]
i = 1
while i < N:
	if b[len(b) - 1] <= a[i][1]:
		b.append(a[i][0])
	i += 1
print(len(b))

Measured memory_bytes: 17584
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
		x=(a*-1*c)+d+(b*e);
	}
	if(a>0){
		x=(b-a)*e;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2684
/*
    Author : Simanta Deb Turja
    Created On: 21/06/20
    Atcoder Beginner Contest 171
*/

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

#define Professor

using ll = long long;
using i64 = unsigned long long;
using ld = long double;

template <typename T> inline T Min (T a, T b, T c) { 
    return min(a, min(b, c)); 
}
template <typename T> inline T Min (T a, T b, T c, T d) { 
    return min(a, min(b, min(c, d))); 
}
template <typename T> inline T Max (T a, T b, T c) { 
    return max(a, max(b, c)); 
}
template <typename T> inline T Max (T a, T b, T c, T d) { 
    return max(a, max(b, max(c, d))); 
}

template <typename T> inline T Ceil(T a, T b) { 
    return ((a % b == 0) ? (a / b) : (a / b + 1)); 
} 
template <typename T> inline T Floor(T a, T b) { 
    return a / b; 
}

template <typename T> inline T Power (T a, T p) { 
    T res = 1, x = a; 
    while ( p ) { 
        if ( p & 1 ) res = ( res * x ); 
        x = ( x * x ); p >>= 1;
    }
    return res; 
}
template <typename T> inline T BigMod (T a,T p,T M) { 
    a %= M; T ret = (T)1; 
    while (p) { 
        if (p & 1) ret = (ret * a) % M; 
        a = (a * a) % M;  p = p >> 1;
    } 
    return ret;
}
template <typename T> inline T InverseMod (T a,T M) { 
    return BigMod (a, M - 2, M); 
}

template <typename T> inline T gcd ( T a, T b ) { 
    a = abs(a); b = abs(b); 
    while ( b ) { 
        a = a % b; swap ( a, b ); 
    } 
    return a;
}
template <typename T> inline T lcm(T x,T y) { 
    return (((x)/gcd((x),(y)))*(y)); 
}


template< typename T1, typename T2, typename T3 > struct Pair { 
    T1 first; T2 second; T3 third; 
};
template< typename T1, typename T2, typename T3, typename T4 > struct Pair4 { 
    T1 first; T2 second; T3 third; T4 fourth; 
};


using ii = pair <int, int>;
using iii = Pair <int, int, int>;
using iiii = Pair4 <int, int, int, int>;

#define endl '\n'

const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const int MOD = (ll)1e9 + 7;
const int N = (int)4e5 + 10;


//++++++++++++++++++Template Ends Here++++++++++++++++++

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    char ch;
    cin >> ch;
    if (ch >= 'A' && ch <= 'Z') {
        cout << "A\n";
    } else {
        cout << "a\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeSearch(Node u, int k){
  if( u==NIL || k==u->key ) return u;
  if( k<u->key ) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while( x!=NIL ){
	  y=x;
	  if( z->key < x->key ) x=x->left;
	  else x=x->right;
  }
  z->parent=y;
  if( y==NIL ) root=z;
  else if( z->key < y->key ) y->left=z;
  else y->right=z;
}
void inorder(Node u){
	if( u->left!=NIL ) inorder(u->left);
	printf(" %d", u->key);
	if( u->right!=NIL ) inorder(u->right);
}
void preorder(Node u){
	printf(" %d", u->key);
	if( u->left!=NIL ) preorder(u->left);
	if( u->right!=NIL ) preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
    	scanf("%d", &x);
    	Node t = treeSearch(root, x);
    	if ( t != NIL ) printf("yes\n");
    	else printf("no\n");
    }
    else if ( com[0] == 'i' ){
    	scanf("%d", &x);
    	insert(x);
    }
    else if ( com[0] == 'p' ){
    	inorder(root);
    	printf("\n");
    	preorder(root);
    	printf("\n");
    }
  }
  return 0;
}

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

const LL MOD = 1000000007;
LL n, m;

LL fac(LL x){
	LL res = 1;
	while (x)
		res = (res * (x--)) % MOD;
	return res;
}

int main(){
	scanf("%lld%lld", &n, &m);
	if (n > m) swap(n, m);
	if (n <= m-2) puts("0");
	else if (n == m-1) printf("%lld\n", fac(n)*fac(m)%MOD);
	else printf("%lld\n", 2*fac(n)*fac(m)%MOD);
	return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

#define MAX_N (1<<18)

struct segtree{
    int n, dat[2*MAX_N-1]; //(1<<17) = 130000

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++) dat[i] = INF;
    }

    void update(int k, int a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }

    //(a,b,0,0,seg.n)で呼ぶ
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return dat[k];
        else{
            int vl = query(a,b,k*2+1,l,(l+r)/2);
            int vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl, vr);
        }
    }
}seg1, seg2;

int n;
int p[200000];
int v2p[200000];
int id;
P val[200000];
vector<int> e[200000];

void solve(int st, int en, int par_id) {
    if(st == en) return;
    int pos, pos2;
    if(st&1) {
        pos = seg1.query(st, en, 0, 0, seg1.n);
    } else {
        pos = seg2.query(st, en, 0, 0, seg2.n);
    }
    pos = v2p[pos];
    if((pos+1)&1) {
        pos2 = seg1.query(pos+1, en, 0, 0, seg1.n);
    } else {
        pos2 = seg2.query(pos+1, en, 0, 0, seg2.n);
    }
    pos2 = v2p[pos2];
    int now_id = id;
    val[id++] = P(p[pos], p[pos2]);
    if(par_id != -1) {
        e[par_id].push_back(now_id);
    }
    
    solve(st, pos, now_id);
    solve(pos+1, pos2, now_id);
    solve(pos2+1, en, now_id);
}

int main(){
    cin >> n;
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]--;
    rep(i,n) v2p[p[i]] = i;
    seg1.init(n);
    seg2.init(n);
    rep(i,n) {
        if(i&1) {
            seg1.update(i, p[i]);
        } else {
            seg2.update(i, p[i]);
        }
    }
    solve(0, n, -1);
    vector<P> ans;
    ans.push_back(val[0]);
    priority_queue<PP, vector<PP>, greater<PP>> que;
    rep(i,e[0].size()) {
        que.push(PP(val[e[0][i]], e[0][i]));
    }
    while(!que.empty()) {
        PP p = que.top();
        que.pop();
        ans.push_back(p.first);
        rep(i, e[p.second].size()) {
            que.push(PP(val[e[p.second][i]], e[p.second][i]));
        }
    }
    
    rep(i,ans.size()) {
        cout << ans[i].first+1 << " " << ans[i].second+1;
        if(i != ans.size()-1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}
































Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

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

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		int count = 0;
		for(int i=0;i<H;i++){
			String s = scan.next();
			for(int j=0;j<W;j++){
				if(s.substring(j, j+1).equals("#")){
					count++;
				}
			}
		}
		if(count==H+W-1){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}
		scan.close();
	}
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = x;
  ll count = 0;
  while (ans <= y) {
    ans <<= 1;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define hhh printf("hhh\n")
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x;}

const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-7;



int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    int N=read();
    printf("%.10f\n", ((N+1)/2)/1./N);
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> ss(n); cin >> ss;
    vector<int> ts(m); cin >> ts;
    vector<int> dp[2] = {vector<int>(m + 1, 1), vector<int>(m + 1)};
    // vector<vector<int>> dp(2, vector<int>(m + 1, 1));
    for(int i = 0; i < n; i++){
        int i1 = i & 1, i2 = !i1;
        dp[i2][0] = 1;
        for(int j = 0; j < m; j++){
            int& num = dp[i2][j + 1];
            if(ss[i] == ts[j]){
                num = dp[i2][j] + dp[i1][j + 1];
                if(num >= M){
                    num -= M;
                }
            }else{
                num = dp[i2][j] + dp[i1][j + 1] - dp[i1][j];
                if(num >= M){
                    num -= M;
                }else if(num < 0){
                    num += M;
                }
            }
        }
    }
    printde(dp);
    cout << dp[n & 1][m] << '\n';
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(k:i64 x:i64));
    (-1000000..1000000 + 1)
        .filter(|n| (x - n).abs() < k)
        .map(|x| x.to_string())
        .collect::<Vec<_>>()
        .join(" ")
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 7\n" => "5 6 7 8 9\n",
    test2: "4 0\n" => "-3 -2 -1 0 1 2 3\n",
    test3: "1 100\n" => "100\n",
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <vector>
#define rep(i, n)	for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	int n;	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	/*calculation*/
	int ans = 100, min;
	int tmp;
	rep(i, n){	//2^...
		tmp = a[i];
		min = 0;
		while(tmp%2 == 0){
			++min;
			tmp /= 2;
		}
		if(ans >= min)ans = min;
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int n;
    cin >> n;
    
    unsigned long long int count = 0;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0) {
            count += i;
        }
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 3552
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cstring>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


#define MAX_V 10000
#define INF 10000000000

struct edge{int to;long long cap,rev;};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,long long cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s)
{
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty())
	{
		int v = que.front();que.pop();
		for(int i = 0;i < G[v].size();++i)
		{
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0)
			{
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v ,int t,long long f)
{
	if(v == t)return f;
	for(int &i = iter[v];i < G[v].size() ;++i)
	{
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to])
		{
			long long d = dfs(e.to,t,min(f,e.cap));
			if(d > 0)
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

long long Dinic(int s,int t)
{
	long long flow = 0;
	while(1)
	{
		bfs(s);
		if(level[t] < 0)return flow;
		memset(iter,0,sizeof(iter));
		long long f;while((f = dfs(s,t,INF)) > 0)flow += f;
	}
}
	

int main()
{
	int n;cin >> n;
	ll ans = 0;
	REP(i,n)
	{
		int a;cin >> a;
		if(a > 0){add_edge(i+1,n+1,a);ans += a;}
		else add_edge(0,i+1,-a);
		for(int j = (i+1);j <= n;j += i+1)
		{
			add_edge(i+1,j,INF);
		}
	}
	
	cout << ans - Dinic(0,n+1) << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int K, X;
  std::cin >> K >> X;
  std::vector<int> ans;
  for(int i=-1000000;i<=1000000;i++){
    if(i<=X){
      if(i+K-1>=X) ans.push_back(i);
    }else{
      if(i-(K-1)<=X) ans.push_back(i);
    }
  }
  for(int i=0;i<ans.size();i++) std::cout << ans[i] << (i==ans.size()-1?"\n":" ");
  return 0;
}


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


int main() {
    int N;
    std::cin >> N;
    std::vector<int> diff(N);

    for (int i = 0; i < N; i++) {
        std::cin >> diff[i];
    }

    std::sort(diff.begin(), diff.end());
    std::cout << diff[N / 2] - diff[N / 2 - 1] << std::endl;
}


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

using namespace std;

int main()
{
	int n, maxx = -1, zbir = 0;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		
		zbir += tmp;
		maxx = max(tmp, maxx);
	}
	
	if (maxx >= zbir - maxx)
	{
		cout << "No";
		return 0;
	}
	
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
def rec(L, X):
    S = [0 for i in range(51)]
    S[0] = 1
    for i in range(1, 51):
        S[i] = 3 + 2 * S[i - 1]
    dic = {}
    def f(L, X):
        if L == 0:
            return 1
        if X < 2:
            return 0
        if (L, X) in dic:
            return dic[(L, X)]
        if X < S[L - 1] + 1:
            dic[(L, X)] = f(L - 1, X - 1)
        elif X == S[L - 1] + 1:
            dic[(L, X)] = f(L - 1, S[L - 1])
        elif X == S[L - 1] + 2:
            dic[(L, X)] = f(L - 1, S[L - 1]) + 1
        else:
            dic[(L, X)] = f(L - 1, S[L - 1]) + 1 + f(L - 1, X - 2 - S[L - 1])
        return dic[(L, X)]
    return f(L, X)

L, X = map(int, input().split())
print(rec(L, X))

Measured memory_bytes: 3188