akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int n, k;
vector<int> w;

// 最大積載量P の k台のトラック で n個の荷物を積めるか調べる
bool check(ll P) {
    int pt = 0;
    for (int ti = 0; ti < k; ti++) {
        ll sum = 0;
        while (pt < n && sum + w[pt] <= P) {
            sum += w[pt++];
        }
        if (pt == n) return true;
    }
    return false;
}

int binary_search() {
    ll ng = 0;
    ll ok = 100000 * 10000;     // 荷物の個数 x 1個あたりの最大重量
    ll mid;
    while (abs(ok - ng) > 1) {
        mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        w.push_back(t);
    }
    cout << binary_search() << endl;
    return 0;
}


Measured memory_bytes: 3536
# AtCoder Beginner Contest 044 - A
# -*- encoding: UTF-8 -*-
n = int(input())
k = int(input())
x = int(input())
y = int(input())

total = 0

if n > k :
  total = int((n - k) * y + k * x)

else :
  total = int(n * x)

print(total)


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

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

string str;
int ans;

class dice{
public:
	int con[6];
	int n[6];

	void res(){
		rep(i, 6) n[i] = con[i];
	}

	void E(){
		int t = n[0];
		n[0] = n[3];
		n[3] = n[5];
		n[5] = n[2];
		n[2] = t;
	}
	void W(){
		int t = n[0];
		n[0] = n[2];
		n[2] = n[5];
		n[5] = n[3];
		n[3] = t;
	}
	void S(){
		int t = n[0];
		n[0] = n[4];
		n[4] = n[5];
		n[5] = n[1];
		n[1] = t;
	}
	void N(){
		int t = n[0];
		n[0] = n[1];
		n[1] = n[5];
		n[5] = n[4];
		n[4] = t;
	}
	void spin(){
		int t = n[1];
		n[1] = n[2];
		n[2] = n[4];
		n[4] = n[3];
		n[3] = t;
	}
};


int main(){
	dice d1, d2;
	rep(i, 6) cin >> d1.n[i];
	rep(i, 6) cin >> d2.n[i];
	rep(i, 6){
		rep(j, 4){
			d1.spin();
			if (d1.n[0] == d2.n[0] && d1.n[1] == d2.n[1] && d1.n[2] == d2.n[2] && d1.n[3] == d2.n[3] && d1.n[4] == d2.n[4] && d1.n[5] == d2.n[5]){
				cout << "Yes" << endl;
				return 0;
			}
		}
		if (i % 2) d1.W();
		else d1.N();
	}
	cout << "No" << endl;
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n;
   cin >> n;
   set<int> s;
   rep (i, n) {
      int x;
      cin >> x;
      s.insert(x);
   }

   if (s.size()%2==0) {
      cout << s.size()-1 << endl;
   } else {
      cout << s.size() << endl;
   }

   return 0;
}

Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
flag = 0
flagcnt = 0
for i in a:
    if i % 2 == 0:
        flagcnt += 1
        if i % 3 == 0 or i % 5 == 0:
            flag += 1
if flag == flagcnt:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int t = S % 3600;
		int m = t / 60;
		int s = t % 60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26284
#include<stdio.h>

#define MAX_N 200000

/* kitaichi = (p*(p+1))/(2*p) */

int main(){
  int n, k;
  double p[MAX_N];
  int i, pi;
  double sum = 0, max;

  scanf("%d %d", &n, &k);
  for(i=0; i<n; i++){
    scanf("%d", &pi);
    p[i] = (double)(pi*(pi+1))/(2*pi);
  }

  for(i=0; i<k; i++){
    max += p[i];
  }
  sum = max;
  for(i=k; i<n; i++){
    sum -= p[i-k];
    sum += p[i];
    if(sum > max){
      max = sum;
    }
  }

  printf("%lf", max);
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value


void solve() {

	string S;
	cin >> S;

	for (int i = 0; i <S.length() - 1;i++){
		if (S[i] == S[i + 1]) {
			cout << "Bad" << endl;
			return;
		}
	}

	cout << "Good" << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
# しぐはキーボードを製作しました。シンプルさを極限まで追求したこのキーボードには、
# 0 キー、1 キー、バックスペースキーの 3 つしかキーがありません。
# 手始めに、しぐはこのキーボードで簡単なテキストエディタを操作してみることにしました。
# このエディタには常に一つの文字列が表示されます（文字列が空のこともあります）。
# エディタを起動した直後では、文字列は空です。キーボードの各キーを押すと、文字列が次のように変化します。
# 0 キー: 文字列の右端に文字 0 が挿入される。
# 1 キー: 文字列の右端に文字 1 が挿入される。
# バックスペースキー: 文字列が空なら、何も起こらない。そうでなければ、文字列の右端の 1 文字が削除される。
# しぐはエディタを起動し、これらのキーを何回か押しました。
# しぐが押したキーを順番に記録した文字列 s が与えられます。
# s の中の文字 0 は 0 キー、文字 1 は 1 キー、文字 B はバックスペースキーを表します。
# いま、エディタの画面にはどのような文字列が表示されているでしょうか？

s = gets
str = String.new
s.length.times do |i|
    case s[i]
    when "0"
        str += "0"
    when "1"
        str += "1"
    when "B"
        if str.length > 0
            str.chop!
        end
    end
end
puts str

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/11  Problem: ARC 091 D / Link: http://arc091.contest.atcoder.jp/tasks/arc091_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,a,k;

LL ans = 0LL;

LL grundy(LL p) {
	if (p%k == 0)return p / k;
	LL nx = p - (p / k) - 1;
	if (nx / k != p / k) {
		return grundy(nx);
	}
	LL x = p / k + 1;
	LL y = (p / k)*k;
	LL z = (p - y) / x;
	return grundy(p - x*z);
}

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

	cin >> N;
	FOR(i, 0, N) {
		cin >> a >> k;
		ans ^= grundy(a);
	}



	cout << (ans==0?"Aoki":"Takahashi") << "\n";

	return 0;
}


Measured memory_bytes: 256
a, b, c, x = int(input()), int(input()), int(input()), int(input())//50
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 10*i + 2*j + k == x:
        ans += 1
        
print(ans)

Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)
#define ps(x) cout << x << endl;
#define ps_end(x) ps(x); return;
#define eb emplace_back
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n, m;

void task() {
	cin >> n;
	cout << 360 / __gcd(360, n) << endl;
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3596
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,a,out=0,mi=1001001;
	cin>>n;
	rep(i,n){
		cin>>a;
		if(mi>a) out++;
		mi=min(mi,a);
	}
	cout<<out<<endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i] && b[i] == c[i]){
            //nothing to do
        }else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]){
            ans++;
        }else{
            ans += 2;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

class DAG {
    int n;
    vector<vector<int>> adj;
    vector<int> visited;

    void dfs(int v) {
        if (visited[v] == 2) {
            is_acyclic = false;
            return;
        } else if (!visited[v]) {
            visited[v] = 2;
            for (int s : adj[v]) {
                dfs(s);
            }
            visited[v] = 1;
            sorted.push_back(v);
        }
    }

public:
    vector<int> sorted;
    DAG(int n) : n(n), adj(n), visited(n) {}
    DAG(vector<vector<int>> &adj) : n(adj.size()), adj(adj), visited(adj.size()) {}
    bool is_acyclic = true;

    void add_arc(int a, int b) {
        assert(0 <= a && a < n && 0 <= b && b < n);
        adj[a].push_back(b);
    }

    void tsort() {
        for (int i = 0; i < n; i++) {
            if (!visited[i]) dfs(i);
        }
        reverse(sorted.begin(), sorted.end());
    }
};

int longest_path(const vector<vector<int>> &adj) {
    int n = adj.size();
    vector<vector<int>> inv(n);
    for (int a = 0; a < n; a++) {
        for (auto b : adj[a]) {
            inv[b].push_back(a);
        }
    }
    vector<int> len(n, -1);
    function<void(int)> set_len = [&](int v) {
        if (len[v] != -1) return;
        if (inv[v].empty()) {
            len[v] = 0;
            return;
        }
        int nax = 0;
        for (int u : inv[v]) {
            set_len(u);
            nax = max(nax, len[u]);
        }
        len[v] = nax + 1;
    };

    for (int i = 0; i < n; i++) {
        set_len(i);
    }

    return *max_element(len.begin(), len.end());
}

int main() {
    int n;
    cin >> n;

    vector<vector<int>> adj(n * (n - 1));
    auto get = [&](int a, int b) {
        if (a > b) swap(a, b);
        return a * n + b;
    };
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        int prev = get(i, a);
        for (int j = 0; j < n - 2; j++) {
            int b;
            cin >> b;
            b--;
            int cur = get(i, b);
//            cout << prev << ' ' << cur << endl;
            adj[prev].push_back(cur);
            prev = cur;
        }
    }

    DAG dag(adj);
    dag.tsort();
    if (!dag.is_acyclic) {
        cout << -1 << endl;
        return 0;
    }

    cout << longest_path(adj) + 1 << endl;
}

Measured memory_bytes: 129132
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int s, ans, l, r;
	bool v = true;
	ans = 0;
	scanf("%d %d",&n,&k);
	l = 1;
	r = n;
	f(i, k) {
		scanf("%d %d", &x, &y);
		l = max(l, x);
		r = min(r, y);
	}
	if (l > r)printf("0\n");
	else printf("%d\n", r - l + 1);


	return 0;
}

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

int n, w = 0;
double m, t = 0;
int a[100];

int main()
{
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		t += a[i];
	}

	for (int i = 0; i < n; i++)
		if ((double)a[i] >= t / (4 * m))
			w++;

	if (w >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
template<typename T>
struct UnionFind
{
	vector<T> par;
	vector<T> rank;
	UnionFind(T n):par(n),rank(n,0){
	   for(T i=0;i<n;i++){
	     par[i]=i;
	   }
	}
	T root(T x){
	  return par[x]==x?x:par[x]=root(par[x]);
	}

	bool unite(T x,T y){
	  if(x==y) return false;
	  x=root(x); y=root(y);
	  if(x==y) return false;
	  if(rank[x]<rank[y]) swap(x,y);
	  if(rank[x]==rank[y]) rank[x]++;
	  par[y]=x;
	  return true;
	}
	bool same(T x,T y){
	  return root(x)==root(y);
	}
};
int main(){
  ll n,k,l;
  cin>>n>>k>>l;
  UnionFind<ll> d(n+1);
  UnionFind<ll> t(n+1);
  rep(i,k){
    ll a,b;
    cin>>a>>b;
    d.unite(a,b);
  }
  rep(i,l){
    ll a,b;
    cin>>a>>b;
    t.unite(a,b);
  }
  map<pll,ll> p;
  for(int i=1;i<=n;i++){
    p[pll(d.root(i),t.root(i))]++;
  }
  for(int i=1;i<=n;i++){
    cout<<p[pll(d.root(i),t.root(i))]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 18048
import sys
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a == b:
    print("YES")
    sys.exit()

sa = abs(a-b)
approach_rate = v-w


if approach_rate * t >= sa:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61788
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) (((a) >> (b)) & 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;
vec a;

//Ｏ(log(max(a,b))
// aとbの最大公約数
int gcd(lint a, lint b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  cin >> N >> K;
  int g;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a.pb(tmp);

    if (i == 0) g = tmp;
    g = gcd(g, tmp);
  }

  sort(ALL(a));

  if (a[a.size() - 1] < K || K % g != 0) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << "POSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 1400
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
div_min = 10**5
idx = 0
for i in range(N):
    div = abs((T-H[i]*0.006) - A)
    if div_min > div:
        div_min = div
        idx =i+1

print(idx)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=3e5+10;
int a[N],n,ans,ans2;
bool check(int lim){
	int now=0;
	for (int i=2;i<=n;i+=2){
		now+=a[i-1]-a[i-2];
		if (now>=lim)now=max(now,a[i]);
	}
	return now+a[n]-a[n-1]>=lim;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),ans2+=a[i];
	if (~n&1){
		int sum1=0,sum2=0;
		for (int i=1;i<=n;i++)sum1+=a[i]*(i&1),sum2+=a[i]*(~i&1);
		cout<<max(sum1,sum2)<<' '<<min(sum1,sum2)<<endl;
		return 0;
	}
	for (int u=1<<30;u;u>>=1)
		if (check(ans+u))ans+=u;
	for (int i=2;i<=n;i+=2)ans+=a[i];
	cout<<ans<<' '<<ans2-ans<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, d;
    cin >> n >> d;
    int ans = (n+d*2) / (d*2+1);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si();
			if(n==0) break;
			int cnt2 = 0,cnt5 = 0;
			for (int i = 1; i <=n ; i++) {
				cnt2+=factorCnt(i,2);
				cnt5+=factorCnt(i,5);
			}
			out.println(Math.min(cnt2, cnt5));
		}
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}

	static int factorCnt(int n,int r){
		int cnt = 0;
		while(n%r==0){
			cnt++;
			n/=r;
		}
		return cnt;
	}
}

Measured memory_bytes: 19028
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  long int n,m;cin>>n>>m;
  vector<long int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<long int> a(m),b(m);
  //vector<vector<bool>> link(n,vector<bool>(n));
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    //link[a[i]-1][b[i]-1]=true;
    //link[b[i]-1][a[i]-1]=true;
  }
  
  vector<int> ans(n,1);
  for(int i=0;i<m;i++){
    if(h[a[i]-1]==h[b[i]-1]){
      ans[a[i]-1]=0;
      ans[b[i]-1]=0;
    }else if(h[a[i]-1]<h[b[i]-1]){
      ans[a[i]-1]=0;
    }else{
      ans[b[i]-1]=0;
    }
  }
  
  long int count=0;
  for(int i=0;i<n;i++){
    if(ans[i]){
      count++;
    }
  }
  
  
  cout<<count;
  
  
  return 0;
}

Measured memory_bytes: 5832
N = int(input())
A = list(map(int, input().split()))

num = [0] * (max(A) + 1)
for i in range(N):
    num[A[i]] += 1

ans = 0
M = len(num)
for i in range(M):
    m = num[i]
    if i > 0:
        m += num[i - 1]
    if i < M - 1:
        m += num[i + 1]
    ans = max(ans, m)
print(ans)


Measured memory_bytes: 13964
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


fn main() {
    input!{
        s: String,
    }
    let n = s.len();
    let mut ans = 0;
    for i in 0..n/2 {
        let ss = s.as_bytes();
        if ss[i] != ss[n - 1 - i] {
            ans += 1;
        }
    }
    println!("{}",ans);
}
                  

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

int main()
{
    string str;
    int a,b;
    cin >> a >> b >> str;
    if(a+b+1 != str.length())
    {
        cout << "No" << endl;
        return 0;
    }
    if(str[a] != '-')
    {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < str.length(); ++i)
    {
        if(i == a) continue;
        if(str[i] < '0' || str[i] > '9')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

long long k, a, b;
long long bis = 1;

int main()
{
	cin >> k >> a >> b;

	bool flag = false;

	if (a + 2 >= b || k < a + 1)
	{
		flag = true;
		bis += k;
		cout << bis << "\n";
		return 0;
	}
	
	k = k - a + 1;
	bis = a;

	bis += (k / 2) * (b-a);
	//bis -= (k / 2) * a;
	bis += (k % 2 != 0);

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

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem1188 : Hierarchical Democracy **/
string s; int pos;

int factor()
{
	vector<int> t;
	
	while (pos<s.size()) {
		if (isdigit(s[pos])) {
			int res=0;
			while (isdigit(s[pos])) {
				res*=10;
				res+=s[pos]-'0';
				pos++;
			}
			t.push_back((res+1)/2);
		} else if (s[pos] == '[') {
			pos++;
			t.push_back(factor());
		} else if (s[pos] == ']') {
			pos++;
			int res=0;
			sort(t.begin(), t.end());
			rep(i, (t.size()+1)/2) {
				res += t[i];
			}
			return res;
		}
	}
	return -1;
}

int main()
{
	int n;
	cin>>n;
	rep(i, n) {
		pos = 1;
		cin>>s;
		cout << factor() << endl;
	}
}

Measured memory_bytes: 1276
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N = i_input()

    l = []
    for i in range(1,math.ceil(sqrt(N))+1):
        if N % i == 0:
            l.append(i)

    ans = INF
    for i in l:
        b = N//i
        c = max(i,b)
        ans = min(ans, len(str(c)))
    print(ans)


if __name__=="__main__":
    main()


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

int main() {
    int n, y; cin >> n >> y;

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n - i; j++) {
            int k = n - i - j;
            if(i * 10000 + j * 5000 + k * 1000 == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int, input().split())

#余弦定理を用いる
#a**2 = b**2 + c**2 −2*b*c*cosA
#a = sqrt(b**2 + c**2 −2*b*c*cosA)
#b,cはOK。cosAを求める。

#時針の角度を求める
hour_hand_angle = 30*H + M/2 #360*H/12 + 360/12*M/60
minute_hand_angle = 360*M/60

#成す角の最小を考える
if hour_hand_angle == 180:
    angle_between_hour_and_minute = 180
elif hour_hand_angle > 180:
    if hour_hand_angle <= minute_hand_angle < 360:
        angle_between_hour_and_minute = minute_hand_angle - hour_hand_angle
    elif 0 <= minute_hand_angle <= hour_hand_angle - 180:
        angle_between_hour_and_minute = 360 - hour_hand_angle + minute_hand_angle
    else:
        angle_between_hour_and_minute = hour_hand_angle - minute_hand_angle
elif hour_hand_angle < 180:
    if 0 <= minute_hand_angle <= hour_hand_angle:
        angle_between_hour_and_minute = hour_hand_angle - minute_hand_angle
    elif hour_hand_angle < minute_hand_angle <= hour_hand_angle + 180:
        angle_between_hour_and_minute = minute_hand_angle - hour_hand_angle
    else:
        angle_between_hour_and_minute = 360 - minute_hand_angle + hour_hand_angle

print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(angle_between_hour_and_minute))))

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;

    int sum = 0;
    for (int i = 0; i < 9; i ++) {
      int t; cin >> t;
      sum += t;
    }
    cout << n - sum << endl;
  }
}


Measured memory_bytes: 3076
//https://atcoder.jp/contests/abc149/tasks/abc149_c
//
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

bool is_prime(const ll n){
    switch(n){
    case 0: // fall-through
    case 1: return false;
    case 2: return true;
    }
    if(n%2 == 0) return false;
    //i=3から奇数のみ調べる
    for(ll i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }
    return true;
}

int main() {
    ll X; cin>>X;
    while(!is_prime(X)){
        ++X;
    }
    cout<<X<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int heights[n];
    int dp[n];
    for (int i = 0; i < n; i++) {
        cin >> heights[i];
    }
    dp[0] = 0;
    dp[1] = abs(heights[1] - heights[0]);
    for (int i = 2; i < n; i++) {
        int x = dp[i-1] + abs(heights[i-1] - heights[i]);
        int y = dp[i-2] + abs(heights[i-2] - heights[i]);
        dp[i] = min(x, y);
    }
    cout <<  dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 4368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin >> n >> m;
    ll ans=min(n,m/2);
    n-=ans;
    m-=2*ans;
    if(n==0){
        ans+=m/4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
import java.util.*
import kotlin.math.max


fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun bitFullSearch(n: Int): List<BitSet> = (0 until (1 shl n)).map { bit ->
    BitSet(n).apply {
        repeat(n) { i ->
            set(i, bit and (1 shl i) > 0)
        }
    }
}

fun main() {
    val n = readLine()?.toInt() ?: return
    val ff = mutableListOf<List<Int>>()
    repeat(n) {
        val f = intList()
        ff.add(f)
    }
    val pp = mutableListOf<List<Int>>()
    repeat(n) {
        val p = intList()
        pp.add(p)
    }
    val bit = bitFullSearch(10)
    var m = Long.MIN_VALUE
    bit.drop(1).forEach { b ->
        var t = 0L
        ff.forEachIndexed { i, fff ->
            var c = 0
            fff.forEachIndexed { j, ffff ->
                if (b.get(j) && ffff == 1) {
                    c++
                }
            }
            t += pp[i][c]
        }
        m = max(m, t)
    }
    println(m.toString())
}

Measured memory_bytes: 43708
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int visited[200000] = {0};
vector<vector<int> > v(200000);
int dfs(int x)
{
    int ans = 0;
    if(visited[x]==0)
    {
        visited[x] = 1;
        ans++;
        int a = v[x].size();
        for(int j = 0;j<a;j++)
        {
            int data = v[x][j];
            ans = ans + dfs(data);
        }
    }
    return ans;
}
void primefactors(int n)
{
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";

}
double fib(int n)
{
    double sol1,sol2;
    sol1 = (1 + sqrt(5))/2;
    sol2 = (1 - sqrt(5))/2;
    sol1 = pow(sol1,n);
    sol2 = pow(sol2,n);
    double ans = sol1 - sol2;
    ans = ans/sqrt(5);
    //ans = int(ans);
    return ans;
}
int digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
int main()
{
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    string ans = "";
    fi(i,n)
    {
        ans += a[i];
        ans += b[i];
    }
    cout<<ans;


}


Measured memory_bytes: 7796
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

template<class T> void readin(T & x)
{
	x = 0;
	int f = 1, ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = x * 10 - '0' + ch;
		ch = getchar();
	}
	x *= f;
}

int N, P[200050];
int f[200050];

void solve()
{
	for(int i = 1; i <= N; i++)
	{
		f[ P[i] ] = f[ P[i] - 1 ] + 1;
	}
	printf("%d\n", N - (* max_element(f + 1, f + N + 1)));
}
int main()
{
	readin(N);
	for(int i = 1; i <= N; i++)
	{
		readin(P[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

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

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

string DIR = "NSWE";

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

    string s; cin >> s;
    int mask = 0;
    for(char c : s) mask |= 1<<DIR.find(c);

    int d1 = (mask>>2)&3;
    int d2 = mask&3;

    bool res = (d1 == 0 || d1 == 3) && (d2 == 0 || d2 == 3);
    cout << (res ? "Yes" : "No") << endl;

    return 0;
}


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

typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp1(a,b,c) P1(a,P(b,c))

int main(){
	while(1){
		int n;
		scanf("%d",&n);
        if(n == 0)break;
        
        set<P1> S1;
        set<P1> S2;
        S1.insert(mp1(0,-1,1000000001));
        S2.insert(mp1(-1,0,1000000001));
        
        for(int i = 0 ; i < n ; i ++){
            char c;
            cin >> c;
            //scanf("\n%c",&c);
            if(c == 'W'){
                int l,s;
                scanf("%d%d",&l,&s);
                set<P1>::iterator itr = S2.lower_bound(mp1(-1,0,0));
                while(1){
                    if(itr->sc.sc > s){
                        S1.insert(mp1(itr->sc.fr,l,s));
                        S1.insert(mp1(itr->sc.fr+s,itr->fr,itr->sc.sc-s));
                        S1.erase(mp1(itr->sc.fr,itr->fr,itr->sc.sc));
                        S2.insert(mp1(l,itr->sc.fr,s));
                        S2.insert(mp1(itr->fr,itr->sc.fr+s,itr->sc.sc-s));
                        S2.erase(itr);
                        break;
                    }
                    else {
                        S1.insert(mp1(itr->sc.fr,l,itr->sc.sc));
                        S1.erase(mp1(itr->sc.fr,-1,itr->sc.sc));
                        S2.insert(mp1(l,itr->sc.fr,itr->sc.sc));
                        s -= itr->sc.sc;
                        S2.erase(itr++);
                    }
                    if(s == 0)break;
                }
            }
            else if(c == 'D'){
                int l;
                scanf("%d",&l);
                set<P1>::iterator itr = S2.lower_bound(mp1(l,0,0));
                while(1){
                    S1.insert(mp1(itr->sc.fr,-1,itr->sc.sc));
                    S1.erase(mp1(itr->sc.fr,l,itr->sc.sc));
                    S2.insert(mp1(-1,itr->sc.fr,itr->sc.sc));
                    S2.erase(itr++);
                    if(itr->fr != l)break;
                }
            }
            else {
                int p;
                scanf("%d",&p);
                set<P1>::iterator itr = S1.upper_bound(mp1(p+1,-1,0));
                printf("%d%c",(--itr)->sc.fr,10);
            }
        }
        printf("%c",10);
    }
}

Measured memory_bytes: 3712
#include<stdio.h>

int main(void)
{
	int i,j,k,l;
	int flag=0;
	
	scanf("%d",&i);
	for(;i>0;i--)
	{
		scanf("%d %d %d",&j,&k,&l);
		if(j*j+k*k==l*l||k*k+l*l==j*j||l*l+j*j==k*k)
		{
			flag = 1;
		}
		if(flag==1)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		flag=0;
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
long long a[maxn];
int main(){
//	freopen("A.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	long long l=2,r=2;
	for(int i=n;i>=1;i--){
		r=r-r%a[i];
		r=r+a[i]-1;
		l+=((a[i]-l%a[i])%a[i]);
		if(l>r){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n",l,r);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { for (TT t : vec) cin >> t; }


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int x, n,a,b=0;
	cin >> x >> n;
	set<int>se;
	rep(i, n) {
		cin >> a;
		se.insert(a);
	}
	while (1) {
		if (!se.count(x - b)) {
			cout << x - b << endl;
			return 0;
		}
		if (!se.count(x + b)) {
			cout << x + b << endl;
			return 0;
		}
		b++;
	}
}


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

stack<int> stk;

int main()
{
	char ch;
	while (cin >> ch)
	{
		if (isdigit(ch)) {
			cin.unget(); 
			int i; cin >> i; stk.push(i);
			continue;
		}
		
		int a = stk.top(); stk.pop();
		int b = stk.top(); stk.pop();
		switch(ch)
		{
			case '+': stk.push(a + b); break;
			case '-': stk.push(b - a); break;
			case '*': stk.push(a * b); break;
		}
	}
	cout << stk.top() << endl;
}



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

int main() {
	int n,alice=0,bob=0,tmp=0,f;
	vector<int>card(100);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> card.at(i);
	}
	if (n % 2 == 0) {//偶数のとき
		for (int i = 0; i < n / 2; i++) {
			for (int i = 1; i < n; i++) {
				if (card.at(i) < card.at(i - 1) && tmp < card.at(i - i)) {
					tmp = card.at(i - 1);
					f = i - 1;

				}
				else if (tmp < card.at(i)) {
					tmp = card.at(i);
					f = i;
				}
			}
			//cout << f<<"aliceのfの値"<<endl;
			alice += tmp;
			card.at(f) = 0;
			tmp = 0;
			for (int i = 1; i < n; i++) {
				if (card.at(i) < card.at(i - 1) && tmp < card.at(i - i)) {
					tmp = card.at(i - 1);
					f = i - 1;

				}
				else if (tmp < card.at(i)) {
					tmp = card.at(i);
					f = i;
				}
			}
			//cout << f << "bobのfの値" << endl;
			bob += tmp;
			card.at(f) = 0;
			tmp = 0;
		}
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			for (int i = 1; i < n; i++) {
				if (card.at(i) < card.at(i - 1) && tmp < card.at(i - i)) {
					tmp = card.at(i - 1);
					f = i - 1;

				}
				else if (tmp < card.at(i)) {
					tmp = card.at(i);
					f = i;
				}
			}
			//cout << f << "aliceのfの値" << endl;
			alice += tmp;
			card.at(f) = 0;
			tmp = 0;
			for (int i = 1; i < n; i++) {
				if (card.at(i) < card.at(i - 1) && tmp < card.at(i - i)) {
					tmp = card.at(i - 1);
					f = i - 1;

				}
				else if (tmp < card.at(i)) {
					tmp = card.at(i);
					f = i;
				}
			}
		    //cout << f << "bobのfの値" << endl;
			bob += tmp;
			card.at(f) = 0;
			tmp = 0;
		}//偶数のとき+1回、fによる初期化が無効になる
	
	}	
	for (int i = 1; i < n; i++) {
		if (card.at(i) < card.at(i - 1) && tmp < card.at(i - i)) {
			//cout << tmp << "tmp変化前" << endl;;
			//cout << card.at(i - 1) << "i-1の値"<<endl;
			tmp = card.at(i - 1);
			f = i - 1;
			//cout << tmp <<"tmpの値a"<< endl;
			//cout << card.at(i) << "iの値" << endl << card.at(i - 1) << "i-1の値" << endl;
			//cout << f << endl;


		}
		else if (tmp <= card.at(i)) {
			tmp = card.at(i);
			f = i; 
			//cout << tmp << "tmpの値b" << endl;
			//cout << card.at(i) << "iの値" << endl << card.at(i - 1) << "i-1の値" << endl;
			//cout << f << endl;

		}
	}
	//cout << f << "aliceのfの値" << endl;
	alice += tmp;
	card.at(f) = 0;
	tmp = 0;
	//cout << alice << endl << bob<<endl ;
	int dif = alice - bob;
	cout<< dif;
}


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

using namespace std;
typedef long long ll;
int main(){
	ll n,m,d; cin>>n>>m>>d;
    if(d==0){
        printf("%.11f",(double)(m-1)/n);
    }
    else{
        printf("%.11f",(double)(m-1)*2*(n-d)/(n*n));
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> ans(n + 2, 0);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        ans[p[i]] = i;
    }
    int tmp = 1;
    int res = 1;
    for (int i = 1; i < n; i++) {
        if (ans[i+1] > ans[i]) tmp++;
        else tmp = 1;
        res = max(res, tmp);
    }
    cout << n - res << endl;
}

Measured memory_bytes: 1792
h,w,d = (int(i) for i in input().split())
a = [[int(i) for i in input().split()] for i in range(h)]
q = int(input())
r = [[int(i) for i in input().split()] for i in range(q)]
b,c = a[0],[]
for i in range(h*w): c.append([0,i])
for i in a[1:]: b+=i
for i in range(h*w):
	c[b[i]-1][1] = i
for i in range(d+1,h*w+1):
	x = abs(c[i-1][1]%w-c[i-d-1][1]%w)+abs((c[i-1][1]-c[i-1][1]%w)//w-(c[i-d-1][1]-c[i-d-1][1]%w)//w)
	c[i-1][0] = c[i-d-1][0]+x
for i in r:
	print(c[i[1]-1][0]-c[i[0]-1][0])

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

using namespace std;
typedef long long ll;

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

	int n, k, c;
	string s;

	cin >> n >> k >> c >> s;

	int L[k], R[k];

	int cur = 0;

	memset(L, -1, k);
	memset(R, -1, k);

	for(int i = 0; i < k; i++){
	
		for(; cur < n; cur++){
			if(s[cur] == 'o'){
				L[i] = cur;
				cur += c + 1;
				break;
			}
		}
	
	}
	cur = n-1;
	for(int i = k-1; i >= 0; i--){
	
		for(; cur >= 0; cur--){
			if(s[cur] == 'o'){
				R[i] = cur;
				cur -= c + 1;
				break;
			}
		}
	
	}

	// for(int i = 0; i < k; i++)
	// 	cout << L[i] << ' ' << R[i] << '\n';

	bool e = false;
	for(int i = 0; i < k; i++)
		if(L[i] == R[i] && L[i] != -1){
			e = true;
			cout << L[i] + 1<< '\n';
		}
	if(!e)
		cout << '\n';
	return 0;
}

/*template < typename T >
long long modexp(T a, T b, T p) {
	// returns a to the power b mod p by modular exponentiation

	long long res = 1;
	long long mult = a % p;
	while (b > 0) {
		if (b & 1) {
			res = (res * mult) % p;
		}
		b >>= 1;
		mult = (mult * mult) % p;
	}

	return res;
}*/

/*int primeModInverse(int a, int n) {
	// returns inverse of a mod n by mod exponentiation, use only if n is prime
	return (int) modexp(a, n - 2, n);
}*/

/*template < typename T >
T gcd(T a, T b) {

	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);

}*/


Measured memory_bytes: 5176