akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

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

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

typedef pair<double, double> p;

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

    double a, b, h, m; cin >> a >> b >> h >> m;

    double minutes = 60 * h + m;
    const double cycle_min = 60 * 12;
    double rad_a = 2 * M_PI  * (minutes / cycle_min);
    double rad_b = (double) 2 * M_PI * (m / 60);

    p hour_p = make_pair(a * cos(rad_a), a * sin(rad_a));
    p min_p = make_pair(b * cos(rad_b), b * sin(rad_b));

    double ans = sqrt(pow(hour_p.first - min_p.first,2) + pow(hour_p.second - min_p.second,2));
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 4172
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), k = in();
	vector<ll>l(n); REP(i, n)l[i] = in();
	sort(ALL(l));
	ll ans = 0;
	REP(i, k) {
		ans += l[n - 1 - i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    long long n;
    queue<long long> b;
    long long num;
    cin>>n;
    if(n==0) break;
    long long sum=0;
    for(int i=0;i<n;i++){
      cin>>num;
      sum+=num;
      b.push(num);
    }
    long long ans=-1;
    for(int j=0;j<10001;j++){
      long long ok=1;
      long long size=b.size();
      for(int i=0;i<size;i++){
	long long num=b.front();
	b.pop();
	if(num!=i+1){
	  ok=0;
	}
	if(num-1>0){
	  b.push(num-1);
	}
      }
      if(ok){
	ans=j;
	break;
      }
      b.push(size);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = int(3e5), mod = int(1e9)  + 7;

ll n, a, b; 

int main () {
	cin >> n >> a >> b;
	if(a == b){
		cout << 1;
		return 0;
	}
	if(a > b || n == 1){
		cout << 0;
		return 0;
	}
	n -= 2;
	cout << n * b - n * a + 1;

return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const long long MAXN=25,MOD=1e9+7;
bool v[MAXN][MAXN];
long long ans[MAXN];
long long n;
map<long long,long long>ma;
long long dp(long long x)
{
	if(ma[x])
		return ma[x];
	return ma[x]=((dp(x/2)+dp((x-1)/2))%MOD+dp((x-2)/2))%MOD;
}
int main()
{
	for(long long i=0;i<20;i++)
	{
		for(long long j=i;j<=20-i;j++)
		{
			if((j|i)!=j)
				continue;
			if(!v[i^j][i+j])
			{
				v[i^j][i+j]=1;
				ans[max(i^j,i+j)]++;
			}
		}
	}
	for(int i=1;i<=20;i++)
	{
		ans[i]+=ans[i-1];
		ma[i]=ans[i];
	}
	scanf("%lld",&n);
	printf("%lld",dp(n));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  int W, a, b; cin >> W >> a >> b;
  if(a + W < b) cout << b - (a + W) << endl;
  else if(b + W < a) cout << a - (b + W) << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<Integer> a = new ArrayList<>();
		int temp;

		for(int i=0; i<n; i++){
			temp = in.nextInt();
			if(i==0){
				a.add(temp);
			}else if(i>0 && a.get(a.size()-1) != temp){
				a.add(temp);
			}
		}

		int count = 1;
		boolean con = false;
		for(int i=1; i<a.size()-1; i++){
			if(a.get(i-1) < a.get(i) && a.get(i) > a.get(i+1)){
				if(con == false){
					count++;
					con = true;
				}else{
					con = false;
				}
			}else if(a.get(i-1) > a.get(i) && a.get(i) < a.get(i+1)){
				if(con == false){
					count++;
					con = true;
				}else{
					con = false;
				}
			}else{
				con = false;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 60724
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18

using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;

int N;
vector<int> ans;

void dfs(int x,int p,int t){
    ans[x] = t;
    for(auto next : G[x]){
        if(next.first == p) continue;
        if(next.second % 2 == 0){
            dfs(next.first,x,t);
        }else{
            dfs(next.first,x,1-t);
        }
    }
}


int main(){
    cin >> N;
    G = vector<vector<Edge>>(N);
  	ans = vector<int>(N);
    rep(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v,w)); 
        G[v].push_back(Edge(u,w)); 
    }
    dfs(0,-1,0);
    rep(i,N){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	string S; cin >> S; 
	if(S == "Sunny") cout << "Cloudy" << endl; 
	if(S == "Cloudy") cout << "Rainy" << endl; 
	if(S == "Rainy") cout << "Sunny" << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

typedef vector<ll> vec;
typedef vector<vec> mat;
#define M 100010
ll n, m;
ll d[M];

void mul(mat &A, mat &B){
	int n = A.size();
	mat C(n, vec(n, 0));
	rep(k, n) rep(i, n) rep(j, n) C[i][j]+=A[i][k]*B[k][j]%mod;
	A.swap(C);
	rep(i, n) rep(j, n) A[i][j] %= mod;
}

int main(){
	scanf("%lld%lld", &n, &m);
	rep(i, m) scanf("%lld",d+i+1);
	d[m+1] = n;
	mat A(3, vec(3, 1));
	A[0][0] = A[0][1] = 2;
	A[2][1] = 0;
	mat B(A);
	rep(i, 3) B[i][0]--;
	mat X(3, vec(3, 0));
	rep(i, 3) X[i][i] = 1;
	rep(i, m+1){
		if(i) mul(X, B);
		ll t = d[i+1]-d[i]-1;
		mat C(A);
		while(t){
			if(t&1) mul(X, C);
			mul(C, C);
			t >>= 1;
		}
	}
	ll res = 0;
	rep(i, 3) res += X[0][i];
	printf("%lld\n", (res+mod)%mod);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

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

int main() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> a(n);
    int g = 0;
    int max = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        g = gcd(g, a[i]);
        max = std::max(max, a[i]);
    }

    if (k % g == 0 && k <= max) {
        puts("POSSIBLE");
    } else {
        puts("IMPOSSIBLE");
    }
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
dmax = [0]*(n+2)
x = []*(n+1)

i = n
ne = 0
while i >= 0:
    dmax[i] = a[i] + dmax[i+1]
    i -= 1

hantei = True
ans = 0
x.append(1)

for i in range(n+1):
    if x[i] < a[i]:
        hantei = False
        break
    else:
        x.append(min((x[i]-a[i]) * 2,dmax[i+1]))
        ans += x[i]

print(ans) if hantei else print(-1)



Measured memory_bytes: 22412
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int ab, bc;
    cin >> ab >> bc;
    cout << ab * bc / 2 << endl;
}


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

int main()
{
	string s;
	int ans = 0;
	while(cin >> s){
		string t;
		for(int i = 0; i < s.size(); ++i){
			if('0' <= s[i] && s[i] <= '9'){
				t.push_back(s[i]);
			} else {
				ans += atoi(t.data());
				t.clear();
			}
		}
		if(t.size()){
			ans += atoi(t.data());
		}
	}
	cout << ans << endl;
}

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

int main(){

    int n,m,p,result,x[100],sum;
    double rate;


    while(cin>>n>>m>>p,n||m||p){

        sum=0;

        for(int i=0;i<n;i++){
            cin>>x[i];
            sum += x[i] * 100;
        }

       int result = sum *(100-p) / 100;
       if(x[m-1]==0) result = 0;
       else result = result/x[m-1];

        cout<<result<<endl;
    }

    return 0;
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
#define ull unsigned long long
#define getbit(x,i) (x>>i)&1

void solve(){
    ll n;cin>>n;
    n--;
    string ans;
    map<ll,char> mp;
    for(ll i=0;i<=25;i++) mp[i]='a'+i;
    while(n>=0){
        ans = mp[n%26]+ans;
        n/=26;
        if(n==0) break;
        else n--;
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        // cout<<"Case #"<<cas<<": ";
        solve();
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

#define n 5
int serve[n];
bool d[n];
int ans = INF;

void perm(int pos, int cost){
    if(pos == n){
        ans = min(cost, ans);
        return;
    }
    for(int i = 0; i < n; ++i){
        if(!d[i]){
            int tmp = cost;
            if(cost != 0 && cost % 10 != 0)
                tmp = 10 * (cost/10+1);
            tmp += serve[i];
            d[i] = true;
            perm(pos+1, tmp);
            d[i] = false;
        }
    }
}

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    for(int i = 0; i < n; ++i)
        cin>>serve[i];
    perm(0, 0);
    cout<<ans<<endl;

    return 0;
}



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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int m=fsc.nextInt();
        if(n==m){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
        fsc.close();
        
    }
    

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end()); // 昇順
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>()); // 降順
#define bsearch(v, n) binary_search(v.begin(), v.end(), n) 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, N;
	int sW, sH;
	sW = 0;
	sH = 0;
	cin >> W >> H >> N;
	vector<int>x, y, a;
	for(int i = 0;i < N; i++) {
		int t1, t2, t3;
		cin >> t1 >> t2 >> t3;
		x.push_back(t1);
		y.push_back(t2);
		a.push_back(t3);
	}

	for(int i = 0; i < N; i++) {
		switch(a[i]) {
			case 1:
				sW = max(sW, x[i]);
				break;
			case 2:
				W = min(W, x[i]);
				break;	
			case 3:
				sH = max(sH, y[i]);
				break;
			case 4:
				H = min(H, y[i]);
				break;
			defalt:	
				break;
		}
	}
	if(W > sW and H > sH) {
		int rslt = (W - sW) * (H - sH);
		cout << rslt << endl;
	} else {
		cout << 0 << endl;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> now(n), size(n);
	now[0] = 1;
	forn(i, 0, n) size[i] = 1;
	forn(i, 0, m) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		if (now[x]) {
			now[y] = 1;
		}
		if (size[x] == 1) now[x] = 0;
		--size[x];
		++size[y];
	}
	int ans = 0;
	forn(i, 0, n) ans += now[i];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
int H,W,c,d=0;
while(1){
scanf("%d",&H);
scanf("%d",&W);

if(H==0&&W==0){break;}

else{
//############################
for(c=1;c<=H;c++){
		for(d=1;d<=W;d++){
			if((c+d)%2==0){
			printf("#");
			}
			else{
			printf(".");
			}
		}
printf("\n");
}
//###########################
printf("\n");
}
}
return 0;
}

Measured memory_bytes: 572
import math

N = int(input())
d = [int(input()) for i in range(5)]

mi = d[0]
Ans = math.ceil(N / mi)
for i in d[1:]:
  Ans += 1
  if i < mi:
    x = math.ceil(N / i) - math.ceil(N / mi)
    Ans += x
    mi = i   

print(Ans)

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

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

bool is_triangle(int a, int b, int c) {
  return (a < (b + c) && b < (c + a) && c < (a + b));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  ll ans = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      // auto it = upper_bound(l.begin() + j + 1, l.end(), abs(l[i] - l[j]));
      for (int k = j + 1; k < n; k++) {
        // if (is_triangle(l[i], l[j], l[k])) ans++;
        if (abs(l[i] - l[j]) < l[k] && l[k] < (l[i] + l[j])) {
          ans++;
        }
        if (l[k] >= (l[i] + l[j])) {
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long N, std::vector<long long> a){
    LL ans = 10000000000;
    for(LL i=-100; i<=100; i++){
        LL val=0;
        REP(j,N){
            val += (i-a[j])*(i-a[j]);
        }
        ans=min(ans, val);
    }cout<<ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int main(){
int n,a[3][100000],h[3][100000];
//int n,a[3][3];
cin >> n;
for (int i=0;i<n;i++){
  for (int j=0;j<3;j++){
    cin >>a[j][i];
  }
}
h[0][0]=a[0][0];
h[1][0]=a[1][0];
h[2][0]=a[2][0];
for (int i=1;i<n;i++){
  h[0][i]=a[0][i]+max(h[2][i-1],h[1][i-1]);
  h[1][i]=a[1][i]+max(h[2][i-1],h[0][i-1]);
  h[2][i]=a[2][i]+max(h[1][i-1],h[0][i-1]);
  //cout <<h[0][i]<<' '<<h[1][i]<<' '<<h[2][i]<<' '<<endl;
}
cout << max(h[0][n-1],max(h[1][n-1],h[2][n-1]));
return 0;
}


Measured memory_bytes: 2560
n = int(input())
P = [int(x) for x in input().split()]
c = 0
for i in range(n - 2):
    if P[i] < P[i + 1] < P[i + 2] or P[i] > P[i + 1] > P[i + 2]:
        c += 1

print(c)

Measured memory_bytes: 2940
//
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<cstdlib>
//
//using namespace std;
//
//struct node{
//    int key;
//    node *prev,*next;
//};
//
//node *nil;
//void init()
//{
//    nil=(node*)malloc(sizeof(node));
//    nil->next=nil;
//    nil->prev=nil;
//}
//
//void insert(int key)
//{
//    node *x=(node*)malloc(sizeof(node));
//    x->key=key;
//    x->next=nil->next;
//    nil->next->prev=x;
//    nil->next=x;
//    x->prev=nil;
//}
//
//void deleteNode(node*t)
//{
//    if(t==nil){
//        return ;
//    }
//    t->prev->next=t->next;
//    t->next->prev=t->prev;
//    free(t);
//}
//
//void deleteFirst()
//{
//    deleteNode(nil->next);
//}
//
//void deleteLast()
//{
//    deleteNode(nil->prev);
//}
//
//node* listSearch(int key)
//{
//    node *cur=nil->next;
//    while(cur!=nil&&cur->key!=key){
//        cur=cur->next;
//    }
//    return cur;
//}
//
//void deleteKey(int key)
//{
//    deleteNode(listSearch(key));
//}
//
//void printList()
//{
//    node*cur=nil->next;
//    int isf=0;
//    while(1){
//        if(cur==nil){
//            break;
//        }
//        if(isf++>0){
//            printf(" ");
//        }
//        printf("%d",cur->key);
//        cur=cur->next;
//    }
//    printf("\n");
//}
//
//int main()
//{
//    int n,key,np=0,nd=0,size=0;
//    char com[20];
//    scanf("%d",&n);
//    init();
//    for(int i=0;i<n;i++){
//        scanf("%s%d",com,&key);
//        if(com[0]=='i'){
//            insert(key);
//            np++;
//            size++;
//        }else if(com[0]=='d'){
//            if(strlen(com)>=6){
//                if(com[6]=='F'){
//                    deleteFirst();
//                }else if(com[6]=='L'){
//                    deleteLast();
//                }else{
//                    deleteKey(key);
//                    nd++;
//                }
//                size--;
//            }
//        }
//    }
//    printList();
//    return 0;
//}
/*
7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
*/

#include<iostream>
#include<cstdio>
#include<list>

using namespace std;

int main()
{
    list<int>v;
    int n,k;
    char com[20];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&k);
            v.push_front(k);
        }else if(com[6]=='L'){
            v.pop_back();
        }else if(com[6]=='F'){
            v.pop_front();
        }else if(com[0]=='d'){
            scanf("%d",&k);
            for(list<int>::iterator it=v.begin();it!=v.end();it++){
                if(*it==k){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(i++){
            printf(" ");
        }
        printf("%d",*it);
    }
    printf("\n");
    return 0;
}



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 
bool kimari[3];
int suuji[3];

int main(){
    int n, m;
    cin >> n >> m;
    
    REP(i, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if(kimari[s]) {
            if(c != suuji[s]) {
                cout << "-1" << endl;
                return 0;
            }
        } else {
            kimari[s] = true;
            suuji[s] = c;
        }
    }

    REP(i, n) {
        if(i == 0) {
            if(kimari[i]) {
                if(suuji[i] == 0) {
                    if(n == 1) {
                        cout << 0;
                    }
                    else {
                        cout << "-1" << endl;
                        return 0;
                    }
                } else {
                    cout << suuji[i];
                }
            } else {
                if(n == 1) cout << 0;
                else cout << 1;
            }
        } else {
            if(kimari[i]) {
                cout << suuji[i];
            } else {
                cout << 0;
            }
        }
    }


    return 0;
}


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

int main() {
  int N, X, ans = 0, M = 2 * pow(10, 5) + 1;
  
  cin >> N;
  
  for (int i = 0; i < N; ++i) {
  	cin >> X;
    if (M > X) {
      M = X;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    static PrintWriter out;
    static InputReader in;
    public static void main(String args[]){
        out = new PrintWriter(System.out);
        in = new InputReader();
        new Main();
        out.flush(); out.close();
    }   
    Main(){
        solve();
    }
    void solve(){
        long n = in.nextLong(), x = in.nextLong();
        long ans = n;
        while(x != 0){
            long a = (n - x) / x, b = (n - x) % x;
            ans += 2 * a * x;
            if(b == 0){
                ans -= x;
                break;
            }
            ans += 2 * (x / b) * b;
            x = x % b; n = b + x; 
            if(x == 0){
                ans -= b;
            }
        }
        out.print(ans);
    }
    public static class InputReader{
        BufferedReader br;
        StringTokenizer st;
        InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
        public String next(){
            while(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){}
            }
            return st.nextToken();
        }
    }
}
        

Measured memory_bytes: 22484
using System;

class Checkpoints {
    static void Main(string[] args)
    {
        int N, M;
        int[] A = new int[51];
        int[] B = new int[51];
        int[] C = new int[51];
        int[] D = new int[51];
        int d = 0, t = 0;
        int ans = 0;
        string[] s;

        s = Console.ReadLine().Split();

        N = int.Parse(s[0]);
        M = int.Parse(s[1]);

        for(int i = 0; i < N; i++) {
            s = Console.ReadLine().Split();
            A[i] = int.Parse(s[0]);
            B[i] = int.Parse(s[1]);
        }

        for(int i = 0; i < M; i++) {
            s = Console.ReadLine().Split();
            C[i] = int.Parse(s[0]);
            D[i] = int.Parse(s[1]);
        }

        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++) {
                d = Math.Abs(A[i]-C[j]) + Math.Abs(B[i]-D[j]);

                if (j == 0) {
                    t = d;
                    ans = 1;
                }
                else if (t > d){
                    t = d;
                    ans = j+1;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main(void) {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  int h = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '-') h++;
  }
  if (h == 1 && s[a] == '-') cout << "Yes\n";
  else cout << "No\n";
  
  return 0;
}

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

int main(){
  int n;
  while(cin >> n){
    int ans = 0;
    for(int a = 0;a <= 9;a++){
      for(int b = 0;b <= 9;b++){
        for(int c = 0;c <= 9;c++){
          for(int d = 0;d <= 9;d++){
            if(a + b + c + d == n) ans++;
          }
        }
      }
    }

    cout << ans << "\n";
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

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

  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,ans=10000000,num=0,suma=0,sumb=0,sumc=0;
    cin>>n>>a>>b>>c;
    int l[n];
    for(int i=0;i<n;i++){
    	cin>>l[i];
    }
    for(int biti=0;biti<(1<<n);++biti){
    	vector<int> s;
    	for(int i=0;i<n;i++){
    		if(biti & (1<<i)){
    			s.pb(1);
    		}
    		else{
    			s.pb(0);
    		}
    	}
    	for(int bitj=0;bitj<(1<<n);++bitj){
    		vector<int> v;
    		for(int j=0;j<n;j++){
    			if(bitj & (1<<j)){
    			    v.pb(1);
    		    }
    		    else{
    			    v.pb(0);
    		    }
    		}
    		for(int i=0;i<n;i++){
    			if(s[i]==0){
    				if(v[i]==0){
    					if(suma!=0){
    						num+=10;
    					}
    					suma+=l[i];
    				}
    				else{
    					if(sumb!=0){
    						num+=10;
    					}
    					sumb+=l[i];
    				}
    			}
    			else{
    				if(v[i]==0){
    					if(sumc!=0){
    						num+=10;
    					}
    					sumc+=l[i];
    				}
    			}
    		}
    		num+=(abs(a-suma)+abs(b-sumb)+abs(c-sumc));
    		if(suma!=0 && sumb!=0 && sumc!=0){
    			ans=min(ans,num);
    		}
    		num=0,suma=0,sumb=0,sumc=0;
    	}
    }
    cout <<ans<<endl;
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1, 0);
    vector<ll> b(m + 1, 0);

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
        b[i] += b[i - 1];
    }


    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        ll s = a[i];
        if (s > k) break;
        
        int bb = upper_bound(b.begin(), b.end(), k - s) - 1 - b.begin();
        int books = bb + i;
        ans = max(ans, books);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6368
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B, X = LI()

S = X / (A**2) * A

if S == A * B:
    print(0)
else:
    if S > A * B / 2:
        BU = 2 * S / A - B
        B = B - BU
        S = S - (A * BU)

    print(math.degrees(math.atan(B**2 / (2*S))))


Measured memory_bytes: 38256
from fractions import gcd
# input
N = int(input())
A = list(map(int,input().split()))
L_A = [0] * (N+1)
R_A = [0] * (N+1)
for i in range(N):
    L_A[1+i] = gcd(L_A[i], A[i])
for i in reversed(range(N)):
    R_A[i] = gcd(R_A[i+1], A[i])
print(max(gcd(L_A[i], R_A[i+1]) for i in range(N)))


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

using Graph = vector<vector<int>>;

int main(){
  int N, X, Y; cin >> N >> X >> Y;
  Graph G(N); //0-indexed
  G[0].push_back(1);
  G[N-1].push_back(N-2);
  for (int i = 1; i < N-1; i++) {
    G[i].push_back(i-1);
    G[i].push_back(i+1);
  }
  G[X-1].push_back(Y-1);
  G[Y-1].push_back(X-1);
  
  vector<int> k(N);
  queue<int> que;
  
  for (int i = 0; i < N; i++) {
    vector<int> dist(N, -1); //iからの距離
    dist[i] = 0;
    queue<int> que;
    
    que.push(i);
    while (!que.empty()) {
      int v = que.front();
      for (int nv : G[v]) {
        if (dist[nv] != -1) continue;
        que.push(nv);
        dist[nv] = dist[v] + 1;
        k[dist[nv]]++;
      }
      que.pop();
    }
  }
  
  for (int i = 1; i < N; i++) {
    cout << k[i] / 2 << endl;
  }
}

Measured memory_bytes: 384
N = int(input())
numbers = [int(i) for i in input().split()]
sorted_numbers = sorted(numbers)

small_median = sorted_numbers[N//2 - 1]
big_median = sorted_numbers[N//2]

for i in range(N):
    if numbers[i] <= small_median:
        print(big_median)
    else:
        print(small_median)


Measured memory_bytes: 26772
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> v;
    ll k = INF<ll>;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        if(k == INF<ll>) k = x+y;
        else if((k+INF<ll>)%2 != (x+y+INF<ll>)%2){
            puts("-1");
            return 0;
        }
        v.emplace_back(x, y);
    }
    vector<ll> nums;
    for (int j = 0; j < 37; ++j) {
        nums.emplace_back(1LL << (36-j));
    }
    if((k+INF<ll>)%2==1) nums.emplace_back(1);
    cout << nums.size() << "\n";
    for (int i = 0; i < nums.size(); ++i) {
        if(i) cout << " ";
        cout << nums[i];
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
        ll xx, yy;
        tie(xx, yy) = v[i];
        ll x = xx+yy, y = xx-yy;
        string s;
        for (auto &&d : nums) {
            if(x < 0 && y < 0) x += d, y += d, s += "L";
            else if(x >= 0 && y >= 0) x -= d, y -= d, s += "R";
            else if(x < 0 && y >= 0) x += d, y -= d, s += "D";
            else x -= d, y += d, s += "U";
        }
        cout << s << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-31 15:40:41
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, k; cin >> n >> k;
  vector<int> a(n); cin >> a;
  if (*max_element(all(a)) < k) {
    cout << "IMPOSSIBLE" << endl; return 0;
  }

  if (find(all(a), k) != a.end()) {
    cout << "POSSIBLE" << endl; return 0;
  }

  int g = a[0];
  for (int i = 0; i < n; ++i) {
    g = __gcd(g, a[i]);
  }

  if (g != 1) {
    if (any_of(all(a), [&](int x){
      return x > k && (x % k) % g == 0;
    })) {
      cout << "POSSIBLE" << endl;
    } else {
      cout << "IMPOSSIBLE" << endl;
    }
  } else {
    cout << "POSSIBLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  vector<int> q,w;
  if(n%2==0){
    for(int i=0;i<n;i+=2){q.push_back(a[i]);}
    for(int i=1;i<n;i+=2){w.push_back(a[i]);}
    reverse(w.begin(),w.end());
    for(int i=0;i<w.size();i++){cout << w[i] << " ";}
    for(int i=0;i<q.size();i++){cout << q[i] << " ";}
  }
  else{
    for(int i=0;i<n;i+=2){q.push_back(a[i]);}
    for(int i=1;i<n;i+=2){w.push_back(a[i]);}
    reverse(q.begin(),q.end());
    for(int i=0;i<q.size();i++){cout << q[i] << " ";}
    for(int i=0;i<w.size();i++){cout << w[i] << " ";}
  }
}

Measured memory_bytes: 3832
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

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

using namespace std;

const LL MOD=1e9+7;

LL n,n2=1,h[200010],a[200010],dat[800010];

LL query(int k,int lb,int ub,int tlb,int tub)
{
  if(ub<tlb||tub<lb) return 0;
  if(tlb<=lb&&ub<=tub) return dat[k];
  return max(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

void upd(int k,LL val)
{
  dat[k]=val;
  while(k>0)
  {
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1],dat[k*2+2]);
  }
}

int main()
{
  cin>>n;
  while(n2<n+1) n2*=2;
  rep(i,n) cin>>h[i];
  rep(i,n) cin>>a[i];
  rep(i,n)
  {
    LL tmp=query(0,0,n2-1,0,h[i]-1);
    upd(h[i]+n2-1,tmp+a[i]);
  }
  cout<<query(0,0,n2-1,0,n)<<endl;
  return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0){
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h> 
#include <algorithm>
using namespace std;
int n, m, a[1000], sum;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sum = (sum + 4 * m - 1) / (4 * m);
	sort(a + 1, a + n + 1);
	for (int i = n; i >= 1; i--) {
		if (a[i] >= sum) {
			m--;
		} else {
			break;
		}
	}
	if (m > 0) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mkpr make_pair
#define ft first
#define sd second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>
inline void read(T &x) {
    x=0; int f=0; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') f=1; if(ch==EOF) return; ch=getchar();}
    while(isdigit(ch)) {x=x*10+(ch-'0'); ch=getchar();} if(f) x=-x;
}

/***********************************************************/

const int MAXN=2111;
int a[MAXN<<2], b[MAXN<<2], l[MAXN<<2], r[MAXN<<2], suf[MAXN], pre[MAXN];
char s[MAXN];
int n, m, sum1, sum2, ans;

int main() {
    scanf("%s", s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;++i) {
        a[i]=s[i]-'0';
        sum1+=a[i];
    }
    for(int i=1;i<=n;++i) {
        scanf("%1d", &b[i]);
        sum2+=b[i];
    }
    if(sum2==0) {
        puts(sum1==0 ? "0" : "-1");
        return 0;
    }
    for(int i=1;i<=n;++i) {
        a[i+n]=a[i+n+n]=a[i+n+n+n]=a[i];
        b[i+n]=b[i+n+n]=b[i+n+n+n]=b[i];
    }
    for(int i=1;i<=n+n+n+n;++i) {
        l[i]=(b[i]==1 ? 0 : l[i-1]+1);
    }
    for(int i=n+n+n+n;i;--i) {
        r[i]=(b[i]==1 ? 0 : r[i+1]+1);
    }
    for(int j=0;j<=n;++j) 
        suf[j]=pre[j]=0;
    for(int j=0;j<n;++j)
        if(a[j+1]!=b[n+1+j]) {
            suf[l[n+1+j]]=max(suf[l[n+1+j]], r[n+1+j]);
            pre[r[n+1+j]]=max(pre[r[n+1+j]], l[n+1+j]);
        }
    for(int j=n-1;j>=0;--j) {
        suf[j]=max(suf[j], suf[j+1]);
        pre[j]=max(pre[j], pre[j+1]);
    }
    ans=1e9;
    for(int i=n+1;i<=n+n;++i) {
        int cnt=0, offset=i-n-1;
        for(int j=0;j<n;++j) 
            cnt+=(a[j+1]!=b[i+j] ? 1 : 0);
        for(int j=0;j<=n;++j) {
            // printf("Shift %d, L %d, R %d, Cnt %d, Ans %d\n", offset, j, suf[j+1], cnt, 2*j+suf[j+1]+abs(suf[j+1]-offset)+cnt);
            ans=min(ans, j*2+suf[j+1]+abs(suf[j+1]-offset)+cnt);
        }
        cnt=0, offset=n-i+1;
        for(int j=0;j<n;++j) 
            cnt+=(a[i+j]!=b[j+1] ? 1 : 0);
        for(int j=0;j<=n;++j) {
            // printf("Shift %d, L %d, R %d, Cnt %d, Ans %d\n", offset, pre[j+1], j, cnt, 2*j+pre[j+1]+abs(pre[j+1]+offset)+cnt);
            ans=min(ans, j*2+pre[j+1]+abs(pre[j+1]+offset)+cnt);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512