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

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

        var N = Integer.parseInt(scanner.next());
        var A = new int[N];
        for(int i=0; i<N; i++)
            A[i] = Integer.parseInt(scanner.next());
        Arrays.sort(A);

        var A_MAX = A[N-1];

        boolean[] isP = new boolean[A_MAX+1];
        Arrays.fill(isP, true);

        int lastValue = 0;
        for(int i=0; i<N; i++) {
            if(!isP[A[i]]) continue;
            if(lastValue == A[i]) {
                isP[A[i]] = false;
                continue;
            }
            for(int j = 2; A[i]*j <= A_MAX ;j++)
                isP[A[i] * j] = false;
            lastValue = A[i];
        }

        int num = 0;
        for(int i=0; i<N; i++) {
            if(isP[A[i]])
                num++;
        }
        System.out.println(num);
    }
}

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

struct node{int l,r;}c[2010];
int n,a[2010],b[2010],l[2010],r[2010],L[2010],ans;
char ch[2010];

bool cmp(node x,node y){return x.r<y.r;}

void work()
{
	scanf("%s",ch),n=strlen(ch),ans=2*n;
	for (int i=0; i<n; i++)  a[i]=(ch[i]=='1'),a[n]+=a[i];
	scanf("%s",ch);
	for (int i=0; i<n; i++)  b[i]=(ch[i]=='1'),b[n]+=b[i];
	if (!b[n])  puts(a[n]?"-1":"0"),exit(0);
	a[n]=b[n]=0;
	for (int i=1; i<n; i++)  l[i]=(b[i]?i:l[i-1]);
	for (int i=n-2; ~i; i--)  r[i]=(b[i]?i:r[i+1]);
	l[0]=(b[0]?0:l[n-1]),r[n-1]=(b[n-1]?n-1:r[0]);
	for (int i=1; i<n; i++)  l[i]=(b[i]?i:l[i-1]);
	for (int i=n-2; ~i; i--)  r[i]=(b[i]?i:r[i+1]);
	for (int i=0; i<n; i++)  l[i]=(i-l[i]+n)%n,r[i]=(r[i]-i+n)%n;
	for (int d=-n,m; d<=n; d++)
		{
			if (d==1500)
				d++,d--;
			if (d<0)  c[m=1]=(node){-d,n},L[m]=-d;
			else  if (d>0)  c[m=1]=(node){n,d},L[m]=n;
			else  c[m=1]=(node){0,0},L[m]=0;
			for (int i=0; i<n; i++)
				if (a[i]!=b[(i+d+n)%n])
					c[++m]=(node){l[i],r[i]},L[m]=l[i];
			sort(c+1,c+m+1,cmp),sort(L+1,L+m+1);
			for (int i=0,j=m; i<=m&&c[j].r>=d; i++)
				{
					while ((j)&&(c[j].l<=L[i]))  j--;
					if (c[j].r>=d)  ans=min(ans,m-1+2*L[i]+2*c[j].r-abs(d));
				}
		}
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vp A(N);
  rep(i,N) {
    int x;
    cin >> x;
    A[i] = P(x,i+1);
  }
  sort(rng(A));
  rep(i,N) {
    cout << A[i].second;
    if(i != N-1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    lint N;
    cin >> N;
    int last=0;
    int sum=0;
    while(sum<N){
        last++;
        sum+=last;
    }
    if(sum==last) rep(i,last) cout << i+1 << endl;
    else{
        rep(i,last) if(i+1!=sum-N) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if (n == 1 || m == 1) {
    ans = max((ll)1, n-2) * max((ll)1, m-2);
  } else {
    ans = (n-2)*(m-2);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;

int main(){
  char X,Y;
  cin>>X>>Y;
  if(X>Y) cout<<">"<<endl;
  else if(X==Y) cout<<"="<<endl;
  else cout<<"<"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N; cin >> N;
	multiset<int> ms;
	set<int> st;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		ms.insert(x);
		st.insert(x);
	}
	ll a = 0, b = 0;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		if (ms.count(*itr) >= 4) {
			a = b = *itr;
		}
		else if (ms.count(*itr) >= 2) {
			b = a;
			a = *itr;
		}
	}
	cout << a * b << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	ll N; cin >> N;
	ll* A = new ll[N];
	ll* B = new ll[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[N - 1 - i] = A[i];
	}
	
	vector<pair<int, ll>> v1, v2;
	ll* p1 = new ll[N];
	ll* p2 = new ll[N];

	p1[0] = 0;
	v1.push_back({ 0, 1 });
	for (int i = 1; i < N; i++) {
		p1[i] = p1[i - 1];

		if (A[i - 1] >= A[i]) {
			int d = A[i - 1] / A[i];
			int digit = -2;

			while (d > 0) { d /= 4; digit += 2; }
			if (digit == 0) {
				pair<int,ll> p = v1.back();
				v1.pop_back();

				p.second++;
				v1.push_back(p);
			}
			else {
				v1.push_back({ digit, 1 });
			}
		}
		else {
			ll a = A[i - 1], b = A[i];
			while (a < b) {
				a *= 4;

				pair<int, ll> p = v1.back();
				v1.pop_back();

				p1[i] += p.second * 2;
				p.first -= 2;

				if (v1.size() == 0) {
					v1.push_back(p);
				}
				else {
					if (p.first == 0) {
						v1[v1.size() - 1].second += p.second;
					}
					else {
						v1.push_back(p);
					}
				}
				
			}
			v1[v1.size() - 1].second++;
		}
	}

	p2[0] = 0;
	v2.push_back({ 0, 1 });
	for (int i = 1; i < N; i++) {
		p2[i] = p2[i - 1];

		if (B[i - 1] >= B[i]) {
			int d = B[i - 1] / B[i];
			int digit = -2;

			while (d > 0) { d /= 4; digit += 2; }
			if (digit == 0) {
				pair<int, ll> p = v2.back();
				v2.pop_back();

				p.second++;
				v2.push_back(p);
			}
			else {
				v2.push_back({ digit, 1 });
			}
		}
		else {
			ll a = B[i - 1], b = B[i];
			while (a < b) {
				a *= 4;

				pair<int, ll> p = v2.back();
				v2.pop_back();

				p2[i] += p.second * 2;
				p.first -= 2;

				if (v2.size() == 0) {
					v2.push_back(p);
				}
				else {
					if (p.first == 0) {
						v2[v2.size() - 1].second += p.second;
					}
					else {
						v2.push_back(p);
					}
				}

			}
			v2[v2.size() - 1].second++;
		}
	}

	ll ans = min(p1[N - 1] + N, p2[N - 1]);
	for (ll i = 1; i < N; i++) {
		ans = min(ans, i + p1[i - 1] + p2[N - 1 - i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
-- Your code here!

import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n<-getLine
    if elem '7' n then putStrLn "Yes" else putStrLn "No"

Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cctype>
using namespace std;
#define P pair<int, const char*>
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

vector<int> books;
vector< vector<int> > desks;
int ans = 0;

void replace_desks(int did){
  REP(i, desks[did].size()){
    if(desks[did][i] != -1) continue;
    FOR(j, i, desks[did].size()){
      if(desks[did][j] != -1){
        swap(desks[did][i], desks[did][j]);
        break;
      }
    }
  }
}

bool is_full(int did){
  REP(i, desks[did].size()) if(desks[did][i] == -1) return false;
  return true;
}

int take_oldbook(){
  int tmp = desks[0][0];
  desks[0][0] = -1;
  replace_desks(0);
  ans += 1;
  return tmp;
}

void put_oldbook(int book){
  FOR(i, 1, desks.size()){
    REP(j, desks[i].size()){
      if(desks[i][j] == -1){
        desks[i][j] = book;
        ans += (i + 1);
        return ;
      }
    }
  }
  ans += (desks.size() + 1);
  return ;
}

void take_book(int book){
  REP(i, desks.size()){
    REP(j, desks[i].size()){
      if(desks[i][j] == book){
        desks[i][j] = -1;
        replace_desks(i);
        ans += (i + 1);
        return ;
      }
    }
  }
  ans += (desks.size() + 1);
  return ;
}

void put_book(int book){
  REP(i, desks.size()){
    REP(j, desks[i].size()){
      if(desks[i][j] == -1){
        desks[i][j] = book;
        ans += (i + 1);
        return ;
      }
    }
  }
  ans += (desks.size() + 1);
  return ;
}

int main(){
  int m, c, n;
  while(cin >>m >>c >>n && m){
    ans = 0;
    books = vector<int>();
    desks = vector< vector<int> >(m, vector<int>(c, -1));
    vector< vector<int> > tmp(n);
    int tmp_int = 0;
    REP(i, n){
      int k; cin >>k;
      vector<int> tmp2(k);
      REP(j, k) cin >>tmp2[j];
      tmp[i] = tmp2;
      tmp_int = max(tmp_int, (int)(tmp2.size()));
    }
    REP(i, tmp_int){
      REP(j, n){
        if(i >= tmp[j].size()) continue;
        books.push_back(tmp[j][i]);
      }
    }

    REP(i, books.size()){
      take_book(books[i]);
      if(is_full(0)){
        put_book(books[i]);
        int tmp_book = take_oldbook();
        put_oldbook(tmp_book);
        take_book(books[i]);
        put_book(books[i]);
      } else{
        put_book(books[i]);
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1288
// 4/3/2020 8:00:11 PM
#include <bits/stdc++.h>  
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
using namespace std ; 
// 2020-04-01
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,
// rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+20;
const int mod = 1e9+7;  
int tests() {  
  int n ,m ; 
  cin >> n >> m; 
  int x,i ;
  vector <int> a(n);
  int sum  = 0 ; 
  forn(i,0,n){
    cin >> x ; 
    sum += x ; 
    a[i] =x ;
  }
  // cout << sum << ' ' << sum /(4*m); 
  // sum /= (4 *m);
  int c = 0 ;
  forn(i,0,n)
    c += ( a[i]*4*m >= sum );
  // cout << c << '\n' ;   
  cout << (c >= m ? "Yes" : "No" )<< '\n' ; 
  return 0;  
} 
int main(){
    I__O ;            
    int cases = 1 ; 
    // cin >> cases ;  
    for(int  _ = 1 ; _ <= cases ; _++ ){   
    // cout << "Case #" << _ << ": ";
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC


Measured memory_bytes: 256
n = int(input())

res = float('inf')
for i in range(0, n + 1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6
    t = n - i
    while t > 0:
        cnt += t % 9
        t //= 9
    res = min(res, cnt)
print(res)


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

const int MAX_N = 100005;

int n, k;
int h[MAX_N];
int n_test;

int solve() {
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; ++i) scanf("%d", h + i);
    int res[MAX_N] = {0};
    res[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i) {
        res[i] = 2e9;
        for(int j = 1; j < k + 1; ++j) {
            if (i < j) break;
            res[i] = min(res[i], res[i - j] + abs(h[i] - h[i - j]));
        }
    }
    return res[n - 1];
}

int main() {
    n_test = 1;
    //scanf("%d", &n_test);
    for(int i = 0; i < n_test; ++i) printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 1024
void main() {
    string n = readln.chomp;
    string m;
    foreach (x; n) {
        m ~= x == '1' ? '9' : '1';
    }
    m.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define vc vector
using namespace std;
int main() {
  string s;
  cin>>s;
  int pointer(s.size()-1);
  pointer=pointer-pointer%2; 
  while (true){
    bool finish(true);
    for (int i(0);i<pointer/2;i++){
      if (s[i]!=s[pointer/2+i]) finish=false;
    }
    if (finish==true){
      cout << pointer << endl;
      return 0;
    }
    pointer -=2;
    if (pointer==0){
      cout << 0 << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 256
c = []
c << gets.split.map(&:to_i)
c << gets.split.map(&:to_i)
c << gets.split.map(&:to_i)

a = [0, c[1][0] - c[0][0], c[2][0] - c[0][0]]
b = [c[0][0], c[0][1], c[0][2]]

if a[1] + b[1] != c[1][1] || a[1] + b[2] != c[1][2] || 
   a[2] + b[1] != c[2][1] || a[2] + b[2] != c[2][2]
   puts "No"
else
    puts "Yes"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans*= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int A,B,C;
    cin>>A>>B>>C;
    int D=max(A,B);
    int E=max(D,C);
    A=E-A;
    B=E-B;
    C=E-C;
    int ans=0;
    int S=max(A,B);
    int X=max(S,C);
    ans+=(A+B+C-X);
    if(C<A&&B<A){
        A=A-(A+B+C-X);
        ans+=(A+1)/2;
        if(A%2==1){
            ans++;
        }
    }
    else if(B<C&&A<C){
        C=C-(A+B+C-X);
        ans+=(C+1)/2;
        if(C%2==1){
            ans++;
        }
    }
    else{
        B=B-(A+B+C-X);
        ans+=(B+1)/2;
        if(B%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}




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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    queue<pair<string,int> > que;
    for(int i=0;i<n;i++){
        string s;
        int in;
        cin >> s >> in;
        que.push(make_pair(s,in));
    }
    int cou=0;
    while(!que.empty()){
        cou+=q;
        pair<string,int> p(que.front()); que.pop();
        p.second-=q;
        if(p.second<=0){
            cout << p.first << " " << cou+p.second << endl;
            cou+=p.second;
        }else{
            que.push(p);
        }
    }
}



Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int a,b,c;
signed main(){
    cin>>a>>b>>c;
    if(a<c&&c<b)puts("Yes");
    else if(a>c&&c>b)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0;
using namespace std;
int n,m,x,y;
bool used[100010];
int dp[100010];
vector<int> vec[100010];
set<int> st;
vector<int> l;
queue<int> s;
void visit(int node){
    if(!used[node]){
        used[node]=true;
        for(int i:vec[node])visit(i);
        l.push_back(node);
    }
}
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>x>>y;
        vec[x].push_back(y);
        st.insert(y);
    }
    for(int i=1;i<=n;i++)visit(i);
    reverse(l.begin(),l.end());
    rep(i,n){
        int node=l[i];
        for(int j:vec[node]){
            dp[j]=max(dp[j],dp[node]+1);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    ggr;
}

Measured memory_bytes: 14200
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
using namespace std;
 
lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
 
 
const int N = 1e6 + 30;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 74e-9;
 
lli bp(lli a, lli b = -2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}
 
int k, n, pat;
int a[N];
int main()
{
	fastio;
	cin >> k >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	pat = a[n - 1] - a[0];
	for (int i = 1; i < n; i++)
	{
		pat = min(pat, k - a[i] + a[i - 1]);
	}
	cout << pat << endl;
	return 0;
}
 
 
/*
  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// Educational DP/DPまとめコンテスト D-Knapsack1
// dp[i][j] := i番目の品物をみて、重さがi以下のときの最大価値
// 2020.5.31

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W; cin >> N >> W;
  vector<ll> w(N, 0), v(N, 0);
  REP(i, N){
    cin >> w[i] >> v[i];
  }
  vector<vector<ll> > dp(N+5, vector<ll>(W+5, 0));
  REP(i, N){
    REP(j, W+1){
      if(j+w[i] < W+2) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
      chmax(dp[i+1][j], dp[i][j]);
      chmax(dp[i+1][j+1], dp[i+1][j]);
    }
  }
  cout << dp[N][W] << endl;
}

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

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

    string alpha = "abcdefghijklmnopqrstuvwxyz";
    vector<int> data (alpha.size());
    
    for ( int i = 0 ; i < s.size() ; i++ ){
        data.at(alpha.find(s.at(i)))++;
    }
    bool judge = false;
    for ( int i = 0 ; i < 26 ; i++ ){
        if ( data.at(i) == 0 ){
            cout << alpha.at(i) << endl;
            judge = true;
            break;
        } 
    }
    if ( judge==false) cout << "None" << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        if type(x) is str:
            x = int(x)
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(self.x * pow(other.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x)
            if isinstance(other, ModInt)
            else ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(other.x * pow(self.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(other, self.x, MOD))
        )


def main():
    n = int(input())
    ls = list(map(ModInt, input().split()))

    ans = ModInt(0)

    sm = sum(ls)

    for i in range(n):
        ans += ls[i] * sm

    sub = ModInt(0)
    for i in range(n):
        sub += ls[i] * ls[i]

    ans -= sub

    ans = ans / 2

    print(ans)


main()


Measured memory_bytes: 63748
N=int(input())
X,Y=[0]*N,[0]*N
for i in range(N):
    X[i],Y[i]=map(int,input().split())

def check(a,b,r):
    if r<0:r=0
    res=[0,0,0]
    flg=True
    for i in range(N):
        tmp=(X[i]-a)**2+(Y[i]-b)**2
        if tmp>r**2:
            flg=False
        if tmp>res[0]:
            res=[tmp,X[i],Y[i]]
    res[0]=flg
    return res

x_ave,y_ave=sum(X)/N,sum(Y)/N
MIN=10**(-12)
r=1500
r_diff=r/2
k=0.5
d=999/1000


#print(x_ave,y_ave)
while r_diff>MIN:
    tmpres = check(x_ave,y_ave,r)
    #print(r,x_ave,y_ave)
    if tmpres[0]:
        r-=r_diff
    else:
        r+=r_diff
    x_ave+=(tmpres[1]-x_ave)*k
    y_ave+=(tmpres[2]-y_ave)*k
    r_diff=r_diff*d
    k=k*d

print(r)

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            print("DENIED")
            exit()

print("APPROVED")


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

int main(){
    int n;
    cin >> n;
    int a[n+1][4];
    for(int i=0;i<n;i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    long long dp[n+1][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
       for(int j=0;j<2;j++){
           dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
           dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
           dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
       }
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, M; cin >> N >> M;
	vector<int>as;
	vector<int>votes(N);
	for (int i = 0; i < N; ++i) {
		int a; cin >> a; as.push_back(a);
	}
	for (int j = 0; j < M; ++j) {
		int b; cin >> b;
		for (int i = 0; i < N; ++i) {
			if (as[i] <= b) {
				votes[i]++;
				break;
			}
		}
	}
	cout << max_element(votes.begin(), votes.end()) - votes.begin()+1<< endl;
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
void tree(vector<set<int>> &g,vector<vector<int>> &t,int x){
  while(!g.at(x).empty()){
    int c=*g.at(x).begin();
    g.at(x).erase(c);
    g.at(c).erase(x);
    t.at(x).push_back(c);
    tree(g,t,c);
  }
  return;
}
bool path(vector<vector<int>> &t,vector<int> &p,int b,int e){
  p.push_back(b);
  if(b==e)
    return 1;
  bool f=0;
  for(int c:t.at(b))
    f|=path(t,p,c,e);
  if(!f)
    p.pop_back();
  return f;
}
int child(vector<vector<int>> &t,int x,int b){
  if(x==b)
    return 0;
  int s=1;
  for(int c:t.at(x))
    s+=child(t,c,b);
  return s;
}
int main(){
  int n;
  cin>>n;
  vector<set<int>> gf(n);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    gf.at(a).insert(b);
    gf.at(b).insert(a);
  }
  vector<set<int>> gs=gf;
  vector<vector<int>> tf(n);
  vector<vector<int>> ts(n);
  tree(gf,tf,0);
  tree(gs,ts,n-1);
  vector<int> p;
  path(tf,p,0,n-1);
  int fc=child(tf,0,p.at((p.size()-1)/2+1));
  int sc=child(ts,n-1,p.at((p.size()-1)/2));
  cout<<(fc>sc?"Fennec":"Snuke")<<endl;
}

Measured memory_bytes: 40960
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K%2==0) {
    cout << A-B << endl;
  }
  else {
    cout << B-A << endl;
  }
}

Measured memory_bytes: 3536
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b)
		printf("%d\n",2*a-1);
	else if(a==b)
		printf("%d\n",2*a);
	else
		printf("%d\n",2*b-1);
	return 0;
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.each do |x|
  h[x] += 1
end
m.times do
  b, c = gets.split.map(&:to_i)
  h[c] += b
end
ans = 0
cnt = 0
h.sort_by{|k, v| -k}.each do |k, v|
  if cnt + v < n
    ans += k * v
    cnt += v
  else
    ans += k * (n - cnt)
    break
  end
end
puts ans

Measured memory_bytes: 39264
#include <iostream>
#include <sstream>
#include <algorithm>
#include "string.h"
#include <vector>
#define OPEN 0
#define MAXN 100010
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
	ios::sync_with_stdio(false);
#if OPEN
	freopen("input.txt", "r", stdin);
#endif
	int N;
	while(cin>>N){
		vector<int> arr;
		for(int i=0;i<N;i++){
			int t;
			
			cin>>t;
			arr.push_back(t);
		}
		vector<int> z(MAXN);
		z[0] = arr[0];
		for(int i =1;i<N;i++){
			z[i] = gcd(z[i-1],arr[i]);
		}
		vector<int> b(MAXN);
		b[0] = arr[arr.size() - 1];
		int cou =0;
		for(int i = arr.size() - 2;i>=0;i--){
			cou++;
			b[cou] = gcd(b[cou-1],arr[i]);
		}
		int maxa= -1;
		for(int i =0;i<N;i++){
			if(i == 0)maxa = b[N-2];
			else
			if(i == N-1){
				maxa = max(maxa,z[N-2]);
			}
			else {
				int ret = gcd(z[i - 1], b[N - (i + 1) - 1]);
				maxa = max(maxa, ret);
			}
		}
		
		cout<<maxa<<endl;
	}
	return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x=0; x<=k; ++x) {
        if (x==s) {
            ans++;
            break;
        }
        for (int y=0; y<=k; ++y) {
            if(x+y==s) {
                ans++;
                break;
            }
            if(s-x-y<=k) {
                ans++;
            }
        }
    }

    P(ans);

    return 0;
}



Measured memory_bytes: 256
/* ex 5_4
   riverstone */

#include <stdio.h>
#include <string.h>
 
int main(void){
    //最高文字列数は10より\0を含めて11
    char sequence[11];
    //max:最大の長さ counter:何文字連続しているかを入れる変数
    int i,max = 0,counter=0;
    
    //入力
    scanf("%s", &sequence[0]);

    for ( i = 0; i < strlen(sequence); i++){   
        //読み取った文字が，A,C,G,Tである時はcounterを1増やす
        if(sequence[i]=='A'||sequence[i]=='C'||sequence[i]=='G'||sequence[i]=='T'){
            counter += 1;
            //その連続数が最高記録ならば最高記録を更新
            if (counter >= max){               
                max = counter;
            }
        }
        else{
            counter=0;
        }
    }

    //最高連続記録の出力
    printf("%d\n", max);
    return 0;
}

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

typedef long long ll;
typedef double d;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    string s;
    cin>>s;
    if(s[1]=='B')
        cout<<"ARC";
    else
        cout<<"ABC";
    nl;
    return 0;
}



Measured memory_bytes: 3608
n = int(input())
A = list(map(int, input().split()))

def bucketsort(A, B):
    C = [0] * (max(A) + 1)
    
    for i in A:
        C[i] += 1
    
    for i in range(1, max(A) + 1):
        C[i] += C[i - 1]
    
    for i in (reversed(A)):
        B[C[i] - 1] = i
        C[i] -= 1
    return B

B = [0] * len(A)
ans = bucketsort(A, B)
ans = [str(i) for i in ans]
print(' '.join(ans))


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

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int count = Integer.parseInt(scan.nextLine());
		String[] strs = scan.nextLine().split(" ");

		long distinctCount = Arrays.stream(strs).mapToInt(str -> Integer.parseInt(str)).distinct().count();

		System.out.println(count == distinctCount ? "YES" : "NO");
		scan.close();
	}
}

Measured memory_bytes: 68680
package main

import (
	"fmt"
)

func main() {
	var n int
	count := 0
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	for i := 0; i < n; i++ {
		if nums[i] != i + 1 {
			count += 1
		}
	}
	if count <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
def main():
    H, W = (int(i) for i in input().split())
    A = [input() for i in range(H)]
    from collections import Counter
    c = Counter(A[0])
    for a in A[1:]:
        c += Counter(a)
    if H % 2 == 0 and W % 2 == 0:
        if all(v % 4 == 0 for v in c.values()):
            return print("Yes")
        else:
            return print("No")
    elif H % 2 == 1 and W % 2 == 1:
        c_odd = sum(1 if v % 2 == 1 else 0 for k, v in c.items())
        if c_odd == 1 and \
            sum(1 if v % 4 == 2 else 0 for v in c.values()) <= \
                (W//2 + H//2):
            return print("Yes")
        else:
            return print("No")
    else:
        if all(v % 2 == 0 for v in c.values()) and \
            sum(1 if v % 4 == 2 else 0 for v in c.values()) <= \
                (W//2 if W % 2 == 0 else H//2):
            return print("Yes")
        else:
            return print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
INF = 10**18


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    dp = [[INF]*(N+1) for _ in range(N)]
    cost = [[INF]*(N+1) for _ in range(N)]

    for i in range(N):
        dp[i][i+1] = A[i]
        cost[i][i+1] = 0

    for w in range(2, N+1):
        for le in range(N-w+1):
            ri = le + w
            for i in range(le+1, ri):
                if dp[le][ri] >= dp[le][i] + dp[i][ri]:
                    dp[le][ri] = dp[le][i] + dp[i][ri]
                    cost[le][ri] = min(cost[le][ri],
                                       cost[le][i] + cost[i][ri] + dp[le][ri])

    print(cost[0][N])


if __name__ == '__main__':
    main()


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int mod[1000001];

int main() {
  int x, y;
  while(cin>>x>>y,x|y){
    fill_n((int *)mod, 1000001, -1);
    int a, b;
    int idx = 0;
    mod[x] = idx;
    while(true){
      // LOG("log %d\n", x);
      idx++;
      x*=10;
      x %= y;
      if(x == 0){
        a = idx;
        b = 0;
        break;
      }
      if(mod[x] != -1){
        a = mod[x];
        b = idx - mod[x];
        break;
      }
      mod[x] = idx;
    }
    printf("%d %d\n", a, b);
  }
}

Measured memory_bytes: 5040
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 2e5+5;
int n,k,a[maxn];
map<int,int> m;
set<pair<int,int> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>k;
    int re=0;
    rep(i,0,n)
    {
        cin>>a[i];
        s.erase({m[a[i]],a[i]});
        m[a[i]]++;
        s.insert({m[a[i]],a[i]});
    }
    while(s.size()>k)
    {
        re+=s.begin()->first;
        s.erase(*s.begin());
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 19840
"use strict";

function Main(input) {
    var a=input.split(" ");
    console.log("%d %d",a[0]*a[1],a[0]*2+a[1]*2);
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int a, b;
    cin >> a >> b;
    cout << max(0, a-b) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;

inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

int main(){
  int n;
  cin>>n;
  while(n){
    n--;
    vector<double> x(4,0);
    vector<double> y(4,0);
    for(int i=0;i<4;i++){
      cin>>x[i]>>y[i];
    }
    double xa,xb,ya,yb;
    xa=x[1]-x[0];
    xb=x[3]-x[2];
    ya=y[1]-y[0];
    yb=y[3]-y[2];
    double a;
    a=xa*yb-xb*ya;
    if(eq(0.0,a)){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 4e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N], b[N], n;
int main () {
	ios::sync_with_stdio(0), cin.tie(0);	
	cin >> n;
	vector<ll> mn, mx;
	mn.pb(0);
	mx.pb(0);
	for (int i = 0; i < n; i ++) {
		cin >> a[i] >> b[i];
		mn.pb(a[i]);
		mx.pb(b[i]);
	}
	sort(all(mn));
	sort(all(mx));
	if (n & 1) {
		ll x = mn[(n + 1) / 2];
		ll y = mx[(n + 1) / 2];
		cout << y - x + 1;
		exit(0);
	}
	ll x1 = mn[(n / 2)], x2 = mn[(n / 2) + 1];
	ll y1 = mx[(n / 2)], y2 = mx[(n / 2) + 1];
	ll Mx = (y1 + y2);
	ll Mn = (x1 + x2);
	return cout << Mx - Mn + 1, 0;
	if ((x1 + x2) % 2 == 0 && (y1 + y2) % 2 == 0)
		return cout << 2 * ((y1 + y2) / 2 - (x1 + x2) / 2 + 1) - 1, 0;
	if ((x1 + x2) % 2 == 0 && (y1 + y2) % 2 == 1) {
		return cout << 2 * ((y1 + y2) / 2 - (x1 + x2) / 2 + 1) , 0;
	}
	if ((x1 + x2) % 2 == 1 && (y1 + y2) % 2 == 1) {
		return cout << 2 * ((y1 + y2) / 2 - (x1 + x2) / 2 + 1) , 0;
	}
	if ((x1 + x2) % 2 == 0 && (y1 + y2) % 2 == 1) {
		return cout << 2 * ((y1 + y2) / 2 - (x1 + x2) / 2 + 1) , 0;
	}
	
	
}

Measured memory_bytes: 10096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    double ans = 0;
    for(int i = 0; i < n; i++)
        ans += 1 / a[i];
    ans = 1 / ans;
    printf("%.8f\n",ans);
    return 0;
}

Measured memory_bytes: 3792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b, p;
    cin >> n >> a >> b;
    vector<int> cnt(3, 0);
    for(int i=0;i<n;++i) {
        cin >> p;
        if(p <= a) {
            ++cnt[0];
        } else if(p <= b) {
            ++cnt[1];
        } else {
            ++cnt[2];
        }
    }

    cout << *min_element(all(cnt)) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<Character, Integer> map = new HashMap<>();
    char[] chars = {'M', 'A', 'R', 'C', 'H'};
    for(int i = 0; i < chars.length; i++){
      map.put(chars[i], 0);
    }
    for(int i = 0; i < n; i++){
      switch(sc.next().charAt(0)){
        case 'M':
          map.put('M', map.get('M')+1);
          break;
        case 'A':
          map.put('A', map.get('A')+1);
          break;
        case 'R':
          map.put('R', map.get('R')+1);
          break;
        case 'C':
          map.put('C', map.get('C')+1);
          break;
        case 'H':
          map.put('H', map.get('H')+1);
          break;
        default:
          break;
      }
    }
    long sum = 0;
    for(int i = 0; i <= 2; i++){
      for(int j = i + 1; j <= 3; j++){
        for(int k = j + 1; k <= 4; k++){
          sum += (long)map.get(chars[i]) * map.get(chars[j]) * map.get(chars[k]);
        }
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 45440
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int k;

void init() {

}

void input() {
	cin >> k;
}

void solve() {
	cout << (k/2) * ((k+1)/2) << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

int main() {
    int k;
    cin >> k;
    string lun = "1";
    for (int i = 1; i < k; i++) {
        for (int j = lun.size()-1; j >= 0; j--) {
            if (j == 0) {
                if (lun[0] == '9') {
                    lun[0] = '1';
                    for (int k = 1; k < lun.size(); k++) lun[k] = '0';
                    lun.push_back('0');
                } else {
                    lun[0]++;
                    for (int k = 1; k < lun.size(); k++) {
                        lun[k] = max((int)'0', lun[k-1]-1);
                    }
                }
            }
            else if (j == lun.size()-1 && (lun[j] == lun[j-1] || lun[j]+1 == lun[j-1]) && lun[j] != '9') {
                lun[j]++;
                break;
            }
            else if (j < lun.size()-1 && (lun[j] == lun[j-1] || lun[j]+1 == lun[j-1]) && lun[j] != '9') {
                lun[j]++;

                for (int k = j+1; k < lun.size(); k++) {
                    lun[k] = max((int)'0', lun[k-1]-1);
                }
                break;
            }
        }
    }
    std::cout << lun << endl;
    return 0;
}


Measured memory_bytes: 256
INF = 10 ** 18

N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, C = map(int, input().split())
    G[L].append([C, R])
    G[R].append([C, L])

for i in range(1, N):
    G[i + 1].append([0, i])

d = [INF] * (N + 1)

def dijkstra(s):
    import heapq
    d[s] = 0
    pque = []
    heapq.heappush(pque, [0, s])
    
    while pque:
        p = heapq.heappop(pque)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(G[v])):
            e = G[v][i]
            if d[e[1]] > d[v] + e[0]:
                d[e[1]] = d[v] + e[0]
                heapq.heappush(pque, [d[e[1]], e[1]])

dijkstra(1)

print (-1 if d[-1] == INF else d[-1])

Measured memory_bytes: 100332
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	k :=-1
	for i :=0; i<4; i++ {
		v , _  :=strconv.Atoi(string(s[i]))
			if v == k {
				fmt.Println("Bad")
				return
			}
			k = v
	}
	fmt.Println("Good")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int n, a, b;
  cin >> n;
  string str;
  double x;
  long double ans = 0;
  FOR(i,n){
    cin >> x >> str;
    if(str=="BTC")
      ans+=x*380000;
    else 
      ans+=x;
  }
  cout << ans fin;
    
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256