akhauriyash/Code-Regression huggingface dataset:
// -*- coding:utf-8-unix -*-

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        k: usize
    }
    let mut v: Vec<usize> = vec![];
    let mut c: char = s[0];
    let mut n: usize = 0;
    for i in 0..s.len() {
        if c != s[i] {
            if n > 0 {
                v.push(n);
            }
            c = s[i];
            n = 1;
        } else {
            n = n+1;
        }
    }
    v.push(n);

    let mut res = 0;
    for i in &v {
        res += i / 2;
    }
    if v.len() == 1 {
        println!("{}", s.len()*k/2);
        return;
    }
    let first = v[0];
    let last = v.last().unwrap();
    if s[0] != *s.last().unwrap() {
        println!("{}", res*k);
    } else {
        res -= first / 2 + last / 2;
        res *= k;
        res += (first + last) / 2 * (k-1) + first / 2 + last / 2;
        println!("{}", res);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N){
  cout << myCeil(N, 2) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        double[] e = new double[n];
        for(int i=0; i<n; i++) {
            int p = in.nextInt();
            e[i] = p * (p+1) / 2.0 / (double)p;
        }
        double max = 0;
        for(int i=0; i<k; i++) {
            max += e[i];
        }
        double cur = max;
        for(int i=0; i<n-k; i++) {
            cur -= e[i];
            cur += e[i+k];
            max = Math.max(max, cur);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 81692
if __name__=="__main__":
    n = int(input())
    myList = []
    while n>0:
        myList.append(n % 10)
        n = n/10
    if myList[0]==2 or myList[0]==4 or myList[0]==5 or myList[0]==7 or myList[0]== 9:
        print("hon")
    elif myList[0]==0 or myList[0]==1 or myList[0]==6 or myList[0]==8:
        print("pon")
    elif myList[0]==3:
        print("bon")

Measured memory_bytes: 9200
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
      	int i;
      	int j = 0;
      

      
      	char[] ss = S.toCharArray();
      
      	
      
	for (i=0;i<N-2;i++){
        	if(ss[i] == 'A'){
            	if(ss[i+1] == 'B'){
                	if(ss[i+2] == 'C'){
                		j++;
                	}
                }
            }
        }
      
      System.out.print(j);
      
	return;

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll a, b;cin >> a >> b;cout << a * b << endl;

	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Flow {
    explicit Flow(int n) {
        mVertices.resize(n);
        mDir.assign(n, 0);
        mIter.assign(n, 0);
    }

    void addEdge(int from, int to, long long int cap) {
        mVertices[from].edge.emplace_back(Edge{to, cap, static_cast<int>(mVertices[to].edge.size())});
        mVertices[to].edge.emplace_back(Edge{from, 0, static_cast<int>(mVertices[from].edge.size())});
    }

    long long int maxFlow(int s, int t) {
        long long int retValue = 0;
        while (true) {
            bfs(s);
            if (mDir[t] == MAX_VALUE)
                break;
            fill(mIter.begin(), mIter.end(), 0);
            long long int flow = 0;
            while ((flow = dfs(s, t, INF_VALUE)) > 0)
                retValue += flow;
        }
        return retValue;
    }

    void bfs(int s) {
        fill(mDir.begin(), mDir.end(), MAX_VALUE);
        queue<int> q;
        q.push(s);
        mDir[s] = 0;
        while (!q.empty()) {
            int t = q.front();
            q.pop();
            int cost = mDir[t] + 1;
            for (const auto &e:mVertices[t].edge) {
                if (mDir[e.to] <= cost || e.capacity <= 0)
                    continue;
                mDir[e.to] = cost;
                q.push(e.to);
            }
        }
    }

    long long int dfs(int s, int t, long long int f) {
        if (s == t)
            return f;
        for (int &i = mIter[s]; i < mVertices[s].edge.size(); ++i) {
            Edge &e = mVertices[s].edge[i];
            if (e.capacity <= 0 || mDir[s] >= mDir[e.to])
                continue;
            long long int d = dfs(e.to, t, std::min(f, e.capacity));
            if (d > 0) {
                e.capacity -= d;
                mVertices[e.to].edge[e.rev].capacity += d;
                return d;
            }
        }
        return 0;
    }

    struct Edge {
        int to;
        long long int capacity;
        int rev;
    };
    struct Vertex {
        vector<Edge> edge;
    };
    vector<Vertex> mVertices;
    vector<int> mDir;
    vector<int> mIter;

    const int MAX_VALUE = 1e9;
    long long int INF_VALUE = (long long int) 1e15;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll V, E;
    cin >> V >> E;
    Flow flow(V);
    REP(i, E) {
        ll a, b, c;
        cin >> a >> b >> c;
        flow.addEdge(a, b, c);
    }
    cout << flow.maxFlow(0, V - 1) << endl;
    return 0;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans;
signed main(){
	ios_base::sync_with_stdio(0);
	int x;
	cin>>x;
	int now=100;
	while(now<x){
		ans++;
		now=now+now/100;
		//cout<<now<<"\n";
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int w, h, n; cin >> w >> h >> n;
    vector<vector<bool>> s(h, vector<bool>(w, false));
    for (int i = 0; i < n; i++) {
        int x, y, a; cin >> x >> y >> a;
        for (int i = (a == 4 ? y : 0); i < (a == 3 ? y : h); i++) {
            for (int j = (a == 2 ? x : 0); j < (a == 1 ? x : w); j++) {
                s[i][j] = true;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) ans += count(s[i].begin(), s[i].end(), false);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
 
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n
 
const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;
 
void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}
 
void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}
 
void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}
 
int main(){
  int a,b;
  cin >>a>>b;
  a--;b--;
  cout<<a*b<<endl;
    
 return 0;
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>) {
    val N = ("0" + readInputLine() + "0").toCharArray().reversed()

    val dp = Array(N.size) { IntArray(2) }

    dp[0][0] = char2int(N[0])
    dp[0][1] = char2int(N[0])

    for (i in 1 until N.size) {
        dp[i][0] = Math.min(dp[i - 1][0] + char2int(N[i]), dp[i - 1][1] + char2int(N[i]) + 1)
        if (i != 1) {
            dp[i][1] = Math.min(dp[i - 1][0] + 10 - char2int(N[i]), dp[i - 1][1] + 10 - char2int(N[i]) - 1)
        } else {
            dp[i][1] = Math.min(dp[i - 1][0] + 10 - char2int(N[i]), dp[i - 1][0] + 10 - char2int(N[i]))
        }
    }

    println(Math.min(dp[N.size - 1][0], dp[N.size - 1][1]))
}

fun readInputLine(): String {
    return readLine()!!
}

fun char2int(c: Char): Int {
    return c - '0'
}


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

int c = 0;
long long int gcd(long long int l, long long int r) {

	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		c++;
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}

int main() {
	while (1) {
		int a, b; cin >> a >> b;
		if (!a)break;
		if (a > b)swap(a, b);
		c = 0;
		int agcd = gcd(a, b);
		cout << agcd << " " << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().split()))

cnt = 1
prev = -1
dir = 0

for i in range(N):
  if prev == -1:
    prev = A[i]
    continue
    
  if dir == 0:
    if prev < A[i]:
      dir = 1
    elif prev > A[i]:
      dir = -1
  elif dir > 0:
    if prev <= A[i]:
      pass      
    else:
      dir = 0
      cnt += 1
  else:
    if prev >= A[i]:
      pass
    else:
      dir = 0
      cnt += 1
  prev = A[i]
  
print(cnt)

Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
const int N = 1e7 + 1;
bool isprime[N];

void seive(){
  fill (isprime + 2, isprime + N, true);
  for(int i = 2; i < N; i ++){
	  if (isprime[i]){
		for(int j = 2 ; i * j < N; j++){
			 isprime[i * j] = false;
	      }  
	   }  
	}
}

void solve(){
	seive();
     int n;
     while(cin >> n){
	  int cnt = 0;
	  for(int i = 1; i <= n; i++)
	    cnt += (isprime[i]);
	  cout << cnt << endl;
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 12876
h,w =map(int,input().split())
D = [[0]*(w+2) for _ in range(h+2)]
for _ in range(1,h+1):
    for inp,i in zip(input(),range(1,w+1)):
        if inp == ".":
            D[_][i] = 0
        else:
            D[_][i] = 1
Ans = True
for i in range(1,h+1):
    for j in range(1,w+1):
        if D[i][j] == 1:
            if D[i+1][j]+D[i-1][j]+D[i][j+1]+D[i][j-1] == 0:
                Ans = False
    if not(Ans):
        break
if Ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#####

import numpy as np
from numpy import newaxis, float32, float64, int32, int64, int16, int8, uint8, uint32, complex64, complex128

#####

def getIntList(inp):
	return [int(_) for _ in inp]
	

from sys import stdin

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	n=int(inputs[0][0])
	m=int(inputs[0][1])

	no=False
	
	dig=-np.ones(n, int32)
	for i in range(m):
		si=int(inputs[1+i][0])-1
		ci=int(inputs[1+i][1])
		
		if dig[si]==-1:
			dig[si]=ci
		elif dig[si]!=ci:
			no=True
			break
		
	if dig[0]==-1:
		if n==1:
			dig[0]=0
		else:
			dig[0]=1
	
	dig[dig==-1]=0
	
	if dig[0]==0 and n>1:
		no=True
	
	if no:
		print("-1")
	else:
		print("".join(map(str, dig)))
			
		
	
	
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
	


Measured memory_bytes: 12796
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete

f a b = max 0 $ (b - a) `div` 2

main = (!!1) <$> getInts >>= flip replicateM getInts >>= print . sum . init . sort . map (apply2 f)


Measured memory_bytes: 4880
#include <iostream>
#include <string>

using namespace std;

string W,P;
int wlen,plen;
int* T;

void makeTable(){
  T = new int[plen];
  T[0] = -1;
  T[1] = 0;
  int front = 0;
  for(int i=1;i<plen-1;i++){
    if(P[front]==P[i]){
      front ++;
    }else{
      front = 0;
    }
    T[i+1] = front;
  }
}

void match(){
  int top = 0;
  while(1){
    for(int i=0;i<plen;i++){
      if(W[i+top]==P[i]){
        if(i==plen-1){
          cout<<top<<endl;
          top = i+top-T[i];
          break;
        }
        continue;
      }else{
        top = i+top-T[i];
        break;
      }
    }
    if(top>wlen-plen) break;
  }
}

int main(){
  cin>>W>>P;
  
  wlen=W.size();
  plen=P.size();

  makeTable();
  match();
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){
    
    int n; 
    cin >> n;
    vector <int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;
    rep(i,n) ans += a[i] - 1;

    cout << ans << endl;

    
}





//              g++ -std=c++1z


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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int N;
	cin >> N;
	long double tot = 0, cur = 0;
	for(int i = 0; i < N; i++){
		cin >> cur;
		tot += (1 / cur);
	}
	tot = 1 / tot;
	cout << tot;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

tocnt = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}

def compare(a, b):
    if a is None:
        return b
    if len(a) > len(b):
        return a
    if len(a) < len(b):
        return b
    return max(a, b)

N, M = MAP()
A = LIST()

# dp[i] := マッチをi本使った状態での最大値
dp = [None] * (N+1)
dp[0] = ''
for i in range(N):
    if dp[i] is None:
        continue
    for j in A:
        cnt = tocnt[j]
        if i+cnt <= N:
            dp[i+cnt] = compare(dp[i+cnt], dp[i] + str(j))
print(dp[N])


Measured memory_bytes: 30196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int gcd(int a,int b){
	int res,max;
	if(a>=b){
		res=b;
		max=a;
	}
	else{
		res=a;
		max=b;
	}

	while(max%res!=0){
		int tem=res;
		res=max%res;
		max=tem;
	}

	return res;
}

int main(void) {
	long a,b;
	while(scanf("%ld",&a)!=EOF){
		scanf("%ld",&b);
		long g,l;
		g=gcd(a,b);
		l=a*(b/g);
		printf("%ld %ld\n",g,l);
	}

	return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, m = LI()
    print("Yes" if n == m else "No")
    return

#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000005
#define maxm 2000005
#define inf 0x3f3f3f3f
#define int long long
#define mod 998244353
#define local
void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
template <typename Tp> void read(Tp &x){
	int fh=1;char c=getchar();x=0;
	while(c>'9'||c<'0'){if(c=='-'){fh=-1;}c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c&15);c=getchar();}x*=fh;
}
int n,m;
int a[maxn],h[maxn],s[maxn];
int pr[maxn],p[maxn],tot,mu[maxn],sg[maxn];
void preprocess(){
	mu[1]=1;
	for(int i=2;i<=m;i++){
		if(!p[i])p[i]=i,pr[++tot]=i,mu[i]=-1;
		for(int j=1;j<=tot;j++){
			if(i*pr[j]>m||p[i]<pr[j])break;
			p[i*pr[j]]=pr[j];
			if(i%pr[j]==0)mu[i*pr[j]]=0;
			else mu[i*pr[j]]=-mu[i];
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=1;i*j<=m;j++){
			sg[i*j]+=mu[i]*i;
			sg[i*j]%=mod;
		}
	}
}
int ans,sum;
signed main(){
	#ifndef local
		file("");
	#endif
	read(n);
	for(int i=1;i<=n;i++)read(a[i]),h[a[i]]++,m=max(m,a[i]),sum+=a[i],sum%=mod;
	preprocess();
	for(int D=1;D<=m;D++){
		for(int i=1;i*D<=m;i++){
			s[D]+=i*h[i*D];
			s[D]%=mod;
		}
	}
	for(int D=1;D<=m;D++){
		ans+=D*s[D]%mod*s[D]%mod*sg[D]%mod;
		ans%=mod;
	}
	(ans-=sum)%=mod;
	printf("%lld\n",(ans*(998244354/2)%mod+mod)%mod);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 43264
#include <stdio.h>
int n, x, i, l[101], ans, hoge, count;
int main(void)
{
    scanf("%d%d", &n, &x);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &l[i]);
    }
    for (i = 0; i < n; i++)
    {
        hoge += l[i];
    }
    if (hoge <= x)
    {
        printf("%d", n + 1);
    }
    else
    {
        for (i = 0; ans <= x; i++)
        {
            ans += l[i];
            count++;
        }
    printf("%d", count);
        
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  ll n,k;cin >>n>> k;
  vector<ll> a(n), sum(n+1);
  for(int i = 0; i < n; ++i)cin >>a[i];
  ll idx =-1;
  for(int i =0; i < n-1; ++i){
    if(a[i]+a[i+1]>=k){
      idx = i;
      break;
    }
  }
  if(idx == -1){
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for(int i = 0; i < idx; ++i){
    cout << i+1 << endl;
  }
  for(int i = n-2; i >= idx; --i){
    cout << i+1 << endl;
  }
}


Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,k;

int main(){
  int ans=0;
  cin >> n ;
  vector<int> a(n);
  REP(i,n) cin>>a[i];
  REP(i,n){
    if (a[i]!=(i+1))ans++;
  }

  if (ans>2){
    cout<<"NO"<<endl;
  }else{
  cout<<"YES"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL poww(LL a,LL n)
{
    if(n==0) return 1;
    LL val=poww(a,n/2);
    if(n%2==0) return (val*val)%mod;
    else return (((val*val)%mod)*a)%mod;
}

LL k, n, fact[3000005], inv[3000005];
string s;

inline LL comb(LL n,LL k)
{
    if(n==0||k==0||n-k<0) return 1;
    return (((fact[n]*inv[k])%mod)*inv[n-k])%mod;
}

int main()
{
	FIO;
	cin >> k >> s;
	fact[0]=1;
	inv[0]=1;
    n = s.length();
	rep(i, 1, n+k+2){
	    fact[i]=(fact[i-1]*i)%mod;
	    inv[i]=poww(fact[i],mod-2);
	}
    LL ans = poww(26LL, n+k);
    rep(i, 0, n-1) {
        LL val = comb(n+k, i);
        val = (val * poww(25, n+k-i)) % mod;
        ans = (ans + mod - val) % mod;
    }
    cout << ans << endl;
}

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

#define ll long long

int main(){

    int a, b;
    cin >> a >> b;

    if( a > b){
        cout << "a > b" << endl;
    }else if(a < b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }


    return 0;
}

Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int c = scan.nextInt();

        int[] list = new int[m];
        int[][] map = new int[n][m];

        for(int i = 0; i < m; i++) {
        	list[i] = scan.nextInt();
        }

        for(int i = 0; i < n; i++) {
        	for(int j = 0; j < m; j++) {
        		map[i][j] = scan.nextInt();
        	}
        }

        int ans = 0;
        for(int i = 0; i < n; i++) {
        	int sum = 0;
        	for(int j = 0; j < m; j++) {
        		sum += map[i][j] * list[j];
        	}
        	if(sum + c > 0)
        		ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    if (m > n * 2) {
        std::cout << n + (m - n * 2) / 4 << std::endl;
    } else {
        std::cout << std::min(m / 2, n) << std::endl;
    }
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int[] nums = new int[3];
		
		for(int i=0; i<nums.length; i++) {
			nums[i] = sc.nextInt();
		}
		
		Arrays.sort(nums);
		
		int cost = 0;
		
		cost = 0 + Math.abs(nums[1] - nums[0]) + Math.abs(nums[2] - nums[1]);
		System.out.println(cost);
	}
	
}


Measured memory_bytes: 21972
//void _(){
//    int n;
//    cin >> n;
//    vi arr(3*n);
//    cin >> arr;
//    vl cheap(n+1),expensive(n+1);
//    {
//        priority_queue<ll,vl,greater<ll>> here;
//        for(int i = 0; i < n; ++i)
//            here.push(arr[i]);
//        ll sum = 0;
//        for(int i = n; i < 2*n; ++i){
//            here.push(arr[i]);
//            sum += here.top();
//            here.pop();
//            cheap[i-n+1] = sum;
//        }
//    }
//    {
//        priority_queue<ll> here;
//        for(int i = 2*n; i < 3*n; ++i)
//            here.push(arr[i]);
//        ll sum = 0;
//        for(int i = 2*n-1; i >= n; --i){
//            here.push(arr[i]);
//            sum += here.top();
//            here.pop();
//            expensive[2*n-i] = sum;
//        }
//    }
//    vl psum(3*n+1);
//    for(int i = 1; i <= 3*n; ++i){
//        psum[i] = psum[i-1]+arr[i-1];
//    }
//    ll ans = -INF;
//    for(int l = 0; l <= n; ++l){
//        ll cur = psum[n+l] - (psum[3*n]-psum[n+l]);
//        cur -= cheap[l];
//        cur += expensive[n-l];
//        ans = max(ans,cur);
//    }
//    print(ans);
//}
//
#include <iomanip>
#include <algorithm>
#include <queue>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
const ll INF = ll(2e18) + 666;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n;
    cin >> n;
    vi arr(3*n);
    cin >> arr;
    vl cheap(n+1),expensive(n+1);
    {
        priority_queue<ll,vl,greater<ll>> here;
        for(int i = 0; i < n; ++i)
            here.push(arr[i]);
        ll sum = 0;
        for(int i = n; i < 2*n; ++i){
            here.push(arr[i]);
            sum += here.top();
            here.pop();
            cheap[i-n+1] = sum;
        }
    }
    {
        priority_queue<ll> here;
        for(int i = 2*n; i < 3*n; ++i)
            here.push(arr[i]);
        ll sum = 0;
        for(int i = 2*n-1; i >= n; --i){
            here.push(arr[i]);
            sum += here.top();
            here.pop();
            expensive[2*n-i] = sum;
        }
    }
    vl psum(3*n+1);
    for(int i = 1; i <= 3*n; ++i){
        psum[i] = psum[i-1]+arr[i-1];
    }
    ll ans = -INF;
    for(int l = 0; l <= n; ++l){
        ll cur = psum[n+l] - (psum[3*n]-psum[n+l]);
        cur -= cheap[l];
        cur += expensive[n-l];
        ans = max(ans,cur);
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 5472
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  int cur = -1, p = -1;
  rep(i,N){
    ini(x,y);
    if(amax(cur , x)) p = y;
  }
  out(cur + p);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
        int a,b;
        cin >> a >> b;
        string str;
        cin >> str;
        string digit="0123456789";
        bool all_sign=true;
        for(int i=0 ; i<a ; i++ ){
                bool sign=false;
                for(int l=0 ; l<10 ; l++ ){
                        if(str[i]==digit[l]){
                                sign=true;
                                break;
                        }
                }
                if(!sign){
                        all_sign=false;
                        break;
                }
        }
        for(int i=a+1 ; i<a+1+b ; i++ ){
                bool sign=false;
                for(int l=0 ; l<10 ; l++ )
                        if(str[i]==digit[l])
                                sign=true;
                if(!sign){
                        all_sign=false;
                        break;
                }
        }
        if(str[a]!='-')
                all_sign=false;
        if(all_sign)
                cout<<"Yes"<<endl;
        else
                cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/06/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[5] = {0};
	int ans = 0;
	scanf("%s", S);
	if(S[0] == S[1]) {
		ans++;
	}
	if(S[1] == S[2]) {
		ans++;
	}
	if(S[2] == S[3]) {
		ans++;
	}
	if(ans != 0) {
		printf("Bad\n");
	} else {
		printf("Good\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  int n,k;cin>>n>>k;
  vector<int>h(n);
  int ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
    if(h.at(i)>=k)
      ans++;
  }
  cout<<ans;
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int k, n;
    int dist = 0;
    cin >> k >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    FOR (i, 1, n) dist = max(dist, a[i] - a[i - 1]);
    dist = max(dist, a[0] + k - a[n - 1]);
    cout << k - dist << endl;

    
    return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;
import java.lang.Math;

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

    while (cin.hasNext()){
      d = cin.nextInt();
      int res = cal_integral(d);
      System.out.println(res);
    }
  }
  
  private static int cal_integral(int d) {
    int base = d, res = 0;
    while (base != 600){
      res += f(base) * d;
      base += d;
    }
    return(res);
  }

  private static int f(int x) {
    return(x * x);
  }
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 0;
  
  for(int i=0; i<N-2; i++){
    if (S.at(i) == 'A'){
      if ((S.at(i+1) == 'B')&&(S.at(i+2) == 'C')){
        count++;
      }
    }
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> mondai(N);
  for(int i=0; i<N; i++){
    int d;
    cin>>d;
    mondai.at(i)=d;
  }
  sort(mondai.begin(), mondai.end());
  int count=0;
  for(int k=0; k<=mondai.at(N-1); k++){
    if(mondai.at((N/2)-1)<k && mondai.at(N/2)>=k){
      count++;
    }
  }
  cout<<count<<endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b) + (a == c) + (b == c) == 1) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
loop do
  n = gets.chomp.to_i
  break if n == 0

  keys = gets.chomp.split(' ').map(&:to_i)
  station_list = ('a'..'z').to_a + ('A'..'Z').to_a

  enc_stations = gets.chomp
  dec_stations = ''

  enc_stations.size.times do |i|
    pos = station_list.index(enc_stations[i])
    dec_stations << station_list[pos - keys[i % keys.size]]
  end

  puts dec_stations
end

Measured memory_bytes: 6124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int ridetime;
    int first;
    int always;
};
int main() {
    int n; cin >> n;
    vector<P> v(n-1);
    rep(i,n-1){
        cin >> v[i].ridetime >> v[i].first >> v[i].always;
    }

    rep(i,n-1){
        int ans = v[i].first+v[i].ridetime;
        for(int j = i+1; j < n-1; j++){
            if(v[j].first>=ans){
                ans = v[j].first;
                ans += v[j].ridetime;
            }else{
                ans = v[j].first + ((ans - v[j].first - 1) / v[j].always + 1)*v[j].always;
                ans += v[j].ridetime;
            }
        }
        cout << ans << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

bool cmp(int i,string s,string t)
{
	int j,f=1;
	for(j=0;j<s.length();j++)
	{
		if(s[(j+i)%(s.length())]!=t[j]){
			f=0;break;
		}
	}
	return f;
}

int main(){ FastIO;

string s,t;cin>>s>>t;
int f=0;
for(int i=0;i<s.length();i++)
{
	f=f|cmp(i,s,t);
}
cout<<(f ? "Yes" : "No");


return 0;
}


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

int main() {
   int A[3];
   for (int i = 0; i < 3; i++) cin >> A[i];
   sort(A, A + 3);

   int cnt = 0;
   while (1) {
      if (A[0]+2 > A[2]) break;
      A[0] += 2;
      cnt++;
   }
   while (1) {
      if (A[1]+2 > A[2]) break;
      A[1] += 2;
      cnt++;
   }

   sort(A, A + 3);
   if (A[0] == A[1] && A[1]+1 == A[2]) {
      cout << cnt + 1 << endl;
   } else if (A[0]+1 == A[1] && A[1] == A[2]) {
      cout << cnt + 2 << endl;
   } else {
      cout << cnt << endl;
   }

   return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String n = sc.next();
		String s[] = new String[N];
		int a[] = new int[N];

		for (int i = 0; i < N; i++) {
			s[i] = n.substring(i, i+1);
		}

		for (int i = 0; i < N; i++) {
			if (i == 0) {
				//東に向いている人の数を数える
				for (int j = 1; j < N; j++) {
					if (s[j].equals("E")) {
						a[i]++;
					}
				}
			} else {
				//自分より右にいる人で西を向いている人は方向を変える必要がある
				if (s[i-1].equals("W")) {
					a[i] = a[i-1] + 1;
				} else {
					a[i] = a[i-1];
				}
				//自分が東を向いている場合は自分の分を抜く
				if (s[i].equals("E")) {
					a[i]--;
				}
			}
		}
		Arrays.sort(a);
		System.out.println(a[0]);
	}
}


Measured memory_bytes: 53708
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
a,b,c = gets.chomp.split.map(&:to_i)

if c > a+b
  if 4 * a * b - (c-(a+b))**2 < 0
    puts 'Yes'
  else
    puts 'No'
  end
else
  puts 'No'
end

Measured memory_bytes: 4092