akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();
    for (int i = 0; i < N; i++) {
      if (match(s, t, i)) {
        System.out.println(N + i);
        return;
      }
    }
    System.out.println(N * 2);
  }

  private static boolean match(char[] s, char[] t, int start) {
    for (int i = start; i < s.length; i++) {
      if (s[i] != t[i - start]) return false;
    }
    return true;
  }
}


Measured memory_bytes: 21972
n=int(input())
m=n
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(1,12):
  n-=26**i
  if n<=0:
    count=i
    break
n=m

for i in range(1,count):
  n-=26**i
n-=1

B=[]
for i in range(count-1,0,-1):
  B.append(n//(26**i))
  n-=(n//(26**i))*(26**i)
B.append(n)

C=[]
for i in B:
  C.append(A[i])
print(''.join(C))

Measured memory_bytes: 9236
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <random>
#include <cassert>

using namespace std;

const int N = 1e5;

int A, B, M;
int a[N], b[N];
struct Ticket { int x, y, c; } t[N];

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> A >> B >> M;
	for (int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	int mna = 1e9;
	for (int i = 0; i < A; ++i) {
		mna = min(mna, a[i]);
	}
	int mnb = 1e9;
	for (int i = 0; i < B; ++i) {
		mnb = min(mnb, b[i]);
	}
	int ans = mna + mnb;
	for (int i = 0; i < M; ++i) {
		cin >> t[i].x >> t[i].y >> t[i].c;
		--t[i].x, --t[i].y;
		ans = min(ans, a[t[i].x] + b[t[i].y] - t[i].c);
	}
	cout << ans << '\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
// ※※※ 解答不能 ※※※
// 解き直し.
// sugim48氏.
// https://atcoder.jp/contests/arc097/submissions/2498127
// 正答者の解答を勉強する.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;

vector<vector<int>> f(vector<int> a, vector<int> b){
    int N = a.size();
    vector<vector<int>> c(N, vector<int>(N + 1));
    rep(x, N) rep(y, N) c[x][y + 1] = c[x][y] + (a[x] < b[y]);
    return c;
}

int main(){
    int N;
    scanf("%d", &N);
    vector<int> a(N), b(N);
    rep(t, N * 2) {
        char s[2];
        scanf("%s", s);
        int i;
        scanf("%d", &i);
        i--;
        if (s[0] == 'W') a[i] = t;
        if (s[0] == 'B') b[i] = t;
    }
    vector<vector<int>> aa = f(a, a), ab = f(a, b), ba = f(b, a), bb = f(b, b);
    vector<vector<int>> dp(N + 1, vector<int>(N + 1, INT_MAX));
    dp[0][0] = 0;
    rep(x, N + 1) rep(y, N + 1) {
        if (x < N) dp[x + 1][y] = min(dp[x + 1][y], dp[x][y] + aa[x][x] + ab[x][y]);
        if (y < N) dp[x][y + 1] = min(dp[x][y + 1], dp[x][y] + bb[y][y] + ba[y][x]);
    }
    printf("%d\n", dp[N][N]);
    return 0;
}

Measured memory_bytes: 78848
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

void calc(vector< pair<ll,ll> >& a, vector< pair<ll,ll> >& b) {
    ll a_i = 0, b_i = 0, cnt = 0;
    while(b_i < b.size()) {
        if (a_i != a.size() && a[a_i].first < b[b_i].first) {
            cnt += a[a_i].second;
            a_i++;
        } else {
            b[b_i].second = cnt;
            b_i++;
        }
    }
}

int main() {
    int n;
    vector< pair<ll,ll> > a, b, c;
    cin >> n;
    REP(i, n) {
        ll e;
        cin >> e;
        a.emplace_back(e, 1);
    }
    SORT(a);
    REP(i, n) {
        ll e;
        cin >> e;
        b.emplace_back(e, 0);
    }
    SORT(b);
    REP(i, n) {
        ll e;
        cin >> e;
        c.emplace_back(e, 0);
    }
    SORT(c);
    calc(a, b);
    calc(b, c);
    ll res = 0;
    EACH(i, c) res += i->second;
    cout << res << endl;
    return 0;
}

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

int main()
{
    set<char> s;
    char a;
    int n;
    while(cin>>n){
        for(int i=0;i<n;i++){
            cin>>a;
            s.insert(a);
        }
        int sum=s.size();
        if(sum==1) cout<<"One"<<endl;
        else if(sum==2) cout<<"Two"<<endl;
        else if(sum==3) cout<<"Three"<<endl;
        else cout<<"Four"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def prime_decomposition(n):
    i = 2
    result = []
    while i ** 2 <= n:
        while not n % i:
            result.append(i)
            n //= i
        i += 1
    if n > 1:
        result.append(n)
    return result

a, b = map(int, input().split())
s = set(prime_decomposition(a))
t = set(prime_decomposition(b))
print(len(s & t) + 1)

Measured memory_bytes: 3060
//98tarunkumar
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rlop(i,n) for(int i=n;i>0;i--)
#define lli long long int
#define sf ios::sync_with_stdio(false); cin.tie(NULL);
#define ainp(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define aout(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";
#define f(i, a, b) for(int i=a; i<b; i++)
#define lop(a,b) for(int i=a;i<b;i++)
#define ln cout<<"\n"
#define MOD 1e9+7

/*int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};*/ // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction




int main(){
	sf;
	
	lli n;
	cin>>n;
	lli a[n];
	ainp(a,n)
	lli c=0;
	for(int i=0;i<n;i++){
		if(i%2==0 and a[i]%2)
			c++;
	}
	cout<<c;

	


	
}








Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int a, b, c;
            int totalTime = 0;
            bool judge1, judge2;

            judge1 = judge2 = false;

            a = cin.GetInt();
            b = cin.GetInt();
            c = cin.GetInt();

            while (!judge1 && !judge2)
            {
                judge1 = totalTime % 60 <= c && totalTime % 60 + a >= c;
                totalTime += a + b;
                judge2 = totalTime % 60 == 0;
            }

            totalTime -= a + b;

            if (judge1)
                Console.WriteLine((totalTime / 60) * 60 + c);
            else
                Console.WriteLine(-1);
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ', ',' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

Measured memory_bytes: 19936
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) {
        cin >> A[i];
    }
    auto minA = min_element(A.begin(), A.end());
    auto maxA = max_element(A.begin(), A.end());
    int pivot_idx;
    int pivot;
    if (abs(*minA) > abs(*maxA)) {
        pivot = *minA;
    }
    else {
        pivot = *maxA;
    }
    auto it = find(A.begin(), A.end(), pivot);
    pivot_idx = std::distance(A.begin(), it);
    bool is_positive = true;
    if (pivot < 0)
        is_positive = false;

    vector<pint> move_list;
    rep(i, N) {
        if (i != pivot_idx) {
            A[i] += A[pivot_idx];
            move_list.push_back(make_pair(pivot_idx + 1, i+1));
        }
    }


    vint B(N, 0);
    int s = 0;
    int pre_idx = -1;
    if (is_positive == true) {
        rep(i, N) {
            s += A[i];
            B[i] = s;
            if (pre_idx != -1) {
                move_list.push_back(make_pair(pre_idx + 1, i + 1));
            }
            pre_idx = i;
        }
    }
    else {
        for (int i = N - 1; i >= 0; i--) {

            s += A[i];
            B[i] = s;
            if (pre_idx != -1) {
                move_list.push_back(make_pair(pre_idx + 1, i + 1));
            }
            pre_idx = i;
        }
    }

 
    

    //rep(i, N) {
    //    if (A[i] >= 0) {
    //        s += A[i];
    //        B[i] = s;
    //        if (pre_idx != -1) {
    //            mode_list.push_back(make_pair(pre_idx + 1, i + 1));
    //        }
    //        pre_idx = i;
    //    }
    //}
    //s = 0;
    //pre_idx = -1;
    //for (int i = N - 1; i >= 0; i--) {
    //    if (A[i] < 0) {
    //        s += A[i];
    //        B[i] = s;
    //        if (pre_idx != -1) {
    //            mode_list.push_back(make_pair(pre_idx + 1, i + 1));
    //        }
    //        pre_idx = i;
    //    }

    //}
    cout << move_list.size() << endl;
    for (auto &it : move_list) {
        cout << it.first << " " << it.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc  = new Scanner(System.in);
for(int i=1;;i++) {
	int x= sc.nextInt();
	if(x==0) break;
	System.out.printf("Case %d: %d\n",i,x);
}
sc.close();
	}
	
}


Measured memory_bytes: 60740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    cin>>n>>t;
    int a,b,i,j=0,ar[n];
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if(b<=t) {ar[j]=a;
        j++;}
    }
    if(j==0) cout<<"TLE"<<endl;
    else{
    int s=j;
    sort(ar,ar+s);
    cout<<ar[0]<<endl;
    }

     return 0;



}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }ll c=0LL;
  sort(all(a),greater<ll>());
  rep(i,n){
    if(i>=k){
      c+=a[i];
    }
  }
  cout<<c;
}

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


int main()
{
  int N;
  int a = 0, b = 0;
  int max = -1;
  cin >> N;
  int mochi[100];

  for(int i=0;i<N;i++) {
      cin >> mochi[i];
  }
  sort(mochi, mochi+N, greater<int>());

  int dan = 1;
  for(int i=0;i<N-1;i++) {
    if (mochi[i] != mochi[i+1]) {
      dan++;
    }
  }
  cout << dan << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - a + b) << endl;
}

Measured memory_bytes: 3592
def main():
    n = int(input())
    heights = [-1] + [int(h) for h in input().split()]
    cost = [0] * (1 + n)
    if n >= 2:
        cost[2] = abs(heights[2] - heights[1])
    for stone in range(3, n+1):
        a = abs(heights[stone-1] - heights[stone]) + cost[stone-1]
        b = abs(heights[stone-2] - heights[stone]) + cost[stone-2]
        if a < b:
            cost[stone] = a
        else:
            cost[stone] = b

    print(cost[n])


main()


Measured memory_bytes: 14052
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    ans = 0
    for idx, a in enumerate(A):
        if (idx + 1) % 2 == 1 and a % 2 == 1:
            ans += 1
    return ans


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 61708
S = input()
T = input()
s = []
t = []
for i in range(len(S)):
    s.append(S[i])
    t.append(T[i])

key2 = 0

for i in range(len(S)):
    if t[0] == s[i]:
        key = i
        s_key = s[i::] + s[0:i]
        for j in range(len(S)):
            if s_key == t:
                key2 = 1
                break

if key2 == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define MAX_N (1<<18)
struct StarrySky {
  int seg_m[2*MAX_N-1], seg_a[2*MAX_N-1];

  void add(int a, int b, int x, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      seg_a[k] += x;
      return;
    }
    add(a, b, x, k*2+1, l, (l+r)/2);
    add(a, b, x, k*2+2, (l+r)/2, r);
    seg_m[k] = max(
      seg_m[k*2+1] + seg_a[k*2+1],
      seg_m[k*2+2] + seg_a[k*2+2]
    );
  }

  int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return seg_m[k] + seg_a[k];
    return max(query(a, b, k*2+1, l, (l+r)/2),
               query(a, b, k*2+2, (l+r)/2, r)) + seg_a[k];
  }
};

int N, M;
int L[200000], R[200000];
StarrySky seg;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  vector<P> xs;
  rep(i, N) {
    cin >> L[i] >> R[i];
    xs.pb(P(L[i], R[i]));
  }
  sort(all(xs));

  rep(i, M+2) {
    seg.add(i, i+1, i);
  }
  int m = N+1;
  // m <- max(|X| + maxR-minL)
  rep(i, N) {
    int l = xs[i]._1, r = xs[i]._2;
    seg.add(0, r+1, 1);
    m = max(m, seg.query(0, M+2)-l);
  }
  cout << max(m-1-M, 0) << "\n";
  return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

using P1 = array<char, 26>;
using P2 = array<char, 365>;

struct state{
    array<char, 26> prv;
    array<char, 365> ans;
    int val;
    bool operator<(const state &a) const { return val > a.val; }
    state(P1 a, P2 b, int x) : prv(a), ans(b), val(x) {};
};


int main() {
    int d;
    cin >> d;
    array<int, 26> A{};
    for (auto &&k : A) cin >> k;
    vector<array<int, 26>> v(d);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    vector<int> ans(d);
    int W = 400;
    vector<state> a;
    a.emplace_back(P1{}, P2{}, 0);
    fill(a[0].prv.begin(),a[0].prv.end(), -1);
    for (int i = 0; i < d; ++i) {
        priority_queue<state> Q;
        for (auto &&s : a){
            for (int k = 0; k < 26; ++k) {
                state ss(s);
                ss.ans[i] = k;
                ss.val += v[i][k];
                ss.prv[k] = i;
                for (int l = 0; l < 26; ++l) {
                    ss.val -= (i-ss.prv[l])*A[l];
                }
                Q.emplace(ss);
                if(Q.size() > W) Q.pop();
            }
        }
        a.clear();
        while(!Q.empty()) a.emplace_back(Q.top()), Q.pop();
    }
    for (auto &&m : a.back().ans) {
        printf("%d\n", m+1);
    }
    return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <class T> vector<T> prime(T N) {
    vector<T> pri;
    vector<bool> is_prime;
    is_prime    = vector<bool>(N + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < N + 1; i++) {
        if (is_prime[i]) {
            pri.push_back(i);
            for (int j = 2 * i; j < N + 1; j += i)
                is_prime[j] = false;
        }
    }
    return pri;
}

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

    int x;
    scan(x);
    auto pri = prime(x + 100000);
    sort_(pri);
    int ans = *lower_bound(all(pri), x);
    print(ans);

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using qll=tuple<ll,ll,ll,ll>;

constexpr ll INF = 1LL << 60;
struct Fast{ Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(numeric_limits<double>::max_digits10); } } fast;
#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
inline ll CEIL(ll a,ll b){ return (a<0) ? -(-a/b) : (a+b-1)/b; }
inline ll FLOOR(ll a,ll b){ return -CEIL(-a,b); }

#if 1
#include <atcoder/all>
using namespace atcoder;
#endif


void solve()
{
	const ll BIG=1000000000;
	ll n,k;  cin >> n >> k;
	vector<vector<ll>> a(n,vector<ll>(n));
	rep(i,0,n-1)rep(j,0,n-1){ ll a_; cin>>a_; a[i][j]=a_; }

	mcf_graph<ll,ll> graph(2*n+2);
	vvll egid(n,vll(n));

	ll s=2*n,t=2*n+1;
	rep(v,0,n-1){
		graph.add_edge(s,v,k,0);
	}
	rep(v,n,2*n-1){
		graph.add_edge(v,t,k,0);
	}
	rep(v,0,n-1)rep(u,0,n-1){
		egid[v][u]=graph.add_edge(v,u+n,1,BIG-a[v][u]);
	}
	graph.add_edge(s,t,n*k,BIG);

	pll fc=graph.flow(s,t,n*k);

	cout << n*k*BIG-fc.second << '\n';
	vector<string> ans(n,string(n,'.'));
	rep(v,0,n-1)rep(u,0,n-1){
		auto eg=graph.get_edge(egid[v][u]);
		if (eg.flow==1) ans[v][u]='X';
	}
	each(e,ans) cout << e << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());

int main(){
  ll n,i,j;
  cin>>n;
  vector<ll> d(n);
  for(i=0;i<n;i++){
    cin>>d[i];
  }
  
  sort(d.begin(),d.end());
  
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 1024
import bisect
n,m = map(int,input().split())
a = []
b = []
ans = 'IMPOSSIBLE'
for _ in range(m):
    a1,b1 = map(int,input().split())
    a.append(a1)
    b.append(b1)
c = sorted(zip(a,b))
a.sort()
for i in range(m):
    if c[i][0] == 1:
        tmp1 = bisect.bisect_left(a,c[i][1])
        tmp2 = bisect.bisect_right(a,c[i][1])
        for j in range(tmp1,tmp2):
            if c[j][1] == n:
                ans = 'POSSIBLE'
print(ans)

Measured memory_bytes: 34012
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		while(true){
			int x=stdIn.nextInt();
			int y=stdIn.nextInt();
			if(x==0&&y==0){
				break;
			}
			if(x>y){
				int tmp=x;
				x=y;
				y=tmp;
			}
			System.out.println(x+" "+y);
		}
	}
}

Measured memory_bytes: 35008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

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

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

    vector<int> p(n),q(n),s(n);

    rep(i,n){
        cin >> p[i];
    }
    rep(i,n){
        cin >> q[i];
    }
    rep(i,n){
        s[i] = i+1;
    }

    int a(0),b(0),i(1);
    while(next_permutation(s.begin(),s.end())){
        if(p==s)    a = i;
        if(q==s)    b = i;

        i++;
    }

    cout << abs(a-b) << endl;

    return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int res = 0;
    int t = min(A+B, 2*C);
    while(X>0 && Y>0) {
        res += t;
        X--; Y--;
    }

    if(X==0 && Y>0) {
        int tt = min(B, 2*C);
        while(Y>0) {
            res += tt;
            Y--;
        }
    } else if(Y==0 && X>0) {
        int tt = min(A, 2*C);
        while(X>0) {
            res += tt;
            X--;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
res = [1] * N
#path = [[] for _ in range(N)]
for _ in range(M):
  A, B = list(map(int, input().split()))
  if H[A - 1] <= H[B - 1]:
    res[A - 1] = 0
  if H[B - 1] <= H[A - 1]:
    res[B - 1] = 0
  #path[A - 1].append(B - 1)
  #path[B - 1].append(A - 1)

#print(H)
print(sum(res))
#print(path)

Measured memory_bytes: 20108
<?php
  fscanf(STDIN,"%d%d", $k,$s);
  $count =0;
  for($x=0; $x<=$k; $x++){
      for($y=0; $y<=$k; $y++){
          $z = $s-($x+$y);
          if($z >= 0 && $z <= $k){
                  $count++;
          }
      }
  }
  echo $count;

Measured memory_bytes: 4604
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
    print(abs(a[0] - W))
else:
    x = abs(a[-2] - a[-1])
    y = abs(a[-1] - W)
    
    ans = max(x, y)
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  ll back = A[0];
  ll tmp = 1;
  for (int i = 1; i < N; i++) {
    if (back == A[i]) {
      tmp++;
      continue;
    }
    if (tmp % 2 == 1) ans++;
    back = A[i];
    tmp = 1;
  }
  if (tmp % 2 == 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    ll l,q;
    cin>>l>>q;
    vector<vector<ll>> A(n,vector<ll>(30));
    int j=0;
    for(int i=0;i<n;i++){
        while(j+1<n && a[j+1]-a[i]<=l){j++;}
        A[i][0]=j;
    }
    for(int i=1;i<30;i++){
        for(int t=0;t<n;t++){
            A[t][i]=A[A[t][i-1]][i-1];
        }
    }
    while(q--){
        ll a,b;
        cin>>a>>b;
        if(a>b){swap(a,b);}
        a--; b--;
        ll count=0;
        for(int t=29;t>=0;t--){
            if(A[a][t]<b){count+=1LL<<t; a=A[a][t];}
        }
        while(a<b){a=A[a][0]; count++;}
        cout<<count<<endl;
    }
    
    
    
    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if(k == 1){
    cout << 0 << endl;
  }else{
    n -= k;
    cout << n << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(i, a, n) for (int i = a; i < n; i++)
#define f1(i, a, n) for (int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ers erase
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvpii vector<vpii>
#define vbl vector<bool>
#define upb upper_bound
#define lwb lower_bound
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define umap unordered_map
#define uset unordered_set
#define gcd __gcd
const ll MOD = 1e9 + 7;
#define INF INT_MAX
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n; cin >> n;
    ll count[n+5], arr[n];
    f(i,0,n+5) count[i] = 0;
    f(i,0,n)
    {
        cin >> arr[i];
        count[arr[i]] ++;
    }
    ll total = 0;
    f(i,0,n+5)
    {
        if(count[i] == 0) continue;
        ll temp = count[i];
        temp = (temp *(temp-1))/2;
        total += temp;
    }
    //cout << total << " raj\n";
    f(i,0,n)
    {
        ll old = (count[arr[i]]*(count[arr[i]] - 1))/2;
        ll nw = ((count[arr[i]] - 1) * (count[arr[i]] - 2))/2;
        cout << total - old + nw << '\n';
    }
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main(){

	int m,f,r,sum;
	for(;;){
		cin>>m>>f>>r;
		sum=m+f;
		if(m==-1&&f==-1&&r==-1)
			break;
		else if(m==-1||f==-1)
			cout<<"F";
		else if(sum>=80)
			cout<<"A";
		else if(sum>=65)
			cout<<"B";
		else if(sum>=50)
			cout<<"C";
		else if(sum>=30)
			if(r>=50)
			    cout<<"C";
			else
				cout<<"D";
		else
			cout<<"F";
		cout<<endl;
	}
		return 0;
	}

Measured memory_bytes: 1152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());


int main(){
    fastIO;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0 ; i < n; i ++ )
        cin >> a[i];
    int res = 0;
    for(int i = 1; i < n; i ++ ){
        if(a[i] == a[i-1])
            res ++ , i ++ ;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 || i%5==0)
		{
			sum=sum;
		}
		else
		{
			sum+=i;
		}
	}
	cout<<sum<<'\n';
}

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

using namespace std;

const int M = 1 << 21;
const int MOD = 1e9 + 7;
int n, t[22][22], dp[M];

int solve (int i, int mask) {
    if (i == n) return 1;
    int &ret = dp[mask];
    if (ret != -1) return ret;
    ret = 0;
    for (int j = 0; j < n; j++) {
        if (t[i][j] && !((mask>>j)&1)) ret = (ret + solve (i+1, mask|(1<<j))) % MOD;
    }
    return ret;
}

int main () {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> t[i][j];
        }
    }
    memset (dp, -1, sizeof dp);
    cout << solve (0, 0);
}


Measured memory_bytes: 8448
def main():
    n = int(input())
    t, a = list(map(float, input().split(' ')))

    min_diff = 100000000000000000000000000
    min_index = -1
    hs = list(map(float, input().split(' ')))
    for i in range(n):
        h = hs[i]
        cu_diff = abs(a - (t - h * 0.006))
        if cu_diff < min_diff:
            min_diff = cu_diff
            min_index = i

    print(min_index+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  int max = 0;
  for(int i =1 ; i <=1000;i++){
    for(int j = 2; j < 10; j++){
      int n = pow(i,j);
      if( n <= X && n > max) max = n;
    }
  }
      cout << max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N, M, t[51], i, a, b;
    scanf("%d %d", &N, &M);
    for(i = 1; i <= N; i++) t[i] = 0;
    for(i = 0; i < M; i++){
        scanf("%d %d", &a, &b);
        t[a]++;
        t[b]++;
    }
    for(i = 1; i <= N; i++) printf("%d\n", t[i]);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<cstring>

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil=(Node *)malloc(sizeof(Node));
    nil->prev=nil;
    nil->next=nil;
}

void insert(int key) {
    Node *x=(Node *)malloc(sizeof(Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    x->prev=nil;
    nil->next=x;
}

Node* listSearch(int key) {
    Node *cur=nil->next;
    while (cur !=nil && cur->key != key) {
        cur=cur->next;
    }
    return cur;
}

void deleteNode(Node* t) {
    if (t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

int printList() {
    Node* cur=nil->next;
    int isf=0;
    while(cur!=nil) {
        if(isf++>0) printf(" ");
        printf("%d", cur->key);
        cur=cur->next;
    }
    printf("\n");
}

int main() {
    int key, n, i;
    char com[20];
    scanf("%d", &n);
    init();
    for (i=0; i<n;i++) {
        scanf("%s%d", com, &key);
        if (com[0]=='i') insert(key);
        else if (com[0]=='d') {
            if (strlen(com)>6) {
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
        }
        else deleteKey(key); 
    }
}

printList();
}



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

int n;

int main() {
	scanf("%d", &n);
	int ans = 0;
	long long cnt = 0;
	for (int i = 1; i * i <= n - 1; ++i)
		++ans, cnt += (n - 1) / i - i;
	printf("%lld\n", ans + (cnt << 1));
	return 0;
}



Measured memory_bytes: 3832
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const mod = int(1e+9) + 7

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	N := len(S)
	dp := make([][13]int, N+1)
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		var c int
		if S[i] == '?' {
			c = -1
		} else {
			c = int(S[i] - '0')
		}
		// 前の桁までの余り
		for j := 0; j < 13; j++ {
			// 現在の桁
			for k := 0; k < 10; k++ {
				if c != -1 && c != k {
					continue
				}
				dp[i+1][(j*10+k)%13] += dp[i][j]
			}
		}
		for j := 0; j < 13; j++ {
			dp[i+1][j] %= mod
		}
	}

	fmt.Fprintln(wtr, dp[N][5])
	wtr.Flush()
}


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


int main() {
  vector<int> num(10000);
  rep(i,10000) {
    cin >> num.at(i); 
  };
  rep(i,10000) {
    if (num.at(i) != 0) {
      cout << "Case " << i+1 << ":" << " " << num.at(i) <<endl; 
    }
  }
}


Measured memory_bytes: 3124
n, q = map(int, input().split())
INF = 2**31 - 1

k = 1
while k < n:
    k *= 2

A = [-1] * (k-1) + [2**31-1] * k


def min_query(a, b, k, l, r):
    if r <= a or b <= l:
        ans = INF
    elif a <= l and r <= b:
        ans = A[k]
    else:
        c1 = min_query(a, b, 2*k+1, l, (l+r)//2)
        c2 = min_query(a, b, 2*k+2, (l+r)//2, r)
        ans = min(c1, c2)
    return ans


for i in range(k-2, -1, -1):
    A[i] = min(A[2*i+1], A[2*i+2])

for i in range(q):
    com, x, y = map(int, input().split())

    if com == 0:
        cur = k-1+x
        A[cur] = y
        while cur > 0:
            cur = (cur-1) // 2
            A[cur] = min(A[2*cur+1], A[2*cur+2])
    else:
        print(min_query(x, y+1, 0, 0, k))



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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    priority_queue<int> pq;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        while (!pq.empty() && pq.top() > a[i]) pq.pop();
        if (pq.empty() || pq.top() != a[i]) {
            pq.emplace(a[i]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4520
#include <bits/stdc++.h>
#define int long long 
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
ll K;
int nz;
vll ap, an;

bool check(ll x){
    int np = ap.size(),
        nn = an.size();

    ll cnt = 0LL;

    // neg
    if(x < 0LL){
        for(auto& a : ap){
            ll b = (-x - 1) / a;
            cnt += nn - (int)(upper_bound(_all(an), b) - begin(an));
        }
    }
    else {
        cnt += 1LL * np * nn;
    }
    
    if(x >= 0LL){
        // zero
        cnt += nz * (np + nn);
        cnt += nz * (nz - 1) / 2;

        // pos
        for(auto& vec : {ap, an}){
            int n = vec.size();
            rep(i, n){
                auto a = vec[i];
                ll b = x / a;
                cnt += max(0LL, (int)(upper_bound(_all(vec), b) - (begin(vec) + i+1)));
            }
        }
    }

    return cnt >= K;
}

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

    int n; cin >> n >> K;
    vi a(n); for(auto& e : a) cin >> e;
    for(auto& e : a){
        if(e > 0) ap.emplace_back(e);
        else if(e < 0) an.emplace_back(-e);
        else nz++;
    }
    sort(_all(ap));
    sort(_all(an));

    const ll M = (ll)(1e18);
    ll lb = -M, ub = M;
    rep(loop, 70){
        ll mid = (lb + ub) / 2;
        if(check(mid)){
            ub = mid;
        }
        else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[110];
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N) {
        if(i % 2 == 0 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    long long int h, w, n;
    cin >> h >> w >> n;

    vector<pair<int, int>> square;// north-west corner
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(1 <= a - j && (a - j) + 2 <= h
                && 1 <= b - k && (b - k) + 2 <= w){
                    square.push_back({a - j, b - k});
                }
            }
        }
    }
    sort(square.begin(),square.end());

    vector<long long int> count(10);
    long long int temp = 1;
    for(int i=0; i<square.size(); i++){
        if(i != square.size() - 1
        && square[i].first  == square[i+1].first
        && square[i].second == square[i+1].second){
            temp += 1;
        }
        else{
            count[temp] += 1;
            temp = 1;
        }
    }

    count[0] = (h - 2) * (w - 2);
    for(int i=1; i<10; i++){
        count[0] -= count[i];
    }
    
    for(int i=0; i<10; i++){
        cout << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10476
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var A, B, C, D int
	fmt.Scan(&A,&B,&C,&D)
	for {
		C -= B
		if C <= 0 {
			fmt.Println("Yes")
			break
		}
		A -= D
		if A <= 0 {
			fmt.Println("No")
			break
		}
	} 
}

Measured memory_bytes: 1820
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] a = new int[N];

      for (int i = 0; i < a.length; ++i) {
        a[i] = in.nextInt();
      }

      int spell = 0;
      int color = 10000;

      for (int i = 1; i < a.length; ++i){
        if (a[i] == a[i - 1]) {
          a[i] = color;
          --color;
          ++spell;
        }
      }

      System.out.println(spell);
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

struct UnionFind {
    vector<int> p; 
    UnionFind(int n) : p(n, -1) { };
    bool unite(int u, int v) { 
        if ((u = root(u)) == (v = root(v))) return false;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v]; p[v] = u;
        return true;
    }
    bool find(int u, int v) { return root(u) == root(v); }
    int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); }
    int size(int u) { return -p[root(u)]; }
};

int main() {
    int n, m; cin >> n >> m;
    vint a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
    }
    int cnt = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if(i == j) continue;
            uf.unite(a[j]-1, b[j]-1);
        }
        if(uf.size(0) != n) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>();
    let v1 = s[0..2].parse::<i32>().unwrap();
    let v2 = s[2..4].parse::<i32>().unwrap();
    if (v1 == 0 || v1 > 12) && (v2 == 0 || v2 > 12) {
        println!("NA");
    } else if v1 == 0 || v1 > 12 {
        println!("YYMM");
    } else if v2 == 0 || v2 > 12 {
        println!("MMYY");
    } else {
        println!("AMBIGUOUS");
    }
}


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

typedef long long ll;

int main()
{
	int n;
	cin>>n;
	ll cnt = 0, lo;
	for(int i = 0; i < n; i++)
	{
		ll tmp;
		cin>>tmp;
		if( i == 0 ) lo = tmp;
		else
		{
			if(lo > tmp) cnt += (lo-tmp);
			else lo = tmp;
		}
	}
	cout<<cnt<<endl;
}
		


Measured memory_bytes: 3536