akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;

    vector<int> X(N);
    for(int i = 0; i < N; i++)
    {
        cin >> X.at(i);
    }

    int min = 100 * 100 * 100;

    for(int p = 0; p < 100; p++)
    {
        int total = 0;
        for(int i = 0; i < N; i++)
        {
            total += pow((X.at(i) - (p+1)), 2);
        }
        if(total < min)
        {
            min = total;
        }
    }

    cout << min;

    return 0;
}

Measured memory_bytes: 256
import sys
s = input()
mm1 = False
mm2 = False

if 0 < int(s[:2]) < 13:
    mm1 = True
if 0 < int(s[-2:]) < 13:
    mm2 = True

if mm1 == True and mm2 == True:
    print("AMBIGUOUS")
    sys.exit()
if mm1 == False and mm2 == False:
    print("NA")
    sys.exit()
if mm1 == True and mm2 == False:
    print("MMYY")
    sys.exit()
if mm1 == False and mm2 == True:
    print("YYMM")
    sys.exit()
print("NA")

Measured memory_bytes: 40496
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string ALP = "abcdefghijklmnopqrstuvwxyz";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int x,a,b,d;
  cin >> x >> a >> b;
  d = b-a;
  cout << ((d<=0)?"delicious":(d>x)?"dangerous":"safe") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;





int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

    int ind[n + 1];
    memset(ind, 0, sizeof ind);
    bool comp[n + 1];
    memset(comp, false, sizeof comp);
    set<int> st;
    for (int i = 1; i < n + 1; i++) st.insert(i);
    vector<int> prev;
    for (int i = 1; i < n + 1; i++) prev.pb(i);

    int ans = 0;
    while (!st.empty()) {
        vector<int> here;
        ans++;
        bool cs = false;
        bool vis[n + 1];
        memset(vis, false, sizeof vis);
        vector<int> just;
        for (int i : prev) {
            int j = a[i][ind[i]];
            if (vis[i] || vis[j]) continue;
            if (a[j][ind[j]] == i) {
                ind[i]++;
                ind[j]++;
                vis[i] = vis[j] = true;
                if (ind[i] == n - 1) {
                    just.pb(i);
                }
                else {
                    here.pb(i);
                }

                if (ind[j] == n - 1) {
                    just.pb(j);
                }
                else {
                    here.pb(j);
                }
                cs = true;
            }
        }

        if (!cs) {
            cout << -1;
            return 0;
        }

        for (int e : just) st.erase(e);
        prev = here;

    }

    cout << ans;


}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll m;
ll a[MAX_N];

ll acc[MAX_N];
map<ll, ll> cnt;
map<ll, ll> tmp_cnt;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &m);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 1; i <= n; ++i) {
    acc[i] = acc[i - 1] + a[i];
  }

  for (int i = 0; i <= n; ++i) {
    acc[i] %= m;
    cnt[acc[i]] += 1LL;
  }

  ans = 0LL;

  for (int i = 0; i < n; ++i) {
    tmp_cnt[acc[i]] += 1LL;

    ll cur_key = acc[i];

    ans += cnt[cur_key] - tmp_cnt[cur_key];
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 9728
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll a,b;
  cin>>a>>b;
  if(a>8||b>8)
  cout<<":("<<endl;
  else
  cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1009991
string T;
ll n, k, r, s, p;
char zyanken(char y) //
{
    if (y == 'p')
    {
        return 's';
    }
    else if (y == 'r')
    {
        return 'p';
    }
    else if (y == 's')
    {
        return 'r';
    }
    cout << "ofdjdaffadfdddaso";
    return '0';
}
ll ten(char y)
{
    if (y == 'p')
    {
        return p;
    }
    else if (y == 'r')
    {
        return r;
    }
    else if (y == 's')
    {
        return s;
    }
    cout << "ofdjaso";
    return 0;
}
string g;
vector<ll> memo(200005);
ll dp(ll u) //u回やった時、今後の最大値
{
    if (memo[u] != 0)
    {
        return memo[u];
    }
    if (u == n)
    {
        return 0;
    }
    ll res = 0;
    if (u < k)
    {
        g = g + zyanken(T[u]);                //じゃんけんにかつ
        res = dp(u + 1) + ten(zyanken(T[u])); //じゃんけんに勝った時の点をresにする。
        memo[u] = res;
        return res;
    }
    if (zyanken(T[u]) == g[u - k])
    {
        if (g[u - k] != zyanken(T[u - k]))
        {
            g = g + zyanken(T[u]);
            res = dp(u + 1) + ten(zyanken(T[u]));
        }
        else
        {
            g = g + T[u];
            res = dp(u + 1);
        } //同じ手で勝っている場合は、別にどちらでも良いのではないのか？
        memo[u] = res;
        return res;
    }
    //u回目に出そうとした値が,u-k回目と被ってしまった時にどうする？？
    //u-k番目がもし勝っている状態ならば変更すればいい。
    //u-kが負けている状態なら、特に操作する必要はない。(得点だけだから??)
    //↑重要なのはk個過去だけでそれより過去の情報はいらないはず。
    g = g + zyanken(T[u]);
    res = dp(u + 1) + ten(zyanken(T[u]));
    memo[u] = res;
    return res;
}
int main()
{
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> T;
    cout << dp(0); //indexで回す。(0回目で今0の時の今後の最大値は何か。)
}

Measured memory_bytes: 10104
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, mut p: [usize; n]);
    p.sort();
    println!("{}", p[..k].iter().sum::<usize>());
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;
  cin>>N;
  long sum=0;
  for(long i=1;i<=N;i++){
    if(i%3==0){
      continue;
    }
    if(i%5==0){
      continue;
    }
    else{
      sum+=i;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3636
N=int(input())
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
ans=[]
for i in range(1,55555+1):
    if i%5==1:
        if is_prime(i):
            ans.append(i)
            if len(ans)==N:
                break
print(*ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;cin>>n>>m;
  ll in=-100000000000000;
  ll a[m],b[m],c[m];
  vector<pair<ll,ll>>list[n+1];
  for(ll i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    list[a[i]].push_back(make_pair(b[i],c[i]));
    
  }
  ll score[n+1];
  //cout<<list[1][1].first<<list[1][1].second<<endl;return 0;
  for(ll i=0;i<=n;i++)score[i]=in;
  score[1]=0;
  ll ans;
  for(ll i=0;i<3*n;i++){
    bool update=false;
    for(ll j=0;j<m;j++){
      if(score[a[j]]!=in){
          if(score[b[j]]<score[a[j]]+c[j]){
            score[b[j]]=score[a[j]]+c[j];
          }
      }
    }
    if(i==n-2)ans=score[n];
      if(i>=n-1&&score[n]>ans){
        cout<<"inf"<<endl;
        return 0;
      }
    
  }
  cout<<ans<<endl;
}


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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int n, k;
int h[MAXN];
int dp[MAXN];

signed main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> h[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++)
            if (i - j >= 1) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
import math
A, B, H, M = map( int, input().split() )
pi = math.pi
thetaA = math.radians(  M * 6   )
thetaB = math.radians(  ( 60 * H + M ) / 2)
xa = A * math.cos( thetaA )
ya = A * math.sin( thetaA )
 
xb = B * math.cos( thetaB )
yb = B * math.sin( thetaB )
 
print( math.sqrt( ( xa - xb ) ** 2 + ( ya - yb ) ** 2 ) )

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[100005],y[100005];
int main()
{
    int j1=0,j2=0,o1=0,o2=0,a,b,c,d1=-1,d2=-1;
    cin>>a;
    for(b=0;b<a;b++)
    {
        scanf("%d",&c);
        if(b%2==0)
        {
            x[c]++;
            if(x[c]>j1)
            {
                if(c!=d2)
                {
                    j2=j1;
                    d2=c;
                }
                j1=x[c];

            }
            else if(x[c]>j2)
            {
                j2=x[c];
            }

        }
        else
        {
            y[c]++;
            if(y[c]>o1)
            {

                if(d1!=c)
                {
                    d1=c;
                    o2=o1;
                }
                o1=y[c];

            }
            else if(y[c]>o2)
            {
                o2=y[c];
            }
        }
    }
    if(d1==d2)
        cout<<min(a-j1-o2,a-j2-o1);
    else
        cout<<a-j1-o1;
    return 0;
}



Measured memory_bytes: 1024
import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb


def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def main():

    N, M = map(int, input().split())
    ac = [0 for _ in range(N)]
    wa = [0 for _ in range(N)]

    for _ in range(M):
        p, s = my_input().split()
        p = int(p) - 1
        if s == 'AC':
            ac[p] = 1
        else:
            if ac[p] == 0:
                wa[p] += 1

    # print(ac)
    # print(wa)

    for i in range(N):
        if ac[i] == 0:
            wa[i] = 0

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 47536
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <string.h>
#define MAX 111
using namespace std;

int main()
{
    char a[101];
    char b[101];
    scanf("%s%s",a,b);
    if (strlen(a)!=strlen(b))
        printf("No\n");
    else if(strcmp(a,b)==0)
        printf("Yes\n");
    else {
        bool flag;
        for (int i = 1;i<strlen(a);i++) {
            flag = true;
            for (int j = 0;j<strlen(a);j++) {
                int pos = (j+i)%strlen(a);
                if (a[pos]!=b[j])
                    flag = false;
            }
            if (flag){
                printf("Yes\n");
                break;
            }
        }
        if (flag == false)
            printf("No\n");
    }
	return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]

#ワーシャルフロイド法  注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

graph = csr_matrix(c) #隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) #有向の場合directed=True
#dist_matrixの中身はfloatになっているので注意！

#for i in range(10):
#	print(c[i])

ans = 0
for i in range(H):
	for x in A[i]:
		if x == 1 or x == -1:
			continue
		else:
			ans += c[x][1]

print(int(ans))



Measured memory_bytes: 19568
a = [ ]

a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i

k = gets.to_i

catch :break do
  for i in 0...a.size
    for j in (i+1)...a.size
      unless a[j] - a[i] <= k
        puts ':('
        throw :break
      end
    end
  end
  puts 'Yay!'
end


Measured memory_bytes: 1788
//１つの整数 x を読み込み、それをそのまま出力するプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iCount;
    int iInputDataSet;

    //変数の初期化
    iInputDataSet = 1;
    iCount = 1;

    while (iInputDataSet != 0)
    {
        scanf("%d",&iInputDataSet);
        if (iInputDataSet != 0)
        {
            printf("Case %d: %d\n",iCount,iInputDataSet);
        }
        iCount++;
    }
    return 0;
}


Measured memory_bytes: 1916
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    ll N, A, B; cin >> N >> A >> B;
    if((A+B) % 2) cout << min(A-1, N-B) + 1 + (B-A-1) / 2 << endl;
    else cout << (B-A) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    ll left,right;cin>>left>>right;
    int ans=2019;
    for(ll i = left;i<min(right, left+2019*2);i++){
        for(ll j = i+1;j<=min(right, left+2019*2);j++){
            if(ans>(i*j)%2019)ans = (i*j)%2019;
        }
    }
    co(ans);
}


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

int main(){
   int A,B,C,X,ret=0;
   cin >> A >> B >> C >> X;
   X /= 50;
   for (int i=0; i<=min(X/10,A); ++i){
      for (int j=0; j<=min((X-10*i)/2,B); ++j){
        int k = X-10*i-2*j;
        if(k <= C) ++ret;
      }
   }
   cout << ret << endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){ printf("Yes\n");
}
else{ printf("No\n");
}
return 0;
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

//約数列挙O(root n)
PLL div(ll n){
  for(ll i=sqrt(n); i>=1; --i){
    if(n%i == 0) return PLL(i,n/i);
  }
  return PLL(0,0);
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll S;cin >> S;
  // S = x1y2 - x2y1;
  // S = E9y2 - x2;
  ll E9 = 1e9;
  ll x1=E9,y1=1;
  ll y2=((S+E9-1)/E9);
  ll x2= x1*y2 - S; 
  cout << 0 SP 0 SP x1 SP y1 SP x2 SP y2 << endl;
  return 0;
}


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

const int MAX = 3;
int main() {
	string s[MAX];
	for (int i = 0;i < MAX;i ++) cin >> s[i];
	for (int i = 0;i < MAX;i ++) cout << (char)(s[i][0] -'a' + 'A');
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

小文字を大文字に変える時は、('A' - 'a')を追加すれば変換できる
逆に大文字を小文字に変える時は正負を入れ替えてね
*/

Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  val rn = StdIn.readLine().trim.toInt
  val ra = (0 until rn).map{ _ =>
    StdIn.readLine().trim.toInt
  }.toArray
  
  def insertionSort(a: Array[Int], n: Int, g: Int): (Array[Int], Int) = {
    var cnt = 0
    (g-1 until n).foreach{ i =>
      //println(s"insertion($i):" + a.toList)
      var v = a(i)
      var j = i - g
      while(j >= 0 && a(j) > v){
        a(j+g) = a(j)
        j = j - g
        cnt += 1
      }
      a(j+g) = v
    }
    (a, cnt)
  }

  def gapArray(max: Int): Array[Int] = {
    def loop(buff: ListBuffer[Int] = ListBuffer.empty[Int], i: Int = 1): Array[Int] = {
      if(max < i) buff.toArray.reverse
      else loop(buff += i, i*3+1)
    }
    
    loop()
  }
  
  def shellSort(a: Array[Int], n: Int): (Array[Int], Array[Int], Int) = {
    var cnt = 0
    /*
    var m = 4
    var g: Array[Int] = (m to 0 by - 1).map(p => p).toArray
    */
    var g: Array[Int] = gapArray(a.length)
    var m = g.size
    //println("g:" + g.mkString(" "))
    (0 until m).foreach{ i =>
      val (_, rcnt) = insertionSort(a, n, g(i))
      cnt = cnt + rcnt
    }
    
    (a, g, cnt)
  }
  
  val rshell    = shellSort(ra.clone(), rn)

  //println("ra:" + ra.toList.mkString(" "))
  println(rshell._2.size)
  println(rshell._2.toList.mkString(" "))
  println(rshell._3)

  rshell._1.toList.foreach(println)

}


Measured memory_bytes: 350748
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int x[n];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; i++) {
        ans += min(x[i], k - x[i]);
    }
    printf("%d\n", 2 * ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	v1 a(n);
	int m = 0;
	rep(i, n){
		cin >> a.at(i);
		m = max(m, a.at(i));
	}
	v1 b(m+1);
	b.at(0) = 0;
	rep(i,n){
		int k = a.at(i);
		if(b.at(k)>=2) continue;
		int j = 1;
		while(k <= m){
			b.at(k)++;
			j++;
			k = a.at(i)*j;
		}
	}
	int c = 0;
	/*rep(i, m){
		cout << b.at(i) << " ";
	}*/
	rep(i, n){
		if(b.at(a.at(i)) == 1) c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 8020
#include <iostream>


using std::cout;
using std::cin;
using std::endl;

int main(){

    int A,B,N;

    cin >> N;
    
    if(N == 1){

        cout << "Hello World" << endl;
    }

    else if(N == 2){
        
        cin >> A >> B; 

        cout << A + B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// Code for D - Teleporter
	n := nextInt()
	k := nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	lmap := map[int]bool{1: true}
	l := []int{1}
	var s int
	for true {
		i := l[len(l)-1] - 1
		n := a[i]

		_, ok := lmap[n]
		if ok {
			s = n
			break
		}

		l = append(l, n)
		lmap[n] = true
	}

	var si int
	for i := range l {
		if s == l[i] {
			si = i
			break
		}
	}

	if k < si {
		fmt.Println(l[k])
	} else {
		m := (k - si) % (len(l) - si)
		fmt.Println(l[m + si])
	}
}


Measured memory_bytes: 18092
from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = [0] * n

# deque の代わりにタプルを使い捨てにしてみる。
# quが未定義だと言われる，なんで，グローバルじゃないの？
# じゃない。nonlocal宣言で解決した。


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = (start_v,)
    # 始点からvに移動するまでの最短距離: dist[v]
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        nonlocal qu
        if dist[v] != BIG:
            # 既に訪問済みで距離が求められている。
            return
        dist[v] = d
        qu = qu + (v,)

    push(start_v, 0)

    while len(qu):
        v = qu[0]
        qu = qu[1:]
        # 始点からvの次の頂点へ移動する距離。
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(ans[i] // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54748
n = int(input())
a = list(map(int, input().split()))
if n == 1:
    print('YES')
    exit()
suma = sum(a)
if sum(a) % (n*(n+1)//2) > 0:
    print('NO')
    exit()
k = 2*suma//(n*(n+1))
diffs = [a[i+1] - a[i] - k for i in range(-1, n-1)]
if all([d<=0 and -d % n == 0 for d in diffs]):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14292
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i;
  char t[200000];
  
  scanf("%s", t);
  
  for( i = 0; t[i] != '\0'; i++ ){
      if( t[i] == '?' ){
          t[i] = 'D';
      }
      printf("%c", t[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,w=0;
  std::cin >> x>>y;
  std::vector<int> v(x);
  std::vector<int> dp(x,INF);
  rep(i,x)std::cin >> v[i];
  dp[0]=0;
  repone(i,x){
    Repone(j,y+1){
      if(i-j>-1)   dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
      else break;
    }
  }
  std::cout << dp[x-1] << '\n';
}


Measured memory_bytes: 1920
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	if N%2 == 1 {
		fmt.Println("0")
	} else {
		N /= 2
		ans := 0
		for N != 0 {
			ans += N / 5
			N /= 5
		}
		fmt.Println(ans)
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    if(a >= k) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        if(b >= k) {
            b -= k;
        } else {
            b = 0;
        }
    }
    cout << a << " " << b;
    return 0;
}

Measured memory_bytes: 256
import itertools
n,q = map(int,input().split())
s = input()
lr = []
for i in range(q): lr.append(list(map(int, input().split())))
ac = [1 if i!=0 and 'AC'==s[i-1:i+1] else 0 for i in range(0,len(s))]
acc = list(itertools.accumulate(ac))
for i in lr: print(acc[i[1]-1]-acc[i[0]-1])


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

int main() {
  string S;
  cin >> S;
  bool a=true;
  int k=S.size();
  for(int i=0;i<(k-1)/2;i++){
    if(S.at(i) != S.at(k-i-1))
      a = false;
  }
  for(int i=0;i<(k-1)/2;i++){
    if(S.at(i) != S.at((k-3)/2-i))
      a = false;
  }
  if(a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
      
  
}

Measured memory_bytes: 256
object Main {
	def main(args: Array[String]): Unit = {
			val in = new java.util.Scanner(System.in)
			rec(in,1)
	}
	def rec(in:java.util.Scanner,count:Int):Unit = {
	  val a = in.nextInt()
	  if(a == 0) return
	  println("Case "+count+": "+a)
	  rec(in,count+1)
	}
}

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

using namespace std;

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

    bool win = 0;
    for(int i = 1, x; i <= n; i++) {
        cin >> x;
        win |= x % 2;
    }
    cout << (win ? "first" : "second");
}


Measured memory_bytes: 256
N, A, B, C = map(int,input().split())
ans = [[0, 0, 0, 0]]
for i in range(N):
    l = int(input())
    ans = [[p[j] + l * (i == j) for j in [0, 1, 2]] + [p[3]+(i < 3)] for p in ans for i in range(4)]
print(min(abs(p[0] - A) + abs(p[1] - B) + abs(p[2] - C) + p[3] * 10 - 30 for p in ans if min(p[:3]) > 0))

Measured memory_bytes: 19572
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

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

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int64 combination(int64 n, int64 p) {
  int64 bunshi = 1;
  int64 bunbo = 1;
  for (int64 i = n; i > n - p; i--) {
    bunshi *= i;
  }
  for (int64 i = 1; i <= p; i++) {
    bunbo *= i;
  }
  return bunshi / bunbo;
}

int main() {
  int N;
  cin >> N;
  vector<int64> A(N);
  cin >> A;
  for (int64 i = 1; i < N; i++) {
    A[i] += A[i - 1];
  }
  A.push_back(0);
  sort(A.begin(), A.end());
  int64 tmp = 1;
  vector<int64> num_of_identical_sum;
  for (int64 i = 1; i < N + 1; i++) {
    if (A[i - 1] == A[i]) {
      tmp++;
    } else {
      if (tmp != 1) {
        num_of_identical_sum.push_back(tmp);
      }
      tmp = 1;
    }
  }
  if (tmp != 1) {
    num_of_identical_sum.push_back(tmp);
  }
  int64 length_num_of_idencital_sum = num_of_identical_sum.size();
  int64 result = 0;
  for (int64 i = 0; i < length_num_of_idencital_sum; i++) {
    result += combination(num_of_identical_sum[i], 2);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;


void solve() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];

  ll h = 0, ans = 0;
  rep(i, n) {
    if (h > a[i]) {
      ans += h-a[i];
      a[i] = h;
    }
    chmax(h, a[i]);
  }
  cout << ans << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 4836
N,A = map(int,input().split())
X = [int(e) for e in input().split()]
# dp[i][k][s]: i番目まで見てk個選んで総和sとなる場合の数
# 初期条件: dp[0][0][0] = 1
# 遷移: dp[i][k][s] += dp[i-1][k-1][s-X[i]] + dp[i-1][k][s]
# 答え: sum(dp[N][k][k*A] 1 <= k <= N)
s_max = 2500
dp = [[[0]*(s_max+1) for k in range(N+1)] for i in range(N+1)]
dp[0][0][0] = 1
for i in range(1,N+1):
    for k in range(N+1):
        for s in range(s_max+1):
            dp[i][k][s] += dp[i-1][k][s]
            if k != 0 and 0 <= s-X[i-1] <= s_max:
                dp[i][k][s] += dp[i-1][k-1][s-X[i-1]]
ans = 0
for k in range(1,N+1):
    s = k*A
    ans += dp[N][k][s]
print(ans)

Measured memory_bytes: 92892
s=input()
cnt1b,cnt2b,cnt1w,cnt2w=0,0,0,0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='0':
      cnt1b+=1
    else:
      cnt1w+=1
  else:
    if s[i]=='0':
      cnt2b+=1
    else:
      cnt2w+=1
print(min(cnt1b+cnt2w,cnt2b+cnt1w))

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

int main(){
	int a, b, c, x, d;
	
	cin >> a >> b >> c;
	d = 0;
	for( x = a; x <= b; x++){
		if(c % x == 0){
			d++;
		}
	}
	cout << d << endl;	
	return 0;	
}

Measured memory_bytes: 3100
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		long[] a = Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
		long[] b = Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();

		long k = b.Sum() - a.Sum();

		long l = 0;
		for(int i = 0; i < N; i++)
		{
			if(a[i] > b[i])
			{
				l += a[i] - b[i];
				b[i] = a[i];
			}
		}

		long m = 0;
		for(int i = 0; i < N; i++)
		{
			if(a[i] < b[i])
			{
				long num = (b[i] - a[i]) / 2;
				m += num;
				a[i] += 2 * num;
			}
		}

		if(m < l)
		{
			Console.WriteLine("No");
			return;
		}

		long n = l;
		for(int i = 0; i < N; i++)
			if(a[i] < b[i])
				n += (b[i] - a[i]);

		Console.WriteLine((n <= k) ? "Yes" : "No");		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 15840
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(A);
            var n = A[N - 1];
            var r = 0;
            var abs = n;
            for (var i = 0; i < N - 1; i++)
            {
                var tmp = Math.Abs(A[i] - n / 2);
                if (tmp <= abs)
                {
                    r = A[i];
                    abs = tmp;
                }
            }
            Console.WriteLine($"{n} {r}");
        }
    }
}


Measured memory_bytes: 21088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n;cin>>n;
	map<string, int> m;
	rep(i, n){
		string s;
		cin>>s;
		int v = m[s];
		m[s]++;
	}
	vector<pair<int, int>> p;
	vector<string> ss;
	int cou = 0;
	for(auto i = m.begin(); i != m.end();i++){
		p.push_back(make_pair(i->second, cou));
		ss.push_back(i->first);cou++;
	}
	sort(all(p));
	vector<string> ans;
	int ma = p[p.size()-1].first;
	for(int i = p.size()-1;i>=0;i--){
		if(p[i].first==ma){
			ans.push_back(ss[p[i].second]);
		}else{
			break;
		}
	}
	sort(all(ans));
	debug("   \n");
	rep(i, ans.size()){
		cout << ans[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 28816
eval'N,M,A,*B='+`dd`.split*?,
s=[d=x=0]*9*M
B.map{|b|e=b;A>b&&b+=M;x+=t=b-A
[0,M].map{|m|s[m-~A]+=1;s[m+b]-=t;s[m-~b]+=t-1}
A=e}
p x-s.map{|s|d+=$.+=s}.max

Measured memory_bytes: 48964
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
while (line = lines.shift()) {
	const [n, max] = line.split(' ').map(Number);
	if (n === 0 && max === 0) {break;}
	const prices = lines.shift().split(' ').map(Number);
	const allSum = [];
	prices.map((priceA, indexA) => {
			prices.map((priceB, indexB) => {
				if (indexA !== indexB) {
					const sum = priceA + priceB;

					if(sum <= max) {
						allSum.push(sum);
					}
				}
			})
		}
	);
	const answer = allSum.sort((a,b) => b - a)[0];
	console.log(answer || 'NONE');
}


Measured memory_bytes: 55784
#include<bits/stdc++.h>
using namespace std;
const long long mxn = 55555;

vector< int > prime;


bool ar[mxn + 10];

void p()
{
	for(int i = 4;i < mxn; i+=2)
	{
		ar[i] = true;
	}
	prime.push_back(2);
	//cout<<"done"<<endl;
	//int lm = sqrt(mxn);
	for(long long i = 3; i < mxn; i+= 2)
	{
		if(!ar[i])
		{
			prime.push_back(i);
			//cout<<i*i<<" ";
			for(long long j = i*i; j < mxn; j += 2*i)
			{
				ar[j] = true;
			}
		}
	}
	
}

vector< int > ans;

bool y(int pos , int cnt , int sum)
{
	//cout<<pos<<" "<<cnt<<" "<<sum<<endl;
	if(cnt==5)
	{
		for(int i = 0; prime[i] <= sqrt(sum);i++)
		{
			if( sum%prime[i] == 0)
			{
				return false;
			}
		}
		return true;
	}
	if(pos==ans.size())
	{
		return 0;
	}
	bool ret = y(pos+ 1 , cnt+1 , sum+ans[pos]);
	ret |= y(pos+1, cnt , sum);
	return ret;
}

int main()
{
	memset(ar , false , sizeof ar);
	p();
	int n;
	cin>>n;
	
	for(int i = 0; i < prime.size(); i++)
	{
		if(ans.size()==n)
		break;
		
		if(prime[i]%5==1)
		{
			ans.push_back(prime[i]);
		}
	
	}
	for(int i = 0; i < ans.size(); i++)
	{
		if(i)
		cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
   int N,M;
   cin >> N >> M;
   int min=1,max=N;
   int l,r;
   for(int i=0;i<M;i++){
       cin >> l >> r;
       
       if(min<l) min = l;
       if(max>r) max = r;
   }
   
   if(min>max) cout << 0 << endl;
   else cout << max - min + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c);
    Cout(a-b+1);
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin>>s,s!="#"){
    ll y,m,d;
    cin>>y>>m>>d;
    if(y>31){
      cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
    }else if(y==31){
      if(m>=5){
	cout<<"?"<<" "<<1<<" "<<m<<" "<<d<<endl;
      }else cout<<s<<" "<<y<<" "<<m<<" "<<d<<endl;
    }else{
      cout<<s<<" "<<y<<" "<<m<<" "<<d<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>

int main(void) {
	int n;
	int count[26];
	int i;
	for (i = 0; i < 26; i++) count[i] = 9999;
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		int localCount[26] = {0};
		char S[64];
		int j;
		if (scanf("%63s", S) != 1) return 1;
		for (j = 0; S[j] != '\0'; j++) {
			int idx = S[j] - 'a';
			if (0 <= idx && idx < 26) localCount[idx]++;
		}
		for (j = 0; j < 26; j++) {
			if (localCount[j] < count[j]) count[j] = localCount[j];
		}
	}
	for (i = 0; i < 26; i++) {
		int c = 'a' + i;
		int j;
		for (j = 0; j < count[i]; j++) putchar(c);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans;
  b = b/x + 1;
  if (a > 0) a = (a-1)/x + 1;
  else a = 0;
  ans = b - a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		Solver sol = new Solver();
		sol.solve();
		out.close();
	}
	private static final class Solver {
		public void solve() {
			char[] line = in.next().toCharArray();
			ArrayDeque<Character> deque = new ArrayDeque<>();
			for (char c : line) {
				if (c == 'B') {
					if (!deque.isEmpty()) deque.pollLast();
				} else {
					deque.addLast(c);
				}
			}
			while (!deque.isEmpty()) out.print(deque.pollFirst());
			out.println();
		}
	}
	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;
		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 34828
line = input()
a = int(line[:2])
b = int(line[2:])

if a < 1:
  if b < 1:
    print("NA")
  elif b < 13:
    print("YYMM")
  else:
    print("NA")
elif a < 13:
  if b < 1:
    print("MMYY")
  elif b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b < 1:
    print("NA")
  elif b < 13:
    print("YYMM")
  else:
    print("NA")


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	if n%2 == 0 {
		left := n/2 - 1
		right := n / 2
		for i := 0; i < n; i += 2 {
			fmt.Scan(&ar[right], &ar[left])
			right++
			left--
		}
	} else {
		fmt.Scan(&ar[n/2])
		left := n/2 - 1
		right := n/2 + 1
		for i := 1; i < n; i += 2 {
			fmt.Scan(&ar[right], &ar[left])
			right++
			left--
		}
	}
	for i, v := range ar {
		if i == 0 {
			fmt.Printf("%d", v)
		} else {
			fmt.Printf(" %d", v)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 6912
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	int n,a;
	cin >> n;
	map<int,int> mp;
	rep(i, n) {
		cin >> a;
		if (mp[a] != 0) {
			mp.erase(a);
		} else {
			mp[a]++;
		}
	}

	cout << mp.size() << endl;
}






Measured memory_bytes: 4864