akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

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

    string s; cin >> s;
    rep(i, s.size()){
        cout << 'x';
    }
    cout << next;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <bool> have(N, false);
	for (int ii = 0; ii < K; ++ii){
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j){
			int tmp;
			cin >> tmp;
			tmp--;
			have[tmp] = true;
		}
	}

	int ans = 0;
	for (int ii = 0; ii < N; ++ii){
		if (have[ii] == false)
		{
			ans++;
		}
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(1000001)

n, m = map(int, input().rstrip().split())
dist = [[500000 for i in range(n)]for j in range(n)]

for i in range(n):
    for j in range(n):
        if (i==j):
            dist[i][j]=0

a = []
b = []
c = []

for i in range(m):
    x, y, z = map(int, input().rstrip().split())
    dist[x-1][y-1] =  min(dist[x-1][y-1], z)
    dist[y-1][x-1] =  min(dist[x-1][y-1], z)
    a.append(x-1)
    b.append(y-1)
    c.append(z)
    
for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
#print(dist)
result = m

for i in range(m):
    for j in range(n):
        if dist[j][a[i]] + c[i] == dist[j][b[i]]:
            result -= 1
            break

print(result)

Measured memory_bytes: 42460
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    int maxSide = 0, total = 0;
    FOR(i, 0, N) {
        int a;
        cin >> a;
        maxSide = max(maxSide, a);
        total += a;
    }

    cout << (total - maxSide > maxSide ? "Yes" : "No") << endl;
    return 0;
};


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

struct Request {
    int a, b;
};

static int compare(const Request &lhs, const Request &rhs) {
    return lhs.a < rhs.a;
}

int solution(const int n, vector<Request> reqs) {
    //TODO: check if n and reqs are valid
    sort(reqs.begin(), reqs.end(), compare);
    int m = reqs.size();
    int foo = 0;
    int rig = n + 1;
    for (int i = 0; i < m; ++i) {
        if (reqs[i].a >= rig) {
            foo++;
            rig = reqs[i].b;
        } else {
            rig = min(reqs[i].b, rig);
        }
    }
    if (rig <= n) foo++;
    return foo;
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<Request> reqs(m, Request());
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &reqs[i].a, &reqs[i].b);
    }
    printf("%d\n", solution(n, reqs));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  int ans=0;
  cin>>x>>y;
  if(x==3){
    ans+=100000;
  }
else if(x==2){
   ans+=200000;
}
else if(x==1){
   ans+=300000;
}

  if(y==3){
   ans+=100000;
  }
else if(y==2){
   ans+=200000;
}
  else if(y==1){
   ans+=300000;
  }
 
if(x==1&&y==1){
  ans+=400000;
}
cout<<ans<<endl;
return 0;
}

    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

int n,ans;
string s,t;
signed main(){
    cin>>s;
    n=s.size();
    rep(i,n){
    	if(s[i]=='B'&&s[i+1]=='C'){
    		t+="X";
    		i++;
    	}
    	else t+=s[i];
    }
    int cnt=0,cntX=0;
    rep(i,n){
    	if(t[i]=='A'||t[i]=='X'){
    		cnt++;
    		if(t[i]=='X'){
    			cntX++;
    			ans+=cnt-cntX;
    		}
    	}
    	else {
    		cnt=0;cntX=0;
    	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 776
A, B, C, D = input()
o = ["+", "-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            s = A + o[i]  + B + o[j] + C + o[k] + D
            if eval(s) == 7:
                print(s + "=7")
                exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, m;
  cin >> n >> m;
  dump((n-1)*(m-1));
  return 0;
}


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

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

vector<ll> fact(200010,0), factinv(200010,0);

ll exp(ll b, ll e) {
    ll ans = 1;
    while (e) {
        if (e&1) ans = ans * b % MOD;
        e >>= 1;
        b = b * b % MOD;
    }
    return ans;
}

void pp(void) {
    fact[0] = 1;
    for (ll i=1;i<=200000;i++) {
        fact[i] = fact[i-1] * i % MOD;
    }
    factinv[0] = 1;
    factinv[1] = 1;
    for (ll i=2;i<=200000;i++) {
        factinv[i] = exp(fact[i],MOD-2) % MOD;
    }
}

int main(void) {
    ll N, M, K;
    cin >> N >> M >> K;

    pp();
    ll ans1 = N * (N-1) % MOD;
    ans1 = ans1 * (N+1) % MOD;
    ans1 = (ans1 * M % MOD) * M % MOD;
    ll ans2 = M * (M-1) % MOD;
    ans2 = ans2 * (M+1) % MOD;
    ans2 = (ans2 * N % MOD) * N % MOD;
    ll ans = ans1 + ans2;
    ans %= MOD;
    ans = ans * exp(6,MOD-2) % MOD;
    ans = ans * fact[N*M-2] % MOD;
    ans = ans * factinv[K-2] % MOD;
    ans = ans * factinv[N*M-K] % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N, L;
	cin >> N >> L;
	set<string> ST[100001];
	ll G = 0;
	rep(i, N) {
		string S;
		cin >> S;
		int M = S.size();
		ST[M].insert(S);
	}
	for (int i = 100000; i > 0; i--) {
		if (ST[i].size() & 1) {
			ll K = L - i + 1;
			ll GK = 1;
			while (K % 2 == 0) {
				GK <<= 1;
				K /= 2;
			}
			G ^= GK;
		}
		for (string S : ST[i]) {
			S.pop_back();
			ST[i - 1].insert(S);
		}
		ST[i].clear();
	}
	if (G) co("Alice");
	else co("Bob");

	Would you please return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>
#define N 250 //max nodes is up to 250

typedef struct{
  int key; //key
  int par; //parrent
  int left; //left side
  int right; //right side
}node;



node T[N]; //identifying each nodes 

int main(){
  int n,i;

  scanf("%d",&n); //input needed node numbers

  for(i=0; i<n; i++) T[i].par = -1; //

  for(i=0; i<n; i++){
    scanf("%d",&T[i].key); //input quantity of keys with space between
  }


  for(i=0; i<n; i++){

    if(i != 0) T[i].par = (i+1)/2-1;

    if(2*(i+1)-1 < n) T[i].left = 2*(i+1)-1;
    else T[i].left = -1;

    if(2*(i+1) < n) T[i].right = 2*(i+1);
    else T[i].right = -1;

  }

  for(i=0; i<n; i++){

    printf("node %d: key = %d, ", i+1, T[i].key);
    //moveing order 
    if(T[i].par != -1) printf("parent key = %d, ",T[T[i].par].key); //
    if(T[i].left != -1) printf("left key = %d, ",T[T[i].left].key); 
    if(T[i].right != -1) printf("right key = %d, ",T[T[i].right].key);

    printf("\n");

  }

  return 0;
}

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

int digit(int i){
	int c=0;
	while(i>0){
		c += i%10;
		i /= 10;
	}
	return c;
}

int main(void){
	int n, a, b, ans=0;
	cin >> n >> a >> b;
	for(int i=1; i<=n; i++){
		if(digit(i)>=a && digit(i)<=b) ans += i;
	}
	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, A, B; cin >> N >> A >> B;
    if(A > B) swap(A, B);
    if((B-A)%2==0) cout << (B-A)/2 << endl;
    else{
        ll res1 = 0, res2 = 0;
        res1 = (A-1) + (B-A-1)/2 + 1;
        res2 = (N - B) + (B-A-1)/2 + 1;
        cout << min(res1, res2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int n = a < b ? a : b;
    int m = a > b ? a : b;
    for (int i = 0; i < m; i++) {
      System.out.print(n);
    }
    System.out.println();
  }
}

Measured memory_bytes: 23124
#include <stdio.h>

void main(void)
{
    char c[3];
    scanf("%s",c);

    if((c[0] == '7') ||
        (c[1] == '7') ||
        (c[2] == '7') ) {
        printf("Yes");
    }else {
        printf("No");
    }
    return;
}

Measured memory_bytes: 1732
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<iostream>
using namespace std;
const int N = 666;
int main() {
	int n, m;
	while(cin >> n >> m) {
		if(n == 0 && m == 0) break;
		int ss = n * m % 2;
		if(ss) puts("no");
		else puts("yes");
	}
	return 0;
}

Measured memory_bytes: 1116
#include<stdio.h>
#include<string.h>
int main(void)
{
    int n,p;
    char s[100];
    scanf("%s",s);
    n = strlen(s) - 1;
    int i,count = 0;
    if (n % 2 == 0)
    {
        for(i = 0 ; i < (n / 2)  ; i++)
        {
            if(s[i] != s[n - i])
            {
                count++;
            }
        }
    }
    else
    {
        for(i = 0 ; i <= n / 2 ; i++)
        {
            if(s[i] != s[n - i])
            {
                count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1720
#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)
#define all(x) (x).begin(),(x).end()

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 A, B;
    cin >> A >> B;

    int cnt = 0;

    repd(i, A, B + 1) {
        if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10) cnt++;
    }

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

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

int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	if(x/d > k)
	{
		cout << x - k*d << endl;
		return 0;
	}

	ll ans1 = x - (x/d)*d;
	ll ans2 = abs(ans1 - d);
	if((k - x/d)%2 == 0)
		cout << ans1 << endl;
	else
		cout << ans2 << endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 X;
  cin >> X;
  int64 now = 100, y = 0;
  while(now < X) {
    int64 low = now / 100;
    now += low;
    ++y;
  }
  cout << y << endl;
}

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

int main()
{
    int64_t n ;
    cin >> n ;
    vector<int64_t> data(n) ;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> data.at(i) ;
    }

    int64_t a = -10000000000;         
    int64_t b = data.at(0); 

    for(int i = 1 ; i < n ; i++)
    {
        //cout << data.at(i) - b << endl ;
        a = max(a, data.at(i) - b) ;
        b = min(b, data.at(i)) ;
    }
    cout << a << endl ;
}



Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;

int main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double centerx = w / 2.0;
    double centery = h / 2.0;
    double menseki = (double)w * (double)h;
    double halfMenseki = menseki / 2.0;
    cout << halfMenseki << " ";
    if (x == centerx && y == centery) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string S; cin >> S;
    string R = "";
    int cnt = 0;
    for(int i = S.size()-1; i >= 0; i--) R += S[i];
    for(int i = 0; i < S.size(); i++){
        if(S[i] != R[i]) cnt++;
    }
    cout << cnt/2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)

int factorial(int x) {
	int num = 1;
	while (x>0) {
		num *= x;
		x--;
	}
	return num;
}

int main() {
	int n;
	cin >> n;
	vector<pair<int, int> > coords(n);
	vector<int> vec(n);
	rep(i, n) {
		cin >> coords.at(i).first;
		cin >> coords.at(i).second;
		vec.at(i) = i;
	}
	double sum = 0;
	int num = factorial(n);
	do {
		for (int i=0; i<vec.size()-1; i++) {
			int x1 = coords.at(vec[i]).first;
			int y1 = coords.at(vec[i]).second;
			int x2 = coords.at(vec[i+1]).first;
			int y2 = coords.at(vec[i+1]).second;
			double dist = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
			sum += dist;
		}
	} while (next_permutation(vec.begin(), vec.end()));
	double avg = sum / num;
	cout << fixed << setprecision(8);
	cout << avg << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
    if(a==5 && b==7 && c==5)
	printf("YES");
	else if(a==7 && b==5 && c==5)
	printf("YES");
	else if(a==5 && b==5 && c==7)
	printf("YES");
	else printf ("NO");	
} 

Measured memory_bytes: 128
/*
 * @Author: Kaizyn
 * @Date: 2020-04-12 19:55:49
 * @LastEditTime: 2020-04-12 20:51:17
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n, m;
int a[N];
map<int, long long> dp[2][N];

inline void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i/2-1; j <= i/2+1; ++j) {
            if (dp[0][i].count(j)) {
                if (dp[0][i+1].count(j)) dp[0][i+1][j] = max(dp[0][i+1][j], dp[0][i][j]);
                else dp[0][i+1][j] = dp[0][i][j];
                if (dp[1][i+1].count(j+1)) dp[1][i+1][j+1] = max(dp[1][i+1][j+1], dp[0][i][j]+a[i+1]);
                else dp[1][i+1][j+1] = dp[0][i][j]+a[i+1];
            }
            if (dp[1][i].count(j)) {
                if (dp[0][i+1].count(j)) dp[0][i+1][j] = max(dp[0][i+1][j], dp[1][i][j]);
                else dp[0][i+1][j] = dp[1][i][j];
            }
        }
    }
    /*
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n/2; ++j) {
            cout << "[" << dp[0][i][j] << " " << dp[1][i][j]  << "]" << " \n"[j==n/2];
        }
    }
    */
    cout << max(dp[0][n][n/2], dp[1][n][n/2]) << endl;
}

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

Measured memory_bytes: 79428
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,m,k; cin>>n>>m>>k;
  vector<int> a(n),b(m);
  vector<ll> asum(n+1),bsum(m+1);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
    asum.at(i+1)=asum.at(i)+a.at(i);
  }
  for(int i=0; i<m; i++){
    cin>>b.at(i);
    bsum.at(i+1)=bsum.at(i)+b.at(i);
  }
  int ans{};
  for(int i=0; i<n+1; i++){
    ll k2 = k-asum.at(i);
    if(k2<0) continue;
    auto it = upper_bound(bsum.begin(),bsum.end(),k2);
    int c = it - bsum.begin();
    ans = max(ans,i+c-1);
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 8004
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner teclado = new Scanner(System.in);
		String S = teclado.nextLine();
		int c = 0;
		int v[] = new int [4];
		for(int i = 0; i<4; i++) {
			v[i] = S.charAt(i);
		}
		if(v[0] == v[1] || v[1] == v[2] || v[2] == v[3]) {
			System.out.println("Bad");
		}else {
			System.out.println("Good");
		}
		teclado.close();
		

	

	 }
}




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

// 最大公約数を求める
long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long A, B;
    cin >> A >> B;

    // 最大公約数を求める
    long long G = GCD(A, B);

    // G を素因数分解して、「素因数の個数 + 1」が答え
    const auto &pf = prime_factorize(G);
    cout << pf.size() + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k;
string s, t;
vector<int> v, pref;

int32_t main(){_
   
   cin >> n >> k;
   ++n;

   for (int i = 0; i < n; ++i)
   {
      v.push_back(i);
      if (pref.empty()){
         pref.push_back(i);
      }
      else{
         pref.push_back(pref.back()+i);
      }
   }

   int ans = 0;
   for (int i = k-1; i < n; ++i)
   {
      //starting k and ending k
      int st = pref[i];
      int sz = (int)(pref.size());
      int end = pref.back() - ((sz-1-i-1 < 0) ? 0 : pref[sz-1-i-1]);
      ans += end - st + 1;
      ans %= mod; 
   }

   cout<<ans;

   return 0;
}

Measured memory_bytes: 6628
n = int(input())
ans = n
for i in range(n+1):
    c = 0
    t = i
    while(t > 0):
        c += t%6
        t //= 6
    t = n-i
    while(t > 0):
        c += t%9
        t //= 9
    if ans > c:
        ans = c
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

def solve(H: int, W: int, N: int, a: "List[int]"):
    cur_index = 0
    answer_grid = [[0]*W for _ in range(H)]

    for i in range(H):
        if i%2 == 0:
            for j in range(W):
                answer_grid[i][j] = cur_index+1
                a[cur_index] -= 1
                if a[cur_index] == 0:
                    cur_index += 1

        else:
            for j in range(W-1,-1,-1):
                answer_grid[i][j] = cur_index+1
                a[cur_index] -= 1
                if a[cur_index] == 0:
                    cur_index += 1
    for i in range(H):
        print(*answer_grid[i])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, W, N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
w, h, n = map(int, input().split())
xu = w
xl = 0
yu = h
yl = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        xl = max(x, xl)
    elif a == 2:
        xu = min(x, xu)
    elif a == 3:
        yl = max(y, yl)
    else:
        yu = min(y, yu)
print(max(0, (xu-xl))*max(0, (yu-yl)))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (scanner.nextInt() >= k) {
                count++;
            }
        }
        System.out.println(count);
    }
}



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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int n; cin >> n;
	vector<pair<int, int>> a(n);

#define ff first
#define ss second

	for (auto &i : a)
		cin >> i.ff >> i.ss;
	sort(range(a));
	int ab = a[0].ff - a[0].ss, bl = a[0].ff + a[0].ss;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int c_ab = a[i].ff - a[i].ss, c_bl = a[i].ff + a[i].ss;
		ans = max({ans, c_ab - ab, c_bl - bl});
		ab = min(ab, c_ab);
		bl = min(bl, c_bl);

	}
	cout << ans << endl;
}


// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/*
 * LOOK DUDE ... IT AINT DEFINETELY EASY BUT YOU AINT THAT WEAK EITHER
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 6344
import java.util.*;
import java.math.*;
// i am at my limit
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        long[] ary = new long[n];
        // number of 0s have to be greater
        for( int i = 0; i < n; i++ ) ary[i] = in.nextLong();
        long xor = 0L;
        for( int i = 50; i >= 0; i-- ) {
            int ones = 0;
            for( int j = 0; j < n; j++ ) {
                if((ary[j]&(1L<<i)) > 0 ) ones++;
            }
            if( ones < n-ones && xor+(1L<<i) <= k) xor += (long) (1L<<(long)i); // if 1 is less than 0s, and adding it to xor will keep it less than k
        }

        long ans = 0L;
        for( long i : ary ) ans += (long) (i^xor);
        System.out.println(ans);
    }
}

Measured memory_bytes: 60200
//xenowi`tz -- Jai Shree Ram
#include<bits/stdc++.h>
using namespace std;

#define fori(i,a,b) for (long long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define MAXN 400005
#define pb push_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> arr(400000,0);
	for (int i = 1; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			int dist = min(abs(i-x)+abs(j-y)+1, j-i);
			arr[dist] += 1;
		}
	}
	for (int k = 1; k < n; k++) {
		cout << arr[k] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1792
import math
D, G = map(int,input().split())
S = [list(map(int,input().split())) for k in range(D)]

ans = 10**9+7
for k in range(1<<D):
    temp_score = 0
    solved = 0
    not_used = [k for k in range(D)]
    for l in range(D):
        if k&(1<<l):
            temp_score += 100*(l+1)*S[l][0] + S[l][1]
            not_used.remove(l)
            solved += S[l][0]
    if temp_score >= G:
        ans = min(ans,solved)
    else:
        if (not_used[-1]+1)*(S[not_used[-1]][0]-1)*100 + temp_score >= G:
            solved += math.ceil((G-temp_score)/((not_used[-1]+1)*100))
            ans = min(ans,solved)

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,K;
vector<ll> A;
vector<ll> nxt;
map<ll,ll> mnidx;
map<ll,ll> idx;
map<ll,bool> aru;

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

  cin>>N>>K;
  A.resize(N);
  nxt.resize(N+1);
  rep(i,N){
    cin>>A[i];
    if(mnidx.count(A[i])==0)mnidx[A[i]]=i;
  }

  nxt[N]=0;
  for(ll i=N-1;i>=0;i--){
    if(idx.count(A[i])){
      if(idx[A[i]]+1==N){
        nxt[i]=0;
      }else{
        nxt[i]=nxt[idx[A[i]]+1];
      }
    }else{
      if(mnidx[A[i]]+1==N){
        if(i==N-1){
          nxt[i]=N;
        }else{
          nxt[i]=0;
        }
      }else{
        nxt[i]=mnidx[A[i]]+1;
      }
    }
    idx[A[i]]=i;
  }

  //rep(i,N)dbg(nxt[i]);

  vector<ll> vs;
  ll crt=nxt[0];
  //dbg(crt);
  vs.push_back(0);
  while(crt!=0){
    vs.push_back(crt);
    crt=nxt[crt];
  }

  //rep(i,vs.size())dbg(vs[i]);
  K--;
  K%=(ll)vs.size();
  deque<ll> dq;

  repl(i,vs[K],N){
    if(aru[A[i]]){
      while(dq.back()!=A[i]){
        aru[dq.back()]=false;
        dq.pop_back();
      }
      aru[dq.back()]=false;
      dq.pop_back();
    }else{
      aru[A[i]]=true;
      dq.push_back(A[i]);
    }
  }
  rep(j,dq.size())cout<<dq[j]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 45428
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define REP(i, a, b) for(i = a; i < b; i++)
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[100000];
int b[100000];
int c[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	int sumC = 0;
	rep(i, n) { c[i] = a[i] - b[i]; sumC += c[i]; }
	if (sumC < 0) { cout << "-1" << endl; return 0; }
	
	vector<int> vec;
	rep(i, n) {
		if (c[i] >= 0) {
			vec.push_back(c[i]);
		}
	}
	sort(vec.begin(), vec.end());
	
	rep(i, n) {
		if (sumC < vec[i]) break;
		sumC -= vec[i];
	}
	cout << n - i << endl;
	return 0;
}

Measured memory_bytes: 3576
from itertools import groupby, chain
N, K, Q, *A = map(int, open(0).read().split())
ans = float("inf")
for Y in set(A):
    C = sorted(chain.from_iterable(v[:len(v) - K + 1] for v in (sorted(v) for k, v in groupby(A, key=lambda a: a >= Y) if k) if len(v) >= K))
    if len(C) >= Q:
        ans = min(ans, C[Q - 1] - Y)
print(ans)

Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[100005][13];

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%13;
    a=a*a%13;
    n/=2;
  }
  return ans;
}

int main() {
  string s; cin >> s;
  int n=s.size();
  dp[0][0]=1ll;
  rep(i,n)rep(j,13){
    if(s[i]=='?'){
      rep(d,10){
        int ni=i+1,nj=j;
        nj+=d*rui(10,(n-1-i)%12); nj%=13;
        dp[ni][nj]+=dp[i][j];
        dp[ni][nj]%=mod;
      }
    }
    else{
      int ni=i+1,nj=j;
      nj+=(s[i]-'0')*rui(10,(n-1-i)%12); nj%=13;
      dp[ni][nj]+=dp[i][j];
      dp[ni][nj]%=mod;
    }
  }
  cout << dp[n][5] << endl;
}


Measured memory_bytes: 10624
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	ll i,j,k,n,c=0;cin>>n;
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) for(k=1;k<=n;k++){
		c+=__gcd(i,__gcd(j,k));
	}cout<<c<<endl;
}


Measured memory_bytes: 3612
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut vec: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    for index in 0..n {
        let i = index + 1;
        if vec[index] == i {
            ans += 1;
            if index == n - 1 {
                vec.swap(n - 1, n - 2);
                continue;
            }
            vec.swap(index, index + 1);
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2796
n,k = map(int,input().split())
r,s,p = map(int,input().split())

S = list(input())
T = [0]*n

for i in range(n):
    l = S[i]
    if(l == "r"):
        T[i] = p
    if(l == "s"):
        T[i] = r
    if(l == "p"):
        T[i] = s

sm = 0
#print(T)
for i in range(n):
    sm += T[i]
#print(sm)

for i in range(k,n):
    if(S[i-k]==S[i]):
        sm -= T[i]
        S[i] = "o"

#print(T)
print(sm)

Measured memory_bytes: 4792
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    int n,sum=0;
    cin >> n;
    std::vector<int> v(n);
    for(auto &it:v)cin>>it,sum+=it;
    sum = round((double)sum / n);
	ll a=sum;
	ll ans=0;
	//cout<<a<<endl;
	for(int x:v)
	{
		ans+=((a-x)*(a-x));
	}
    //cout<<sum<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//quicksort
#include<bits/stdc++.h>//包含了所有头文件 
using namespace std;
#define int long long
typedef pair<int,char> P;


int partition(P* A,int p,int r) {
	int x=A[r].first;
	int i=p-1;
	for(int j=p; j<r; j++) {
		if(A[j].first<=x) {
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}


void quicksort(P* A,int p,int r) {
	if(p<r) {
		int q=partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}


signed main(){
	int n;
	cin>>n;
	P A[n];
	for(int i=0; i<n; i++)
		cin>>A[i].second>>A[i].first;
	map<int,string> m1,m2;
	for(int i=0; i<n; i++)
		m1[A[i].first]+=A[i].second;
	quicksort(A,0,n-1);
	for(int i=0; i<n; i++)
		m2[A[i].first]+=A[i].second;
	bool flag=1;
	for(int i=0; i<n; i++)
		flag&=m1[A[i].first]==m2[A[i].first];//这段代码写的牛逼啊 
	if(flag)
		cout<<"Stable"<<endl;
	else
		cout<<"Not stable"<<endl;
	for(int i=0; i<n; i++) {
		cout<<A[i].second<<" "<<A[i].first<<endl;
	}
	return 0;
}


Measured memory_bytes: 10172
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  long double a,b;cin>>a>>b;
  cout<<(ll)(a*b+1.0E-14);
}


Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	rep(i,n)cin>>v[i];
	ll g=v[0];
	range(i,1,n){
		g=gcd(g,v[i]);
	}
	cout<<(k<=*max_element(all(v))&&k%g==0?"POSSIBLE":"IMPOSSIBLE")<<endl;
	
}



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

int main(){
    int n; cin >> n;
    vector<int> h(n);
 
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
 
    vector<int> dp(n, INT_MAX);
    
 
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
 
    for(int i = 2; i < n; i++){
       
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    
 
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int a[5]={};
    int k;
   // int h[5]={};
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    cin>>k;
    if(a[4]-a[0]>k) cout<<":("<<endl;
    else if(a[4]-a[0]<=k) cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <sstream>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  int count2 = 0;
  int count4 = 0;
  long long a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 4 == 0) {
      count4++;
    }else if(a[i] % 2 == 0) {
      count2++;
    }
  }
  int others = n - (count4 + count2);
  if(others <= count4 || (count2 == 0 && others <= count4+1)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
struct Node{
        int value;
        Node *left,*right,*parent;
};
Node *nil,*root;
void print(Node *now,bool sign){
        if(now==nil)return;
        if(!sign)
                cout<<" "<< now->value;
        print(now->left,sign);
        if(sign)
                cout <<" "<< now->value ;
        print(now->right,sign);
}
void insert(int x){
        Node *now;
        now=root;
        while(now!=nil){
                if(x>now->value){
                        if(now->right==nil)break;
                        now=now->right;
                }
                else{
                        if(now->left==nil)break;
                        now=now->left;
                }
        }
        Node *in;
        in=(Node *)malloc(sizeof(Node));
        if(now->value < x)
                now->right=in;
        else now->left=in;
        in->parent=now;
        in->left=in->right=nil;
        in->value=x;
        return;
}
int main(){
        nil=(Node *)malloc(sizeof(Node));
        root=(Node *)malloc(sizeof(Node));
        root->left=root->right=nil;
        root->parent=root;
        nil->parent=root;
        nil->left=nil->right=nil;
        int N,x;
        string str;
        cin >> N;
        bool signal=true;
        for(int i=0 ; i<N ; i++ ){
                cin >> str;
                if(str=="insert"){
                        cin >> x;
                        if(signal){
                                signal=false;
                                root->value=x;
                        }else
                                insert(x);
                }else{
                        print(root,1);
                        cout << endl;
                        print(root,0);
                        cout << endl;
                }
        }
        return 0;
}


Measured memory_bytes: 26496
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string words[4]={"dream","dreamer","erase","eraser"};

  string S;
  cin>>S;

  

  reverse(S.begin(),S.end());
  for(int i=0;i<4;i++)
    reverse(words[i].begin(),words[i].end());



  bool can = true;
  for(int i=0;i<S.size();){
    bool can2=false;
    for(int d=0;d<4;d++)
      {

        string v=words[d];
        if(v==S.substr(i,v.size()))
          {
            i=i+v.size();

            can2=true;

          }

      }

    if(!can2){
      can = false;
      break;
    }

    
  }


if(can) cout<<"YES";
    else cout<<"NO";


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
struct edge{
    int v,nxt;
}e[maxn<<1];
int head[maxn],tot;
int ans[maxn];
void __ADD(int u,int v)
{
    e[++tot].v=v;
    e[tot].nxt=head[u];
    head[u]=tot;
}
void add(int u,int v)
{
    __ADD(u,v);
    __ADD(v,u);
}
int f[maxn],nw=0;
void dfs(int u,int fa)
{
    int x,y;
    if(a[u]>f[nw])
    {
        x=++nw;
        y=0;
        f[nw]=a[u];
    }
    else
    {  
        x=lower_bound(f+1,f+nw+1,a[u])-f;
        y=f[x];
        f[x]=a[u];
    }
    ans[u]=nw;
    for(int i=head[u];i;i=e[i].nxt)
    {
        int v=e[i].v;
        if(v==fa)continue;
        dfs(v,u);
    }
    f[x]=y;
    if(y==0)--nw;
}
void solve(long long n){
    dfs(1,0);
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    for(int i = 1 ; i <= N ; i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0 ; i < N-1 ; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    solve(N);
    return 0;
}


Measured memory_bytes: 23504
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

  int N;
  cin >> N;
  vector<pair<int, int>> v(N);  // B, A
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    v[i] = make_pair(b, a);
  }
  sort(v.begin(), v.end());
  bool ok = true;
  int now = 0;
  for (const auto& p : v) {
    now += p.second;
    if (now > p.first) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a[5];
    rep(i,5)cin >> a[i];
    rep(i,5){
        if(a[i]==0)cout << i +1 << endl;
    }
    return 0;
}

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

int main(){
    int a, b, d;
    long long h=0;
    cin >> a >> b;
    
    d = b - a;
    for(int i =1; i < d; i++) h +=i;
   
    cout << h - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr int MOD = 1e9 + 7;

ll dp[101010][4];

int main() {
    string s; cin >> s;
    int n = (int)s.size();

    dp[0][0] = 1;
    REP(i,n) {
        // use this
        if(s[i]=='A' || s[i]=='?') (dp[i+1][1] += dp[i][0]) %= MOD;
        if(s[i]=='B' || s[i]=='?') (dp[i+1][2] += dp[i][1]) %= MOD;
        if(s[i]=='C' || s[i]=='?') (dp[i+1][3] += dp[i][2]) %= MOD;

        // not use this
        if(s[i]=='?') {
            REP(j,4) (dp[i+1][j] += dp[i][j] * 3) %= MOD;
        } else {
            REP(j,4) (dp[i+1][j] += dp[i][j]) %= MOD;
        }
    }
    
    cout << dp[n][3] << '\n';

    return 0;
}

Measured memory_bytes: 3712