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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

class UnionFind {
private:
    int n;
    vector<int> uni;
public:
    UnionFind(int _n) {
        n = _n;
        uni.clear();
        uni.resize(n, -1);
    }
    int root(int x) {
        if (uni[x] < 0) return x;
        return uni[x] = root(uni[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (uni[x] > uni[y]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;
    }
    void print() {
        for (auto x : uni) cout << x << " ";
        cout << endl;
    }
};

struct edge {
    int from, to, cost;
    edge(){}
    edge(int _from, int _to, int _cost) : from(_from), to(_to), cost(_cost) {}
    bool operator< (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to < e.to : from < e.from) : cost < e.cost;
    }
};

class Kruskal {
private:
    int n;
    vector<edge> edges;
    UnionFind uf;
public:
    Kruskal(int _n) : n(_n), uf(UnionFind(n)) {}
    void addEdge(int _from, int _to, int _cost) {
        edges.emplace_back(_from, _to, _cost);
    }
    int calc() {
        sort(all(edges));
        int res = 0;
        for (auto &e : edges) {
            if (!uf.same(e.from, e.to)) {
                uf.unite(e.from, e.to);
                res += e.cost;
            }
        }
        return res;
    }
};

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

    int n;
    cin >> n;
    Kruskal kr(n);
    rep(i, n) {
        rep(j, n) {
            int c;
            cin >> c;
            if (c == -1) c = 1e9;
            kr.addEdge(i, j, c);
        }
    }
    cout << kr.calc() << endl;
}

Measured memory_bytes: 3436
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=[A[i]-A[i-1] for i in range(N)]
    # print(B)
    K = sum(A)//(N*(N+1)//2)
    if(K*(N*(N+1)//2) != sum(A)):
        print("NO")
        return
    ans = True
    for b in B:
        b-=K
        # print(b)
        if(b%N!=0 or b>0):
            ans = False
    if(ans):
        print("YES")
    else:
        print("NO")
if __name__ == '__main__':
    main()

Measured memory_bytes: 84588
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var yen = 0;
        var bitcoin = 0.0;
        for (int i = 0; i < n; i++)
        {
            var val = Console.ReadLine().Split(' ').ToArray();
            if (val[1] == "JPY")
            {
                yen += int.Parse(val[0]);
            }
            else
            {
                bitcoin += double.Parse(val[0]);
            }
        }

        Console.WriteLine(yen + bitcoin * 380000.0);
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int A[25];
		for(int i=0;i<N;i++){
			cin>>A[i];
		}
		int c = 32;
		for(int i=0;c!=0;i++){
			c = max(c-(c-1)%5,0);
			printf("%d\n",c);
			if(c==0) break;
			c = max(c-A[i%N],0);
			printf("%d\n",c);
		}
	}
	return 0;
}

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

int n, k; // how many stones are left
bool dp[100005];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if ( i - a[j] >= 0 && dp[i - a[j]] == false) {
                dp[i] = true;
            }
        }
    }
    puts(dp[k] ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  ll ans=0;
  ll maxi=a[0];
  for(int i=1;i<n;i++){
    if(maxi>a[i])
      ans+=maxi-a[i];
    else 
      maxi=a[i];
  }
  cout<<ans<<endl;
}

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

using namespace std;
#define lint long long


int main() {
    int N, A, B;
    string s;
    cin >> N >> A >> B;
    
    cin >> s;
    
    int ca = 0;
    int cb = 0;
    
    for(int i = 0; i < N; ++i){
        if(s[i] == 'a'){
            
            if(ca + cb < A + B){
                ++ca;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if(s[i] == 'b') {
            
            if(ca + cb < A + B && cb < B){
                ++cb;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void){
  int A,P;
  scanf("%d %d",&A,&P);
  int apple,partapple,countpart,pie;
  apple = A,partapple = P;
  countpart = apple * 3;
  partapple = partapple + countpart;

  pie = partapple / 2;
  printf("%d\n",pie);
  return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    s=parseInt(readline())
    arr=Vector{Int}([s])
    res=s
    ans=1
    while true
        if res%2==0
            res=div(res,2)
        else
            res=3*res+1
        end
        ans+=1
        for i in 1:length(arr)
            if res==arr[i]
                println(ans)
                exit(0)
            end
        end
        push!(arr,res)
    end
end
main()

Measured memory_bytes: 165364
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
#define mytz __builtin_ctzll
const int inf = 2147483647;
const double eps = 1e-10;
int n;
double ans,in;
int main()
{
	read(n);
	while(n--){
		scanf("%lf",&in);
		ans += 1.0 / in + eps;
	}
	cout << 1.0 / ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.size()-1; i++) {
    if(s[i]==s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	std::string s;
	std::cin >> s;
	if(s=="RSR") {
		print(1);
		return 0;
	}
	int ans=0;
	for(char c:s) if(c=='R') ans++;
	print(ans);
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int r, s, p;
int score(char c){
  if(c=='s') return r;
  if(c=='r') return p;
  if(c=='p') return s;
  return 0;
}

int main(void){

  int n, k;
  std::string t;
  std::cin >> n >> k >> r >> s >> p >> t;

  llint result = 0;

  for(int i=0; i<k; i++){
    char prev = 'a';
    int prev_cnt = 0;
    for(int j=i; j<n; j+=k){
      if(t[j] == prev){
	prev_cnt++;
      }else{
	result += score(prev) * ((prev_cnt+1)/2);
	prev = t[j];
	prev_cnt = 1;
      }
      //std::cout << t[j];
    }
    result += score(prev) * ((prev_cnt+1)/2);
    //std::cout << std::endl;
    //std::cout << result << std::endl;
  }
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 512
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	std::cout << (std::min(A, B) + std::min(C, D)) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long  long
using namespace std;
int main()
{
	ll h,n,x,sum=0;
	cin>>h>>n;
	while(n--)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>=h) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
X,K,D = map(int,input().split())
# 原点に近い位置までの移動回数を求める
count = abs(X) // D
ans = 0
# Kの方が小さければ可能な限り原点に近い位置を求める
if count>K:
    ans = abs(X) - D * K
else:
	# 残りの移動回数が偶数
    if (K-count)%2==0:
        ans = abs(X) % D
    # 残りの移動回数が奇数
    else:
        ans = abs(abs(X) % D - D)
print(ans)


Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
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;}

bool isPrime(int N) {
  if(N==1) return false;
  if(N==2) return true;
  if(N%2==0) return false;
  for(int i=3; i*i < N; i+=2) {
    if(N%i == 0) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X; cin >> X;
  for(int i=X; ;++i) {
    if(isPrime(i)) {
      cout << i <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
/**
*    created: 12.07.2020 02:01:25
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int w, h, n;
    cin >> w >> h >> n;
    int xmax = 200;
    int ymax = 200;
    int xmin = 0;
    int ymin = 0;
    rep(i,n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) chmax(xmin,x);
        if (a == 2) chmin(xmax,x);
        if (a == 3) chmax(ymin,y);
        if (a == 4) chmin(ymax,y);
    }
    chmin(ymax,h);
    chmin(xmax,w);
    if (xmin >= xmax || ymin >= ymax) {cout << 0 << endl; return 0;}
    else {
        cout << (ymax-ymin)*(xmax-xmin) << endl;
        return 0;
    } 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> e(n + 1);
  e[0] = 0;
  rep(i, n) {
    double p;
    cin >> p;
    e[i + 1] = e[i];
    e[i + 1] += (p + 1) / 2;
  }
  double ans = 0;
  rep(i, n - k + 1) { ans = max(ans, e[i + k] - e[i]); }
  printf("%f\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>    //万能头文件
using namespace std;
string  st;
int ans;        //记录次数
bool    flag = true;    //用来标记是否能构造回文
int main()
{
    cin >> st;
    int L=0,R = st.size() - 1;  //定义左、右端
    while ( L <= R )    //运行到字符串中间
    {
        if ( st[L] == st[R] ) {L++,R--;continue;}
        if ( st[L] == 'x' ) {L++,ans++;continue;}
        if ( st[R] == 'x' ) {R--,ans++;continue;}
        flag = false; break;
    }
    ans = flag ? ans : -1;  
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
pos_num = []
for i in range(n+2):
    st_num = int((i*(i-1))/2)
    ed_num = int(((2*n-i+1)*i)/2)
    # print(i,st_num,ed_num)
    pos_num.append(ed_num-st_num+1)
print(sum(pos_num[k:])%(10**9+7))

    




Measured memory_bytes: 21192
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

typedef pair<int,int> P;
typedef long long int ll;

ll M,N;

int main(){

  ios_base::sync_with_stdio(false);
  cin>>N>>M;

  ll cnt=0;
  if(0 <= M-2*N){
    cnt += N;
    M -= 2*N;
    cnt += floor(M/4);
  }
  else{
    cnt += floor(M/2);
  }
  cout<<cnt<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
#define YES "YES"
#define NO "NO"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX = 510000;

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

// 二項係数計算
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 H,W,A,B;
int main(){
    cin >> H >> W >> A >> B;
    if(H > W) swap(H,W), swap(A,B);
    COMinit();
    ll ans = 0;
    ll i = H - A, j = B + 1;
    while(1){
        ll com1 = COM(i-1+j-1,i-1);
        ll com2 = COM(W-j+H-i,W-j);
        ans += (com1*com2)%MOD;
        i--,j++;
        if(i==0 || j== W+1) break;
    }
    pr(ans%MOD);
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll n, m;
    cin >> n >> m;
    vi a(n);
    ll total = 0;
    REP(i, n) {
        ll t;
        cin >> t;
        total += t;
        a[i] = t * 4 * m;
    }
    ll cnt = count_if(begin(a), end(a), [&total](ll x) -> bool { return x >= total; });
    string ans;
    if (cnt >= m)
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(),S.end());

    vector<pair<int,string>> P(N);
    
    int Count = 0;
    for(int i = 1; i < N; i++){
        if(i == 1){
            P[i-1] = make_pair(-1*Count,S[i-1]);
            //cout << P[i-1].first << " " << P[i-1].second << endl;
        }
        if(S[i] == S[i-1]){
            Count++;
            P[i] = make_pair(-1*Count,S[i]);
            //cout << P[i].first << " " << P[i].second << endl;
        }
        else{
            Count = 0;
            P[i] = make_pair(-1*Count,S[i]);
            //cout << P[i].first << " " << P[i].second << endl;
        }
    }
    sort(P.begin(),P.end());
 
    for(int i = 0; i < N; i++){
        if(P[0].first != P[i].first) break;
        cout << P[i].second << endl;
    }
}

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

int main(){
    int x, y, i=1;

    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        
        if(x > y) cout << y << " " << x << endl;
        else cout << x << " " << y << endl;
    }

    return 0;
}


Measured memory_bytes: 3044
defmodule Main do
  def main do
    [x, _n] = IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)

    list = IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)

    case Enum.member?(list, x) do
      false ->
        IO.puts(x)

      true ->
        [bottom_target, bottom_count] = search_bottom(x - 1, list, 1)
        [top_target, top_count] = search_up(x + 1, list, 1)

        cond do
          top_count == bottom_count ->
            IO.puts(bottom_target)

          top_count > bottom_count ->
            IO.puts(bottom_target)

          true ->
            IO.puts(top_target)
        end
    end
  end

  defp search_bottom(target, list, count) do
    case Enum.member?(list, target) do
      true ->
        search_bottom(target - 1, list, count + 1)

      false ->
        [target, count]
    end
  end

  defp search_up(target, list, count) do
    case Enum.member?(list, target) do
      true ->
        search_up(target + 1, list, count + 1)

      false ->
        [target, count]
    end
  end
end

Measured memory_bytes: 30788
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int g[20][20];
int32_t main()
{
	int n=in();int k,x,y;
	memset(g,-1,sizeof g);
	for(int i=0;i<n;i++)
	{
		k=in();
		while(k--)
		{
			x=in();y=in();
			g[i][--x]=y;
		}
	}
	int ans=0;
	for(int mask=0;mask<(1LL<<n);mask++)
	{
		bool ok=1;
		vector<int> d(n);
		for(int i=0;i<n;i++)
		{
			if(mask&(1LL<<i))d[i]=1;
		}
		for(int i=0;i<n;i++)
		{
			if(!d[i])continue;
			
			for(int j=0;j<n;j++)
			{
				if(g[i][j]==-1)continue;
				if(g[i][j]!=d[j])ok=0;
			}
			
		}
		if(ok)ans=max(ans,(int)__builtin_popcountll(mask));
		
	}
	cout<<ans;
	
	
	
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair

void solve() {
    int k, a, b;
    cin >> k >> a >> b;
    cout << ((a + k - 1) / k * k <= b ? "OK" : "NG");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3648
import sys

def prime(maximum):
    sieve = [True] * (maximum + 1)

    def sieved(prime):
        for not_prime in range(prime + prime, len(sieve), prime):
            sieve[not_prime] = False

    sieve[0] = sieve[1] = False
    sieved(2)
    for x in range(3, int(maximum ** 0.5) + 1, 2):
        if sieve[x]: sieved(x)
    return [prime for prime, is_prime in enumerate(sieve) if is_prime]

count = 0
numbers = []
for line in sys.stdin:
    numbers.append(int(line))
    count += 1

counts = []
for i in range(count):
    counts.append(0)

for prime in prime(1000000):
    if prime > 999999:
        break
    for i in range(count):
        if prime <= numbers[i]:
            counts[i] += 1

for count in counts:
    print(count)

Measured memory_bytes: 18576
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	double p = 3.141592653589793;
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	h = h + (double)m / 60;

	double hx = a * sin(double(h) * 2 * p / 12);
	double hy = a * cos(double(h) * 2 * p / 12);
	double mx = b * sin(double(m) * 2 * p / 60);
	double my = b * cos(double(m) * 2 * p / 60);

	//double ans = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));

	double ans = sqrt(pow(hx - mx,2) + pow(hy - my, 2));
	cout << std::setprecision(15) << ans << endl;
}




Measured memory_bytes: 4164
#include<cstdio>
#include<cstring>
char a[10010];
bool c, f;
int main()
{
    scanf("%s",a);
    for(int i=0;i<strlen(a);i++)
    {
        if(a[i]=='C')
        {
            c=true;
        }
        if(a[i]=='F'&&c==true)
        {
            f=true;
        }
    }
    if(f==true)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
 
    for (int i = 1; i < N; i++) {
      if (A[i - 1] < A[i]) {
        A[i]--;
      } 
      else {
        if (A[i - 1] != A[i]) {
          System.out.println("No");
          return;
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 49708
#include <stdio.h>
#include <string.h>

int
main(int argc, char **argv)
{
	char *weakday[] = {"","SAT","FRI","THU","WED","TUE","MON","SUN"};
	char input[4];
	int i;

	(void)scanf("%s", input);
	for (i = 0; i <= 7; i++) {
		if (strcmp(weakday[i], input) == 0)
			break;
	}
	(void)printf("%d\n", i);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n,k;
	cin>>n>>k;
	lli a[n],i;
	fr(i,n)
	{
		cin>>a[i];
	}
	double b[n],sum=0,ans=0;
	fr(i,n)
	{
		b[i]=(float)(a[i]+1)/2;
	}
	fr(i,k)
	{
		sum+=b[i];
	}
	ans=sum;
	for(i=k;i<n;i++)
	{
		sum-=b[i-k];
		sum+=b[i];
		ans=max(ans,sum);
	}
	cout<<fixed<<setprecision(8)<<ans;
	
	return 0;
}

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

int main() {

    vector<int> v(3);

    cin >> v[0] >> v[1] >> v[2];

    int ans = 0;

    while(1){

        if(v[0] == v[1] && v[1] == v[2]){
            break;
        }

        ans++;

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

        if(v[0] == v[1]){
            v[0]++;
            v[1]++;
        }
        else{
            v[0] += 2;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

a, b = sieve(10**5+3)
X = int(input())

idx = bisect.bisect_left(b, X)
if b[idx] == X:
  ans = X
else:
  ans = b[idx]

print(ans)

Measured memory_bytes: 4220
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define flash_all ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;


int main()
{
	flash_all;
	ll n,i,ac=0,re=0,tle=0,wa=0;
	string s;
	cin>>n;
	while(n--){
		cin>>s;
		for(i=0;i<s.size();i++){
			if(s[i]=='A' && s[i+1]=='C'){
				ac++;
			}
			else if(s[i]=='R' && s[i+1]=='E'){
				re++;
			}
			else if(s[i]=='T' && s[i+1]=='L' && s[i+2]=='E'){
				tle++;
			}
			else if(s[i]=='W' && s[i+1]=='A'){
				wa++;
			}
		}
	}
	cout<<"AC x "<<ac<<nl;
	cout<<"WA x "<<wa<<nl;
	cout<<"TLE x "<<tle<<nl;
	cout<<"RE x "<<re<<nl;
}
//Happy Coding........

Measured memory_bytes: 3644
N, M = map(int, input().split())
paths = [list(map(int, input().split())) for _ in range(M)]

minimumScore = [float('inf') for _ in range(N)]
minimumScore[0] = 0
for _ in range(N-1):
    flag = False
    for a, b, c in paths:
        c = -c
        if minimumScore[a-1] == -float('inf'):
            continue
        if minimumScore[a-1] + c < minimumScore[b-1]:
            minimumScore[b-1] = minimumScore[a-1] + c
            flag = True
    if not flag:
        break


negative = [False for i in range(N)]
for _ in range(N):
    for a, b, c in paths:
        c = -c
        if negative[a-1]:
            negative[b-1] = True
        if minimumScore[a-1] == -float('inf'):
            continue
        if minimumScore[a-1] + c < minimumScore[b-1]:
            negative[b-1] = True
            flag = True
if negative[-1]:
    print('inf')
else:
    print(-minimumScore[N-1])
#print(minimumScore[-1])


Measured memory_bytes: 47576
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;

void solve(){
    int h , a;
    cin>>h>>a;
    cout<<(h + a - 1) / a<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] x = new int[N];
    int[] y = new int[N];
    
    for (int i = 0; i < N; i++) {
      x[i] = Integer.parseInt(sc.next());
      y[i] = Integer.parseInt(sc.next());
    }
    
    int X = 2 * factorial(N-1);
    
    double totalDist = 0;
    for (int i = 0; i < N-1; i++) {
      for (int j = i + 1; j < N; j++) {
        int xdist = x[i] - x[j];
        int ydist = y[i] - y[j];
        double dist = Math.sqrt(xdist*xdist + ydist*ydist);
        totalDist += dist * X;
      }
    }
    
    System.out.println(totalDist/factorial(N));
  }
  
  static int factorial(int n) {
    if (n == 1) {
      return 1;
    }
    return n * factorial(n - 1);
  }
}

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

int res = 1;
int n, par[200001], cnt[200001], m;

int fn(int a) {return par[a] = (par[a] == a) ? a : fn(par[a]);}

void jn(int a, int b)
{
	a = fn(a); b = fn(b);
	if (a != b)
	{
		par[a] = b;
		cnt[b] += cnt[a];
		res = max(cnt[b], res);
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {par[i] = i; cnt[i] = 1;}
	for (int i = 0 ;i < m; i++)
	{
		int a, b; cin >> a >> b;
		jn(a - 1, b - 1);
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 5192
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const long long mod=1e9+7;
long long n,a,b,fac[201010],inv[201010];
long long power(long long a,long long b,long long p)
{
	long long ans=1%p;
	for(;b;b>>=1)
	{
		if(b&1)
			ans=(ans%p*a%p)%p;
		a=(a%p*a%p)%p;
	}
	return ans%p;
}
long long bob(long long x)
{
	long long ans=1;
	for(long long i=n-x+1;i<=n;i++)
		ans=(ans%mod*i%mod)%mod;
	for(long long i=1;i<=x;i++)
		ans=(ans%mod*power(i,mod-2,mod)%mod)%mod;
	return ans%mod;
}
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	long long sum=(power(2,n,mod)-1+mod)%mod;
	printf("%lld",((sum-bob(a)-bob(b))%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long int li;

vector<int> v;
vector<int> dp;

int d(int N)
{

    if (N == 0)
        return 0;
    else if (N < 0)
        return 1000000;
    else
    {
        if (dp[N] != -1)
            return dp[N];

        dp[N] = min( abs(v[N] - v[N-1]) + d(N-1),
                     abs(v[N] - v[N-2]) + d(N-2));
        return dp[N];
    }
}


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

    v.resize(N);
    dp.resize(N);
    for (int i =0 ;i < N; ++i)
        cin >> v[i];
    for (int i = 0; i < N; ++i)
        dp[i] = -1;

    d(N-1);
    cout << dp[N-1];
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int aBefore = sc.nextInt();
		int bAfter = sc.nextInt();
		if (aBefore >= bAfter) {
			System.out.println("delicious");
		}else if (aBefore - bAfter + x >= 0) {
			System.out.println("safe");
		}else{
			System.out.println("dangerous");
		}
	}
}

Measured memory_bytes: 21972
#import <Foundation/Foundation.h>
typedef long long INT;
int main(){
    @autoreleasepool {
        NSMutableSet *set = [NSMutableSet set];
        INT N;
        scanf("%lld",&N);
        for(INT i=0;i<N;i++){
            INT a;
            scanf("%lld",&a);
            if([set containsObject:@(a)]){
                [set removeObject:@(a)];
            } else {
                [set addObject:@(a)];
            }
        }
        printf("%ld",[set count]);
    }
}


Measured memory_bytes: 16800
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 10;

int main() {
	fast_cin();
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	for (int i = 1; i <= h; ++i) {
		int s = 0;
		if (i <= h - 2 * b or i & 1) {
			s = 1;
		}
		for (int j = 0; j < a; ++j) {
			cout << s;
		}
		for (int j = 0; j < w - a; ++j) {
			cout << (1 - s);
		}
		cout << '\n';
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

ll modpower(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n)
{
    return modpower(n, MOD - 2, MOD);
}
void COMinit(vector<ll> &fact, vector<ll> &invfact, ll k)
{ //空っぽの配列を二つ
    fact.resize(k, 0);
    invfact.resize(k, 0);
    fact[0] = 1;
    repi(i, k, 1)
    {
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[k - 1] = inv(fact[k - 1]);
    repd(i, k - 2, -1)
    {
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
    return;
}
ll nCk(vector<ll> &fact, vector<ll> &invfact, ll n, ll k)
{ //この関数を使う前にCOMinit
    if (k < 0 || n < k)
        return 0LL;
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

//---------main function----------

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle = abs(6. * m - m / 2. - h * 30.);
    if (angle > 180)
        angle = 360 - angle;
    double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(angle * M_PI / 180));
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 4160
#include <stdio.h>
int a[10101];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=2; i<=n; i++)
    {
        a[i]+=a[i-1];
    }
    int Min=1e+8,t;
    for(i=2; i<=n; i++)
    {
        t=a[n]-a[i]-a[i];
        if(t<0)
            t*=-1;
        if(t<Min)
        {
            Min=t;
        }
    }
    printf("%d\n",Min);
    return 0;
}









Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

  int n, m;
  cin >> n >> m;

  vector<int> a(n);
  vector<pair<int,int>> v(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> v[i].fi >> v[i].se;

  sort(ALL(a), less<int>());
  sort(ALL(v), [](const auto& a, const auto& b){return a.se > b.se;});

  int sum = 0;
  int i = 0;
  int j = 0;
  while (i < n) {
    sum += max(a[i], v[j].se);
    i++;
    v[j].fi--;
    if (v[j].fi == 0) {
      j++;
      if (j == m) break;
    }
  }
  while (i < n) {
    sum += a[i];
    i++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2560
function main(input) {
    const args = input.split('\n')
    const kn = args[0].split(' ')
    const limit = parseInt(kn[1])
    const heights = args[1].split(' ').map( x => parseInt(x, 10))
    console.log(heights.filter( x => x >= limit).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28608
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Dice dice = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        int a = stdIn.nextInt();
        for(int i = 0; i < a; i++) {
            int T = stdIn.nextInt();
            int S = stdIn.nextInt();
            Dice copy = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
             
            int ans = solv(T,S,copy,0); 
            System.out.println(ans);
        }
    }
    public static int solv(int a, int b, Dice dice,int count) {
        if(dice.Top == a && dice.S == b) return dice.E;
        if(count == 4) return -1;
        int ans = -1;
        Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnN();
        ans = Math.max(solv(a,b,tmp,count+1),ans);
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnS();
        ans = Math.max(solv(a,b,tmp,count+1),ans);
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnE();
        ans = Math.max(solv(a,b,tmp,count+1),ans);
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnW();
        ans = Math.max(solv(a,b,tmp,count+1),ans);
         
        return ans;
    }
     
     
     
}

class Dice {
    int Top; //1
    int Bottom; //6
    int N; //   5
    int S; //   2
    int W; //左 4
    int E; //右 3
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
 public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


Measured memory_bytes: 26944
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010], mx[200010], tmp1[200010];
int main(){
  int n;
  while(cin>>n){
    for(int i=0; i<n; ++i){
      cin>>a[i];
      if(i==0)
        mx[i]=a[i];
      else
        mx[i]=max(mx[i-1], a[i]);
    }
    set <int> st;
    st.insert(0);
    st.insert(n+1);
    int it;
    for(int i=n-1; i>=0; --i){
      it=*--st.lower_bound(a[i]);
      tmp1[a[i]]=it;
      st.insert(a[i]);
    }
    int ans=n, p=1, tmp;
    for(int i=0; i<=n; ++i){
      for(p;p<=n;++p){
        if(tmp1[p]<=i)
          continue;
        break;
      }
      tmp=i;
      ans=min(ans, tmp+(n-p+1));
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 11904
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while(true) {
			int people = sc.nextInt();
			int m = sc.nextInt();

			if(people == 0 && m == 0) {
				break;
			}

			int num = people - 1;
			int jugh = people;
			boolean[] ans = new boolean[people];
			Arrays.fill(ans, true);
			while(jugh > 1) { //?????£??????????????°???1?????????????????§??°?????????
				int count = 0;

				while(count < m) { //?????£??¬?????¢?????????

					num = (num + 1) % people;
					if(ans[num]) {
						count++;
					}
				}
				ans[num] = false;
				jugh--;
			}

			//????????¨???
			for(int $ = 0; $ < people; $++) {
				if(ans[$]) {
					System.out.println($ + 1);
				}
			}
		}

	}

}

Measured memory_bytes: 26688
import java.util.ArrayList;
import java.util.Scanner;

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

        Scanner scan = new Scanner(System.in);

        while(true){
            int a = scan.nextInt();
            int b = scan.nextInt();
            int x;

            if(a == 0 && b == 0){
                break;
            }

            if(a > b){
                x = a;
                a = b;
                b = x;
            }

            System.out.println(a + " " + b);
        }

    }
}


Measured memory_bytes: 34812
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  if(N%2==0){
    cout<<N<<endl;
  }
  else cout<<N*2<<endl;

    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if a<b:
        a,b = b,a
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b
def gcd_all(A):
    x = A[0]
    if len(A) == 1:
        ret = A[0]
    else:
        for i in range(1,len(A)):
            x = gcd(x,A[i])
        ret = x
    return ret

n,k = map(int,input().split())
a = list(map(int,input().split()))
x = gcd_all(a)
ans = 0
for b in a:
    if b >= k:
        if (b-k)%x == 0:
            ans = 1
            break
print(["IMPOSSIBLE","POSSIBLE"][ans])

Measured memory_bytes: 19748