akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int N=500010;
int n;
map<int,int> mp;
int main()
{
	scanf("%d",&n);
	int now=1,cnt=0;
	while (n--)
	{
		int x;
		scanf("%d",&x);
		if (x<now)
		{
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		while (mp[x]>0 && x>0)
		{
			mp[x]=0;
			x--;
			cnt--;
		}
		mp[x]=1;
		cnt++;
		while (mp[now]>0 && now<N)
		{
			now++;
		}
		now=min(now,cnt);
		if (x==0)
		{
			now=1e9;
		}
	}
    return 0;
}

Measured memory_bytes: 14808
#include <cstdio>
#include <cmath>
#include <iostream>
 
using namespace std;
 
typedef  long long ll;
 
ll p[55], nlen[55];
 
ll solve(ll n, ll x)
{
    if(x <= n) return 0;
    nlen[n]=(1ll<<(n+2))-3;
    if(x >= nlen[n] - 1) return p[n];
    if(x == nlen[n] / 2 + 1) return (p[n] / 2 + 1);
    else if(x < nlen[n] / 2 + 1)
        return solve(n - 1, x - 1);
    else
        return p[n] / 2 + 1 + solve(n - 1, x - nlen[n] / 2 - 1);
}
 
int main()
{
    for(int i = 0; i <= 50; ++i)
    {
        p[i] = pow(2, i + 1) - 1;
       // nlen[i] = pow(2, i - 1) * 8 - 3;
    }
    ll n, x;
    cin>>n>>x;
    cout<<solve(n, x)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



int main(){
    int n, W; cin >> n >> W;
    VI w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    //i番目(0-order)まで, 　重さj で価値最大値
    vector<VLL> dp(n+1, VLL(W+1, 0));
    REP(i, n){
        REPS(j, W){
            if(j - w[i] >= 0)
                chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);

            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << "\n";
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    auto itr = max_element(ALL(v));
    int mnum = *itr;
    int mid = itr - v.begin();
    int halfid = -1;
    int half = 1 << 30;
    rep(i, n)
    {
        if (i == mid)
            continue;
        if (abs(mnum / 2 - v[i]) < half)
        {
            half = abs(mnum / 2 - v[i]);
            halfid = i;
        }
    }
    cout << mnum << " " << v[halfid] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

int main() {
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	map<int,int> k;
	rep(i,0,n) {
		int num;
		cin >> num;
		k[num]++;
	}
	int m;
	cin >> m;
	rep(i,0,m) {
		int num;
		cin >> num;
		if(k.find(num) != k.end() && k[num] != 0) {
			k[num]--;
		} else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int D,G;
    cin >>D>>G;
    vector<int> p(D);
    vector<int> c(D);
    for(int i = 0; i<D; i++) cin >> p[i] >> c[i];

    int ans = 100000000;
    for(int A = 0; A < (1 << D); A++) {
        int cnt = 0;
        int sum = 0;
        int res = 0;
        for(int B = 0; B < D; B++) {
            if(A & (1 << B)) {
                cnt += 100*(B + 1) * p[B] + c[B];
                sum += p[B];
            } else {
                res = B;
            }
        }
        if(cnt < G) {
            int tmp = 100*(res + 1);
            int ned = (G - cnt + tmp - 1) / tmp;
            if(ned > p[res]) continue;
            sum += ned;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    string s;
    cin >> s;

    vector<int> Rbefore(N);
    vector<int> Gbefore(N);
    vector<int> Bbefore(N);

    vector<int> Rafter(N);
    vector<int> Gafter(N);
    vector<int> Bafter(N);

    int Rseen = 0;
    int Bseen = 0;
    int Gseen = 0;
    for (int i = 0; i < N; i++)
    {
        Rbefore[i] = Rseen;
        Bbefore[i] = Bseen;
        Gbefore[i] = Gseen;

        switch (s[i]) {
            case 'R':
            Rseen++;
            break;
            case 'G':
                Gseen++;
                break;
            case 'B':
                Bseen++;
        }
    }

    Bseen = 0;
    Rseen = 0;
    Gseen = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        Rafter[i] = Rseen;
        Gafter[i] = Gseen;
        Bafter[i] = Bseen;
        switch (s[i]) {
            case 'R':
                Rseen++;
                break;
            case 'G':
                Gseen++;
                break;
            case 'B':
                Bseen++;
        }
    }

    int64_t c = 0;
    for (int64_t i = 0; i < N; i++)
    {
        if (s[i] == 'R') {
            c += Gbefore[i] * Bafter[i];
            c += Bbefore[i] * Gafter[i];
        }

        if (s[i] == 'G')
        {
            c += Rbefore[i] * Bafter[i];
            c += Bbefore[i] * Rafter[i];
        }

        if (s[i] == 'B')
        {
            c += Rbefore[i] * Gafter[i];
            c += Gbefore[i] * Rafter[i];
        }
    }

    for (int64_t i = 0; i < N; i++)
    {
        for (int64_t k = i+1; k < N; k++)
        {
            if (s[i] == s[k])
                continue;

            if ((i + k) % 2)
                continue;

            int64_t j = (i + k) >> 1;
            if (s[i] == s[j] || s[k] == s[j])
                continue;

            c--;
        }
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
8 5
-9 -7 -4 -3 1 2 3 4
)");
#define cin input
#endif

int main()
{
	int n,k;
	cin >> n >> k;
	
	vector<int> x(n);
	/*REP(i,n)
		cin >> x[i];*/
	for (auto& i:x)
		cin >> i;

	int min = INF;
	int sum = 0;
	REP(i, n-k+1)
	{
		sum = x[i+k-1]-x[i]+std::min(abs(x[i+k-1]),abs(x[i]));
		if (min>sum)
			min = sum;
	}
	cout << min << endl;
}

Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H, W := sc.nextInt(), sc.nextInt()
	A := make([][]rune, H)
	for i := 0; i < H; i++ {
		A[i] = sc.nextRuneSlice()
	}
	ok := true
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			found := false
			if A[i][j] == '#' {
				if j != 0 && A[i][j-1] == '#' { // left
					found = true
				} else if i != 0 && A[i-1][j] == '#' { // up
					found = true
				} else if j != W-1 && A[i][j+1] == '#' { // right
					found = true
				} else if i != H-1 && A[i+1][j] == '#' { // down
					found = true
				}
			} else {
				continue
			}
			if !found {
				ok = false
			}
		}
	}

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 640
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define inpv(a,n) vector<ll> a(n); for(ll i=0;i<n;i++){cin>>a[i];}
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define iniv(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);
ll mod=MOD;

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}

int main() 
{
	// #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
	fio;
	ll testcase=1;
	//cin>>testcase;
	while(testcase--)
	{
		ld x,t,n;
		cin>>n>>x>>t;
		ll cur=0;
		ll ans=0;
		while(cur<n)
		{
			cur+=x;
			ans+=t;
		}
		ol(ans);
	}
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
string S;
int main (){
    cin >> N >> S;
    int x = 0;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(S[i] == 'I') x++;
        if(S[i] == 'D') x--;
        ans = max( x , ans );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 1e9;
int k;
int ary[100005];
void solve(int p, int q) {
    if (ary[p] <= q) return;
    ary[p] = q;
    solve(p * 10 % k, q);
    solve((p + 1) % k, q + 1);
}
int main(void) {
    cin >> k;
    for (int i = 0; i < k; ++i) ary[i] = 45;
    solve(1, 1);
    cout << ary[0] << endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<long long> a(n+1,0);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    vector<long long> v;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v.push_back(a[j]-a[i]);
        }
    }
    long long res=0;
    for(int bit=50;bit>=0;bit--){
        int cnt=0;
        int m=v.size();
        for(int i=0;i<m;i++){
            if(v[i]&(1ll<<bit))cnt++;
        }
        if(cnt>=k){
            //cout<<bit<<endl;
            res+=1ll<<bit;
            vector<long long> vv;
            for(int i=0;i<m;i++){
                if(v[i]&(1ll<<bit))vv.push_back(v[i]);
            }
            v=vv;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6128
#include <stdio.h>
#include <string.h>
 
#define M 1046527
#define L 14
 
char H[M][L];
 
int char2int(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
 
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * char2int(str[i]);
    p *= 5;
  }
  return ret;
}
 
int h1(int key) {
  return key % M;
}
 
int h2(int key) {
  return 1 + (key % (M - 1));
}
 
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
 
int insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
 
int main(void) {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
 
    if(cmd[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}
 

 

Measured memory_bytes: 16968
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(k, s);
    int res = 0;

    rep(i, k + 1)rep(j, k + 1)if(i + j <= s && i + j + k >= s)++res;

    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int length = str.length();
        for (int i = 0; i < length; i++) {
            if(str.charAt(i) == '1') System.out.print(9);
            else System.out.print(1);
        }
    }
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

ll a[3];
ll n;

int main(){
    ios::sync_with_stdio(0);
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    ll res = abs(a[1] - a[0]) + abs(a[2] - a[1]);
    cout << res;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int X, Y , Z;
  int N, M;
  int x[100], y[100];
  int flag[2];
  int i;

  cin >> N >> M >> X >> Y;
  for(i = 0;i < N;i++) cin >> x[i];
  for(i = 0;i < M;i++) cin >> y[i];
  for(i = 0;i < 2;i++) flag[i] = 0;

  for(Z = X+1;Z <= Y;Z++){
    for(i = 0;i < N;i++){
      if(Z <= x[i]){
        flag[0] = 1;
        break;
      }
    }
    if(flag[0] == 0){
      for(i = 0;i < M;i++){
        if(y[i] < Z){
          flag[1] = 1;
          break;
        }
      }
    }
    if(flag[0] == 0 && flag[1] == 0) break;
    else if(Z != Y) {
      flag[0] = 0;
      flag[1] = 0;
    }
  }
  if(flag[0] == 0 && flag[1] == 0) cout << "No War" << endl;
  else cout << "War" << endl;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    string str;
    cin >> n;
    map<string , int> m;
    while(n--){
        cin >> str;
        m[str]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;


    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int a = 0;a < N;a++){
    cin >> A[a];
    B[a] = A[a];
  }
  
  sort(A.begin(),A.end());
  if(A[N-1] == A[N-2]){
   for(int a = 0;a < N;a++)cout << A[N-1] << endl; 
    
  }else{
   for(int a = 0;a < N;a++){
    if(B[a] == A[N-1]){
     cout << A[N-2] << endl; 
    }else{
      cout << A[N-1] << endl; 
    }
     
     
   }
    
    
  }
}

Measured memory_bytes: 4824
#include<stdio.h>
int main(){
  int a,b,c,n,m,i;
  int d;
  while(scanf("%d %d %d",&a,&b,&c),a||b||c){
    if(a<b){
      if(b>c)b=c;
    }
    else if(a>c)a=c;
    d=a*a+b*b;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&m);
      if((m+m)*(m+m)>d)printf("OK\n");
      else     printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
while 1:
    n = int(input())
    if n ==0 :break
    e = [1 for _ in range(2*n+1)]
    for i in range(2,n+1):
        if i *i >n:pass
        if e[i] == 1:
            for j in range(2,int(2*n/i) + 1):
                e[i*j] = 0
    print(sum(e[n+1:2*n+1]))

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

int main(){

	int n,count=0;
  	long long x,y,d;
  	cin >> n >> d;
  	d = d*d;
  	for(int i=0; i<n; ++i){
      cin >> x >> y;
      if(x*x + y*y <= d){
        count++;
      }
    }

    cout << count << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)998244353
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[200010], place[200010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		place[a[i]] = i;
	}
	int l = 1, r = 2, ans = n - 1;
	for (; r <= n; r++) {
		if (place[r] < place[r - 1]) {
			ans = min(ans, n - r + l);
			l = r;
		}
	}
	ans = min(ans, n - r + l);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;

int main(){
  int n; cin>>n;
  vector<int> now(n+1,0);
  now[0]=3;
  ll ans=1;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    ans*=now[a];
    now[a]--; now[a+1]++;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

struct UnionFind{
    vector<int> par,rank;
    
    //初期化
    UnionFind(int n){
        for(int i=0;i<=n;++i){
            par.push_back(i);
            rank.push_back(0);
        }
    }

    //根をFind
    int find(int i){
        if(par[i]==i)return i;

        return par[i]=find(par[i]);
    }

    //Union
    void unite(int x,int y){
        int rx=find(x);
        int ry=find(y);

        if(rx==ry)return;

        if(rank[rx]>rank[ry])par[ry]=rx;
        else{
            par[rx]=ry;
            if(rank[rx]==rank[ry])
                rank[ry]++;
        }
    }

    //同じ木に属するか判定
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N,M;cin>>N>>M;
    UnionFind UF(N);
    int X[100010],Y[100010],Z[100010];
    for(int i=0;i<M;i++){
        cin>>X[i]>>Y[i]>>Z[i];
        UF.unite(X[i],Y[i]);
    }
    map<int,int>mp;
    for(int i=1;i<=N;i++){
        mp[UF.find(i)]++;
    }
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6900
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

template<typename T>
class RangeUpdateQuery {
public:
    explicit RangeUpdateQuery(int n, T def) : N(calcN_(n)) {
        mVal.assign(2*N+1, make_pair(-1, def));
    }
    void update(int l, int r, T value, int ts){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ mVal[offset+l-1].first = ts; mVal[offset+l-1].second = value; l++; }
            if(r&1){ mVal[offset+r-2].first = ts; mVal[offset+r-2].second = value; }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            res = max(mVal[i], res);
        }
        return res.second;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, pair<int, T> value, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            mVal[idx] = value;
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
        }
    }
    const int N;
    vector<pair<int,T>> mVal;
};

bool valid(const vector<int>& a, const vector<int>& upper){
    const int N = a.size();
    RangeUpdateQuery<int> seg(N, 0);
    for(int i=1;i<a.size();i++){
        if(a[i] <= a[i-1]){
            int c = a[i];
            while(c >= 0){
                int v = seg.get(c);
                if(v == upper[c]-1){
                    seg.update(c, c+1, 0, i);
                    --c;
                } else {
                    seg.update(c, c+1, v+1, i);
                    break;
                }
            }
            if(c < 0) return false;
        } else {
            seg.update(a[i-1]+1, a[i]+1, 0, i);
        }
    }
    return true;
}

long long pow(long long a, long long p){
    if(a == 1) return 1;
    if(p == 0) return 1;
    auto res = pow(a, p/2);
    res *= res;
    if(p%2 == 1) res *= a;
    return min(res, 200000LL);
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    vector<int> v;
    for(auto& t : a){
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    map<int, int> idx;
    for(int i=0;i<v.size();i++) idx[v[i]] = i;
    for(auto& t : a) t = idx[t];
    int L = 0, R = N;
    vector<int> upper(N);
    while(R-L > 1){
        int mid = (L+R)/2;
        upper[0] = pow(mid, v[0]);
        for(int i=1;i<N;i++) upper[i] = pow(mid, v[i]-v[i-1]);
        if(valid(a, upper)) R = mid;
        else L = mid;
    }
    cout << R << endl;
}

Measured memory_bytes: 16116
import sys
input = sys.stdin.readline
def solve():
  n,z,w = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  if n == 1:
    ans = abs(w-a[0])
  else:
    ans = 0
    #最小化する方向に動く
    tmp = abs(a[n-2]-a[n-1])
    tmp2 = abs(a[n-1]-w)
    ans = max(tmp,tmp2)
  print(ans)
solve()
  

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

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

void solve(){
  int n;
  cin >> n;
  ll a[n], ans = 1;
  rep(i, n) cin >> a[i];
  for(int i = 0; i < n; i++){
    ans = lcm(ans, a[i]);
  }
  cout << ans << endl;

}

int main(){
  solve();
  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m;
	cin >> n >> m;
	m /= 1000;
	bool ans = false;
	for(ll i=0; i<=n and !ans;i++){
		for(ll j=0; j<=n; j++){
			if(i+j<=n){
				if((i + j*5 + (n-i-j)*10) == m){
					cout << (n-i-j) << " " << j << " " << i;
					return 0;
				}
			}
		}
	}
	if(!ans)
		cout << "-1 -1 -1";
}

Measured memory_bytes: 3648
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int cr = sc.nextInt();
	int D = sc.nextInt();
	int x = sc.nextInt();
	for(int i = 0; i < 10; i++){
		x = cr*x - D;
		System.out.println(x);
		}
}
}


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

typedef long long ll;

const ll MOD = 1e9 + 7;

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

    int n; cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    bool ok = true,uku = true;
    bool ok2 = true;
    if(n%2==1){
        for(int i=0;i<n;i+=2){
            if(i==0 && mp[i]!=1){
                uku = false;
                break;
            }
            else if(i!=0 && mp[i]!=2){
                ok = false;
                break;
            }
        }
    }else{
        for(int i=1;i<n;i+=2){
            if(mp[i]!=2){
                ok2 = false;
                break;
            }
        }
    }
    if(!uku || !ok || !ok2){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i=1;i<=n/2;i++){
        ans = (ans * 2) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long a,b,c,d;cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}


Measured memory_bytes: 3648
n=int(input())
s=input()
count=0
if n==3:
    if s=="ABC":
        count=1
else:
    s=list(s)
    for i in range(n-3+1):
        if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
            count+=1
print(count)




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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, x;
    int l[100];
    cin >> n >> x;
    for (int i = 0; i < n; i++)
        cin >> l[i];

    int d[110] = {};
    int cnt = 1;
    for (int i = 2; i <= n + 1; i++)
    {
        d[i] = d[i - 1] + l[i - 2];
        if (d[i] <= x)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//union find{
int o[100];
int u[200];
// ??¨??????????±???????
int root(int s){
  while(o[s]>=0)
    s=o[s];
  return u[s];
}

// x??¨y????±??????????????????????
void merge(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;
  o[x]+=o[y];
  o[y]=x;
}
// x??¨y?????????????????????true
bool same(int x,int y){
  return root(x) == root(y);
}
//}end of union find
int main(){
  string str;
  for(int i=0;i<26;i++){
    o[i+'a']=-1;
    u[i+'a']=i+'a';
  }
  merge('q','w');merge('q','e');merge('q','r');merge('q','t');merge('q','a');merge('q','s');merge('q','d');merge('q','f');merge('q','g');merge('q','z');merge('q','x');merge('q','c');merge('q','v');merge('q','b');
merge('y','u');merge('y','i');merge('y','o');merge('y','p');merge('y','h');merge('y','j');merge('y','k');merge('y','l');merge('y','n');merge('y','m');
 while(cin>>str,str!="#"){
    int ans=0;
    for(int i=0;i<str.size()-1;i++){
      if(!same(str[i],str[i+1])){
	ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
int K,N,i,max,min;
scanf("%d",&K);
scanf("%d",&N);
int A[N],a[N];
for(i=1;i<=N;i++)
scanf("%d",&A[i]);
max=K-A[N]+A[1];
for(i=1;i<N;i++){
a[i]=A[i+1]-A[i];
if(a[i]>max)
max=a[i];
}
min=K-max;
printf("%d",min);
return 0;
}

Measured memory_bytes: 3288
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

void show(vector<int>& data){
	for(int i=0;i<data.size();i++){
		cout<<data[i];
		if(i==data.size()-1){
			cout<<endl;
		}else{
			cout<<" ";	
		}
	}
}




int main(){
	
	int size;
	cin>>size;
	vector<int> arr;
	arr.resize(size);
	for(int i=0;i<size;i++){
		int num;
		cin>>num;
		arr[i]=num;
	}
	show(arr);
	
	for(int i=1;i<size;i++){
		int key=arr[i];
		int j=i-1;
		while(j>=0 && arr[j]>key){
			arr[j+1]=arr[j];
			j--;
		}
		arr[j+1]=key;
		show(arr);
	}

	
	return 0;
}

Measured memory_bytes: 1200
s = int(input())
if s >= 10:
  n = str(s)
  if n[-1]=="3":
    print("bon")
  else:
    if n[-1]=="0"or n[-1]=="1"or n[-1]=="6"or n[-1]=="8":
      print("pon")
    else:
      print("hon")
else:
  if s==3:
    print("bon")
  else:
    if s==1 or s==6 or s==8:
      print("pon")
    else:
      print("hon")

Measured memory_bytes: 9148
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0, k = 0;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    vector<ll> candi;
    for (int i=1; i*i<=sum; i++) {
        if (sum%i == 0) {
            candi.push_back(i);
            candi.push_back(sum/i);
        }
    }
    vector<ll> buf1(n);
    ll ans = 0;
    for (ll i : candi) {
        for (int j=0; j<n; j++) {
            buf1.at(j) = a.at(j)%i;
        }
        sort(buf1.begin(), buf1.end());
        ll A = 0, B = 0;
        for (int j=0; j<n; j++) {
            A += buf1.at(j);
        }
        for (int j=n-1; j>=0; j--) {
            A -= buf1.at(j);
            B += i - buf1.at(j);
            if (max(A, B) > k) continue;
            else {
                ans = max(ans, i);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> lgt(n,0);
	REP(i,n) {
		ll a;
		cin>>a;
		lgt[a]++;
	}
	ll diam=-1;
	REP(i,n) {
		if(lgt[n-1-i]>0) {
			diam=n-1-i;
			lgt[n-1-i]--;
			break;
		}
	}
	FOR(i,1,diam+1) {
		if(lgt[max(diam-i,i)]==0) {
			cout<<"Impossible"<<endl;
			return 0;
		}
		lgt[max(diam-i,i)]--;
	}
	REP(i,n) {
		if(i<(diam+1)/2+1&&lgt[i]>0) {
			cout<<"Impossible"<<endl;
			return 0;
		}
	}
	cout<<"Possible"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  long long K,A,B,ans=0;
  cin >> K >> A >> B;
  if(K<=A){
    cout << K+1 << endl;
    return 0;
  }
  ans=B;
  for(long long i=A+1; i<K; i+=2){
    if(i+2<=K) ans+=B-A;
    else ans+=1;
  }
  if(K+1<=ans) cout << ans <<  endl;
  else cout << K+1 << endl;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

ll a, b, sq, mx, aa;
ll ans;

ll sqr(ll x) {
  ll l = 1;
  ll r = 1e9;
  while (r - l > 1) {
    ll mid = (l + r) >> 1;
    if (mid * mid <= x) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}

void solve() {
  scanf("%lld %lld", &a, &b);
  if (a > b) swap(a, b);
  sq = sqr(a * b - 1);
  ans = sq;
  if (a <= sq) {
    ans--;
  }
  mx = (a * b - 1) / (sq + 1);
  if (b <= mx) {
    ans--;
  }
  ans += mx;
  cout << ans << endl;
}

main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    solve();
  }
}


Measured memory_bytes: 384
#include <stdio.h>


int main(void){

  int color[9] = {0};


  int num;
  scanf("%d",&num);
  int i;

  for(i = 0; i < num;i++){
    int tmp;
    scanf("%d",&tmp);
    if(tmp > 3200)
      tmp = 3200;

    color[tmp / 400]++;
  }

  //calc min
  int min = 0;
  for(i = 0; i < 8;i++){
    if(color[i] > 0)
      min++;
  }
  
  //calc max
  int max = min + color[8];

  if(min == 0)
    min = 1;

  printf("%d %d",min,max);
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

string N;
ll DP[10][2][2][2][2][2];

ll rec(int digit, bool tight, bool b1, bool b2, bool b3, bool b4){
	if(digit==N.size()){
		if(b1 && b2 && b3) return 1;
	}
	if (DP[digit][tight][b1][b2][b3][b4]!=-1) return DP[digit][tight][b1][b2][b3][b4];
	int digit_num = N[digit] - '0';
	int ub = (tight ? digit_num : 9);
	ll res = 0;
	REP(i, ub+1){
		if(i==3 || i==5 || i==7 || (b4 && i==0)){
			res += rec(digit+1, (tight && i==ub), (b1 || (i==3)), (b2 || (i==5)), (b3 || (i==7)), (b4 && (i==0)));
		}
	}
	DP[digit][tight][b1][b2][b3][b4] = res;
	return res;
}

int main(){
	cin >> N;

	memset(DP, -1, sizeof(DP));

	cout << rec(0, true, false, false, false, true) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main() {

    fast
    int n;
    cin>>n;

    if(n>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }



    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <memory.h>
#include <deque>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int M=100005;
const int N=1000001;
const int K=1000000009;
const ll MAX=1000000000000000000ll;
string s,k;
int dp[3003][3003];
int calc(int i,int j)
{
	if(i==s.size()||j==k.size())
		return 0;
	int &ret=dp[i][j];
	if(ret!=-1)
		return ret;
	if(s[i]==k[j])
		return ret=calc(i+1,j+1)+1;
	return ret=max(calc(i+1,j),calc(i,j+1));
}
void print(int i,int j)
{
	if(i==s.size()||j==k.size())
		return;
	int &ret=dp[i][j];
	if(s[i]==k[j]&&ret==calc(i+1,j+1)+1)
	{
		cout<<s[i];
		print(i+1,j+1);
	}
	else
	{
		if(ret==calc(i+1,j))
			print(i+1,j);
		else
			print(i,j+1);
	}
}
int main(){
    cin>>s>>k;
    memset(dp,-1,sizeof(dp));
    calc(0,0);
    print(0,0);
}

Measured memory_bytes: 35968
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int N = sc.nextInt();
            int M = sc.nextInt();
            if(N == 0)break;
            int ans = 0;
            int price = M / N;
            for(int i = 0 ; i < N ; i++){
                int a = sc.nextInt();
                if(a < price)
                    ans += a;
                else
                    ans += price;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 32552
#include<iostream>
using namespace std;
 
int main(){
 int r,c,total=0;
 cin >> r >> c;
 int table[r+1][c];
 
 for(int i=0; i<r; i++){
   int sum=0;
   for(int j=0; j<c; j++){
     cin >> table[i][j];
     sum += table[i][j];
     cout << table[i][j] << " ";
     if(i==0) table[r][j] = 0;
     table[r][j] += table[i][j];
   }
   cout << sum << endl;
   total += sum;
 }
 for(int j=0; j<c; j++) cout << table[r][j] <<" ";
 cout << total << endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const int mod=1e9+7;
int main()
{       
    int N; cin>>N;
    vector<int> a(N),b(N);
    REP(i,N){
        cin>>a[i];
        b[i]=abs(i-(N-(i+1)));
    }
    sort(ALL(a)); sort(ALL(b));
    if(a!=b) cout<<0<<endl;
    else{
        int ans=1;
        REP(i,N/2) ans=ans*2%mod;
        cout<<ans<<endl;
    }
}


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

#define ll long long

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

  ll n, d, cnt = 0;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      cnt += 1;
  }
  cout << cnt << endl;
  
  return 0;
}


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

int gcd(int a, int b){

int p,q,r;
if(a<b){p=b;b=a;a=p;

}
   while((r=b%a)!=0){
   q=b/a;
   b=a;
   a=r;
   }
   return a;
}

int main(void)
{
    int a, b;
   while(cin >> a >> b) {
     int lcm = a/gcd(a,b)*b;
     cout << gcd(a,b) << " " << lcm << endl;
   }
   return 0;
}


Measured memory_bytes: 3068
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	m := make([]int, N)
	max := 0
	for i := 0; i < N; i++ {
		if a[i] > max {
			m[i] = a[i]
			max = a[i]
		} else {
			m[i] = max
		}
	}
	if K == 1 {
		fmt.Println(m[N-1] - a[0])
		return
	}
	r := math.MaxInt64
	for bit := (1 << uint(K)) - 1; bit < (1 << uint(N)); bit = next_combination(bit) {
		q := make([]int, 0)
		for i := 0; i < N; i++ {
			if (bit & (1 << uint(i))) > 0 {
				q = append(q, i)
			}
		}
		if q[0] > 0 {
			continue
		}
		r = Min(r, calc(a, m, q))
	}
	fmt.Println(r)
}

func calc(a, m, q []int) int {
	sum := 0
	max := 0
	x := make([]bool, len(a))
	for i := 0; i < len(q); i++ {
		x[q[i]] = true
	}
	for i := 0; i < len(a); i++ {
		if x[i] {
			if max < a[i] {
				max = a[i]
			} else {
				max++
				sum += max - a[i]
			}

		} else {
			max = Max(max, a[i])
		}
	}
	return sum
}

func next_combination(sub int) int {
	x := sub & -sub
	y := sub + x
	return (((sub & ^y) / x) >> 1) | y
}

func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}
func Max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


Measured memory_bytes: 1280