akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) v.begin(),v.end()

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
ll 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;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];
int main(){
    int n,m; cin >> n >> m;
    string ans;
    if (n == m) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

    long long a;
    cin >> a;
    bool cont = true;

    for(int i = 0; i < N-1; i++){
        long long b;
        cin >> b;

        long long x = a;
        long long y = b;

        if(a < b){
            long long tmp = a;
            a = b;
            b = tmp;
        }

        long long r = a%b;
        while(r != 0){
            a = b;
            b = r;
            r = a%b;
        }

        a = x*(y/b);
    }

    cout << a << endl;

    return 0;
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

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


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int d,t,s;
        cin>>d>>t>>s;
        if(t*s>=d)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  cin >> n;
  vector<int> ans;
  ll sum = 0, cnt = 0, two = 1;
  while (n != sum) {
    ll temp = (n-sum)/two;
    int s = ((temp %2) + 2) % 2;
    ans.emplace_back(s);
    if (cnt % 2 == 0) sum += two*s;
    else sum -= two*s;
    cnt++;
    two *= 2;
  }
  reverse(all(ans));
  rep(i,(int)ans.size()) cout << ans[i];
  if (ans.size() == 0) cout << 0;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3664
n,m = map(int,input().split())
A = [int(input()) for i in range(m)]+[n+1]

cur_step = 0
steps = []
ans = 1
for a in A:
	if a-cur_step == 0:
		ans = -1
		break
	if a == 1:
		steps.append(1)
		cur_step = 2
		continue
	steps.append(a-1-cur_step)
	cur_step = a+1
#ごり押しパターン計算
pat = [1,2]
inf = 10**9+7
while len(pat) < max(steps):
	pat.append((pat[-1]+pat[-2])%inf)

if ans == -1:
	print(0)
else:
	for step in steps:
		if step == 0:
			continue
		ans = (ans*pat[step-1])%inf
	print(ans)

Measured memory_bytes: 7848
import java.util.Scanner;

    public class Main{
        public void solve(){
		int n,k,zero,ichi;
		ichi = 0;
		zero = 0;
        Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		while(n!=0){
			for(int i=0;i<n;i++){
				k = sc.nextInt();
				if(k<=1){
					ichi++;
				}
				if(k<=0){
					zero++;
				}
			}
			if(n==ichi){
				System.out.println("NA");
			}else{
				System.out.println(n-zero+1);
			}
			n=sc.nextInt();
			ichi = 0;
			zero = 0;
		}
        }
    public static void main(String[]args){
    Main obj = new Main();
    obj.solve();
    }
    }

Measured memory_bytes: 158404
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    int n,x;
    cin >> n >> x;
    int l[n];
    rep(i,0,n) cin >> l[i];
    int ans = 1;
    int d = l[0];
    int prev = 0;

    rep(i,1,n+1){
        
        if(d+prev <= x){
            ans++;
            prev = d + prev;
            if(i != n) d = l[i];
        }else{
            break;
        }
    }
    cout << ans << endl;

}

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

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

S = [0]*M
C = [0]*M
for i in range(M):
    S[i], C[i] = map(int, input().split())

result = 0
flag = True
a = [-1]*N
for i in range(M):
    if (a[S[i]-1] != -1 and a[S[i]-1] != C[i]) or (N != 1 and S[i] == 1 and C[i] == 0):
        flag = False
        break
    if a[S[i]-1] == -1:
        a[S[i]-1] = C[i]
        result += C[i]*(10**(N-S[i]))

if flag:
    if N != 1 and result < 10**(N-1):
        result += 10**(N-1)
    print(result)
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize(3)
#endif
#define ls (rt<<1)
#define rs (rt<<1)|1
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e6+100;
const int mod=1e9+7;
char str[maxn], str2[maxn];
bitset<maxn> a, b;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define pb push_back

using namespace std;

int main() {
	int n, t, val = 0, s[300000], cnt[300000], temp, ada[300000];
	vector<int> tambah;
	set<int> masih, done;
	set<int>::iterator it, ti;
	scanf("%d", &n);
	t = (1 << n);
	for (int i = 0; i < t; i++)
		scanf("%d", &s[i]);
	sort(s, s + t);
	memset(cnt, 0, sizeof cnt);
	memset(ada, 0, sizeof ada);
	for (int i = 0; i < t; i++) {
		temp = s[i];
		masih.insert(val);
		while (i < t) {
			if (s[i] != temp)
				break;
			s[i++] = val;
			cnt[val]++;
		}
		i--;
		val++;
	}
	cnt[val - 1]--;
	if (cnt[val - 1] < 1)
		masih.erase(val - 1);
	done.insert(val - 1);
	ada[val - 1]++;
	while (n--) {
		tambah.clear();
		for (it = done.begin(); it != done.end(); it++) {
			val = *it;
			for (int i = 0; i < ada[val]; i++) {
				ti = masih.lower_bound(val);
				if (ti == masih.begin()) {
					puts("No");
					return 0;
				}
				ti--;
				temp = *ti;
				cnt[temp]--;
				if (cnt[temp] == 0)
					masih.erase(temp);
				tambah.pb(temp);
			}
		}
		for (int i = 0; i < (int) tambah.size(); i++) {
			temp = tambah[i];
			ada[temp]++;
			if (ada[temp] == 1)
				done.insert(temp);
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <map>
#include <math.h>

using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b); i >= (b); --i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define repr1(i, n) for (int i = (n); i > 0; --i)
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const int found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, ull p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  rep(_,t) solve();
  return 0;
}

void solve() {
  int W,H,x,y;
  scanf("%d%d%d%d", &W, &H, &x, &y);

  printf("%.10f %d", double(W) * H / 2, x * 2 == W && y * 2 == H);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    map<int,int> ct;
    rep(i,n) {
        int x; cin >> x;
        ct[x]++;
    }
    vint x;
    for (auto itr = ct.begin(); itr != ct.end(); itr++) {
        if (itr->second >= 2) x.push_back(itr->first);
    }
    sort(rall(x));
    if (x.size() == 0) cout << 0 << endl;
    else if (x.size() == 1) {
        if (ct[x[0]] >= 4) cout << (ll)x[0]*x[0] << endl;
        else cout << 0 << endl;
    }
    else if (x.size() >= 2) {
        if (ct[x[0]] >= 4) cout << (ll)x[0]*x[0] << endl;
        else cout << (ll)x[0]*x[1] << endl;
    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  set<char> st;
  for(int i = 0; i < k; ++i){
    char c; cin >> c;
    st.insert(c);
  }
  for(;;){
    string s = to_string(n);
    bool f = true;
    for(auto e:s){
      f &= st.find(e) == st.end();
    }
    if(f)break;
    n++;
  }
  cout << n << endl;
}


Measured memory_bytes: 3632
H, W = gets.chomp.split.map(&:to_i)
HW_MAX = 10**5
answer = HW_MAX

1.upto(H - 1) do |i|
  a = i * W
  b = ((H - i) / 2) * W
  c = (((H - i) / 2) + ((H - i) % 2)) * W

  if ([a, b, c].max - [a, b, c].min) < answer
    answer = [a, b, c].max - [a, b, c].min
  end

  a = i * W
  b = (W / 2) * (H - i)
  c = ((W / 2) + (W % 2)) * (H - i)

  if ([a, b, c].max - [a, b, c].min) < answer
    answer = [a, b, c].max - [a, b, c].min
  end
end

1.upto(W - 1) do |i|
  a = i * H
  b = ((W - i) / 2) * H
  c = (((W - i) / 2) + ((W - i) % 2)) * H

  if ([a, b, c].max - [a, b, c].min) < answer
    answer = [a, b, c].max - [a, b, c].min
  end

  a = i * H
  b = (H / 2) * (W - i)
  c = ((H / 2) + (H % 2)) * (W - i)

  if ([a, b, c].max - [a, b, c].min) < answer
    answer = [a, b, c].max - [a, b, c].min
  end
end

puts answer

Measured memory_bytes: 1788
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n = I()
    a = sorted(LI(), reverse=True)
    r = 0
    for i in range(n):
        r += a[i*2+1]

    return r



print(main())


Measured memory_bytes: 41916
inf = float('inf')

# distの初期化: dist = [inf for _ in range(N)]; dist[start] = 0
# True - >正常に更新, False -> 負閉路有り
def bellmanford(dist,edges,N):
    for i in range(N):
        for v ,nv, w in edges:
            if dist[nv] > dist[v] + w:
                dist[nv] = dist[v] + w
                # 頂点数Nなら更新は高々N-1回で済む
                # N回目に更新を行うなら負閉路があるということ
                if i == N-1 and nv == N-1:
                    return False
    return True

N,M = map(int,input().split())
info = []
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1; b -= 1; c = -c
    info.append((a,b,c))
 
dist = [inf for _ in range(N)]
dist[0] = 0

flag = bellmanford(dist,info,N)
ans = -dist[N-1] if flag is True else "inf"
print(ans)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,x; cin>>n>>x;
  vll a(n);
  rep(i,n){
    ll b; cin>>b;
    a[i]=abs(b-x);
  }
  
  ll ans=ngcd(a);
  cout<<ans<<endl;
  
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a=0,w=0,t=0,r=0;
    for(int i=0; i<n; i++){
      string s;
      cin>>s;
      switch (s[0])
      {
      case 'A':
        a++;
        break;
      case 'W':
        w++;
        break;
      case 'T':
        t++;
        break;
      case 'R':
        r++;
        break;
      default:
        break;
      }
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
}

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

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

    int n;
    cin >> n;

    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];

    auto trim = [&](const vector<pair<int, int>> &as, int k) {
        vector<pair<int, int>> ret;
        for (auto &p : as) {
            if (p.second <= k) {
                ret.emplace_back(p);
                k -= p.second;
                if (k == 0) break;
            } else {
                ret.emplace_back(p.first, k);
                break;
            }
        }
        return ret;
    };

    auto increment = [&](vector<pair<int, int>> as, int k) {
        if (as.size() == 1 && as[0].first == k - 1) return vector<pair<int, int>>();
        if (as.back().first != k - 1) {
            auto t = as.back();
            as.pop_back();
            if (t.second > 1) {
                as.emplace_back(t.first, t.second - 1);
                as.emplace_back(t.first + 1, 1);
            } else {
                as.emplace_back(t.first + 1, 1);
            }
        } else {
            auto t = as.back();
            as.pop_back();
            auto u = as.back();
            as.pop_back();
            if (u.second > 1) {
                as.emplace_back(u.first, u.second - 1);
                as.emplace_back(u.first + 1, 1);
            } else {
                as.emplace_back(u.first + 1, 1);
            }
            as.emplace_back(0, t.second);
        }
        vector<pair<int, int>> ret;
        for (auto &p : as) {
            if (ret.empty() || ret.back().first != p.first) {
                ret.emplace_back(p);
            } else {
                ret.back().second += p.second;
            }
        }
        return ret;
    };

    auto ok = [&](int k) -> bool {
        vector<pair<int, int>> cur = {{0, as[0]}};
        for (int i = 1; i < n; i++) {
            if (as[i - 1] < as[i]) {
                if (cur.back().first == 0) {
                    cur.back().second += as[i] - as[i - 1];
                } else {
                    cur.emplace_back(0, as[i] - as[i - 1]);
                }
            } else {
                cur = trim(cur, as[i]);
                cur = increment(cur, k);
                if (cur.empty()) return false;
            }
        }
        return true;
    };

    int l = 0, r = n;
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (ok(m)) {
            r = m;
        } else {
            l = m;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

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

    set < string > used;
    vector < string > ans;
    for (int i = 0; i < (int)s.size(); i++) {
        int max_k = min(5, (int)s.size() - i);
        for (int j = 1; j <= max_k; j++) {
            string st = s.substr(i, j);
            if (used.find(st) == used.end()) {
                ans.push_back(st);
                used.insert(st);
            }
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans[K - 1] << endl;

    return 0;
}


Measured memory_bytes: 1792
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
AB = 2*c*max(x,y)
A_AB = 10**11
AB_B = 10**11
if x-y > 0:
  A_AB = a*(x-y)+2*c*y
if y-x > 0:
  AB_B = 2*c*x+b*(y-x)

ans = min(A_B,A_AB,AB_B,AB)
print(ans)


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

using namespace std;

int main(){
  string s;
  cin >> s;
  int ans_1=0;
  int ans_2=0;
  bool flag=true;
  for(int i=0;i<s.size();i++){
    if(flag){
      if(s.at(i) != '0'){
        ans_1++;
      }
      if(s.at(i) != '1'){
        ans_2++;
      }
    }
    else{
      if(s.at(i) != '1'){
        ans_1++;
      }
      if(s.at(i) != '0'){
        ans_2++;
      }
    }
    flag = !flag;
  }

  cout << min(ans_1, ans_2) << endl;
  return 0;
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m+1]={};
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x;
        for(int j=0;j<x;j++)
        {
            cin>>y;
            ++a[y];
        }
    }
    int ans=0;
    for(int i=0;i<=m;i++)
        if(a[i]==n) ++ans;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string s;

char k[] = "keyence";
void solve(){
	int ml = 0;
	int mr = 0;
	int c = 0;
	rep(i, s.size()){
		if(s[i] == k[c]){
			c++;
			chmax(ml,c);
		}
		else break;
		if(c == 7) break;
	}
	c = 0;
	repr(i, s.size()){
		if(s[i] == k[6 - c]){
			c++;
			chmax(mr,c);
		}
		else break;
		if(c == 7) break;
	}
	if(ml + mr >= 7)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

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

		solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
double o(double*a,double*b,double*c){
	return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);
}
double x,p[8];
int i;
int main(void){
	for(;~scanf("%lf,",p+i++%8);)
		i%8||(x=o(p,p+2,p+4),puts(x*o(p+2,p+4,p+6)>0&&x*o(p+4,p+6,p)>0&&x*o(p+6,p,p+2)>0?"YES":"NO"));
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) (v).begin(), (v).end()

int main () {
	int n; cin >> n;
	vint a(n);
	rep(i,n) cin >> a[i];
	sort(be(a));
	reverse(be(a));
	long long ans=0;
	rep(i,n-1) {
		int k=(i+1)/2;
		ans+=a[k];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4044
N = int(input())
H = [int(x) for x in input().split()]

count = []
current_count = 0
for x in range(N - 1):
    if H[x] >= H[x + 1]:
        current_count += 1
    else:
        count.append(current_count)
        current_count = 0
count.append(current_count)

print(max(count))

Measured memory_bytes: 14252
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := true
	cntr := make(map[rune]int)
	for _, c := range s {
		cntr[c]++
	}
	for _, cnt := range cntr {
		if cnt != 2 {
			ans = false
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<Integer> set = new HashSet<>();
    for(int i = 0; i < n; i++){
      set.add(sc.nextInt());
    }
    System.out.println(set.size());
  }
}

Measured memory_bytes: 23252
import sys
import math
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = 0
bob = 0
for i in range(0, len(li) - 1, 2):
    alice += li[i]
    bob += li[i + 1]
if (len(li) % 2 != 0):
    alice+=li[-1]
print(alice-bob)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll c = 0;
	for (int z=1;z<=sqrt(n);z++){
		if (n % z == 0){
			ll q1 = n/z;
			ll k1 = n/z-1;
			ll k2 = n/q1-1;
			if (k1 != 0 && n/k1 == n%k1){
				c += k1;
			}
			if (q1 == z) continue;
			if (k2 != 0 && n/k2 == n%k2){
				c += k2;
			}
		}
	}
	cout << c << endl;
	cin >> n;
}

Measured memory_bytes: 256
fun main() {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }

    var current = 1000L

    for (i in 0 until N - 1) {

        var stock = 0L
        if (A[i] < A[i + 1]) {
            stock = current / A[i]
        }
        current += (A[i + 1] - A[i]) * stock
    }
    print(current)
}


Measured memory_bytes: 36532
#include <stdio.h>
#define MAX 100

int main(){ 

	int i;
    int n = 0;
	char str[MAX];
  
   	scanf("%s", str);

    // printf("%s", str);

    for(i=0; i<(MAX-7); i++){
        if(str[i-7]=='F' && str[i-6]=='E' && str[i-5]=='S'&& str[i-4]=='T' 
        && str[i-3]=='I' && str[i-2]=='V' && str[i-1]=='A' && str[i]=='L') {
            n = i - 7;
        }
    }




    for(i=0; i<n; i++){
        printf("%c", str[i]);
    }



return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<int>A(N);
	rep(i, 0, N)cin >> A[i];
	vector<int>ans(N, 0);
	rep(i, 0, N) {
		if (i - A[i] < 0)ans[0]++;
		else ans[i - A[i]]++;
		if (i + A[i] + 1 < N)ans[i + A[i] + 1]--;
	}
	rep(i, 1, N) {
		ans[i] += ans[i - 1];
	}
	rep(j, 0, K - 1) {
		A = ans;
		ans.assign(N, 0);
		rep(i, 0, N) {
			if (i - A[i] < 0)ans[0]++;
			else ans[i - A[i]]++;
			if (i + A[i] + 1 < N)ans[i + A[i] + 1]--;
		}
		int cnt = (ans[0] == N ? 1 : 0);
		rep(i, 1, N) {
			ans[i] += ans[i - 1];
			if (ans[i] == N)cnt++;
		}
		if (cnt == N)break;
	}
	rep(i, 0, N) {
		cout << ans[i];
		if (i != N - 1)cout << " ";
		else cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 4788
#include <iostream>

using namespace std;

const int MAX_N = 3 * 100000;

int main() {
	int n;
	string s;

	cin >> n;
	cin >> s;

	int E[MAX_N];
	int W[MAX_N];
	int sum = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			sum++;
		}
		E[i] = sum;
	}

	sum = 0;

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'E') {
			sum++;
		}
		W[i] = sum;
	}

	int ans = MAX_N;

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			ans = min(ans, W[i + 1]);
		}
		else if (i == n - 1) {
			ans = min(ans, E[i - 1]);
		}
		else {
			ans = min(ans, W[i + 1] + E[i - 1]);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll n, a, b,ans;
	cin >> n >> a >> b;
	ans = b * (n-1)+a - a * (n-1)-b + 1;
	if (a > b)
		ans = 0;
	if (n == 1 && a != b)
		ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector> 
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define int long long

signed main() { 
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double rad = 2 * M_PI * (h / 12.0 + m / 720.0 - m / 60.0); 
 
    double ans = sqrt(a * a + b * b  - 2 * a * b * cos(rad));

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 4116
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,w_max;
	cin>>n>>w_max;
	ll w[n+1],v[n+1];
	
	for (int i = 1; i <=n; ++i)
		cin>>w[i]>>v[i];
	
	ll dp[n+1][w_max+1];
	
	for(int i=0;i<=n;i++){
		for(int j=0;j<=w_max;j++){
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(w[i]<=j)
				dp[i][j] = max(v[i] + dp[i-1][j-w[i]], max(dp[i][j-1], dp[i-1][j]));
			else
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
		}
	}
	cout<<dp[n][w_max]<<'\n';
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl

#define int long long
using ll = long long;
const ll mod = LLONG_MAX;

int n,k;
int a[100010];
signed main(){
  cin>>n>>k;
  rep(i,n)cin>>a[i];

  sort(a,a+n);
  bool flag=false;
  bool flag2=false;

  if(k>a[n-1]){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  int temp=a[0];
  for(int i=0;i<n-1;i++){
    temp=__gcd(temp,a[i+1]);
  }

  for(int i=0;i<n;i++){
    if((a[i]%temp)!=0){
      flag=true;
    }
  }
  rep(i,n){
    if(a[i]==k)flag=true;
  }
  rep(i,n-1){
    if(a[i]!=a[i+1])flag2=true;
  }

  if(k%temp==0 && k<=a[n-1] && flag2)flag=true;


  if(!flag){
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<"POSSIBLE"<<endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	int width = 0;
	int high = 0;
	int radius = 0;
	int x = 0;
	int y = 0;
	static const int INPUT_WHR_MIN = 0;
	static const int INPUT_WHR_MAX = 100;
	static const int INPUT_XY_MIN = -100;
	static const int INPUT_XY_MAX = 100;
	cin >> width;
	cin >> high;
	cin >> x;
	cin >> y;
	cin >> radius;
     
	assert (INPUT_WHR_MIN < width && width <= INPUT_WHR_MAX); /* Precondition */
	assert (INPUT_WHR_MIN < high && high <= INPUT_WHR_MAX); /* Precondition */
	assert (INPUT_XY_MIN <= radius && radius <= INPUT_XY_MAX); /* Precondition */
	assert (INPUT_XY_MIN <= x && x <= INPUT_XY_MAX); /* Precondition */
	assert (INPUT_XY_MIN <= y && y <= INPUT_XY_MAX); /* Precondition */
 
	/* Calculatoin */
	if((radius <= y && y <= high - radius)&&(radius <= x && x <= width - radius)){
		cout << "Yes" << endl;	
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,W;
    cin>>n>>W;
    //vector<int> v(n),w(n);
    //rep(i,n) cin>>v[i]>>w[i];
    int dp[W+10]={0};
    rep(i,n){
        int v,w;
        cin>>v>>w;
        for(int i=w;i<=W;i++){
            if(i-w>=0) dp[i]=max(dp[i],dp[i-w]+v);
            //else dp[i]=dp[i-1];
        }
    }
    //rep(i,W+1) cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<dp[W]<<endl;
    return 0;
}


Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int K = sc.nextInt();
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			final int X = (A + K - 1) / K * K;
			
			if(A <= X && X <= B) {
				System.out.println("OK");
			}else {
				System.out.println("NG");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); i++)
int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i], v[i]--;
	vector<int> a(n);
	a[0] = 1;
	int nxt = v[0];
	int cnt = 0;
	while(true) {
		// cout << nxt << " " << cnt << endl;
		if(nxt == 1) {
			cout << ++cnt << endl;
			return 0;
		}
		if(a[nxt]) {
			cout << -1 << endl;
			return 0;
		}
		a[nxt] = 1;
		nxt = v[nxt];
		cnt++;
	}
}

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

using namespace std;

double dp[105][105];

int main(){
  int N,T,L,B;
  while(cin >> N >> T >> L >> B, N) {
    memset(dp,0,sizeof(dp));
    vector<int> grid(N+1);
    for(int i=0;i<L;++i) {
      int l; cin >> l;
      grid[l]=-1;
    }
    for(int i=0;i<B;++i) {
      int b; cin >> b;
      grid[b]=1;
    }
    dp[0][0]=1;
    for(int i=0;i<T;++i) {
      for(int j=0;j<N;++j) {
        for(int k=1;k<=6;++k) {
          int next=j+k;
          if(next>N) next=2*N-next;
          if(grid[next]==-1) dp[i+2][next]+=dp[i][j]/6;
          else if(grid[next]==1) dp[i+1][0]+=dp[i][j]/6;
          else dp[i+1][next]+=dp[i][j]/6;
        }
      }
    }
    double ans=0;
    for(int i=1;i<=T;++i) ans+=dp[i][N];
    printf("%.10f\n",ans);
  }
  
  return 0;
}


Measured memory_bytes: 3276
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

d = [[A[i][j] for i in range(N)]for j in range(N)]

for k in range(N):#wwa-ssyarru
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])

for i in range(N):#言われた通りに直でつなげるだけで最短炉更新されたらもう無理
    for j in range(N):
        if A[i][j]!=d[i][j]:
            print(-1)
            exit()

ans = 0
#経由で=のとこ合ったらそこはつかわない
for i in range(N):
    for j in range(N):
        ok = True
        for k in range(N):
            if k == i or k == j:
                continue
            if d[i][j]==d[i][k]+d[j][k]:
                ok=False
        if ok:
            ans+=d[i][j]

print(ans//2)


Measured memory_bytes: 93272
from sys import stdin
import heapq

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

for i in range(n):
    li[i] = li[i]*(-1)

heapq.heapify(li)

for i in range(m):
    a = heapq.heappop(li)*(-1)
    a = a//2
    heapq.heappush(li,a*(-1))

li.sort()
print(sum(li)*(-1))

Measured memory_bytes: 14180
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

int main() {
	ll n; cin >> n;
	ll o = 0;
	ll e = 0;
	rep(i, 0, n) {
		ll a; cin >> a;
		if (a & 1) {
			o++;
		}
		else {
			e++;
		}
	}
	if (o & 1)cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a;
 	cin >> a;
 	if(a<1200){
 		cout << "ABC" << endl;
 	}else if(a<2800){
 		cout << "ARC" << endl;
 	}else{
 		cout << "AGC" << endl;
 	}
 }

Measured memory_bytes: 256
N = gets.to_i
h = gets.split.map(&:to_i)

dp = [10 ** 9] * N

dp[0] = 0
dp[1] = (h[0] - h[1]).abs

1.upto(N - 1) do |n|
  dp[n] = [dp[n - 2] + (h[n - 2] - h[n]).abs, dp[n - 1] + (h[n - 1] - h[n]).abs, dp[n]].min
end

puts dp[N - 1]

Measured memory_bytes: 21000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, h;
    cin >> n >> h;

    vector<int> b(n);
    int m = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a >> b[i];
        m = max(m, a);
    }

    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());

    int k = 0;
    for (int i = 0; i < n && b[i] > m && h > 0; i++) {
        k++;
        h -= b[i];
    }

    if (h > 0) k += (h + m - 1) / m;

    cout << k << endl;

    return 0;
}

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

using namespace std;
const int base = 1e9 + 7;

long long h, w, n, node[1000000], cnt = 0;

int main() {
    //freopen("in.txt", "r",stdin);
    //freopen("out.txt", "w", stdout);
    cin >> h >> w >> n;
    while(n--) {
        long long a, b;
        cin >> a >> b;
        for(int i = -2; i <= 0; i++) {
            for(int j = -2; j <= 0; j++) {
                if(a + i >= 1 && a + i <= h - 2) {
                    if(b + j >= 1 && b + j <= w - 2) {
                        node[cnt++] = base * (a + i) + (b + j);
                    }
                }
            }
        }
    }
    sort(node, node + cnt);
    int tmp = 1;
    long long zero = (h - 2) * (w - 2);
    long long ans[10] = {0};
    for(long long i = 0; i < cnt; i++) {
        if(node[i] == node[i + 1]) tmp++;
        else {
            ans[tmp]++;
            zero--;
            tmp = 1;
        }
    }
    cout << zero << endl;
    for(int i = 1; i < 10; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
vector<pair<int, int>> to[100005];
vector<int> color(100005);
void dfs(int a, int p = -1)
{
    for (auto e : to[a])
    {
        if (e.first == p)
            continue;
        color[e.first] = (e.second % 2 == 0 )? color[a] : (1 - color[a]);
        dfs(e.first, a);
    }
}
int main()
{
    int n;
    cin >> n;
    rep(i, n-1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        to[u].emplace_back(v, w);
        to[v].emplace_back(u, w);
    }
    dfs(0);
    rep(i, n)
    {
        cout << color[i] << endl;
    }
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

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

  ll x = std::min(B - 1, N);
  std::cout << A * x / B << '\n';
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <memory.h>

int ch(int i){
	switch(i){
		case 0:return 'S';
		case 1:return 'H';
		case 2:return 'C';
		case 3:return 'D';
	}
}

int main(void){
	int a[4][14],c,i,j,n;
	char b;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %c %d",&b,&c);
		if(b=='S')
			a[0][c]=1;
		else if(b=='H')
			a[1][c]=1;
		else if(b=='C')
			a[2][c]=1;
		else
			a[3][c]=1;
	}
	for(i=0;i<=3;i++){
		for(j=1;j<=13;j++){
			if(a[i][j]==0)
				printf("%c %d\n",ch(i),j);
		}
	}
	return 0;
}

Measured memory_bytes: 596