akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000
#define NIL -1
struct node{
	int parent,right,left;
};
struct node T[MAX];
int n;

void preorder(int);
void inorder(int);
void postorder(int);

int main(void)
{
	int i,v,l,r,root;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].parent = NIL;
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
	
	T[v].right = r;
	T[v].left = l;
	if(l != NIL ) T[l].parent = v;
	if(r != NIL ) T[r].parent = v;
	}
	for(i=0; i<n; i++) if(T[i].parent ==NIL) root = i;
	
	printf("Preorder\n");
	preorder(root);
	printf("\n");
	printf("Inorder\n");
	inorder(root);
	printf("\n");
	printf("Postorder\n");
	postorder(root);
	printf("\n");
}

void preorder(int u){
	if(u==NIL) return;
	printf(" %d",u);
	preorder(T[u].left);
	preorder(T[u].right);
}

void inorder(int u){
	if(u==NIL) return;
	inorder(T[u].left);
	printf(" %d",u);
	inorder(T[u].right);
}

void postorder(int u){
	if(u==NIL) return;
	postorder(T[u].left);
	postorder(T[u].right);
	printf(" %d",u);
}


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

int main()
{
  long N;
  long A[100010]={0};
  long value;
  long ans=1;
  long maxim=1000000007;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>value;
    A[value]+=1;
    if(value==0)ans=(ans*(4-A[0]))%maxim;
    else ans=(ans*(A[value-1]+1-A[value]))%maxim;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 200005
using namespace std;
char str[N],mm[N];
int dp[N];
int route[N];
int a[30];
int main(void)
{
    scanf("%s",str + 1);
    int l = strlen(str+1);
    //memset(nex,-1,sizeof(nex));
    memset(route,-1,sizeof(route));
    memset(dp,0x3f,sizeof(dp));
    memset(a,-1,sizeof(a));
    int id = 0;
    for(int i = l+2;i < N;i++)
        dp[i] = 0;
    for(int i = 0; i < 26; i++)
        a[i] = l+1;
    for(int i = l; i >= 1; i--)
    {
        a[str[i]-'a'] = i;
        for(int j = 0; j < 26; j++)
        {
            if(dp[i] > dp[a[j] + 1] + 1)
            {
                mm[i] = j;
                dp[i] = dp[a[j] + 1]+1;
                route[i] = a[j] + 1;
            }
        }
    }
    int f = 1;
    while(f<=l+1)
    {
        printf("%c",mm[f] + 'a');
        f = route[f];
    }
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 55;
const int S = 101010;
int n, k;
int a[N];
int ans[S];
int ansSz;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	int lst = -1;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	k++;
	while(k > 0) {
		int nxt = -1;
		for (int i = 0; i < n; i++) {
			if (i != lst) {
				if (a[i] == 0) {
					printf("-1\n");
					return 0;
				}
				a[i]--;
//				ans[ansSz++] = i + 1;
				if (nxt == -1 || a[i] < a[nxt])
					nxt = i;
			}
		}
		for (int i = 0; i < n; i++) {
			if (i != lst && i != nxt)
				ans[ansSz++] = i + 1;
		}
		ans[ansSz++] = nxt + 1;
		lst = nxt;
		k--;
	}
	printf("%d\n", ansSz);
	for (int i = 0; i < ansSz; i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll cnt[5];
    ll answer;

    cin >> N;

    rep(i, 5) cnt[i] = 0;
    
    rep(i, N){
        string S;
        cin >> S;

        if (S[0] == 'M') cnt[0] ++;
        else if (S[0] == 'A') cnt[1] ++;
        else if (S[0] == 'R') cnt[2] ++;
        else if (S[0] == 'C') cnt[3] ++;
        else if (S[0] == 'H') cnt[4] ++;
    }

    answer = 0;
    answer += cnt[0]*cnt[1]*cnt[2];
    answer += cnt[0]*cnt[1]*cnt[3];
    answer += cnt[0]*cnt[1]*cnt[4];
    answer += cnt[0]*cnt[2]*cnt[3];
    answer += cnt[0]*cnt[2]*cnt[4];
    answer += cnt[0]*cnt[3]*cnt[4];
    answer += cnt[1]*cnt[2]*cnt[3];
    answer += cnt[1]*cnt[2]*cnt[4];
    answer += cnt[1]*cnt[3]*cnt[4];
    answer += cnt[2]*cnt[3]*cnt[4];

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}


int main(){
  int n, k; cin >> n >> k;
  vi data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());

  int res = 1e9 + 1;
  for(int i = 0; i <= n - k; i++){
    int tmp = data.at(k + i - 1) - data.at(i);
    if(tmp < res) res = tmp;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

class UnionFind {
 public:
  explicit UnionFind(int N) : par(N) {
    for (int n = 0; n < N; ++n) {
      par[n] = n;
    }
  }
  void Unite(int x, int y) {
    int rx = Root(x);
    int ry = Root(y);
    if (rx != ry) {
      par[rx] = ry;
    }
  }
  int MaxSize() {    
    unordered_map<int, int> cnt_map;
    for (int i = 0; i < par.size(); ++i) {
      int parent = Root(i);
      ++cnt_map[parent];
    }
    int res = 0;
    for (const auto& p : cnt_map) {
      res = max(res, p.second);
    }
    return res;
  }

 private:
  int Root(int x) {
    if (par[x] == x) return x;
    return par[x] = Root(par[x]);
  }

  vector<int> par;
};

int main() {
  int N, M;
  cin >> N >> M;  
  UnionFind uf(N);
  for (int m = 0; m < M; ++m) {
    int A, B;
    cin >> A >> B;
    uf.Unite(A-1, B-1);
  }
  
  cout << max(1, uf.MaxSize()) << endl;

  return 0;
}


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

int main(void){

  string S;
  cin >> S;

  int ans = 0;
  int count = 0;
  for(int i =0;i < S.size(); i++){

    if(S.at(i) == 'A') count++;
    else if(S.at(i) == 'T')count++;
    else if(S.at(i) == 'C')count++;
    else if(S.at(i) == 'G')count++;
    else count = 0;

    if(count > ans) ans = count;
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc119/tasks/abc119_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 10;
// const int X_I_MAX = 1e8;
// const int X_I_MAX = 100;

int N;
double x[N_MAX];
char u[N_MAX][4];

void solve() {
  double ans = 0;
  REP(i, N) {
    if (strcmp(u[i], "JPY") == 0) {
      ans += x[i];
    } else {
      ans += x[i] * 380000.0;
    }
  }
  printf("%.4lf\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%lf%s", x + i, u[i]);
}

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


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [0]*N
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])

Measured memory_bytes: 52208
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll f[3005][3005];
int A,B,C,D;
int main() {
	scanf("%d%d%d%d",&A,&B,&C,&D);
	f[A][B]=1;
	for(int i=A;i<=C;i++) {
		for(int p=B;p<=D;p++) {
			if(i>A) {
				f[i][p]+=f[i-1][p]*p;
			}
			if(p>B) {
				f[i][p]+=f[i][p-1]*i;
			}
			if(i>A && p>B) {
				f[i][p]-=f[i-1][p-1]*(i-1)%mod*(p-1);
			}
			f[i][p]=(f[i][p]%mod+mod)%mod;
		}
	}
	printf("%lld\n",f[C][D]);
	return 0;
}


Measured memory_bytes: 74012
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        long a = in.nextLong();
        long b = in.nextLong();
        long k = in.nextLong();
        if (a < k) {
            out.println(0, Math.max(0, b + a - k));
        } else {
            out.println(a - k, b);
        }
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint l[105];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> l[i];
	sort(l+1, l+n+1);
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			for(int k = 1; k <= n; k++){
				if(j >= k) continue;
				if(l[i] != l[j] && l[j] != l[k] && l[i]+l[j] > l[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void)
{
	int a[3], i, j, n;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	if (n == 2){
		for (j = 1; j <= a[0] && j <= a[1]; j++){
			if (a[0] % j == 0 && a[1] % j == 0){
				printf("%d\n", j);
			}
		}
	}
	
	if (n == 3){
		for (j = 1; j <= a[0] && j <= a[1] && j <= a[2]; j++){
			if (a[0] % j == 0 && a[1] % j == 0 && a[2] % j == 0){
				printf("%d\n", j);
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
# coding:utf-8

import sys
input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


def move_uv(x, y):
    ut = x + y
    vt = x - y
    command = ''
    u, v = 0, 0
    for i in range(len(D)):
        if u <= ut and v <= vt:
            command += 'R'
            u += D[i]
            v += D[i]
        elif u <= ut and v > vt:
            command += 'U'
            u += D[i]
            v -= D[i]
        elif u > ut and v <= vt:
            command += 'D'
            u -= D[i]
            v += D[i]
        else:
            command += 'L'
            u -= D[i]
            v -= D[i]

    return command


N = int(input())
point = []
max_length = 0
for i in range(N):
    x, y = inpl()
    max_length = max(max_length, abs(x) + abs(y))
    point.append([x, y])

parity = sum(point[0]) % 2
judge = True
for p in point:
    if parity ^ sum(p) % 2:
        judge = False
        break

if not judge:
    print(-1)
else:
    D = [2 ** i for i in range(len(bin(max_length)) - 1)]
    D.reverse()

    # X + Yが偶数の時は長さ1の腕を足す
    if parity == 0:
        D.append(1)
    print(len(D))
    print(' '.join(map(str, D)))
    for i in range(N):
        print(move_uv(point[i][0], point[i][1]))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long Ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
     Ans += i; 
    }
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll n,m,x;
vector<ll> a;
void input(){
    cin>>n>>m>>x;
    scan_vector(m,a);
}
void src(){
    ll sum=0;
    rep(i,m){
        if(a[i]>x){sum++;}
    }
    cout<<min(sum,m-sum);
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	sunuke := make(map[int]bool, n)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			sunuke[a] = true
		}
	}
	var cnt int
	for _, v := range sunuke {
		if v == true{
			cnt++
		}
	}
	fmt.Println(n - cnt)
}


Measured memory_bytes: 2460
# -*- coding:utf-8 -*-
import math
n, h = map(int, input().split())
l = []
ans = 0

for tmp in range(n):
    a, b = map(int, input().split())
    l.append((a,b))

factor = sorted(l, key=lambda tmp:tmp[1])
max_a = max(l, key=lambda tmp:tmp[0])
while h > 0:
    if len(factor) != 0:
        max_b = factor[-1]
    else:
        max_b = (-1,-1)
    if max_a[0] < max_b[1]:
        h -= max_b[1]
        factor.pop()
        ans += 1
    else:
        ans += math.ceil(h/max_a[0])
        h -= max_a[0]*math.ceil(h/max_a[0])
print(ans)

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        int j = s.size() - i - 1;
        if (s[i] != s[j]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    bool yes = false;
    for (int i = 1; i <= 9; i++) {
        if (N % i == 0 && N / i <= 9) {
            yes = true;
            break;
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,k,num[N],sum=0;
ll ksm(ll x,ll y)
{
	if(y==0)
	{
		return 1;
	}
	else if(y==1)
	{
		return x;
	}
	ll ret=ksm(x,y/2);
	if(y%2==1)
	{
		return ((ret*ret)%MOD*x)%MOD;
	}
	return (ret*ret)%MOD;
}
int main(){
	ll i,j;
	cin>>n>>k;
	for(i=k;i>=1;i--)
	{
		num[i]=ksm(k/i,n);
		for(j=i*2;j<=k;j+=i)
		{
			num[i]=(num[i]+MOD-num[j])%MOD;
		}
		sum=(sum+i*num[i])%MOD;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n,k;cin>>n>>k;
    if(k==1)cout<<0<<endl;
    else cout<<n-k<<endl;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
    int N;
    cin >> N;
    int g;
    vector<int> A(N);
    for (int i=0;i<N;++i) {
        cin >> A[i];
        if (i==0)
            g = A[i];
        else
            g = gcd(g, A[i]);
    }

    cout << g << endl;
    return 0;
}


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

class RollingHash {
   private:
    template <ll mod>
    struct mPair {
        ll v0, v1;
        mPair operator*(const mPair &p) { return mPair{(v0 * p.v0) % mod, (v1 * p.v1) % mod}; }
        mPair operator+(const mPair &p) { return mPair{(v0 + p.v0) % mod, (v1 + p.v1) % mod}; }
        mPair operator-(const mPair &p) { return mPair{(v0 + mod - p.v0) % mod, (v1 + mod - p.v1) % mod}; }
        mPair operator*(const ll &x) { return mPair{(v0 * x) % mod, (v1 * x) % mod}; }
        mPair operator+(const ll &x) { return mPair{(v0 + x) % mod, (v1 + x) % mod}; }
        mPair operator*(const pair<int, int> &p) { return mPair{(v0 * p.first) % mod, (v1 * p.second) % mod}; }
        mPair operator+(const pair<int, int> &p) { return mPair{(v0 + p.first) % mod, (v1 + p.second) % mod}; }
        pair<int, int> to_pair() { return make_pair(v0, v1); }
    };
    vector<mPair<1000000007>> hash, bpow;
    const mPair<1000000007> base = {1069, 10007};

   public:
    const int len;
    // O(|S|)
    RollingHash(string s) : len(s.size()) {
        hash.assign(len + 1, {0, 0});
        bpow.assign(len + 1, {0, 0});
        bpow[0] = {1, 1};
        for (int i = 0; i < len; i++) {
            hash[i + 1] = hash[i] * base + s[i];
            bpow[i + 1] = bpow[i] * base;
        }
    }

    // 文字列[l,r)のハッシュ値を返す O(1)
    pair<int, int> get(int l, int r) { return (hash[r] - hash[l] * bpow[r - l]).to_pair(); }
    pair<int, int> get() { return get(0, len); }
    
    // h1 + h2(ハッシュ値h1とハッシュ値h2の結合) O(1)
    pair<int, int> connect(pair<int, int> h1, pair<int, int> h2, int len_h2) { return (bpow[len_h2] * h1 + h2).to_pair(); }
    
    // [l1,r1)の文字列とbの[l2,r2)の文字列の最長共通接頭辞の長さを返す O(log(min(|S1|,|S2|)))
    int LCP(RollingHash &b, int l1, int r1, int l2, int r2) {
        int ok = -1, ng = min(r1 - l1, r2 - l2) + 1;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
                ok = mid;
            else
                ng = mid;
        }
        return ok;
    }
};

int n;

bool solve(int len, string s) {
    RollingHash rh0(s);
    for (int i = 0; i + 2 * len <= s.size(); i++) {
        for (int j = i + len; j + len <= s.size(); j++) {
            if (rh0.get(j, j + len) == rh0.get(i, i + len)) return true;
        }
    }
    return false;
}

int binary_search(int ok, int ng, string s) {
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (solve(mid, s)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    string s;
    cin >> n >> s;
    int ans = binary_search(-1, s.size(), s);
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int a,b,n;
  int total_sum = 0;
  cin >> n >> a >> b;

  for (int i=1; i<=n; ++i) {
    int temp = i;
    int temp_sum = 0;
    while(temp!=0) {
      temp_sum += temp%10;
      temp /= 10;
    }
    if (temp_sum >= a && temp_sum <= b)
      total_sum += i;
  }
  cout << total_sum << endl;
  return 0;
}

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


using namespace std;



int main() {

	const int64_t maxx = pow(10, 18);
	
	int N;
	cin >> N;
	int64_t total = 1;
	vector<int64_t> A(N);
	for (int i = 0; i < N; i++) {
		
		cin >> A[i];

		if (A[i] == 0) {
			cout << 0;
			return 0;
		}
		
	}

	for (int i = 0; i < N; i++) {

		if (maxx/total < A[i]) {
			cout << -1;
			return 0;
		}


		total *= A[i];

		
		

	}

	

	cout << total;
	return 0;


}

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

struct node{ //range update, point query
	int s,e,m;
	long long v,lazy;
	node *l,*r;
	node(int S,int E){
		s=S;e=E;m=(s+e)/2;
		v=0;lazy=0;
		if(s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	void laze(){
		if(s==e){v+=lazy;lazy=0;return;}
		l->lazy+=lazy;r->lazy+=lazy;
		lazy=0;
		return;
	}
	void update(int x,int y,long long nv){
		if(s==x&&e==y){lazy+=nv;laze();return;}
		if(y<=m)l->update(x,y,nv);
		else if(x>m)r->update(x,y,nv);
		else{l->update(x,m,nv);r->update(m+1,y,nv);}
	}
	long long query(int x){
		laze();
		if(s==e)return v;
		if(x<=m)return l->query(x);
		return r->query(x);
	}
}*root;

int main(){
	int n;
	long long d,a;
	scanf("%d%lld%lld",&n,&d,&a);
	pair<long long,long long> p[n];
	long long x,h;
	root=new node(0,n-1);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x,&h);
		h=(h%a==0?h/a:h/a+1);
		p[i]=make_pair(x,h);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		root->update(i,i,p[i].second);
	}
	long long ans=0;
	int ptr=-1;
	for(int i=0;i<n;i++){
		while(ptr<n-1&&p[ptr+1].first-p[i].first<=2*d){
			ptr++;
		}
		long long cur=root->query(i);
		//printf("%lld %lld\n",i,cur);
		if(cur<=0)continue;
		root->update(i,ptr,-cur);
		ans+=cur;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<ll, ll> pii;
const ll mod = 998244353;
const int sz = 2 * 1e5 + 50, inf = 1e9 + 10;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	ll n;
	cin >> n;
	cout << a[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
int main(){
  int count;
  int d[102];
  scanf("%d", &count);

  for(int i=0; i<count; i++){
    scanf("%d", &d[i]);
  }

  std::vector<int> dv(d, d+count);

  std::sort(dv.rbegin(), dv.rend());
  int score=0;
  for(int i=0; i+1<count; i+=2){
    score += dv[i] - dv[i+1];
  }
  if( count%2 == 0) printf("%d\n", score);
  else printf("%d\n", score+dv[count-1]);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next(), week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for (int i = 0; i < 7; i++)
      if (S.equals(week[i])) System.out.println(7 - i);
  }
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	int n, m;
	while(scanf("%d %d %d %d", &a, &b, &c, &d)!=EOF)
	{
		n = max(a,c);
		m = min(b,d);
		if(m < n)
		{
			printf("0\n");
		}
		else
		{
			printf("%d\n",m - n);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  int maxi = -1;
  int mini = 1e9;
  rep(i,n){
    int a;
    cin >> a;
    maxi = max(maxi,a);
    mini = min(mini,a);
  }
  P(maxi-mini);
}

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


Measured memory_bytes: 256
/*#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> v[100009];;
vector<int> v1;
int a[100009];
int b[100009];
int tree[100009];
int num=0;
int DFS(int i,int p)
{
    v1.push_back(i);
    int ans=0;
    b[i]=num;
    num++;
    for(int j=0;j<v[i].size();j++)
    {
        int k=v[i][j];
        if(k==p)continue;
        ans+=1+DFS(k,i);
    }
    a[i]=ans;
    return ans;
}
int query(int node,int l,int r,int s,int e)
{

}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    a[1]=DFS(1,-1);
    int q;
    for(int i=1;i<=n;i++)
    {
        build(1,0,n-1,k);
    }
    while(q--)
    {
        int x,y;
        int u;
        cin>>u;
        if(u==1)
        {
            cin>>x;
         cout<<query(1,0,n-1,b[x],b[x]+a[x]);
        }
        else
        {

        }
    }
}
*/
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans1=0;
long long a[100009];
vector<pair<long long,long long> > v;
int main()
{
    memset(a,0,sizeof(a));
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    /*for(int i=0; i<n; i++)
    {
        if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
            ans1=max(ans1,(long long)a[i]*a[i]);
        if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i+3]==a[i+4])
            ans1=max(ans1,(long long)a[i]*a[i+3]);
        if(a[i]==a[i+1]&&a[i]!=a[i+2]&&a[i+3]==a[i+4])
            ans1=max(ans1,(long long)a[i]*a[i+3]);
        if(a[i]==a[i+1]&&a[i+2]==a[i+3])
            ans1=max(ans1,(long long)a[i]*a[i+2]);
    }*/
    v.push_back(make_pair(a[0],1));
    for(int i=1;i<n;i++)
    {
        if(a[i]==v[v.size()-1].first)
            v[v.size()-1].second++;
        else
            v.push_back(make_pair(a[i],1));
    }
    long long ans=0;
    for(int i=0;i<v.size();i++)
    {
        if(v[i].second<=1)
            v[i].first=0;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        int x=v[i].first;
        int y=v[i].second;
        if(y>=4)
        {
            ans=max(ans,(long long)x*x);
            if(v[i+1].second>=2)
            ans=max(ans,(long long )x*v[i+1].first);
        }
        if(y>=2)
        {
            if(v[i+1].second>=2)
                ans=max(ans,(long long )x*v[i+1].first);
        }

    }
    cout<<ans;
}


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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int g[10][10];

int main(){
	//IO();
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	ll ans=0;
	for(int i=0;i<n-k;i++)
		ans+=a[i];
	printf("%lld\n",ans);


}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);

		while(true){

			//???????????????????????????????????????
			String n = scan.next();

			if(n.equals("-")){
				break;
			}

			//?????£????????????????????°?????????????????????
			int m = scan.nextInt();

			//????????????????????°?????°???????????????
			for(int i = 0; i < m; i++){
				//?????£??????????????????????????????????????????
				int h = scan.nextInt();

				//??????????????????????????????
				String left = n.substring(0 , h);
				String right = n.substring(h);

				//???????????£????????¨????????\???????????????
				n = right + left;
			}

			//???????????¨???
			System.out.println(n);
		}


	}

}

Measured memory_bytes: 26352
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 400
#define MO 1000000007
using namespace std;
int A[MAXN+5],B[MAXN+5];
int sum[MAXN+5][MAXN+5];
int dp[MAXN+5][MAXN+5];
int tot[MAXN+5];
int N,C;
void prepare()
{
	for(int i=1;i<=N;i++)
	{
		sum[i][0]=B[i]-A[i]+1;
		for(int j=A[i];j<=B[i];j++)
			tot[j]=1;
		for(int k=1;k<=C;k++)
			for(int x=A[i];x<=B[i];x++)
			{
				tot[x]=1LL*tot[x]*x%MO;
				sum[i][k]=(1LL*sum[i][k]+tot[x])%MO;
			}
	}
}
int DFS(int pos,int res)
{
	if(pos==1)
	{
		return sum[pos][res];
	}
	if(dp[pos][res]!=-1)
		return dp[pos][res];
	int ret=0;
	for(int k=0;k<=res;k++)
		ret=(1LL*ret+1LL*DFS(pos-1,res-k)*sum[pos][k]%MO)%MO;
	dp[pos][res]=ret;
	return ret;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d %d",&N,&C);
	for(int i=1;i<=N;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=N;i++)
		scanf("%d",&B[i]);
	prepare();
	int ans=DFS(N,C);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i = n; i < (int) N; i++)
#define p(s)		cout<<(s)<<endl
using namespace std;

int main() {
	int N,K,ans;
	cin>>N>>K;
	ans=K*pow(K-1,N-1);
	p(ans);
	return 0;
}


Measured memory_bytes: 384
/*=====Bismillahir Rahmanir Rahim=====*\
!                                      !
!(^,^)Ron is back(-o,o-)               !
!         MD. TAREK MAHMUD RONY        !
!            CSE 12th Batch            !
!           Comilla University         !
\*====================================*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define test             ll t;cin>>t;while(t--)
#define nl               endl
#define mp(a,b)          make_pair(a,b)
#define F                first
#define S                second
#define vc               vector<int>
#define vcl              vector<ll>
#define pb               push_back
#define vc_sum(a)        accumulate(a.begin(),a.end(),0)
#define vc_max(a)        *max_element(a.begin(),a.end())
#define vc_min(a)        *min_element(a.begin(),a.end())
#define vc_sort(a)       sort(a.begin(),a.end())
#define vc_gsort(a)      sort(a.begin(),a.end(),greater<int>())
#define vc_uni(a)        a.erase(unique(a.begin(),a.end()),a.end())
#define ulta(a)          reverse(a.begin(),a.end())
#define RON              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define yes              cout<<"YES"<<nl
#define no               cout<<"NO"<<nl
#define M                1000000007
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
using namespace std;
int main()
{
    RON;
    ll n;
    cin>>n;
    string s;
    while(n)
    {
        n--;
        s.pb('a'+n%26);
        n/=26;
    }
    ulta(s);
    cout<<s<<nl;
    return 0;
}



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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    string tmp;
    for(int i=0;i<n;i++){
        if(mp.count(v[i])){
            cout<<"No"<<endl;
            return 0;
        }
        if(i!=0){
            if(v[i][0]!=tmp[tmp.length()-1]){
                cout<<"No"<<endl;
                return 0;
            }
            tmp=v[i];
            mp[v[i]]=1;
        }else{
            tmp=v[i];
            mp[v[i]]=1;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    long long n,k;
	cin>>n>>k;
	long long a[n];
	long long c=0;
	for(long long i=0;i<n;i++) cin>>a[i];
	sort(a, a+n, cmp);
	for(long long i=k;i<n;i++) c+=a[i];
	cout<<c;
	return 0;
}

Measured memory_bytes: 1792
def fall(S,H):
    for h in range(H-1):
        for i in range(5):
            if S[h][i]=="0":
                S[h][i] = S[h+1][i]
                S[h+1][i] = "0"
    return S
while True:
    H = int(input())
    if H==0:
        break
    S = [list(input().split()) for i in range(H)]
    S = S[::-1]
    ans = 0
    k = 1
    while k!=0:
        k = 0
        for h in range(H):
            s = S[h]
            for l in range(3):
                for r in range(5,2+l,-1):
                    if s[l]=="0":
                        continue
                    if s[l:r].count(s[l])==(r-l):
                        k = 1
                        ans += int(s[l])*(r-l)
                        S[h][l:r] = ["0"]*(r-l)
        for i in range(H):
            S = fall(S,H)
    print(ans)


Measured memory_bytes: 5632
#include <stdio.h>

int min(const int a, const int b);
inline int min(const int a, const int b)
{
    return a > b ? b : a;
}

int main()
{
    int n, k, c[2] = {0};
    scanf("%d %d\n", &n, &k);

    char s[100008];
    fread(s, sizeof(s), 1, stdin);

    char last = s[0];
    for (int i = 1; i < n; i++)
    {
        c[s[i] == last] ++;
        last = s[i];
    }

    c[1] += min(c[0], 2 * k);
    printf("%d", c[1]);

    return 0;
}


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

int n;
vector<int> a,b,c;
int main(){
  cin >> n;
  for(int i=0;i<n;i++) { int p; cin >> p; a.push_back(p); }
  for(int i=0;i<n;i++) { int p; cin >> p; b.push_back(p); }
  for(int i=0;i<n;i++) { int p; cin >> p; c.push_back(p); }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());

  long long ans = 0;
  for(int i=0;i<n;i++){
    long long ap = lower_bound(a.begin(),a.end(), b[i]) - a.begin();
    long long cp = c.end() - upper_bound(c.begin(),c.end(), b[i]);
    ans += ap*cp;
  }
  cout << ans << endl;
  return 0;
}


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

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

  for (int i = 0; i < N; i++) {
    
    string s;
    cin >> s;
    
    if (s == "Y") {
      Type = "Four";
      break;
      } else {
      Type = "Three";
    }
  }
  cout << Type << endl;

}

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

int gcd(int x, int y){
  if(x % y == 0) return y;
  
  int next = x % y;
  return gcd(y, next);
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int mi = a.at(0);
  for(int i = 1; i < n; i++){
    mi = gcd(mi, a.at(i));
    if(mi == 1) break;
  }
  
  if(k % mi || k > a.at(n-1)) cout << "IMPOSSIBLE" << endl;
  else cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 3608
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    l_max = 0
    r_min = float('inf')
    for _ in range(m):
        l, r = map(int, input().split())
        l_max = max(l_max, l)
        r_min = min(r_min, r)
    print(max(r_min + 1 - l_max, 0))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 40556
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;

typedef long long ll;
typedef unsigned long long ull;

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


ll mod = 998244353LL;

ll fact[300011];
ll fact_inv[300011];

ll pow_mod(ll x, ll n, ll mod) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return ans % mod;
}

void init() {
	fact[0] = fact_inv[0] = 1;

	for(ll i = 1; i <= 300010; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = pow_mod(fact[i], mod - 2, mod) % mod; // フェルマーの小定理で逆元を求める
	}
}

ll comb(ll n, ll r) {
	return ((fact[n] * fact_inv[n - r] % mod) * fact_inv[r]) % mod;
}


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

	init();

	ll ans = 0;
	for(ll x = 0; x <= N; x++) {
		if (K < A * x) continue;
		if ((K - A * x) % B != 0) continue;

		ll y = (K - A * x) / B;
		if (y > N) continue;
		ans += comb(N, x) * comb(N, y) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int fun(int a)
{
    int u = 0;
    while(a)
    {
        a/=10;
        u++;
    }
    return u % 2;
}
int main()
{
    string s;
    cin >> s;
    int n = s.length();
    vector<int> L, R, vec(n,0);
    int c =0;
    for(auto a : s)
    {
        if(a == 'L') L.push_back(c);
        else R.push_back(c);
        c++;
    }
    for(int x =0; x<n; x++)
    {
        if(s[x] == 'L')
        {
            int z = lower_bound(R.begin(), R.end(), x) - R.begin();
            z--;
            int g = R[z];
            if((x - g) % 2 == 0)vec[g]++;
            else vec[g+1]++;
        }
        else
        {
            int z = lower_bound(L.begin(), L.end(), x) - L.begin();
            int g = L[z];
            if((g - x) % 2 == 0)vec[g]++;
            else vec[g-1]++;
        }
    }
    for(auto a: vec)cout << a << " ";
    
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S,T;
  cin>>S>>T;
  int count=0;
  rep(i,3){
    if(S[i]==T[i])count++;
  }
  cout <<count<<endl;
  return 0;
}

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

int main() {
	string s;
	for (int i = 0; i < 4; i++) {
		cin >> s;
	}
	if (s[0] == s[1]) {
		cout << "Bad";
	}
	else if (s[1] == s[2]) {
		cout << "Bad";
	}
	else if (s[2] == s[3]) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}
}

Measured memory_bytes: 256
from subprocess import*
call(('python3','-c',"""
from numpy import*
from scipy.sparse import*
_,*s=open(0)
s=array([list(map(int,t[:-1]))for t in s])
g=csr_matrix(s)
m=csgraph.floyd_warshall(g)
d=m.max()
i=m[0]%2<1
j=i^True
print(all(s[i][:,i]==0)*all(s[j][:,j]==0)*int(d+1)or-1)
"""))

Measured memory_bytes: 64320
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main()
{
    ins(n);
    VI h(n);
    rep(i,n)in(h.at(i));
    VI dp(n+1);
    rep(i,n+1)dp.at(i)=INF;
    dp.at(0)=0;
    dp.at(1)=abs(h.at(0)-h.at(1));
    For(i,2,n){
        dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }
    print(dp.at(n-1));
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
#-------------------------------------

n = int(input())
b = list(map(int,input().split()))
b += [b[n-2]]
a = []

for i in range(n):
    if i == 0 :
        a.append(b[0])
        continue
    if b[i] >= b[i-1]:
        a.append(b[i-1])
    else:
        a.append(b[i])

print(sum(a))

Measured memory_bytes: 38384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
        //console.log('%s',input);
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
        var b = parseInt(input[1], 10);
        var c = parseInt(input[2], 10);
	//出力
if((b*10+c)%4 == 0){
	console.log('YES');
}else{
console.log('NO');
}
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int X,n,q;
int r[100001],t[100000],a[100000];

int main() {
    scanf("%d%d",&X,&n);
    for(int i=1;i<=n;i++) scanf("%d",r+i);
    scanf("%d",&q);
    for(int i=0;i<q;i++) scanf("%d%d",t+i,a+i);

    int sl=0,sr=X,ll=0,rr=X;
    for(int i=0,j=1;i<q;i++) {
        for(;j<=n && r[j]<=t[i];j++) {
            int d=r[j]-r[j-1];
            if(j%2==1) {
                sl += max(d-ll,0);
                sl = min(sl,sr);
                ll = max(ll-d,0);
                rr = max(rr-d,0);
            } else {
                sr -= max(d-(X-rr), 0);
                sr = max(sl,sr);
                rr = min(rr+d,X);
                ll = min(ll+d,X);
            }
        }
        a[i] = max(a[i],sl);
        a[i] = min(a[i],sr);

        int v=ll+(a[i]-sl);
        if(j%2==1) v-=t[i]-r[j-1];
        else v+=t[i]-r[j-1];
        v = min(v,X); v=max(v,0);
        printf("%d\n",v);
    }
    
    return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;
class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
long n=sc.nextLong();
long d=sc.nextLong();
int cnt=0;

//long x[],y[]; x=new long[n]; y=new long[n];
long[] x=new long[(int)n];
long[] y=new long[(int)n];
int i=0;

while((n--)>0){
x[i]=sc.nextLong();
y[i]=sc.nextLong();
if(d*d>=(x[i]*x[i]+y[i]*y[i]))
cnt++;
i++;
}
System.out.println(cnt);
}


}

Measured memory_bytes: 63192
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
c = 0
for i in itertools.permutations(list(range(1, N+1)), N):
    c +=1
    if p == i:
        a = c
    if q == i:
        b = c
print(abs(a-b))

Measured memory_bytes: 3064