akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int n, m;
vector<vector<int>> g;
vector<bool> used;

void dfs(vector<int> &path, int i) {
	used[i] = true;
	path.emplace_back(i);

	for (auto next : g[i]) {
		if (used[next]) {
			continue;
		}

		dfs(path, next);
		break;
	}
}

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

	cin >> n >> m;

	g.resize(n);
	used.resize(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<int> ans;
	dfs(ans, 0);

	reverse(begin(ans), end(ans));
	used[0] = false;
	ans.pop_back();

	dfs(ans, 0);

	cout << ans.size() << endl;
	for (int i = 0; i < (int)ans.size(); i++) {
		if (i) cout << " ";
		cout << ans[i] + 1;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 11128
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 105;

int i,j,k,n,l[N];

void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>l[i];
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            for(k=j+1;k<=n;k++)
            {
                vi v(3);
                v[0]=l[i],v[1]=l[j],v[2]=l[k];
                sort(all(v));
                if(v[0]+v[1]>v[2] && v[0]!=v[1] && v[1]!=v[2] && v[0]!=v[2])
                    ans++;
            }
        }
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String[] tokens = in.readLine().split(" ");
		long X = Long.parseLong(tokens[0]);
		long Y = Long.parseLong(tokens[1]);

		long val = X;
		List<Long> list = new ArrayList<>();
		while (val <= Y) {
			list.add(val);
			val *= 2;
		}
		System.out.println(list.size());
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e6;
const long inf=1e15;
int main(){
	int N;cin>>N;
	long v; 
	long acm[N+1],pm[N+1]; acm[0]=0;
	rep(i,0,N){ cin>>v; acm[i+1]=acm[i]+v; }
	rep(i,0,N+1){ pm[i]=2*acm[i]-acm[N]; }
	long ans=inf;
	rep(i,2,N-1){
		int j = lower_bound(pm,pm+i,acm[i]-acm[N])-pm;
		int k = lower_bound(pm+i,pm+N,acm[i])-pm;
        if(abs(pm[j-1]-acm[i]+acm[N]) < abs(pm[j]-acm[i]+acm[N])) j--;
        if(abs(pm[k-1]-acm[i]) < abs(pm[k]-acm[i])) k--;
		long a=max(acm[j],acm[i]-acm[j]);
		long b=min(acm[j],acm[i]-acm[j]);
		long c=max(acm[k]-acm[i],acm[N]-acm[k]);
		long d=min(acm[k]-acm[i],acm[N]-acm[k]);
		ans=min(ans,max(a,c) - min(b,d));
	}cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, std::vector<long long> A){
  vector<int> kaisa(N+2);
  int tmpSum = 0;
  FOR(x, 2, N+2) {
    kaisa.at(x) = tmpSum + x-1;
    tmpSum = kaisa.at(x);
  }

  vector<int> counts(N+2);
  REP(x, N) {
    counts.at(A.at(x)) += 1;
  }

  int sum = 0;
  for(const auto& e : counts) {
    if (e == 0) continue;

    sum += kaisa.at(e);
  }

  for(const auto& a : A) {
    cout << sum - kaisa.at(counts.at(a)) + kaisa.at(counts.at(a)-1) << endl;
  }
}

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


Measured memory_bytes: 7296
from collections import defaultdict
n, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

dp = defaultdict(int)
dp[0] = 0
for w, v in wv:
    dp_cur = list(dp.items())
    for w_cur, v_cur in dp_cur:
        if w_cur+w <= W:
            dp[w_cur+w] = max(dp[w_cur+w], v_cur+v)

# print(dp)
print(max(dp.values()))

Measured memory_bytes: 4072
#include <iostream>
#include <map>
 
using namespace std;
 
map<int, int> dist;
 
int main() {
    int n;
    while (cin >> n) {
        dist.clear();
        if (n == 0) break;
        int p, d1, d2;
        for (int i = 0; i < n; i++) {
            cin >> p >> d1 >> d2;
            dist[p] = d1 + d2;
        }
        int max = 0, max_p;
        for (map<int, int>::iterator m = dist.begin(); m != dist.end(); m++) {
            if ((*m).second > max) {
                max = (*m).second;
                max_p = (*m).first;
            }
        }
        cout << max_p << ' ' << max << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
 
int main() {
int n,s[105],sum=0,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++) {scanf("%d",&s[i]);sum+=s[i];}
if(sum%10) ans=sum;
else {
int del=0;
for(int i=1;i<=n;i++) {
if(s[i]%10&&(!del||del>s[i])) del=s[i];
}
if(del) ans=sum-del;
else ans=0;
}
cout<<ans<<endl;
return 0;
}

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

int main(void){
  int n,d,i,j,k,ans = 0;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  for(i=0; i<n; i++){
    for(j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      int norm = 0;
      for(k=0; k<d; k++){
        int dif = abs(x[i][k] - x[j][k]);
        norm += dif*dif;
      }
      bool flag = false;
      for(k=0; k<=norm; k++){
        if(k*k==norm){
          flag = true;
        }
      }
      if(flag){ans += 1;}
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    
    int result = 0;
    int amount = A - (B + C);
    if(amount < 0){
      result = (B + C) - A;
    }
    
    System.out.println(result);
  }
}


Measured memory_bytes: 23636
n = int(input())
a = [int(input()) for _ in range(n)] + [0]

sorted_a = sorted(a)
a_first = sorted_a[-1]
a_second = sorted_a[-2]

for i in range(n):
    if a[i] == a_first:
        print(a_second)
    else:
        print(a_first)

Measured memory_bytes: 14708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e3;
const int INF=1e9;
int main(){
  long K;cin>>K;
  cout<<50<<endl;
  rep(i,0,50){
    if(i<K%50){
      cout<<49+K/50+50-(K%50-1);
    }else{
      cout<<49+K/50-K%50;
    }if(i<49) cout<<" ";
  }cout<<endl;
}

Measured memory_bytes: 256
# 2020/07/05
# AtCoder Beginner Contest 173 - B

# Input
n = int(input())
d = dict()
d['AC'] = 0
d['WA'] = 0
d['TLE'] = 0
d['RE'] = 0

for i in range(n):
    s = input()
    d[s] = d[s] + 1

# Output
print('AC x ' + str(d['AC']))
print('WA x ' + str(d['WA']))
print('TLE x ' + str(d['TLE']))
print('RE x ' + str(d['RE']))


Measured memory_bytes: 9208
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();

        long count = 1;
        long num = x;
        while (num < y) {
            num = num * 2;
            if (num > y) break;
            else count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21972
S = str(input())
if S[0] == S[1] == S[2] == S[3] or S[0] == S[1] == S[2] or S[1] == S[2] == S[3] or S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
else:
    print("Good")


Measured memory_bytes: 9028
/*
      author : nishi5451
      created: 11.08.2020 00:39:48
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=c && c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 3612
// STRIVER_79 
// Lets goto the next level 
// AIM 6* at CC and CM at CF *__* 

#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)(1e9 + 21)
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long 
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define in(x) scanf("%intd", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define fi first
#define se second
#define kitna se
#define endl "\n"
#define pi pair<int, int>
#define LL long long 
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax =  (int)(1*1e5+10);

// int SPF[N+5];

// void SOF()
// {
//     SPF[1] = 1;
//     for (int i=2; i<N; i++)
//         SPF[i] = i;
//     for (int i=4; i<N; i+=2)
//         SPF[i] = 2;
 
//     for (int i=3; i*i<N; i++)
//         {
//         if (SPF[i] == i)
//             {
//             for (int kon=i*i; kon<N; kon+=i)
//                 if (SPF[kon]==kon)
//                    SPF[kon] = i;
//             }
//         }
// }
int a[nax];
int n; 
int dp[nax]; 
int func(int ind)
{
	if(ind==(n-1))
		return 0;
	else if(dp[ind]!=-1) return dp[ind];
	else
	{
		int ans = 1e9+5; 
		for(int i = 1;i<=2;i++)
		{
			if(ind+i<n)
				ans = min(ans,abs(a[ind+i]-a[ind]) + func(ind+i));

		}
		return dp[ind] = ans; 
	}

}





signed main(){

int t=1; 
//cin >> t;
// string s; 
// getline(cin,s);

while(t--)
{
    cin >> n;
    for0(i,n) cin >> a[i]; 	
    ini(dp,-1); 
    cout << func(0); 

}

rr;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int mod = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
//解説
int main() {
    int n; cin >> n;
    vector<tuple<string, int, int> > a;
    for (int i = 1; i <= n; ++i) {
        string s;
        int p;
        cin >> s >> p; p = -p;
        a.push_back(tie(s, p, i));
    }
    sort(a.begin(), a.end());
    rep(i, n) cout << get<2>(a[i]) << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
  
 int n = read.to!int;
 int x = read.to!int;
    
 if(x == 1 || x == 2 * n - 1){
  "No".writeln;
  return;
 }
    
 "Yes".writeln;
    
 int[] ans;
 int a = n + x;
 if(a > 2 * n - 1) a -= 2 * n - 1;
 foreach(i; a .. n * 2) ans ~= i;
 foreach(i; 1 .. a) ans ~= i;
    
 ans.map!(to!string).array.join(" ").writeln;
}


Measured memory_bytes: 15356
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, Q;
int S[200000], T[200000], X[200000];
vector<pair<pair<int, int>, int>> v;
vector<pair<int, int>> D;
vector<int> t;
int ans[200000];
int main(){
	cin >> N >> Q;
	for(int i=0; i<N; i++){
		cin >> S[i] >> T[i] >> X[i];
		S[i] -= X[i];
		T[i] -= X[i];
		v.PB({ {S[i],T[i]},X[i] });
		t.PB(S[i]);
		t.PB(T[i]);
	}
	sort(v.begin(), v.end());
	for(int i=0; i<Q; i++){
		int d;
		cin >> d;
		D.PB({ d,i });
		t.PB(d);
	}
	sort(D.begin(), D.end());
	sort(t.begin(), t.end());
	t.erase(unique(t.begin(), t.end()), t.end());

	set<int> now;
	int idx1 = 0;
	int idx2 = 0;
	priority_queue<pair<int,int>> fin;
	for(int i=0; i<t.size(); i++){
		while(!fin.empty() && fin.top().first == -t[i]){
			now.erase(fin.top().second);
			fin.pop();
		}
		while(idx1 < N && v[idx1].first.first == t[i]){
			now.insert(v[idx1].second);
			fin.push({ -v[idx1].first.second,v[idx1].second });
			idx1++;
		}
		while(idx2 < Q && D[idx2].first == t[i]){
			if(now.size() == 0) ans[D[idx2].second] = -1;
			else ans[D[idx2].second] = *now.begin();
			idx2++;
		}
	}

	for(int i=0; i<Q; i++) cout << ans[i] << endl;
}

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

using namespace std;

map<string,long long int> m;

void process(string &s)
{
	vector<int> charCount(26,0);
	for(int i = 0; i<s.length(); i++)
			charCount[s[i]-'a']++;
	string sortedStr = "";
	for(int i = 0; i<26; i++)
	{
		for(int j = 0; j<charCount[i];j++)
		{
			sortedStr += ('a'+i);
		}
	}
	m[sortedStr]+=1;
}

int main()
{
	int n; cin>>n;
	string s;
	for(int i = 0; i<n; i++)
	{
		cin>>s;
		process(s);
	}

	long long int ans = 0;
	for(auto key: m)
	{
		long long int eq = m[key.first]-1;
		ans += (eq*(eq+1))/2;
	}

	cout<<ans;
	return 0;
}


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

int main(){
    int N,M; cin>>N>>M;
    vector<int> P(M+1),city(M+1);
    vector<vector<int>> Ms(N+1,vector<int>());
    
    for(int i=1; i<=M; i++){
        int x,y; cin>>x>>y;
        P[i]=x;
        city[i]=y;
        Ms[x].push_back(y);
    }

    for(int i=1; i<=N; i++){
        sort(Ms[i].begin() , Ms[i].end());
    }

    for(int i=1; i<=M; i++){
        cout << setfill('0') << setw(6) << right << P[i];
        auto ite = lower_bound(Ms[P[i]].begin(), Ms[P[i]].end(), city[i]);
        cout << setfill('0') << setw(6) << right << ite - Ms[P[i]].begin() + 1;
        cout << endl;
    }

}


Measured memory_bytes: 9444
(defun outer (l1 l2)
 (union (set-difference l1 l2)
        (set-difference l2 l1)))

(defun solve (l tl)
  (cond 
    ((null l) (if (null tl) "Yes" "No"))
    (t (solve (cdr l) (outer tl (list (car l)))))))

(defun main ()
  (let ((str (read-line)))
    (princ (solve (loop :as c 
                        :across str 
                        :collect c) 
                  '()))))

(main)
    
 

Measured memory_bytes: 3944
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
string s;
int k;
int32_t main()
{
        cin >> s >> k;
        for(int i = 0 ; i < sz(s) ; i ++)
        {
                int x = ('z' - s[i] + 1) % 26;
                if(x > k)
                        continue;
                s[i] = 'a' , k -= x;
        }
        if(k > 0)
                s.back() = (s.back() - 'a' + k % 26) % 26 + 'a';
        return cout << s << endl , 0;
}
                                                                                                                                                                                                          


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int n,k,mx,a[N];
int main() {
	n = rd(), k = rd();
	for (int _=1;_<=n;_++) a[_] = rd(), mx = max(mx, a[_]);
	int g = a[1];
	for (int _=2;_<=n;_++) g = __gcd(g, a[_]);
	if (k <= mx && (mx-k)%g == 0) puts("POSSIBLE"); else puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1000000000
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


int main(){
  ll N,i,ans;
  cin >> N;
  
  ll A[N];
  cin >> A[0];
  ans = A[0];
  
  for(i=1 ; i<N ; i++){
    cin >> A[i];
    ans = gcd(ans,A[i]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] += 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
const int maxn = 110;
int a[maxn];
bool cmp(int a, int b){
    return a>b;
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int tot = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        tot += a[i];
    }
    sort(a, a+n, cmp);
    bool flag = true;
    for(int i=0; i<m; i++){
        if(4*m*a[i] < tot){
            flag = false;
            break;;
        }
    }
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}




Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
  int N = nextInt();
  ArrayList<String> s = nextCharArray();
  String t = "";
  for(int i = 0; i < N / 2; i++){
    t += s.get(i);
  }
  if((t + t).equals(myconv(s, 0))){
    myout("Yes");
  }else{
    myout("No");
  }
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 37812
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        if(H%A==0)
        {
            System.out.println(H/A);
        }
        else
        {
            System.out.println(H/A+1);
        }
    }
}

Measured memory_bytes: 23764
n = int(input())
a = list(map(int, input().split()))

while True:
    m = min(a)
    for i in range(len(a)):
        if a[i] != m:
            a[i] = a[i] % m
    a.sort()
    z = a.count(0)
    a = a[z:]
    if min(a) == m:
        break
print(m)


Measured memory_bytes: 14252
import java.util.Scanner;

  public class Main{
  public static void main (String[] args){

  Scanner scanner= new Scanner(System.in);
  int n =scanner.nextInt();

  if(n%2==0){
  System.out.println(n);
  }else{
  System.out.println(2*n);
  }

  }

  }
  

Measured memory_bytes: 21844
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        s:String
    }
    let t = if s == String::from("Sunny") {
        String::from("Cloudy")
    } else if s == String::from("Cloudy") {
        String::from("Rainy")
    } else {
        String::from("Sunny")
    };
    println!("{}", t);
}


Measured memory_bytes: 4352
# encoding: utf-8
N = int(input())

ans = 10 ** 9 + 7

for A in range(1, N):
    B = N - A
    ans_tmp = 0
    for i in range(6):
        if A < 1: break
        ans_tmp += A % 10
        A = A // 10
    for i in range(6):
        if B < 1: break
        ans_tmp += B % 10
        B = B // 10
    if ans_tmp < ans: ans = ans_tmp

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    int n;
    cin>>n;
    ll k; cin>>k;
    int q;cin>>q;
    vector<ll> a(n,k);
    map<int,int> freq;
    int m = 0;
    for(int i=0;i<q;++i)
    {
        int x; cin>>x; x--;
        freq[x]++;
        m+=1;
    }
    for(int i=0;i<n;++i)
    {
        a[i]-=m;
        a[i]+=freq[i];
    }
    for(int i=0;i<n;++i)
    {
        if(a[i]>0)
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}

const int m=2019;
int main()
{
ll n;
cin>>n;
ll sum=0;
Rep(i,n+1){
    ll a=n/i;
    sum+=a*((a*i)+i)/2;
}
cout<<sum<<endl;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>//
using namespace std;
int main()
{

    long n,x;
    cin>>n;
    x=n%10;
    if(x==3)
    {
        cout<<"bon"<<endl;
    }
   else if(x==2||x==4||x==5||x==7||x==9)
        cout<<"hon"<<endl;
   else if(x==0||x==1||x==6||x==8)
        cout<<"pon"<<endl;

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
    
    ll test=1;//cin>>test;
    while(test--){
        string s;
        cin>>s;
        if(s.back()=='s'){
            s.push_back('e');
            s.push_back('s');
        }
        else {
            s.push_back('s');
        }
        cout<<s;

    }
    return 0;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    ll n,a,b;
    while(cin>>n>>a>>b){
        ll t = a + b;
        ll q = n/t; ll r = n%t;
        ll ans = q*a  + min(r, a);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
memo = {}
ans = 0

for a in A:
  ans += a
  if a in memo:
    memo[a] = memo[a] + 1
  else:
    memo[a] = 1
    
Q = int(input())

for _ in range(Q):
  B, C = map(int, input().split())
  
  if B in memo and memo[B] != 0:
    n = memo[B]
    memo[B] = 0
    ans -= B * n
    if C in memo:
      memo[C] += n
    else:
      memo[C] = n
    ans += C * n
    
    print(ans)
  else:
    print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	YES(regex_match(s,regex("A?KIHA?BA?RA?")));
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	var status string
	switch {
	case a-b >= 0:
		status = "delicious"
	case b-a > 0 && b-a <= x:
		status = "safe"
	case b-a > x:
		status = "dangerous"
	}
	fmt.Println(status)
}


Measured memory_bytes: 512
/*
[abc126] C - Dice and Coin
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N, K;

double solve() {
    double ans = 0;
    for (int k = 1; k <= N; k++) {
        int p = 0;
        while ((k << p) < K) {
            p++;
        }
        ans += pow(0.5, p);
    }
    ans /= N;

    return ans;
}

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

    cout << setprecision(15) << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

ll N, M;
vector<vector<int>> G;
vector<int> C;
vector<bool> V;

bool is_bigraph(int n) {
  bool is = true;

  for (int nn : G[n]) {
    if (C[nn] == C[n])
      return false;
    else {
      if (C[nn] == -1) {
        C[nn] = 1 - C[n];
        is = is && is_bigraph(nn);
      }
    }
  }

  return is;
}

int main(void) {
  cin >> N >> M;
  G.resize(N);
  C.assign(N, -1);
  V.assign(N, false);

  int a, b;
  rep(i, M) {
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  C[0] = 0;
  if (is_bigraph(0)) {
    ll B = 0, W = 0;
    rep(i, N) {
      B += (C[i] == 0);
      W += (C[i] == 1);
    }
    cout << B * W - M << endl;
  } else {
    cout << N * (N - 1) / 2 - M << endl;
  }

  return 0;
}


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

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

    unsigned int i = 0;
    while (i < S.size())
    {
        if (S.substr(i, 8) == "dreamera")
        {
            i += 5;
        }
        else if (S.substr(i, 7) == "dreamer")
        {
            i += 7;
        }
        else if (S.substr(i, 5) == "dream")
        {
            i += 5;
        }
        else if (S.substr(i, 6) == "eraser")
        {
            i += 6;
        }
        else if (S.substr(i, 5) == "erase")
        {
            i += 5;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
n = int(input())
a = input().rstrip()
b = input().rstrip()
c = input().rstrip()

cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]: continue
    elif a[i] != b[i] and a[i] != c[i] and b[i] != c[i]: cnt += 2
    else: cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long n,m,l[100500],r[100500],ll,rr=1000010,ans;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
   {
    cin>>l[i]>>r[i];
    ll=max(ll,l[i]);
    rr=min(rr,r[i]);
   }
    ans=rr-ll+1;
    if(ans<0) ans=0;
    cout<<ans;
	return 0;
}


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

int main()
{
  lli a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a==b)
  {
  		cout<<"YES"<<endl;return 0;
	}
	lli diff1=abs(b-a);
	lli diff2=(v*t)-(w*t);
	if(diff2>=diff1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
  	
  
 
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long k;
long long ans;
int main(){
    cin>>k;
    queue<long long > que;
    for(int i=1;i<=9;i++){
        que.push(i);

    }
    long long x=0;
    for(long long  i=0;i<k;i++){
        x=que.front();
        que.pop();
        if(x%10!=0){
            que.push((x*10)+(x%10)-1);
        }
        que.push(10*x+x%10);
        if(x%10!=9){
            que.push((x*10)+(x%10)+1);
        }
    }
    cout<<x;
    return 0;
}




Measured memory_bytes: 1792
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

string s, r;
int n;

int main() {
	cin >> n >> s >> r;
	for (int i = 0; i < n; i++) {
		if (s.substr(i, n - i) == r.substr(0, n - i)) {
			cout << n * 2 - (n - i) << endl;
			return 0;
		}
	}
	cout << n * 2 << endl;
//	cin >> n;
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{

    int N;
    bool ans = true;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin>>tmp;
        if(tmp%2==0){
            if(tmp%3==0||tmp%5==0){

            }else
            {
                ans = false;
            }
            
        }

    }
    
    if (ans)
    {
        cout << "APPROVED" << endl;
    }else
    {
        cout << "DENIED" << endl;
    }
    
    

}


Measured memory_bytes: 256
/*
题意是求一个序列中"所有子序列的中位数"所组成的序列的中位数 
看题解了，完全不会。https://www.cnblogs.com/quzhizhou/p/9535597.html  

首先我们先二分最后序列的中位数。设tot为中位数 >= mid的区间个数，若中位数序列的中位数 >= mid，
则有tot >= n(n+1)/4。
我们另外构造一个序列b[i], 当a[i]>=mid时b[i]=1, 否则bi=-1. 
那么若区间[l, r]的中位数 >= mid, 则b[l]+...+b[r] >= 0. 
于是我们求出序列b[i]的前缀和序列sum[i]，那么问题就变成了求满足l <= r且sum[r]-sum[l-1]>=0的数对(l,r)数量(0<=l,r<=n)，
这个问题可以用与求逆序对数量相似的方法解决. 树状数组即可. 
*/ 
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int NN = 110000;
int a[NN], l, r, n, mid, ans;
int s[NN * 2];  
//树状数组，注意，[-n-1, n], 为了让每一个存的值都是>0, 都加上n即可（因为树状数组不能从0开始）
//所以开双倍空间给数组 

int lowbit(int x){
	return x & (-x);
} 

void add1(int x, int k){
	while (x <= n * 2){
		s[x] += k;
		x += lowbit(x);
	}
}

int getsum(int x){
	int sum = 0;
	while (x > 0){
		sum += s[x];
		x -= lowbit(x);
	}
	return sum;
}
/*
bool check(int mid){
	//memset(s, 0, sizeof(s));  //树状数组清0 
	 for(int i=1;i<=2*n;i++)s[i]=0;
	//与求逆序对的方法相同 
	add1(n, 1);  //因为在每个数的基础上都加了n，所以这句话相当于在和等于0的点+1
	long long sum = 0;
	long long tmp = 0;
	for (int i=1; i<=n; i++){
		if (a[i] >= mid) sum++;
		else sum--;
		tmp += getsum(sum + n);
		add1(sum + n, 1);
	} 
	long long nn = n * (n + 1) / 4; //注意！nn必须给long long 
	if (tmp >= nn) return true;
	else return false;
}*/ 

int check(int mid)
{
    for(int i=1;i<=2*n;i++)s[i]=0;
    ll tot=0, sum=0;
    add1(n,1);
    for(int i=1;i<=n;i++){
        sum+=(a[i]>=mid?1:-1);
        tot+=getsum(sum+n);
        add1(sum+n,1);
    }
//    printf("%d %lld\n",mid,tot);
    return tot>=1ll*n*(n+1)/4;
}

int main(){
	//freopen("atcoderarc101d.in", "r", stdin);
	
	scanf("%d", &n);
	l = 0x7fffffff; r = 0;
	for (int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= r) r = a[i];
		if (a[i] <= l) l = a[i];
	}
	//printf("%d %d\n", l, r);
	/*while (l <= r){
		mid = (l + r) / 2;
		if (check(mid)){
			ans = mid; 
			l = mid + 1;
		} else r = mid-1;
	}
	printf("%d", ans);*/
	
	
	while(l<r){
        int mid=(l+r+1)>>1;
        if(check(mid))l=mid;
        else r=mid-1;
    }
    printf("%d\n",l);
	
	return 0;
} 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int a[4];
	for(int i = 1; i <= 3; i ++)
		cin >> a[i];
	int mn = 1e9;
	do
	{
		umin(mn, (int)((abs)(a[2]-a[1])+ (abs)(a[3]-a[2])));
	}while(next_permutation(a + 1, a + 4));
	cout << mn;



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

using namespace std;

#define endl '\n'
#define tab " "
#define lli long long int


void read(){
    lli T, D, P, ans;
    cin >> T >> D >> P;

    if(T >= P) ans = P + D;
    else if (T < P){
        if(D >= (P-T)) ans = P + D;
        else if (D < (P-T)) ans = T + D + D + 1;
    }

    cout << ans << endl;

    return;
}

int main(void){
    read();
    return 0;
}

Measured memory_bytes: 3600
N, K = map(int, input().split())

qs = 0
for i in range(1, N+1):
    if i >= K:
        qs += 1/N
    elif i < K:
        q = 1/N
        while i < K:
            q *= 1/2
            i *= 2
        qs += q
print(qs)

Measured memory_bytes: 9044
from sys import stdin
import sys

N = int(input())
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(N):
    a = input()
    if a == 'AC':
        c1 += 1
    elif a == 'WA':
        c2 += 1
    elif a == 'TLE':
        c3 += 1
    elif a == 'RE':
        c4 += 1
print("AC x ", c1)
print("WA x ", c2)
print("TLE x ", c3)
print("RE x ", c4)


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

int n;
int li[105];

int main()
{
   scanf("%d",&n);
   int cnt = 1;
   int ans = 0;
   for(int i=1;i<=n;i++)
   {
      scanf("%d",&li[i]);
      if(i==1) continue;
      if(li[i] == li[i-1])
      {
         cnt ++;
      }
      else
      {
         ans += cnt/2;
         cnt = 1;
      }
   }
   ans +=cnt/2;
   printf("%d\n",ans);
 	return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans =0;
    if (n>=3 && m>=3){
        ans += (n-2)*(m-2);
    }else if (n==1){
        ans = m-2;
    }else if (m==1){
        ans = n-2;
    }
    if (m==1 && n==1) {
        ans =1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256