akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;

int main( void ) {
    ios::sync_with_stdio( false );
    int n, k;
    cin >> n >> k;
    if( k == 1 ) {
        cout << 0 << '\n';
    }
    else {
        cout << n - k << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll x,y;
    cin>>x>>y;

    ll wari=y/x;
    ll count=0;
    while(wari!=0){
        wari/=2;
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
int main() {
	int n, d, x, i, j,k, dp[11][111111],p[11][11],cx;
	cin >> n >> d >> x;
	for (i = 0; i < d; i++)
		for (j = 0; j < n; j++)
			cin >> p[i][j];
	for (k = 0; k < d - 1; k++) {
		for (i = 0; i <= n; i++)
			for (j = 0; j <= x; j++)
				dp[i][j] = 0;
		for (i = 0; i < n; i++) {
			for (j = 0; j <= x; j++) {
				if (j < p[k][i])
					dp[i + 1][j] = dp[i][j];
				else
					dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - p[k][i]] + p[k + 1][i]);
			}
		}
		cx = x;
		for (j = 0; j <= x; j++)
			x = max(x, dp[n][j] + cx - j);
	}
	cout << x << endl;
}


Measured memory_bytes: 4244
def main():    
    n = int(input())
    b = list(map(int,input().split()))
    a = [0]*n
    a[0] = b[0]
    for i in range(n-2):
        a[i+1] = min(b[i],b[i+1])
    a[-1] = b[-1]
    print(sum(a))
    
if __name__ == '__main__':
    main()

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
ll K;
ll A[200100], F[200100];

bool can(ll x){
    ll s = 0;

    for(int i=0;i<N;++i){
        if(A[i] * F[i] > x){
            s += (A[i] * F[i] - x + F[i] - 1) / F[i];
        }
    }

    return s <= K;
}

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

    std::cin >> N >> K;

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

    std::sort(A, A + N);

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

    std::sort(F, F + N);
    std::reverse(F, F + N);

    ll lb = 1001001001001001001, ub = -1;
    while(lb - ub > 1){
        ll m = (lb + ub) / 2;

        if(can(m)){
            lb = m;
        }else{
            ub = m;
        }
    }

    std::cout << lb << std::endl;
}


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

int main()
{
  int n, k, count = 0;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 0; i < n; i++)
    if (h[i] >= k)
      count++;
  cout << count << endl;
}

Measured memory_bytes: 640
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  Vi K(n);
  vector<vector<int>> A(n,vector<int>(m));
  REP(i,n){
    IN(K[i]);
    REP(j,K[i]){
      IN(A[i][j]);
    }
  }
  Vi data(m);
  REP(i,n) {
    REP(j,K[i]){
      data[A[i][j]-1]++;
    }
  }
  REP(i,m){
    if(data[i]==n) c++;
  }
  OUT(c);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}


int dp[200002];
ll summ[200002];
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= 200001; ++i)
		summ[i] = summ[i-1] + i;
    ll ans = 0;
    for(int i = k; i <= (n+1); ++i)
    {
		ll minsum = summ[i-1];
		ll maxsum = summ[n] - summ[n-i];
		ans = ans + (maxsum - minsum + 1); 
		ans %= mod;
	}
	cout << ans%mod;
    return 0;
}


Measured memory_bytes: 5224
#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;
  }
}

const lint INF=1e18;

int src,sink;
static const int MAX_SIZE=105;
struct edge{
  int to;
  lint cap;
  int rev;
  edge(int st,lint sc,int sr){
    to=st;cap=sc;rev=sr;
  }
};
vector<edge> g[MAX_SIZE];
int rankk[MAX_SIZE],seen[MAX_SIZE];
void add_edge(int from,int to,lint cap){
  g[from].pb(edge(to,cap,g[to].size()));
  g[to].pb(edge(from,0,g[from].size()-1));
}
void bfs(int v){
  memset(rankk,-1,sizeof(rankk));
  rankk[v]=0;
  queue<int>q;q.push(v);
  while(!q.empty()){
    int cur=q.front();q.pop();
    REP(i,g[cur].size()){
      edge& e=g[cur][i];
      if(e.cap>0 && rankk[e.to]==-1){
        rankk[e.to]=rankk[cur]+1;
        q.push(e.to);
      }
    }
  }
}
lint dfs(int v,lint f){
  if(v==sink) return f;
  for(int& i=seen[v];i<g[v].size();++i){
    edge& e=g[v][i];
    if(e.cap>0 && rankk[e.to]>rankk[v]){
      int d=dfs(e.to,min(e.cap,f));
      if(d>0){
        e.cap-=d;
        g[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
lint max_flow(int s,int t){
  src=s;sink=t;
  lint flow=0;
  while(1){
    bfs(src);
    if(rankk[sink]==-1) return flow;
    lint f;
    memset(seen,0,sizeof(seen));
    while((f=dfs(src,INF))>0){
      flow+=f;
    }
  }
}
int n;
int ar[105];

int main(){
  cin>>n;
  int S=n+1,T=n+2;
  lint ans=0;
  for(int i=1;i<=n;++i){
    cin>>ar[i];
    if(ar[i]>0) add_edge(i,T,ar[i]);
    else add_edge(S,i,-ar[i]);
    ans+=max(0,ar[i]);
  }


  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j) if(j%i==0){
      add_edge(i,j,INF);
    }
  }
  ans-=max_flow(S,T);
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
	int a,b;
	scanf("%i%i",&a,&b);
	if(a==1 && b==2) printf("3");
	if(a==1 && b==3) printf("2");
	if(a==2 && b==3) printf("1");
	if(a==3 && b==1) printf("2");
	if(a==3 && b==2) printf("1");
	if(a==2 && b==1) printf("3");
	return 0;
}


Measured memory_bytes: 128
n, k, q = list(map(int, input().split()))

b = [k]*n

for i in range(q):
    a = int(input())
    b[a-1] += 1

b = list(map(lambda x: x-q, b))

for i in range(len(b)):
    if b[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9844
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int k;
		cin >> k;
		if(cin.fail()) break;
		for(int i=0;i<k;i++) cout << "ACL";
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3640
import sys
A, B = [int(v) for v in input().split()]

sAB = ''
for i in range(B):
    sAB += str(A)

sBA = ''
for i in range(A):
    sBA += str(B)


if sAB > sBA:
    print(sBA)
else:
    print(sAB)



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

int main(){
	int N;
	int ans = 0;
	cin >> N;
	vector<int> ary(N);
	for(int i=0; i<N; ++i){

		cin >> ary[i];


	}   

	for (int i = 1; i < ary.size() - 1; i++)
	{
		if(ary[i-1] < ary[i] && ary[i] < ary[i+1] ){
			ans++;
			continue;
		}

		if(ary[i-1] > ary[i] && ary[i] > ary[i+1] ){
			ans++;
			continue;
		}

	}


	std::cout << ans << std::endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		b.at(i) = a.at(i);
	}
	sort(b.begin(), b.end());
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (a.at(i) != b.at(i)) sum++;
	}
	if (sum <= 2) cout << "YES" << endl; else cout << "NO"  << endl;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    agc032b()
}

fun agc032b() {
    val n = readLine()!!.toInt()

    val all = (1..n).map { left -> (left + 1..n).map { right -> Edge(left, right) } }.flatten()
    val remove = (1..n / 2).map { Edge(it, (n / 2 * 2) - it + 1) }
    val filtered = all.filter { it !in remove }

    val answer = "${filtered.size}" + System.lineSeparator() +
            filtered.joinToString(System.lineSeparator()) { "${it.from} ${it.to}" }

    println(answer)
}

private data class Edge(val from: Int, val to: Int)


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var Aarray = retreiveLongArray();

			//最初の枝が生えてないと無理
			if (Aarray[0] > 0　&& N>0) {
				Console.WriteLine(-1);
				return;
			}

			//Nが0の時の例外処理
			if (N == 0) {
				if (Aarray[0]==1) {
					Console.WriteLine(1);
					return;
				}
				Console.WriteLine(-1);
				return;
			}

			checked {
				var maxChoutens = new Dictionary<long, long>();//可能な限り枝を伸ばした場合
				var minChoutens = new Dictionary<long, long>();
				maxChoutens.Add(0, 1);
				for (int i = 1; i <= N; i++) {
					var kouho = (maxChoutens[i - 1] - Aarray[i - 1]) * 2;
					if (kouho <= 0) {//頂点がマイナスになる場合、不可能
						Console.WriteLine(-1);
						return;
					}

					kouho = Math.Min(kouho, long.MaxValue/2);
					maxChoutens.Add(i, kouho);

					//N番目のチェックをしていない
					if (i==N) {
						if (kouho<Aarray[i]) {
							Console.WriteLine(-1);
							return;
						}
					}

				}

				long eda = 0;
				for (var i = N; i >= 0; i--) {
					eda += Aarray[i];
	
					eda = Math.Min(eda, long.MaxValue / 2);
					minChoutens.Add(i, eda);
				}

				//答えを求める
				long choutenCount = 0;
				for (int i = 0; i <= N; i++) {
					choutenCount += Math.Min(minChoutens[i], maxChoutens[i]);
				}

				//答えの出力
				Console.WriteLine(choutenCount);
			}
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 46036
character_list = list(input())
new_character_list = []

for i in range(len(character_list)):
 if(character_list[ i ] == '0' ):
  new_character_list.append(character_list[ i ])
 elif(character_list[ i ] == '1'):
  new_character_list.append(character_list[ i ])
 else:
  if(len(new_character_list) != 0):
   new_character_list.pop()

print(''.join(new_character_list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N;
    while (cin >> N, N) {
        vector<pair<double, string>> v;
        rep(i, N) {
            string l;
            int p, a, b, c, d, e, f, s, m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            v.emplace_back(1. * (f * m * s - p) / (a + b + c + (d + e) * m), l);
        }

        rep(i, N) v[i].first *= -1;
        sort(all(v));
        rep(i, N) v[i].first *= -1;

        rep(i, N) cout << v[i].second << endl;
        cout << "#" << endl;
    }
}

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int x=in.nextInt();
		int a=in.nextInt();
		if(x<a)
			System.out.println(0);
		else
			System.out.println(10);
	}
}
	

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

// main
int main(){
    string num;
    rep(i,3){
        string rgb;
        cin >> rgb;
        num += rgb;
    }
    if(stoi(num) % 4 == 0){
        cout << "YES" << endl;
    }else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

long long n, x, ans;

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%lld%lld",&n,&x);
	ans = n;
	long long a = min(x, n-x);
	long long b = max(x, n-x);
	
	while(true){
		if(b % a == 0){
			ans += (b/a * 2 * a - a);
			break;
		}
		ans += (b/a * 2 * a);
		b %= a;
		swap(a, b);
	}

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



	return 0;
}

Measured memory_bytes: 256
#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;

vector<tuple<int,int,int,int>> qry;
int N, M, Q, ans, A[10];

void solve(int c, int v)
{
	if(c==N) {
		int sum=0;
		for(auto[a,b,c,d]: qry) if(A[b]-A[a]==c) sum+=d;
		ans=max(ans,sum);
		return;
	}
	A[c]=v;
	for(int i=v;i<=M;i++) solve(c+1,i);
}

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));
	cin>>N>>M>>Q;
	qry.resize(Q);
	for(auto &[a,b,c,d]: qry) {
		cin>>a>>b>>c>>d;
		--a; --b;
	}
	for(int i=1;i<=M;i++) solve(0,i);
	cout<<ans<<'\n';
	return 0;
}

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

void sort(int* x, int* y) {
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int main() {
    int x, y; cin >> x >> y;
    int r;

    if (x < y) sort(&x, &y);
    while (y > 0) {
        r = x % y;
        x = y; 
        y = r;
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

#define reg register
#define MAX_N 1007
#define MAX_X 5007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int fa[MAX_N], p[MAX_N], f[MAX_N][MAX_X], g[MAX_N];

inline void addE (int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

inline void chmin (int &x, int y) { x > y ? x = y : 0; }

int tmp[MAX_X];
void dfs (int x) {
    rep (j, 0, p[x]) f[x][j] = 0;
    for (int i = head[x]; i; i = nxt[i]) {
        dfs(to[i]);
        int a = p[to[i]], b = g[to[i]];
        rep (j, 0, p[x]) tmp[j] = 1e9;
        rep (j, 0, p[x]) if (f[x][j] < 1e9) {
            if (j + a <= p[x]) chmin(tmp[j + a], f[x][j] + b);
            if (j + b <= p[x]) chmin(tmp[j + b], f[x][j] + a);
        }
        rep (j, 0, p[x]) f[x][j] = tmp[j];
    }
    g[x] = 1e9;
    rep (j, 0, p[x]) chmin(g[x], f[x][j]);
}

int main () {
    read(N);
    rep (i, 2, N) read(fa[i]), addE(fa[i], i);
    rep (i, 1, N) read(p[i]);
    dfs(1);
    if (g[1] < 1e9) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 18688
#First In First Outのキュー
from collections import deque #dequeを用いる

import copy #参照渡し

#入力
h,w= map(int,input().split())

maze = [list(input()) for _ in range(h)] #訪問先を変更するために、listにする

ans=0

def bfs(sx,sy,c):
  maxlen=0
  que = deque() #キューに要素を追加するときはque.append([i,j])、取り出すときはque.popleft()
  que.append([sx,sy,0]) #初期値
  c[sy][sx] = '@'
  dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]] # ↓、→、←、↑

  #bfs キューから取り出し、移動先をキューに追加、キューから取り出し、移動先をキューに追加...を繰り返す
  while que: #ゴールに着くまでにキューの要素がなくなったらゴール不可

    x,y,tmp = que.popleft() #キューから要素を取り出す（座標を取り出す）

    for dx,dy in dxy: #(x,y)→(next_x,next_y)の1マス分の移動を考える（上下左右で4パターン存在）

      if 0 <= x+dx < w and 0 <= y+dy < h and c[y+dy][x+dx]=='.': #(移動先は行列内) かつ (空きマスの場合)
        que.append([x+dx,y+dy,tmp+1]) #キューに移動先を追加して、移動先の手数を+1する
        c[y+dy][x+dx] = '@' #訪問済みは@に置換する
        maxlen=max(maxlen,tmp+1)# maxlenを更新
  return maxlen

for Sy in range(h):
  for Sx in range(w):
    Maze=copy.deepcopy(maze)
    if Maze[Sy][Sx]=='.':
      #print(Sy,Sx,Gy,Gx,Maze)
      Tmp=bfs(Sx,Sy,Maze)
      #print(Sy,Sx,Gy,Gx,Maze)
      ans=max(ans,Tmp)
print(ans)

Measured memory_bytes: 3436
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	var a [3][3]int
	var c [3][3]int

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			a[i][j] = getInt()
		}
	}

	N := getInt()
	for k := 0; k < N; k++ {
		b := getInt()
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if a[i][j] == b {
					c[i][j] = 1
				}
			}
		}
	}

	ans := "No"
	for i := 0; i < 3; i++ {
		if c[0][i]+c[1][i]+c[2][i] == 3 {
			ans = "Yes"
		}
	}
	for i := 0; i < 3; i++ {
		if c[i][0]+c[i][1]+c[i][2] == 3 {
			ans = "Yes"
		}
	}
	if c[0][0]+c[1][1]+c[2][2] == 3 {
		ans = "Yes"
	}
	if c[0][2]+c[1][1]+c[2][0] == 3 {
		ans = "Yes"
	}
	out(ans)
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n,a[101],s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i%2!=0&&a[i]%2!=0)
		s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int x;
	cin >> x;
	vector<int> v = {2000, 1800, 1600, 1400, 1200, 1000, 800, 600, 400, 200};
	for (int i = 1; i < v.size(); i++)
	{
		if (x >= v[i])
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    rep(i, N) {
        cin >> L[i];
    }
    int cnt = 1;
    int sum = 0;
    rep(i, N) {
        sum += L[i];
        if (sum > X) {
            break;
        }
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define int long long

const int N = 1e5 + 10;
int n, x, ans, ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	
	for (int i = 1; i < n; i++) {
		int tmp = max(0LL, ar[i] + ar[i - 1] - x), rem = min(tmp, ar[i]);
		ans += tmp;
		ar[i] -= rem;
		ar[i - 1] -= tmp - rem;
		assert(ar[i - 1] >= 0 && ar[i] >= 0);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	int n,b;cin>>n>>b;
    if(b==1)return cout<<"0",0;
	if(b<=n)return cout<<"1",0;
	int x=(b-n);
	int y=0;
	if(x%(n-1)==0)y=x/(n-1);
	else y=x/(n-1)+1;
	cout<<y+1<<endl;
}

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

int main() {
    int n;
    cin >>n;
    vector<int> p(n);
    int ret = 0;
    int tmp_min = 2 * 100000 + 1; // 1≤N≤2×105よりも大きい
    for (int i = 0; i < n; i++) {
        cin >>p.at(i);
        tmp_min = min(tmp_min, p.at(i));
        if (p.at(i) <= tmp_min) ++ret;
    }
    cout << ret << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

vll dp(100005),vis(100005),adj[100005];
ll n,m,x,y;

void dfs(int cur) {
	vis[cur] = 1;
	for(auto x : adj[cur]) {
		if(!vis[x])
			dfs(x);
		dp[cur] = max(dp[cur],1+dp[x]);
	}
}

int main() {
	IOS
	cin >> n >> m;
	while(m--) {
		cin >> x >> y;
		adj[x].pb(y);
	}
	fori(i,1,n,1) {
		if(!vis[i]) {
			dfs(i);
		}
	}
	cout << *max_element(all(dp)) << endl;
}


Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x: a) {
    cin >> x;
    x--;
  }

  vector<bool> visited(n);
  visited[0] = true;
  int count = 0;
  int now = 0;
  while (true) {
    count++;
    now = a[now];
    if (now == 1) break;
    if (visited[now]) {
      cout << -1 << endl; // impossible
      return 0;
    }
    visited[now] = true;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
from functools import reduce

def binom(n, r):
    if n < r or n < 0 or r < 0: return 0
    
    if n - r < r: r = n - r
    if r == 0: return 1
    elif r == 1: return n

    numerator = [n - r + 1 + k for k in range(r)]  # (n-r+1)*(n-r+2)*...*(n-1)*n
    denominator = [1+ k for k in range(r)]         # 1*2*...*(r-1)*r

    # reduce prod(numerator)//prod(denominator)
    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    
    # calculate nCr
    return reduce(lambda x, y: x*y, numerator)


N, A, B = map(int, input().split())
*V, = map(int, input().split())
V = sorted(V, reverse=True)
ans = 0
ways = 0
if len(set(V[:A])) == 1:
    ans = V[0]
    n = V.count(ans)
    for i in range(A, min(B, n)+1): ways += binom(n, i)
else:
    ans = sum(V[:A]) / A
    min_num = min(V[:A])
    n_min = V.count(min_num)
    n_min_lst = V[:A].count(min_num)
    ways = binom(n_min, n_min_lst)
print(ans)
print(ways)

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

int main() {
	int w; scanf("%d", &w);
	string s;
	while (w) {
		s += to_string(w % 3);
		w /= 3;
	}
	string a, b;
	bool back = false;
	for (char c : s) {
		if (c == '2'&&back) {
			a += '0';
			b += '0';
		}
		else if (c == '2') {
			back = true;
			a += '1';
			b += '0';
		}
		else if (c == '1'&&back) {
			a += '1';
			b += '0';
		}
		else if (back) {
			back = false;
			a += '0';
			b += '1';
		}
		else {
			a += '0';
			b += c;
		}
	}
	if (back)b += '1';
	string ans;
	rep(i, max(a.size(), b.size())) {
		if (i < a.size() && a[i] == '1')ans += '-';
		else if (i < b.size() && b[i] == '1')ans += '+';
		else ans += '0';
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 3320
#include <stdio.h>
#include <math.h>
#define Pi 3.1415926535898

int main(void)
{
	double x=0.0,y=0.0,angle=0.0,s_num,rad;
	while(scanf("%lf,%lf",&s_num,&rad)){
		if(s_num==0) break;
		x+=s_num*sin(Pi*angle/180);
		y+=s_num*cos(Pi*angle/180);
		angle+=rad;
	}
	printf("%d\n",(int)x);
	printf("%d\n",(int)y);
	return 0;
}

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

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

    long long min_ans = 2, max_ans = 2;
    for (int i = K - 1; i >= 0; i--) {
        if (max_ans < A[i]) {
            cout << -1 << endl;
            return 0;
        }
        if (min_ans % A[i] != 0 && max_ans % A[i] != 0 && min_ans / A[i] == max_ans / A[i]) {
            cout << -1 << endl;
            return 0;
        }

        if (min_ans % A[i] == 0) {
            min_ans = min_ans / A[i] * A[i];
        } else {
            min_ans = (min_ans / A[i] + 1) * A[i];
        }
        max_ans = max_ans / A[i] * A[i];
        max_ans += A[i] - 1;
    }

    cout << min_ans << " " << max_ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

class Solver {
};

signed main() {
	int n;
	cin >> n;
	cin.ignore();
	vector<string> strs(n);
	for (int i = 0; i < n; i++) {
		getline(cin, strs[i]);
	}

	vector<vector<tuple<int, int>>> graph(n + 1, vector<tuple<int, int>>(0));
	for (int i = 0; i < n; i++) {
		if (strs[i].size() >= 4 && strs[i].substr(0, 4) == "goto") {
			int to = 0;
			string name = strs[i].substr(5, strs[i].size() - 6);
			for (int j = 0; j < n; j++) {
				if (name == strs[j].substr(0, strs[j].size() - 1)) {
					graph[i].emplace_back(j, 0);
					break;
				}
			}
			graph[i].emplace_back(i + 1, 1);
		}
		else {
			graph[i].emplace_back(i + 1, 0);
		}
	}

	priority_queue <tuple<int, int>,
		vector<tuple<int, int>>, greater<tuple<int, int>>> que;
	vector<int> costs(n + 1, 1e9);
	que.emplace(0, 0);
	while (que.size()) {
		int cost, now;
		tie(cost, now) = que.top();
		que.pop();
		if (costs[now] <= cost)continue;

		costs[now] = cost;
		for (int i = 0; i < graph[now].size(); i++) {
			int to = get<0>(graph[now][i]);
			int next_cost = cost + get<1>(graph[now][i]);

			if (costs[to] <= next_cost)continue;
			que.emplace(next_cost, to);
		}
	}

	cout << costs[n] << endl;
}


Measured memory_bytes: 3244
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define N 100005
#define mod 1000000007
using namespace std;  
typedef long long ll;
int a[N],inv[N],last[N],n;
inline int qpow(int x,int p){
    int ret = 1;
    for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) ret=1LL*ret*x%mod;
    return ret;
}
int C(int n,int m){
    if (m>n) return 0;
    return 1LL*a[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
    cin>>n;++n;
    a[0]=1;
    for (int i=1;i<=n;i++) a[i]=1LL*i*a[i-1]%mod;
    inv[n]=qpow(a[n],mod-2);
    for (int i=n-1;i>=0;i--) inv[i]=1LL*inv[i+1]*(i+1)%mod;
    int x,p1,p2;
    for (int i=1;i<=n;i++){
        cin>>x;
        if (last[x]){
            p1=last[x];
            p2=i;
        }
        last[x]=i;
    }
    int num=n-(p2-p1+1);
    for (int k=1;k<=n;k++){
        int ans=C(n,k)-C(num,k-1);
        if (ans<0) ans+=mod;
        cout<<ans<<endl;
    }
    return 0;
}

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

main() {
    while(1) {
        int n;
        cin >> n;
        if(!n) break;
        vector<string> s(n);
        rep(i, n) cin >> s[i];
        rep(i, n) {
            rep(j, s[i].size() - 1) if(s[i][j] == '.' and s[i][j + 1] != '.')
                s[i][j] = '+';
        }
        rep(i, n) {
            rep(j, s[i].size()) {
                if(s[i][j] == '+') {
                    int pos = i + 1;
                    bool flag = false;
                    int nxt;
                    rep2(k, i + 1, n - 1) {
                        if(j >= s[k].size()) break;
                        if(s[k][j] == '+') {
                            flag = true;
                            nxt = k;
                            break;
                        } else if(s[k][j] != '.')
                            break;
                    }
                    if(flag) {
                        rep2(k, i + 1, nxt - 1) s[k][j] = '|';
                    }
                }
            }
        }
        rep(i, n) rep(j, s[i].size()) if(s[i][j] == '.') s[i][j] = ' ';
        rep(i, n) cout << s[i] << "\n";
    }
}


Measured memory_bytes: 3616
a,b=map(int, input().split())
ans=0
if(a>b):
    ans+=a
    a=a-1
    if(a>b):
        ans+=a
    else:
        ans+=b
else:
    ans+=b
    b=b-1
    if(a>b):
        ans+=a
    else:
        ans+=b
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
ll gcd(ll a, ll b){
    if(!b) return a;
    return gcd(b,a%b);
}
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    ll ma=0,g;
    rep(i,0,n){
        cin>>a[i];
        ma=max(ma,a[i]);
        if(i)g=gcd(g,a[i]);
        else g=a[i];
    }
    if(ma>=k&&!(k%g))cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
int main(void);

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

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


int main(void){
	ll A,B;
    cin >> A >> B;

    ll g = gcd(A,B);
    ll ans = 0;
    double s = sqrt(g);
    ll i = 1;
    
    while(i <= g){
        if(g%i == 0){
            ans++;
            if(i>1){
                while(g%i == 0){
                    g = g/i;
                }
            } 
                                    
            //cout << i << " "<< g << endl;
        }

        if(i > sqrt(g) && i < g){
            ans++;
            break;
        }
        i++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int cek_panjang (int angka){
	int v1=1000000000;
	int a=0;
	for(int i=0; i<10; i++){
		if(angka/v1!=0){
			a=10-i;
			break;
		}
		v1/=10;
	}
	return a;
}

int fx(int angka, int banyak){
	int v1=1000000000;
	int total=0,temp;
	for(int i=0;i<10-banyak; i++){
		v1/=10;
	}
	
	for(int i=0; i<banyak; i++){
		temp=(angka/v1);
		total+=temp;
		angka=angka%v1;
		v1/=10;
	}
	
	return total;
}

int main(){
	int loop,angka;
//	scanf("%d", &loop);

	scanf("%d", &angka);
	int a=cek_panjang(angka);
	int total=fx(angka,a);
	
	printf("%s\n", angka%total==0?"Yes":"No");
	
	return 0;
}

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

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

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

int main(){
    int i,j;
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    VI cnt(p,0);
    if(p==2){
        ll ans=0;
        for(i=n-1;i>=0;i--){
            if((s[i]-'0')%2==0) ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    else if(p==5){
        ll ans=0;
        for(i=n-1;i>=0;i--){
            if((s[i]-'0')%5==0) ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    int r=0;
    int te=1;
    for(i=n-1;i>=0;i--){
        r+=(s[i]-'0')*te;
        r%=p;
        te*=10;
        te%=p;
        cnt[r]++;
    }
    cnt[0]++;
    ll ans=0;
    for(i=0;i<p;i++) ans+=cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>N >> S;
  T = S.substr(0, N/2);
  if (T+T == S) cout <<"Yes" << endl;
  else cout <<"No" << endl;
  
  
  
   




}


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

int n;
int x[1000], y[1000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d %d", &x[i], &y[i]);
    
    if (n == 2) {
        printf("%5.15lf\n", hypot(x[1] - x[0], y[1] - y[0]) / 2);
        return 0;
    }
    double ans = 0.0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                int d[3];
                d[0] = (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
                d[1] = (x[k] - x[j]) * (x[k] - x[j]) + (y[k] - y[j]) * (y[k] - y[j]);
                d[2] = (x[i] - x[k]) * (x[i] - x[k]) + (y[i] - y[k]) * (y[i] - y[k]);
                sort(d, d + 3);
                if (d[2] >= d[0] + d[1]) {
                    ans = max(ans, sqrt(d[2]) / 2);
                    continue;
                }
                double s = sqrt(1.0 - static_cast<double>(d[0] + d[1] - d[2]) *
                           (d[0] + d[1] - d[2]) / 4 / d[0] / d[1]);
                ans = max(ans, sqrt(d[2]) / s / 2);
            }
        }
    }

    printf("%5.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#define pb push_back
#define mkp make_pair
using namespace std;

const int maxn = 200005;
typedef long long ll;

int n,ma;
int cnt[maxn];

bool check()
{
    int mi = (ma+1)/2;
    for(int i=1;i<mi;i++)
        if(cnt[i])
            return 0;
    if(ma&1)
    {
        if(cnt[mi]!=2)
            return 0;
    }
    else
    {
        if(cnt[mi]!=1)
            return 0;
    }
    for(int i=mi+1;i<=ma;i++)
        if(cnt[i]<2)
            return 0;
    return 1;
}
int main()
{
    int x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        ma = max(ma,x);
        cnt[x]++;
    }
    if(check())
        puts("Possible");
    else
        puts("Impossible");
}


Measured memory_bytes: 256