akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#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__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e7 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	vector<ll> a(n);
	for(auto &x : a) cin >> x;
	sort(all(a));
	
	if(a[0] == 0) return puts("0"), 0;

	ll mx = (ll)1e18;

	ll res = 1;
	for(auto &x : a){
		if(res > (mx / x)) return puts("-1"), 0;
		res *= x;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3992
#include <iostream>
using namespace std;
int homay(int num){
int a=0;
for(;;){
if(num%2)break;
else{
a++;
num/=2;
}
}
return a;
}

int main(){
int n,a=0,hoge;
cin>>n;
for(int i=0;i<n;i++){
cin>>hoge;
a+=homay(hoge);
}
cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	ll a, b, c = 1000;
	a = 1000 / x[0];
	b = 1000 % x[0];
	rep(i, n - 1) {
		c = max(c, x[i + 1] * a + b);
		a = c / x[i + 1];
		b = c % x[i + 1];
	}
	cout << c << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 100005

int n,q,u,v,a,b;
vector<vector<int> > G(ARRAY_MAX);
int cnt[ARRAY_MAX];
bool checked[ARRAY_MAX];//消したノードかどうか,true;消したノード
bool used[ARRAY_MAX];//調べたかどうか

void dfs(int now){
    //今いる場所

    if(cnt[now] == 0){
        return;
    }

    if(cnt[now] == 1){
        checked[now] = true;//削った
        cnt[now] = cnt[now]-1 >= 0 ? cnt[now]-1 : 0;
        REP(i,G[now].size()){
            //nowとつながっているノードの次数を1つ下げる
            cnt[G[now][i]] = cnt[G[now][i]]-1 >= 0 ? cnt[G[now][i]]-1 : 0;
        }
    }

    REP(i,G[now].size()){

        if(cnt[G[now][i]] >= 2){
            //次数が2以上のものについては見ない
            continue;
        }
        dfs(G[now][i]);
    }
    return;
}



int main(){

    cin >> n;
    REP(i,n){
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
        cnt[u]++;
        cnt[v]++;
    }
    //グラフ構築終了
    REP(i,n){
        dfs(i);
    }

    cin >> q;

    REP(i,q){
        cin >> a >> b;
        a--;
        b--;
        if(checked[a] == false && checked[b] == false){
            //両方閉路の中
            cout << "2" << endl;
        }else{
            cout << "1" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 11856
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,out=0;
    cin>>n>>a>>b;
    for(int i=1;i<n+1;i++){
        if(i/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+i%10>=a&&i/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+i%10<=b){
            out+=i;
        }
    }
        cout<<out<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int sign(int A){
    return (A>0)-(A<0);
}

int main()
{
  int N;
  int x[100000];
  int y[100000];
  int t[100000];
  int genzai_x = 0;
  int genzai_y = 0;
  int genzai_t = 0;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i=0;i<N;i++){
    int x_kyori = x[i] - genzai_x;
    int y_kyori = y[i] - genzai_y;
    
    int yosoku_t = genzai_t + sign(x_kyori)*x_kyori + sign(y_kyori)*y_kyori;
    if(t[i] < yosoku_t || (t[i]-yosoku_t)%2 != 0){
      cout << "No" << endl;
      return 0;
    }

    genzai_x = x[i];
    genzai_y = y[i];
    genzai_t = t[i];
    
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200000)
#define MOD (1000000007)


typedef struct 
{
    ll a;
    ll b;
    ll c;
}job;

int acs_js(const void *a, const void *b){return (((job*)a)->b) - (((job*)b)->b);} /* 1,2,3,4.. */


job js[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%ld %ld",&(js[i].a),&(js[i].b));
        js[i].c = js[i].b-js[i].a;
    }

    qsort(js,n,sizeof(job),acs_js);

    ll t=0;
    for(int i=0;i<n;i++)
    {
        t+=js[i].a;
        if(t>js[i].b)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 9596
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < (N); ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MAXN=3e5;
LL A[MAXN]={0},minusx[MAXN]={0},pre[MAXN]={0},ans[MAXN]={0};

int main(){
    DRII(n,m);
    REP(i,n){RI(A[i]);--A[i];}
    LL BF=0;
    REP(i,n-1){
        
        
        LL s=A[i],t=A[i+1];
        if(t<s)t+=m;
        BF+=t-s;
        minusx[s+1]+=1,minusx[t+1]+=-1;
        pre[s+1]+=+s+1,pre[t+1]+=-1-s;
    }
    REPP(i,1,2*m)pre[i]+=pre[i-1],minusx[i]+=minusx[i-1];
    
    REP(i,m)ans[i]=BF+pre[i]-i*minusx[i]+pre[i+m]-(i+m)*minusx[i+m];
    printf("%lld\n",*min_element(ans, ans+m));
}

Measured memory_bytes: 7168
N = int(input())
S = list(input())
t = ['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']
ans = []
l = len(t)
for s in S:
    i = t.index(s)
    i += N
    if l <= i:
        ans.append(t[i-l])
    else:
        ans.append(t[i])
print(''.join(ans))
    

Measured memory_bytes: 3188
// ABC117_C
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll koma, num_pos;
    cin >> koma >> num_pos;
    vector<ll> positions(num_pos);
    REP(i, num_pos) cin >> positions[i];
    
    // calculation
    if (koma == 1) {
        cout << *MAX(positions) - *MIN(positions) << "\n";
    } else if (num_pos == 1) {
        cout << 0 << "\n";
    } else if (koma >= num_pos){
        cout << 0 << "\n";
    } else {
        sort(positions.begin(), positions.end());  // down ->
        vector<ll> diff(num_pos-1);
        for (ll i = 1; i < num_pos; ++i) {
            diff[i-1] = positions[i] - positions[i-1];
        }
        
//        // 両端から駒を抜いていく (koma-1)個分
//        ll id_front = 0, id_back = num_pos-2;
//        REP(i, koma-1) {
//            if (diff[id_front] >= diff[id_back]) {
//                id_front++;
//            } else {
//                id_back--;
//            }
//        }
//
//        // last
        ll sum = 0;
//        for (ll j = id_front; j <= id_back; ++j) {
//            sum += diff[j];
//        }

        sort(diff.begin(), diff.end());
        for (int j = 0; j < num_pos-1-koma+1; ++j) {
            sum += diff[j];
        }
        cout << sum << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    long h,n,sum=0,i,a=0;
    cin>>h>>n;
    
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum = sum + a;
    }
    
    if(sum>=h)
        cout<<"Yes";
    else
        cout<<"No";
    

    return 0;
}


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

#define ll long long
 
int main() {
    double a, b, n;
    cin >> a >> b >> n;
    double x = min(n, b - 1);
    ll ans = floor((a * x) / b) - a * floor(x / b);
    cout << ans << endl;
}

Measured memory_bytes: 3696
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll dpl[2][2019] = {};
	string s;
	cin >> s;
	tmp = s.size();
	REP(i, tmp){
		int h = s[i] - '0';
		REP(j, 2019){
			dpl[1][(j * 10 + h) % 2019] = dpl[0][j]; 
		}
		dpl[1][h]++;
		ans += dpl[1][0];
		REP(j, 2019) dpl[0][j] = dpl[1][j];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <string.h>
int main(void)
{
	int a,n,len1,len2;
	char s[100];
	char t[100];
	scanf("%d",&n);
	if(!(1<=n&&n<=100)){return -1;}
	scanf("%s",s);
	scanf("%s",t);
	if(n==strlen(s)&&n==strlen(t)){
		for(a=0;a<n;a++){
			printf("%c%c",s[a],t[a]);
		}
	}
	else {return -1;}
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int c[15];
int a[15][15];

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

    int n, m, x;
    cin >> n >> m >> x;

    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int poss = 0, ans = INF;
    for (int mask = 0; mask < (1<<n); mask++) {
        int cost = 0;
        vector<int> b(m);
        for (int book = 0; book < n; book++) {
            if (mask & (1<<book)) {
                cost += c[book];
                for (int i = 0; i < m; i++) {
                    b[i] += a[book][i];
                }
            }
        }
        bool can = 1;
        for (int i = 0; i < m; i++) {
            if (b[i] < x) {
                can = 0;
            }
        }
        poss |= can;
        if (can) {
            ans = min(ans, cost);
        }
    }

    cout << (poss ? ans : -1);
}

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

int main() {
  string S;
  cin >> S;
  
  // ここにプログラムを追記
  if(S.at(0)=='a'){
      cout << "vowel" << endl;
    }
  else if(S.at(0)=='i'){
      cout << "vowel" << endl;
    }
  else if(S.at(0)=='u'){
      cout << "vowel" << endl;
    }
  else if(S.at(0)=='e'){
      cout << "vowel" << endl;
    }
  else if(S.at(0)=='o'){
      cout << "vowel" << endl;
    }
  else{
      cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  int A, B; cin >> A >> B;
  cout << ((1 <= A and A <= 9) and (1 <= B and B <= 9) ? A * B : -1) << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
string s,t;
ll dp[3005][3005];
ll recurse(int i,int j)
{
    if(i<=0 or j<=0)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s[i-1]==t[j-1])
    {
        dp[i][j]=recurse(i-1,j-1)+1;
    }
    else
    {
        dp[i][j]=max(recurse(i-1,j),recurse(i,j-1));
    }
    return dp[i][j];
}
int main()
{ quick;

    cin>>s>>t;
   
    memset(dp,-1,sizeof(dp));
    int i=s.size();
    int j=t.size();
   recurse(i,j);
   
    string ans="";
   while(i>0 and j>0)
    {
        
        if(s[i-1]==t[j-1])
        {
            ans=ans+s[i-1];
            i--;
            j--;

        }
        else
        { if(dp[i-1][j]>=dp[i][j-1])
            {
                i--;
            }
            else
                j--;

        }
    }
    reverse(all(ans));
    cout<<ans<<endl;

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 74656
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
	long long H;
	cin >> H;

    long long n = log2(static_cast<double>(H));

    long long ans = pow(2.0, n + 1) - 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())
array = [int(x) for x in input().split()]

tmp_res = 0
tmp_ici = 0
tmp_array = []
for i in array:
    tmp_array.append(abs(tmp_ici-i))
    tmp_ici = i
tmp_array.append(abs(tmp_ici-0))
tmp_sum = sum(tmp_array)

array = [0] + array + [0]
for i in range(n):
    c = array[i]
    cc = array[i+2]
    a = sum(tmp_array[i:i+2])
    print(tmp_sum-a+abs(c-cc))

Measured memory_bytes: 60652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<string> vec(N);

    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }

    int a,b,c,d;
    a = 0;
    b = 0;
    c = 0;
    d = 0;

    for(int i = 0; i < N; i++){
        if(vec.at(i) == "AC"){
            a++;
        }
    }

    for(int i = 0; i < N; i++){
        if(vec.at(i) == "WA"){
            b++;
        }
    }

    for(int i = 0; i < N; i++){
        if(vec.at(i) == "TLE"){
            c++;
        }
    }

    for(int i = 0; i < N; i++){
        if(vec.at(i) == "RE"){
            d++;
        }
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;

}

Measured memory_bytes: 6432
#!/usr/bin/env python3
# DSL_5_B: The Maximum Number of Overlaps

from itertools import accumulate
import sys


if __name__ == '__main__':
    n = int(input())

    ys = [0] * 1001
    rects = [None] * 2 * n
    i = 0
    for line in sys.stdin:
        x1, y1, x2, y2 = [int(j) for j in line.split()]
        rects[i] = (x2, -1, y1, y2)
        rects[i+n] = (x1, 1, y1, y2)
        i += 1

    rects.sort(key=lambda x: x[0])

    max_overlap = 0
    for x, t, y1, y2 in rects:
        if t > 0:
            ys[y1] += 1
            ys[y2] -= 1
        else:
            overlap = max(accumulate(ys))
            if overlap > max_overlap:
                max_overlap = overlap
            ys[y1] -= 1
            ys[y2] += 1

    print(max_overlap)



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    long long D;
    cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        long long X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) {
            ++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
def is_ok(t):
    for c, rc in zip(t, t[::-1]):
        if c != rc:
            return False
    return True


def main():
    s = input()
    N = len(s)
    cond = is_ok(s) and is_ok(s[:(N - 1) // 2]) and is_ok(s[-1 + (N + 3) // 2:])
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
// Hint: Don't look, No need, Let'em Play.

#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n;
    cin >> n;
    const int N = 1e4 + 3;
    int ans[N] = {};
    for (int x = 1; x <= 200; ++x) {
        for (int y = 1; y <= 200; ++y) {
            for (int z = 1; z <= 200; ++z) {
                int calc = x * x + y * y + z * z;
                calc += x * y + y * z + z * x;
                if (calc < N) {
                    ++ans[calc];
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << '\n';
    }
}

signed main() {
    fast;
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    while (t--) {
        solve();
    }

    return 0;
}

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

template < unsigned mod >
class Modint
{
public:
	using uint = unsigned;
	using u64 = uint64_t;
	using i64 = int64_t;

	Modint (const i64 dat = 0) : dat(dat >= 0 ? dat % mod : (mod - (-dat) % mod) % mod) {}

	constexpr Modint operator + (const Modint &v) const { return ( Modint(dat + v.dat) ); }
	constexpr Modint operator - () const { return ( Modint(-((i64)dat)) ); }
	constexpr Modint operator - (const Modint &v) const { return ( (*this) + -v ); }
	constexpr Modint operator * (const Modint &v) const { return ( Modint((u64)dat * v.dat) ); }
	
	constexpr Modint operator ~ () const
	{
		i64 a = dat, b = mod, x1 = 1, x2 = 0, t;
		
		while ( b > 0 ) {
			t = a / b;
			swap(a -= t * b, b);
			swap(x1 -= t * x2, x2);
		}

		return ( Modint(x1) );
	}
	
	constexpr Modint operator / (const Modint &v) const { return ( (*this) * (~v) ); } Modint &operator = (const i64 &v) { return ( (*this) = Modint < mod > (v) ); }
	Modint &operator += (const Modint &v) { return ( (*this) = (*this) + v ); }
	Modint &operator -= (const Modint &v) { return ( (*this) = (*this) - v ); }
	Modint &operator *= (const Modint &v) { return ( (*this) = (*this) * v ); }
	Modint &operator /= (const Modint &v) { return ( (*this) = (*this) / v ); }

	constexpr Modint operator ^ (u64 n) const
	{
		Modint < mod > ret(1), mul(dat);
		while ( n > 0 ) {
			if ( n & 1 ) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ( ret );
	}
	
	bool operator == (const Modint &v) { return ( dat == v.dat ); }
	bool operator != (const Modint &v) { return ( dat != v.dat ); }

	friend ostream& operator << (ostream &os, const Modint &p )
	{
		return ( os << p.dat );
	}
	
	friend istream& operator >> (istream &is, Modint &p )
	{
		i64 data;
		is >> data;
		p = Modint < mod >(data);
		return ( is );
	}

private:
	uint dat;
};

template < typename T > T fact(int n)
{ 
	T data = 1;

	for ( int i = 1; i <= n; i++ ) data *= T(i);

	return ( data );
}

int main()
{
	constexpr int mod = 1000000007;
	int X, Y;

	cin >> X >> Y;

	if ( (X + Y) % 3 != 0 || (X + Y) / 3 > X || (X + Y) / 3 > Y ) {
		cout << 0 << endl;
	} else {
		int n = (X + Y) / 3;
		int k = (X - n);

		Modint < mod > factn = fact < Modint < mod > >(n);
		Modint < mod > factk = fact < Modint < mod > >(k);
		Modint < mod > factkn = fact < Modint < mod > > (n - k);

		Modint < mod > comb = factn / (factk * factkn);
		cout << comb << endl;
	}

	return ( 0 );
}


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

using namespace std;

int main(){
    set<string> vs;
    string S; cin >> S;
    int K; cin >> K;
    int N = S.length();
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
            vs.insert(S.substr(i,j));
        }
    }
    auto itr = vs.begin();
    for(int i=0;i<K-1;i++) ++itr;
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))

even = []

for a in A:
    if a % 2 == 0:
        even.append(a)

ans = []
for e in even:
    if e % 5 == 0:
        ans.append(e)
    elif e % 3 == 0:
        ans.append(e)

if even == ans:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int sums[] = { 0,0 };
	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	int flip = 0;
	for (int i = 0; i < N; i++)
	{
		sums[flip] += A[i];

		flip = 1 - flip;
	}

	cout << abs(sums[0] - sums[1]) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
nums_kazu = len(nums)
nums_sum = 0
average = 0
ans = 0
for i in nums:
    nums_sum += i
average = round(nums_sum/nums_kazu)

for i in nums:
     ans += abs(i - average)**2

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (s[i]!=s[i-1]) {
            ans++;
        }
    }
    COUT(ans);
}


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

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Long();
			}

			var nums = new Dictionary<long, int>();
			for (int i = 0; i < n; i++) {
				if (nums.ContainsKey(a[i])) {
					nums[a[i]]++;
				} else {
					nums[a[i]] = 1;
				}
			}

			var av = nums
				.Where(x => x.Value > 0)
				.ToList();
			if (av.Count == 1) {
				if (av[0].Key == 0) {
					Console.WriteLine("Yes");
				} else {
					Console.WriteLine("No");
				}
			} else if (av.Count == 2) {
				if (av[0].Value == av[1].Value * 2) {
					if (av[1].Key == 0 && ((av[0].Key ^ av[0].Key) == 0)) {
						Console.WriteLine("Yes");
					} else {
						Console.WriteLine("No");
					}
				} else if (av[0].Value * 2 == av[1].Value) {
					if (av[0].Key == 0 && ((av[1].Key ^ av[1].Key) == 0)) {
						Console.WriteLine("Yes");
					} else {
						Console.WriteLine("No");
					}
				} else {
					Console.WriteLine("No");
				}
			} else if (av.Count == 3) {
				if (av[0].Value == av[1].Value
					&& av[1].Value == av[2].Value
					&& ((av[0].Key ^ av[1].Key ^ av[2].Key) == 0)) {
					Console.WriteLine("Yes");
				} else {
					Console.WriteLine("No");
				}
			} else {
				Console.WriteLine("No");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 30048
# include <iostream>
# include <algorithm>
# define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;
int *tree,n;
void add(int x)
{
	while(x <= n)
	{
		tree[x]++;
		x += lowbit(x);
	}
}
ll sum(int x)
{
	ll result = 0;
	while(x > 0) 
	{
		result += tree[x];
		x -= lowbit(x);
	}
	return result;
}
int main(void)
{
	int *a,*b;
	ll ans = 0;
	scanf("%d",&n); a = new int [n];
	for(int i = 0;i < n;i++) scanf("%d",&a[i]); 
	tree = new int [n+1]; b = new int [n];
	for(int i = 0;i < n;i++) tree[i] = 0,b[i] = a[i];
	sort(b,b+n);
	for(int i = 0;i < n;i++) a[i] = lower_bound(b,b+n,a[i])-b+1;
	for(int i = n-1;i >= 0;i--)
	{
		ans += sum(a[i]);
		add(a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5628
from collections import deque
N = int(input())
ans = [True]*(N+1)
already = [False] * (N+1)

td = {i:[] for i in range(1,N+1)}
for i in range(N-1):
	ut,vt,wt = map(int,input().split(' '))
	td[ut].append((vt,wt%2))
	td[vt].append((ut,wt%2))

q = deque([1])
while(q):
	i = q.popleft()
	already[i] = True
	for v,w in td[i]:
		if not already[v]:
			q.append(v)
			#print(i,v,w)
			if w:
				ans[v] = not ans[i]
			else:
				ans[v] = ans[i]

#print(td)

for i in range(1,N+1):
	print(int(ans[i]))









Measured memory_bytes: 45288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    vi a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]+1==a[i+1]){
            ans+=c[a[i]-1];
        }
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD


@mt
def slv(K, S):
    M = 10**9+7
    C = Combination(2*(10**6), M)
    MOD = Mod(M)
    ans = 0
    S = len(S)
    N = S + K

    for k in range(K+1):
        r = K -k
        a = MOD.pow(26, r)
        b = MOD.mul(MOD.pow(25, k), C(k+S-1, k))
        ans = MOD.add(ans, MOD.mul(a, b))
    return ans




def main():
    K = read_int()
    S = read_str()
    print(slv(K, S))


if __name__ == '__main__':
    main()


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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    cout<<ceil(n/2.0)<<endl;
}



Measured memory_bytes: 256
def main():
  a,b,c,k = [int(x) for x in input().split()]
  out = 0
  
  for (num, count) in zip([1, 0, -1], [a, b, c]):
    if k <= 0:
      break
    pick = min(k, count)
    k -= pick
    out += (num*pick)
  print(out)
main()

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

int main(){
  long long int N,ans;
  cin >>N;
  vector<string> s(N);
  for(long long int i=0;i<N;i++){
    string temp;
    cin >>temp;
    sort(temp.begin(),temp.end());
    s.at(i)=temp;
  }
  sort(s.begin(),s.end());
  ans=0;
  long long int count=0;
  for(long long int i=0;i<N-1;i++){
    if(s.at(i)==s.at(i+1))count++;
    else{
      ans+=(count+1)*count/2;
      count=0;
    }
    if(i==N-2){
      ans+=(count+1)*count/2;
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define size_t unsigned long long int 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 0x3f3f3f3f
#define FASTIO ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(0)
#define PI acos(-1)
using namespace std;
void solve()
{
   int n;
   cin>>n;
   if(n>=30)cout<<"Yes";
   else cout<<"No";
}
int main()
{
    FASTIO;
    size_t  t = 1;
    while(t--)
    {
        solve();
    }
   return 0;
}




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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

  LL ans = 0;
  REP (i, n - 1) {
    int over = v[i] + v[i + 1] - x;
    if (over <= 0) continue;

    ans += over;
    if (v[i + 1] < over) {
      v[i] -= over - v[i + 1];
      v[i + 1] = 0;
    } else {
      v[i + 1] -= over;
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  if(s[0]=='M') cout<<6<<endl;
  else if(s[0]=='T'&&s[1]=='U')cout<<5<<endl;
  else if(s[0]=='W')cout<<4<<endl;
  else if(s[0]=='T'&& s[1]=='H')cout<<3<<endl;
  else if(s[0]=='F')cout<<2<<endl;
  else if(s[0]=='S'&&s[1]=='A')cout<<1<<endl;
  else if(s[0]=='S'&&s[1]=='U')cout<<7<<endl;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}


int main() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (k > a.back()) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	ll now = a[0];
	rep1(i, n - 1) {
		now = gcd(now, a[i]);
	}
	if (k%now == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=110;
int cnt=0;
void trace(int a[], int n)
{
    for(int i=0; i<n-1; ++i)
        printf("%d ", a[i]);
    printf("%d\n", a[n-1]);
}

void insertionSort(int a[], int n)
{
    int v, j;
    for(int i=1; i<n; ++i)
    {
        v=a[i];
        j=i-1;
        while(j>=0 && a[j]>v)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        trace(a, n);
    }
}

void bubbleSort(int a[], int n)
{
    int flag, i;
    flag=1;
    while(flag)
    {
        flag=0;
        for(int j=n-1; j>=i+1; --j)
        {
            int tmp;
            if(a[j] < a[j-1])
            {
                tmp=a[j];
                a[j]=a[j-1];
                a[j-1]=tmp;
                ++cnt;
                flag=1;
            }
        }
        ++i;
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    int a[maxn];
    for(int i=0; i<n; ++i)
        scanf("%d", &a[i]);
    bubbleSort(a, n);
    for(int i=0; i<n-1; ++i)
        printf("%d ", a[i]);
    printf("%d\n", a[n-1]);
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 3200
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gint(){
		return Integer.parseInt(s.next());
	};
	public static void main(String[] $){
		long n=s.nextLong();
		long m=s.nextLong();

		if(n==1){
			System.out.println(m);
			return;
		}

		long r=1;

		for(long i=2;i*i<=m;++i){
			int c=0;
			while(m%i==0){
				++c;
				m/=i;
			}
			for(int j=0;j<c/n;++j)
				r*=i;
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int y = N;
    int g = 0;
    int j = pow(10, 8);
    rep(i, 9){
        g += y / j;
        int r = y / j;
        y -= r * j;
        j /= 10;

    }
    if(N % g == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char mp[9][9];
  int n=3;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>mp[i][j];
    }
  }

  cout<<mp[0][0]<<mp[1][1]<<mp[2][2]<<endl;
  return(0);
}


Measured memory_bytes: 256
x,y,a,b,c=gets.split.map(&:to_i)
pp=gets.split.map(&:to_i).sort
qq=gets.split.map(&:to_i).sort
rr=gets.split.map(&:to_i).sort
z=0
pi,qi,ri=a-1,b-1,c-1
pv,qv,rv=pp[-1],qq[-1],rr[-1]
cnt=0
while x+y-z>0
  if x>0&&pv==[pv,qv,rv].max
    pi-=1
    x-=1
    cnt+=pv
    pv = pi>=0&&x>0 ? pp[pi] : 0
  elsif y>0&&qv==[pv,qv,rv].max
    qi-=1
    y-=1
    cnt+=qv
    qv = qi>=0&&y>0 ? qq[qi] : 0
  else
    ri-=1
    z+=1
    cnt+=rv
    rv = ri>=0 ? rr[ri] : 0
  end
end
puts cnt


Measured memory_bytes: 27404
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8");
// 

const chars = input.split("");

const aIdx = chars.findIndex(char => char === 'A');
const zReverseIdx = chars.reverse().findIndex(char => char ==='Z');
const zIdx = chars.length - zReverseIdx;

const length = zIdx - aIdx
console.log(length);

Measured memory_bytes: 34220
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		long[] a = nal(n);
		int mcnt = 0;
		long minAbs = Long.MAX_VALUE;
		long result = 0L;
		for(long av:a) {
			mcnt += av < 0 ? 1 : 0;
			result += Math.abs(av);
			minAbs = Math.min(minAbs, Math.abs(av));			
		}
		result -= mcnt%2 == 0 ? 0 : minAbs * 2;
		System.out.println(result);			
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

int main()
{
int a, b, c;
cin >>a >> b>> c;
if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)) 
	{
    	cout << "YES" << endl;
    }
else cout << "NO" << endl;
}


Measured memory_bytes: 3508
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

#define INF 100000000000L

int main() {
	
	long long a=0, b=0, c=0;
	long long count=0;

	cin >> a >> b >> c;

	vector<long long> s = {};

	for (int i = 1; i <= 100; i++) {
		if (a % i == 0 && b % i == 0) {
			s.push_back(i);
		}

		if (i == a || i == b) {
			break;
		}
	}
	cout << *(s.end()-c) << endl;

}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
len = a.max.to_s(2).length

ans = 0
len.times do |l|
  base = 2 ** l
  n_1 = a.count { |x| x[l] == 1 }
  ans += (n - n_1) * n_1 * base
  ans %= 1000000007
end
puts ans


Measured memory_bytes: 34820
fun main(args: Array<String>) {
  val X = readInt()
  val nMin = X / 105
  val nMax = X / 100
  for (n in nMin..nMax) {
    val xMin = n * 100
    val xMax = n * 105
    if (X in xMin..xMax) {
      println(1)
      return
    }
  }
  println(0)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }



Measured memory_bytes: 31872
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(void){
    int h,w;
    int c[15][15];

    cin >> h >> w;
    map<int, int> a;

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int tmp;
            cin >> tmp;
            if(tmp >= 0){
                if(a.count(tmp) ==0){
                    a[tmp] = 1;
                }
                else{
                    a[tmp]++;
                }
            }
        }
    }


    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(c[i][j] > c[i][k]+c[k][j]){
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }

    int sum = 0;
    for(auto i=a.begin();i!=a.end();i++){
        int key = i->first;
        int value = i->second;
        sum = sum + c[key][1] * value;
    }
    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 256