akhauriyash/Code-Regression huggingface dataset:
/*
  AUTHOR:SOURABH
  CREATED:14:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,h,w,q,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>h>>w;
        if(h==1 || w==1)
            cout<<1;
        else
        {
            q=w/2;
            ans=q*h;
            if(w%2)
            {
            ans+=h/2;
            if(h%2)
                ans+=1;
            }
            cout<<ans;
        }
    }
    return 0;
}




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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];
ll C[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    REP(i, N)
    {
        cin >> C[i];
    }
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    ll sum = 0;
    REP(i, N)
    {
        ll a = 0;
        {
            int ok = -1, ng = N;
            while (abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (A[mid] < B[i])
                    ok = mid;
                else
                    ng = mid;
            }
            a = ok + 1;
        }
        ll c = 0;
        {
            int ok = N, ng = -1;
            while (abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (B[i] < C[mid])
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            c = N - ok;
        }
        sum += a * c;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N - a*1000) / 100;
  c = (N - a*1000 - b*100) / 10;
  d = N - a*1000 - b*100 - c*10;
  if (N < 1000 || N > 9999){
    cout << "No" << endl;
  }
  else if (a == b && a == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && b == d) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<18;
int mtree[2*SZ], Mtree[2*SZ];
bool chk[200000];

int get_min(int s, int e)
{
	int ret=0x7fffffff;
	for(s+=SZ,e+=SZ;s<=e;s>>=1,e>>=1) {
		if(s&1) ret=min(ret,mtree[s++]);
		if(~e&1) ret=min(ret,mtree[e--]);
	}
	return ret;
}

int get_max(int s, int e)
{
	int ret=-1;
	for(s+=SZ,e+=SZ;s<=e;s>>=1,e>>=1) {
		if(s&1) ret=max(ret,Mtree[s++]);
		if(~e&1) ret=max(ret,Mtree[e--]);
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, ans=1, cnt;
	bool ori=false;
	cin>>N>>K;
	for(int i=0;i<N;i++) {
		cin>>mtree[SZ+i];
		Mtree[SZ+i]=mtree[SZ+i];
		if(i && mtree[SZ+i-1]<mtree[SZ+i]) cnt++;
		else cnt=1;
		if(cnt>=K) ori=chk[i]=true;
	}
	for(int i=SZ-1;i;i--) {
		mtree[i]=min(mtree[2*i],mtree[2*i+1]);
		Mtree[i]=max(Mtree[2*i],Mtree[2*i+1]);
	}
	ans=!chk[K-1];
	for(int i=K;i<N;i++) {
		if(get_min(i-K,i)!=mtree[SZ+i-K] || get_max(i-K,i)!=Mtree[SZ+i]) {
			if(!chk[i]) ans++;
		}
	}
	cout<<ans+ori<<'\n';
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<double> v(N);
  REP(i,N) cin >> v[i];
  sort ALL(v);
  double A=v[0];
  for(int i=1;i<N;i++) {
    A+=v[i];
    A/=2;
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int rightx = -1000;
    int lefty = 1000;
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        rightx = max(x, rightx);
    }
    for(int i=0; i<M; i++){
        int y;
        cin >> y;
        lefty= min(y, lefty);
    }
    if(rightx >= lefty){
        cout << "War" << endl;
        return 0;
    }
    else{
        if(min(Y,lefty)-max(X,rightx)>=1){
            cout << "No War" << endl;
        }
        else{
            cout << "War" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>vi;
vector<ll> :: iterator vt;
ll arr[200009];
int main()
{
    ll n,t,x,mul=1,y,z,j,i,k,flag =0,maxi=LONG_LONG_MIN ,mini=LONG_LONG_MAX,sum=0,c=0;
    map<char,ll>mp;
    map<char,ll> :: iterator mt;
    string s, ss;
    cin>>n;
    for(i = 0 ;i<n ;i++)
    {
        cin>>s;
        if(s[0]=='M'||s[0]=='A'|| s[0]=='R' ||s[0]=='C'|| s[0]=='H'){
            mp[ s[0] ]++;
            sum++;
        }

    }
    if(mp.size()<3)
        cout<<0<<endl;
   else{
    mul = mp['M']*mp['A'] *mp['R'] + mp['M']*mp['A']*mp['C'] + mp['M']*mp['A']*mp['H'] + mp['M']*mp['R'] *mp['C'] + mp['M']*mp['R'] *mp['H'] + mp['M']*mp['C'] *mp['H'] + mp['A']*mp['R'] *mp['C'] + mp['A']*mp['R'] *mp['H'] + mp['R']*mp['C'] *mp['H'] + mp['A']*mp['C']*mp['H'];
    cout<<mul<<endl;
   }
   return 0;
}


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

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

    bool d = false;

    for(int i=0;i<=X;i++){
        for(int j=0;j<=X;j++){
            if(2*i+4*j == Y && i + j == X){
                d = true;
            }
        }
    }

    if(d == true){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

   return 0;
}

Measured memory_bytes: 3592
## どうせ8種類だから全列挙する

lst = [int(c) for c in input()]


if lst[0]+lst[1]+lst[2]+lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'+'+str(lst[2])+'+'+str(lst[3])
elif lst[0]+lst[1]+lst[2]-lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'+'+str(lst[2])+'-'+str(lst[3])
elif lst[0]+lst[1]-lst[2]+lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'-'+str(lst[2])+'+'+str(lst[3])
elif lst[0]+lst[1]-lst[2]-lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'-'+str(lst[2])+'-'+str(lst[3])
elif lst[0]-lst[1]+lst[2]+lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'+'+str(lst[2])+'+'+str(lst[3])
elif lst[0]-lst[1]+lst[2]-lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'+'+str(lst[2])+'-'+str(lst[3])
elif lst[0]-lst[1]-lst[2]+lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'-'+str(lst[2])+'+'+str(lst[3])
elif lst[0]-lst[1]-lst[2]-lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'-'+str(lst[2])+'-'+str(lst[3])
  
ans = ans + '=7'
print(ans)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int damerau_levenshtein_distance(const string &a,const string &b,const int alphabet_size){
    unordered_map<int,int> da;
    map<int,unordered_map<int,int>> d;
    int maxdist=a.size()+b.size();
    d[-1][-1]=maxdist;
    for(int i=0; i<=a.size(); ++i){
        d[i][-1]=maxdist;
        d[i][0]=i;
    }
    for(int i=0; i<=b.size(); ++i){
        d[-1][i]=maxdist;
        d[0][i]=i;
    }
    for(int i=1; i<=a.size(); ++i){
        int db=0;
        for(int j=1; j<=b.size(); ++j){
            int k=da[b[j-1]],l=db,cost;
            if(a[i-1]==b[j-1]){
                cost=0;
                db=j;
            }else cost=1;
            d[i][j]=min({d[i-1][j-1]+cost,d[i][j-1]+1,d[i-1][j]+1,d[k-1][l-1]+(i-k-1)+1+(j-l-1)});
        }
        da[a[i-1]]=i;
    }
    return d[a.size()][b.size()];
}

void solve(int n){
    int d;
    vector<string> name(n);
    cin >> d;
    rep(i,0,n) cin >> name[i];
    sort(name.begin(),name.end());

    int count=0;
    rep(i,0,n){
        rep(j,i+1,n){
            if(damerau_levenshtein_distance(name[i],name[j],26)>d) continue;
            ++count;
            cout << name[i] << "," << name[j] << endl;
        }
    }
    cout << count << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int n;
        cin >> n;
        if(!n) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int k, a, b;
    cin >> k >> a >> b;



    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  set<char> st;
  for(int i = 0; i < n; i++){
    char ch; cin >> ch;
    st.insert(ch);
  }
  string ans;
  if(st.size() == 3) ans = "Three";
  else ans = "Four";
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

ll INF = 10000000;
ll mod = 1000000007;//10^9+7



//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int W[N];
    int sum[110] = {0};
    REP(i, N) {
        cin >> W[i];
        sum[i + 1] = sum[i] + W[i];
    }
    int ans = INF;
    REP_1(i, N) {
        int S = abs((sum[N] - sum[i]) - sum[i]);
        chmin(ans, S);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;

typedef pair<long long, string> pls;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e,H, W,Q;
long long A[200000]= {};
long long B[2][200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S[200];
set <long long>sll;
pl buf;
pls bufls;
vector <long long>vl[100005];
vector <pl>vpl[100005];
vector <pls>vpls;
vector <string> vs;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];



int main() {

	cin >> N>>M;

	for (int i = 0; i < M; i++) {
		cin >>B[0][i]>>B[1][i];
		buf.first = B[1][i];
		buf.second = i;
		vpl[B[0][i]].push_back(buf);
		
	}

	for (int i = 0; i <= N; i++) {
		if (vpl[i].size() > 0) {
			sort(vpl[i].begin(), vpl[i].end());
			for (int j = 0; j < vpl[i].size(); j++) {
				B[1][vpl[i][j].second] = j + 1;
			}
		}
	}
	
	for (int i = 0; i < M; i++) {
		S[0] = to_string(B[0][i]);
		reverse(S[0].begin(), S[0].end());
		while (S[0].size() < 6) {
			S[0] += '0';
		}
		reverse(S[0].begin(), S[0].end());
		cout << S[0];

		S[0] = to_string(B[1][i]);
		reverse(S[0].begin(), S[0].end());
		while (S[0].size() < 6) {
			S[0] += '0';
		}
		reverse(S[0].begin(), S[0].end());
		cout << S[0] << endl;

	}
	
	

	return 0;

}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
  string s;
  cin >> s;

  const int n = s.size();

  rep(i,26){
    bool add = true;
    char ch = char('a' + i);
    for(auto &it:s){
      if(it == ch) add =false;
    }

    if(add){
      cout << s << string(1,ch) << endl;
      return 0;
    }
  }

  vector<int> ary;
  rep(i,n) ary.push_back(s[i]-'a');

  bool ok = next_permutation(begin(ary),end(ary));
  if(ok){
    rep(i,n){
      const char cur = char(ary[i] + 'a');
      cout << cur;
      if(s[i] != cur) break;
    }
    cout << endl;
  }else{
    cout <<  -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main() {
	int H, W;
	scanf("%d %d", &H, &W)+1;

	int M[20][20];
	int Mt[20][20];

	char tmp;
	for (int y = 0; y < H; y++) {
		scanf("%c", &tmp) + 1;
		for (int x = 0; x < W; x++) {
			scanf("%c", &tmp) + 1;
			M[y][x] = (tmp == '#') ? -2 : -1;
		}
	}

	int ans = 0;

	for (int sx = 0; sx < W; sx++) {
		for (int sy = 0; sy < H; sy++) {
			if (M[sy][sx] == -2) continue;
			memcpy(Mt, M, sizeof M);

			Mt[sy][sx] = 0;

			bool henka;
			int cnt = 0;
			while (1) {
				henka = 0;
				for (int x = 0; x < W; x++) {
					for (int y = 0; y < H; y++) {
						if (Mt[y][x] == cnt) {
							if (x != 0 && Mt[y][x - 1] == -1) {
								Mt[y][x - 1] = cnt + 1;
								henka = 1;
							}
							if (y != 0 && Mt[y - 1][x] == -1) {
								Mt[y - 1][x] = cnt + 1;
								henka = 1;
							}
							if (x != W - 1 && Mt[y][x + 1] == -1) {
								Mt[y][x + 1] = cnt + 1;
								henka = 1;
							}
							if (y != H - 1 && Mt[y + 1][x] == -1) {
								Mt[y + 1][x] = cnt + 1;
								henka = 1;
							}
						}
					}
				}
				if (!henka) break;
				cnt++;
			}

			if (cnt > ans) ans = cnt;
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
struct EdgeNode{
	int next,to;
}edge[MAXN<<1];
int head[MAXN],cnt=1,N;
void add(int u,int v){
	cnt++; edge[cnt].next=head[u]; head[u] = cnt; edge[cnt].to = v;
}
void insert(int u,int v){
	add(u,v); add(v,u); 
}
const int MOD = 1e9 + 7;
#define LL long long
int sz[MAXN];
LL fac[MAXN],ans[MAXN],sum;

LL qpow(LL x, LL y){
	LL re = 1;
	for (; y; y>>=1,x=x*x%MOD)
		if (y&1) re = re*x%MOD;
	return re;
}
void dfs(int u,int last){
	sz[u] = 1;
	fac[u] = 1;
	for (int i=head[u]; i; i=edge[i].next){
		int v = edge[i].to;
		if (v == last) continue;
		dfs(v,u);
		sz[u] += sz[v];
		fac[u] = fac[u]*fac[v]%MOD;
	}
	fac[u] = fac[u]*sz[u]%MOD;
}

void dfs2(int u,int last,LL p){
	LL t = p;
	for (int i=head[u]; i; i=edge[i].next){
		int v = edge[i].to;
		if (v == last) continue;
		t = t*fac[v]%MOD;
	}
	ans[u] = sum*qpow(t,MOD-2)%MOD*qpow(N,MOD-2)%MOD;
	for (int i=head[u]; i; i=edge[i].next){
		int v = edge[i].to;
		if (v == last) continue;
		p = p*fac[v]%MOD;
	}
	for (int i=head[u]; i; i=edge[i].next){
		int v = edge[i].to;
		if (v == last) continue;
		dfs2(v,u,p*qpow(fac[v],MOD-2)%MOD*(N-sz[v])%MOD);
	}
}

int main(){
	scanf("%d",&N);
	for (int i=1; i<N; i++){
		int u,v; scanf("%d%d",&u,&v);
		insert(u,v);
	}	
	sum = 1LL;
	for (int i=1; i<=N; i++) sum = sum*i%MOD;
	dfs(1,0);
	dfs2(1,0,1);
//	for (int i=1; i<=N; i++) printf("%d ",fac[i]); puts("");
	for (int i=1; i<=N; i++) printf("%I64d\n",ans[i]);
	return 0;
}

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

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}
//約数の総数を返す
int count_divisor(int n){int c[n/2] = {1}; int n_half = n/2; for(int i=2;i<n_half;i++){if(n%i==0){n /= i;c[i]+=1;i--;if(n>1) continue;else break;}  }int r = 1;for(int i=2;i<n_half;i++){r *= c[i];}return r;}
//各桁の数の和を返す
int dig_num(int n){return (n<10) ? n: dig_num(n/10) + n%10;}

int main(){
  int N; cin >> N;
  int D; cin >> D;
  int x[N][D]; REP(i,N){REP(j,D){cin >> x[i][j];}}
  
  int r = 0;
  REP(i,N){
    REP(j,i){
      int dd = 0;
      REP(k,D){
        int diff = x[i][k]-x[j][k];
        dd += diff*diff;
      }
      int d_sq = sqrt(dd);
      if(d_sq*d_sq==dd){r++;}
    }
  }
  
  cout << r << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll long long int
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000010000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 500005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 2*acos(0)
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pair<string,string> , null_type, less<pair<string,string> >, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
	cin >> a >> b;
	cout << a*b;
        
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
string s;
int a[4];
int op[4];
void out() {
    for (int i = 0; i < 3; ++i) {
        cout << a[i];
        cout << (op[i] == 0 ? '+' : '-');
    }
    cout << a[3] << "=7" << endl;
    return;
}
void f(int k, int nm) {
    if (k == 3) {
        if (nm == 7) {
            out();
            exit(0);
        }
        return;
    }
    op[k] = 0;
    f(k + 1, nm + a[k + 1]);
    op[k] = 1;
    f(k + 1, nm - a[k + 1]);
    return;
}
int main(){
    cin >> s;
    a[0] = s[0] - '0';
    a[1] = s[1] - '0';
    a[2] = s[2] - '0';
    a[3] = s[3] - '0';
    f(0, a[0]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long double mypow(long double base, int current)
{
	long double res = 1.0;
	while (current){
		if (current & 1) 
			res *= base;
		current >>= 1;
		base *= base;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	long double sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (i < k) {
			int current = ceil(log2((long double)k / i));
			sum += mypow(0.5, current);
		}
		else
			sum += 1.0;
	}
	cout << fixed << setprecision(12) << sum / n << '\n';
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::map<int64_t, int64_t> member;
	for(int64_t i = 0; i < N; i++)
	{
		member[i] = 0;
	}

	for(int64_t i = 1; i < N; i++)
	{
		int64_t tmp;
		std::cin >> tmp;
		member[tmp - 1]++;
	}

	for (int64_t i = 0; i < N; i++)
	{
		std::cout << member[i] << std::endl;
	}
	
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 16112
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int mn,mx,i,a[4],tot;
vector<int>nr[2];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    for(i=1;i<=3;i++)cin>>a[i],nr[a[i]%2].pb(a[i]);
    sort(a+1,a+4);
    if(nr[0].size()==3 || nr[1].size()==3)cout<<(a[3]-a[1])/2+(a[3]-a[2])/2<<endl;
    else if(nr[0].size()==2)
	{
		mn=min(nr[0][0],nr[0][1]),mx=max(nr[0][0],nr[0][1]);
		tot=(mx-mn)/2;
		if(mx<=nr[1][0])cout<<tot+nr[1][0]-mx<<endl;
		else cout<<tot+(mx-1-nr[1][0])/2+2<<endl;
	}
	else if(nr[1].size()==2)
	{
		mn=min(nr[1][0],nr[1][1]),mx=max(nr[1][0],nr[1][1]);
		tot=(mx-mn)/2;
		if(mx<=nr[0][0])cout<<tot+nr[0][0]-mx<<endl;
		else cout<<tot+(mx-1-nr[0][0])/2+2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(n>m){
        long long t = m;
        m = n;
        n = t;
    }
    if(n==1){
        if(m==1) printf("1\n");
        else printf("%lld\n",m-2);
    }
    else{
        long long valid = (n-2)*(m-2);
        printf("%lld\n",valid);
    }
    return 0;
}


Measured memory_bytes: 1692
#include <cmath>
#include <cstdlib>
#include <cstdio>

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  std::string str;

  std::cin >> str;

  for(int i = str.size()-1; i >= 0; --i) {
    std::cout << str[i];
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<map>
#include<queue>
#include<algorithm>

// dijkstra
template<typename Edge>
struct dijkstra {
  using Graph = std::vector<std::vector<Edge>>;
  using T = typename Edge::cost_type;
  using GP = std::pair<T, int>;
  using Q = std::priority_queue<GP, std::vector<GP>, std::greater<GP>>;

  Graph& G;
  int N;
  std::vector<T> d;
  std::vector<int> pre;
  T INF;
  dijkstra(Graph& Graph, T inf): G(Graph), N(Graph.size()), INF(inf) {}

  void search(int s) {
    Q q;
    d.assign(N, INF);
    pre.assign(N, -1);
    d[s] = 0;
    q.push(GP(0, s));
    while(!q.empty()) {
      GP p = q.top(); q.pop();
      int v = p.second;
      if(d[v] < p.first) continue;
      for(auto e: G[v]) {
        T newd = d[v]+e.cost;
        if(newd >= d[e.to]) continue;
        if(newd >= INF) continue;
        d[e.to] = newd;
        pre[e.to] = v;
        q.push(GP(d[e.to], e.to));
      }
    }
  }
};

struct edge {
  typedef int cost_type;
  cost_type cost;
  int to;
  edge(cost_type c, int t): cost(c), to(t) {}
};

int main() {
  int N, M; std::cin >> N >> M;
  dijkstra<edge>::Graph G(N);
  for(int i = 0; i < M; ++i) {
    int a, b; std::cin >> a >> b; --a; --b;
    G[a].emplace_back(1, b);
    G[b].emplace_back(1, a);
  }
  dijkstra<edge> dij(G, N*2);
  dij.search(0);
  std::cout << "Yes\n";
  for(int i = 1; i < N; ++i) std::cout << (dij.pre[i]+1) << "\n";
  return 0;
}


Measured memory_bytes: 13660
# import math
# from fractions import gcd

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrP = np.array(input().split(),dtype=np.int64)

minnum = arrP[0]

def func152C(arr,minnum):
    ans = 0
    for i in arr:
        if i <= minnum:
            minnum = i
            ans += 1
        else:
            continue
    return  ans

ans = func152C(arrP,minnum)
print(ans)

Measured memory_bytes: 33024
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for i in range(m):
        l,r,d=map(int,readline().split())
        G[l].append((r,d))
        G[r].append((l,-d))

    flags=[False]*(n+1)
    flags[0]=True
    inf=10**10
    x=[-inf]*(n+1)
    q=deque([])
    ans=True
    for i in range(1,n+1):
        if ans==False: break
        if flags[i]==False:
            x[i]=0
            flags[i]=True
            q.append(i)
            while len(q)>0:
                now=q.popleft()
                for t in G[now]:
                    nex=t[0]
                    cost=t[1]
                    if x[nex]==-inf:
                        x[nex]=x[now]+cost
                    else:
                        if x[nex]!=x[now]+cost:
                            ans=False
                            break
                    if flags[nex]==False:
                        flags[nex]=True
                        q.append(nex)

    print("Yes" if ans else "No")

if __name__ == "__main__":
    main()

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

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

    ll N,W;
    cin >> N >> W;
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    vector<ll> weight(N+1), value(N+1);

    weight[0] = 0;
    value[0] = 0;
    for(int i = 1; i <= N; i++){
        cin >> weight[i] >> value[i];
    }

    for(int i = 0; i <= N; i++) dp[0][i] = 0;

    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            if(j - weight[i] >= 0) dp[i][j] = max(dp[i-1][j-weight[i]] + value[i], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
int n,h[100004];
bool check(ll x){
	ll res=0;
	for (int i=0;i<n;i++)
		res+=max(0ll,(h[i]-b*x+a-1)/a);
	if (res<=x) return true;
	return false;
}
int main(){
	cin>>n>>a>>b;
	ll l=-1,r=1e9+1;
	for (int i=0;i<n;i++) cin>>h[i]; 
	a-=b;
	while (r>l+1){
		ll mid=(l+r)/2;
		if (check(mid)) r=mid;
		else l=mid;
	}
	cout<<r;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

const ll INF=1ll << 60;
ll N,M;
ll d[101][101];
ll nexts[101][101]; // next[i][j]: iからjへの最短経路におけるiの直後の頂点
set<PLL> edges;

void traversePath(ll start, ll goal){
    // printf("traversePath %d -> %d: ",start+1,goal+1);
    for (ll cur=start; cur != goal; cur = nexts[cur][goal]){
        // printf("%d ", cur+1);
        auto it = edges.find(make_pair(cur, nexts[cur][goal]));
        if (it != edges.end())
            edges.erase(it);

        it = edges.find(make_pair(nexts[cur][goal], cur));
        if (it != edges.end())
            edges.erase(it);
    }
    // printf("%d\n", goal+1);
}

signed main() {
    cin>>N>>M;
    rep(i,0,101) rep(j,0,101){ d[i][j] = INF; nexts[i][j]=j; }
    rep(i,0,10)
        d[i][i]=0;
    rep(i,0,M){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        edges.insert(make_pair(a,b));
    }

    rep(k,0,N)
        rep(i,0,N)
            rep(j,0,N)
                if(d[i][k] + d[k][j] < d[i][j]){
                    d[i][j] = d[i][k] + d[k][j];
                    nexts[i][j] = nexts[i][k];
                }
    // rep(i,0,N)
    //     rep(j,0,N) {
    //         if (i!=j){
    //             printf("%d -> %d: %d\n", i+1, j+1, d[i][j]);
    //         }
    //     }

    rep(i,0,N) rep(j,0,N){
        if (i!=j)
            traversePath(i, j);
    }
    // printf("M=%d edges.size()=%d\n", M, edges.size());
    cout<<edges.size()<<endl;
    return 0;
}


Measured memory_bytes: 512
let () = Scanf.scanf "%d %d %d %d %d\n" @@ fun x y a b c ->
  let ps = Array.init a @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  let qs = Array.init b @@ fun _ -> Scanf.scanf "%d " @@ fun q -> q in
  let rs = Array.init c @@ fun _ -> Scanf.scanf "%d " @@ fun r -> r in
  Array.sort (fun p p' -> compare p' p) ps;
  Array.sort (fun q q' -> compare q' q) qs;
  Array.sort (fun r r' -> compare r' r) rs;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.sub
    ( Array.of_list @@
      List.merge (fun m n -> compare n m) (Array.to_list (Array.sub ps 0 x)) @@
      List.merge (fun m n -> compare n m) (Array.to_list (Array.sub qs 0 y)) @@
      Array.to_list rs ) 0 (x + y)

Measured memory_bytes: 32288
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define float double 
#define dg(x) cout<<#x<<" :"<<x;
#define dg_array(ar) for(auto x : ar) cout<<x<<" ";cout<<endl;
#define dg_2darray(ar) for(auto x : ar) {for(auto y : x) cout<< y<<" ";cout<<endl;}
#define endl '\n'
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i =0 ; i< n-1 ; i++)
    {
        int x;
        cin >> x;
        mp[x]++;
    }
    for(int i =1 ; i<= n ;i++)
    {
        cout<< mp[i]<<endl;
    }
}

void testcase()
{
    int t;
    cin>>t;
    while(t--)
        solve();
}
int32_t main(){
	fast;
//    testcase();           
   solve();              
}

Measured memory_bytes: 16116
#include<stdio.h>

int main()
{
    int N,i,count=0;
    scanf("%d", &N);
    int num[N];
    for(i=0; i<N; i++)
    {
         scanf("%d", &num[i]);
         if(num[i] != i+1)
            count++;
    }

    if(count>2)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;

}


Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// int mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,c,h,i,j,k,temp,temp2,n,m;
    string a,b,tem="";
    cin >> a;
    for(i=0;i<a.size();i++) tem+="x";
    cout << tem;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define forn(i,n) for(int i=0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fst first
#define snd second

int main() {
    ios::sync_with_stdio(false);
    vi x(3);
    forn(i, 3) cin >> x[i];
    int best = 1e6;
    vi p{0, 1, 2};
    do {
        int a = abs(x[p[1]] - x[p[0]]);
        int b = abs(x[p[2]] - x[p[1]]);
        best = min(best, a + b);
    } while (next_permutation(all(p)));
    cout << best << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1000000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n,m;
    cin>>n>>m;
    vector <int> a(n+1);
    vector <int> adj[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    vector <bool> vis(n+1,true);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        if(a[u]<=a[v])
            vis[u]=false;
        if(a[u]>=a[v])
            vis[v]=false;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=vis[i];
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 9800
from collections import deque

s = deque(str(input()))
q = int(input())

t = 0
for i in range(q):
    o = list(map(str, input().split()))
    if o[0] == "1":
        t += 1
    else:
        if o[1] == "1" and t%2 == 0 or o[1] == "2" and t%2 == 1:
            s.appendleft(o[2])
        else:
            s.append(o[2])

if t%2 == 1:
    s.reverse()

print("".join(s))

Measured memory_bytes: 75608
N, M = map(int,input().split())
ab = [list(map(int,input().split())) for n in range(N)]
ab.sort()
ans = 0
for n in range(N):
    if M > ab[n][1]:
        ans += ab[n][0] * ab[n][1]
        M -= ab[n][1]
    else:
        ans += ab[n][0] * M
        print(ans)
        exit()

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;

int main()
{
	cin>>n;
	for(LL i=1;i<=n;i++) for(LL j=1;j<=n;j++) for(LL k=1;k<=n;k++) ans+=(LL)__gcd(__gcd(i,j),k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int n,K;
int ar[100005];
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n>>K;
  int g=0,mx=0;
  REP(i,n){
    int a;scanf("%d",&a);
    g=__gcd(g,a);
    chmax(mx,a);
  }
  puts((K%g==0 && K<=mx)?"POSSIBLE":"IMPOSSIBLE");
  return 0;
}






Measured memory_bytes: 256
n = int(input())
taro = 0
hanako = 0

for i in range(n):
	animals = input().split()
	taro_animal = animals[0]
	hanako_animal = animals[1]
	if taro_animal > hanako_animal:
		taro += 3
	elif taro_animal < hanako_animal:
		hanako +=3
	else:
		taro += 1
		hanako += 1

print(taro, hanako)

Measured memory_bytes: 7576
#include<iostream>
struct D{int a,b,c;};
main(){
  int a,b,c,N,i,w,x,y,z,m[303];
  D t[1001];
  for(;std::cin>>a>>b>>c>>N,a;){
    for(i=0;i++<301;)m[i]=2;
    for(i=0;N-->0;){
      std::cin>>w>>x>>y>>z;
      D d={w,x,y};
      if(z)m[w]=m[x]=m[y]=1;
      else t[i++]=d;
    }
    for(;i-->0;){
      if((m[t[i].a]&1)+(m[t[i].b]&1)+(m[t[i].c]&1)==2){
	m[t[i].a]&=1;
	m[t[i].b]&=1;
	m[t[i].c]&=1;
      }
    }
    for(i=0;i++<a+b+c;)printf("%d\n",m[i]);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll A, B, H, M;
    cin >> A >> B >> H >> M;
    long double s = H * 30 + M * 0.5;
    long double l = M * 6;
    long double angle = abs(l - s);
    angle = min(angle, 360 - angle);
    long double ans = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(angle * acos(-1) / 180.0));

    printf("%.15Lf", ans);

    return 0;
}


Measured memory_bytes: 4148
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    ll N;
    cin >> N;

    ll A[N];
    ll C[N]={};
    ll FullD=0;

    ll tmp;
    rep(ni,N){
        cin >> tmp;
        tmp--;
        A[ni]=tmp;
        C[tmp]=C[tmp]+1;
    }
    rep(ni,N){
        FullD+=C[ni]*(C[ni]-1) / 2;
    }
    rep(ni,N){
        cout << FullD - (C[A[ni]]-1) << endl;
    }
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main()
{
    int num;
    cin >> num;
    int temp1 = num % 10;
    int temp2 = (num / 10) % 10;
    int temp3 = (num / 100);
    if(temp1 == 7 || temp2 == 7 || temp3 == 7){
        cout << "Yes" <<endl;
    } else {
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

impl<'a> Scanner<'a> {
    fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    fn next<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.iter.next().unwrap().parse().unwrap()
    }
}

fn read() -> String {
    use ::std::io::Read;
    let mut res = String::new();
    ::std::io::stdin().read_to_string(&mut res).unwrap();
    res
}

fn main() {
    let _input = read();
    let mut sc = Scanner::new(&_input);

    let a: [i64; 3] = [sc.next(), sc.next(), sc.next()];

    let ans = a.iter().max().unwrap() - a.iter().min().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

#define SIZE_OF_A 2000001
#define SIZE_OF_C 10001

int A[SIZE_OF_A],B[SIZE_OF_A];

int main(void){ 
   
  int i,k=0,j,n,C[SIZE_OF_C];
 
  scanf("%d",&n);
  for(j = 1 ; j <= n ; j++){
    scanf("%d",&A[j]);
  }
  for(j = 1 ; j <= n ; j++){
    if(A[j] > k){   
      k = A[j];
    }
  }
   
  for(i = 0 ; i <= k ; i++)  C[i] = 0;
  
  for(j = 1 ; j <= n ; j++) C[A[j]] = C[A[j]] + 1;
   
  for(i = 0 ; i <= k ; i++) C[i] = C[i] + C[i-1];
   
  for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]] - 1;
  }

  for(j = 1 ; j <= n ; j++){
    if(j!=1) printf(" ");
    printf("%d",B[j]);
  }
  printf("\n");
   
  return 0;
}

Measured memory_bytes: 16268
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0;i<s.length();i++)
    {
        ans+=s[i]-'0';
    }
    if(ans%9==0)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if(a>b) swap(a,b);
  if((b-a)%2==0){
    cout<<(b-a)/2<<endl;
    return 0;
  }
  else{
    ll ans=(b-a-1)/2;
    cout<<ans+min(a,n-b+1)<<endl;
  }
}


Measured memory_bytes: 256
n = int(input())
s = list(input(''))
a = ['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']
b = 0
for i in range(len(s)):
    for j in range(len(a)):
        if s[i] == a[j]:
            if j+n > len(a)-1:
                s[i] = a[j+n-len(a)]
                break
            else:
                s[i] = a[j+n]
                #print(s)
                break
print(''.join(s))

Measured memory_bytes: 3188
N, X, M = map(int, input().split())

"""
id[X] Xを何番目に訪問したか。-1で無ければ訪問済み。
Xをメモ  A[i+1] = (A[i] * A[i]) % M
length = ループが終わるまでの長さ
"""

id = [-1] * M
A = []  # 訪問したものをメモ
length = 0
total = 0
while id[X] == -1:
    A.append(X)
    id[X] = length
    length += 1
    total += X
    X = (X * X) % M
syuki = length - id[X]
syukisum = sum(A[id[X] : length])
# for i in range(id[X], length):
#     syukisum += A[i]

ans = 0
if N <= length:
    ans = sum(A[:N])
else:
    ans += total
    N -= length
    loop, res = divmod(N, syuki)
    ans += syukisum * loop
    ans += sum(A[id[X] : id[X] + res])
print(ans)


Measured memory_bytes: 13732
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
        hs: [u32; n],
        abs: [(Usize1, Usize1); m],
    }

    let mut graph = vec![vec![]; n];
    for (a, b) in abs {
        graph[a].push(b);
        graph[b].push(a);
    }

    let ans = graph
        .into_iter()
        .enumerate()
        .filter(|(i, neighbors)| neighbors.iter().all(|j| hs[*i] > hs[*j]))
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 12012
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 105

using namespace std;

int main()
{
    ll n,m;

    scanf("%lld %lld",&n,&m);

    printf("%lld\n",(n-1)*(m-1));

    return (0);
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=510;
#define fi first
#define se second
#define mp make_pair

int n;
pair<int,int> x[maxn];
int a[maxn*maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i].fi);
		x[i].se=i;
	}
	
	sort(x+1,x+n+1);
	int s=0;
	for(int i=1;i<=n;i++)
	{
		s+=x[i].se;
		if (s>x[i].fi)
		{
			printf("No\n");
			return 0;
		}
	}
	
	s=0;
	for(int i=n;i>=1;i--)
	{
		s+=n-x[i].se+1;
		if (s>n*n-x[i].fi+1)
		{
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	for(int i=1;i<=n;i++)
	{
		int pos=1;
		a[x[i].fi]=x[i].se;
		for(int j=1;j<x[i].se;j++)
		{
			while(a[pos]!=0) pos++;
			a[pos]=x[i].se;
	    }
	}
	
	for(int i=1;i<=n;i++)
	{
		int pos=x[i].fi;
		for(int j=x[i].se+1;j<=n;j++)
		{
			while(a[pos]!=0) pos++;
			a[pos]=x[i].se;
		}
	}
	
	for(int i=1;i<=n*n;i++)
		printf("%d ",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,v; cin >> a >> v;
    cout << ((a<=8&&v<=8) ? "Yay!" : ":(") << endl;;
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s=1,a[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>n;
	for(;i<n;i++)
	{
		cin>>a[i];
		if(!a[i])
		{
			cout<<0;
			return 0;
		}
	}
	for(i=0;i<n;i++)
	{
		if(1000000000000000000/a[i]<s)
		{
			cout<<-1;
			return 0;
		}
		s*=a[i];
	}
	cout<<s;
}

Measured memory_bytes: 4440
#include <cstdio>
int occur[26];
char s[101];
int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    occur[s[i] - 'a']++;
  }

  for (int i = 0; i < 26; ++i) {
    if (occur[i] & 1) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

Measured memory_bytes: 128