akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<u128> = sc.vec(n);
    let mut ans = 0;
    let mut last = 0;
    for &x in xs.iter() {
        if x < last {
            ans += last - x;
        } else {
            last = x;
        }
    }
    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 15860
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] c = new int[n-1];
        int[] s = new int[n-1];
        int[] f = new int[n-1];
        for(int i = 0; i<n-1; i++) {
            c[i] = sc.nextInt();
            s[i] = sc.nextInt();
            f[i] = sc.nextInt();
        }
        for(int i = 0; i<n-1; i++) {
            int ans = s[i]+c[i];
            for(int j = i+1; j<n-1; j++) {
                if(ans<s[j]) {
                    ans = s[j]+c[j];
                    continue;
                }
                int kaisuu = (int)Math.ceil((double)(ans-s[j])/(double)f[j]);
                //System.out.println(ans + " " +kaisuu);
                ans += c[j] + f[j]*kaisuu-(ans-s[j]);
            }
            System.out.println(ans);
        }
        System.out.println(0);
    }
}

Measured memory_bytes: 26060
#include <iostream>

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

int daycount(int year, int mon, int day) {
	int total = 0;
	int past_year = year-1;
	int past_mon = mon -1;

	if (past_year%3 == 0) {
		total += (past_year * 10 * 20) - (5 * 2 * (past_year/3)); 
	}else {
		total += (past_year * 10 * 20) - ((5 * 2 * (past_year/3))+5*(past_year%3)); 
	}		   		
	if (year%3 == 0) {
		total += past_mon * 20;
	}else {
		total += past_mon * 20 - (past_mon/2);
	}
	return total + (day-1);
}

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

	for (int i = 0; i < n; i++) {
		int Y,M,D;
		cin >> Y;
		cin >> M;
		cin >> D;
		
		cout << daycount(1000,1,1) - daycount(Y,M,D) << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE-UAP
Todo:
https://codeforces.com/contest/1398/problem/E
https://codeforces.com/problemset/problem/374/C
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

const int N=2e6+5;
int n,k,m;

int ck[N];
int a[N];

void HalfDead()
{
      bool flag=true;
      cin>>n;

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


      for(int i=2;i<=1000000;++i)
      {
            int cnt=0;

            for(int j=i;j<=1000000;j+=i)
            {
                  cnt+=ck[j];
            }

            if(cnt>=2)
            {
                  flag=false;
                  break;
            }
      }

      if(flag)
      {
            cout<<"pairwise coprime"<<endl;
            return;
      }

      int g=a[1];
      for(int i=2;i<=n;++i)
      {
            g=__gcd(g,a[i]);
      }

      if(g==1)
      {
            cout<<"setwise coprime"<<endl;
      }
      else
      {
            cout<<"not coprime"<<endl;
      }
      
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);  cout.tie(0);
      int tc=1;
     // cin>>tc;
      while(tc--)
      {
            HalfDead();
      }
      return 0;
}

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

using namespace std;

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

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18;

int n;
ll t[N];

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%lld", t + i);
  }
  ll ans = t[1];
  for(int i = 1; i <= n; ++i){
    ans = ans / __gcd(t[i], ans);
    ans = ans * t[i];
  }
  printf("%lld", ans);
  return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	int ans = 0;
	rep(i,n){
		cin >> a[i];
		while(a[i]%2 == 0){
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N, W;
	std::cin >> N >> W;
	vll w(N), v(N);
	rep(i, 0, N) {
		std::cin >> w[i] >> v[i];
	}

	vector<vll> dp(N + 1, vll(W + 1, 0));

	rep(i, 0, N) {
		repeq(j, 1, W) {
			if (j < w[i]) {
				dp[i+1][j] = dp[i][j];
			}
			else {
				dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			}
		}
	}
	std::cout << dp[N][W] << endl;
	
	return 0;

}


Measured memory_bytes: 80256
N,K = map(int,input().split())
Nei = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    Nei[a].append(b)
    Nei[b].append(a)

def bfs(_N,_Nei,_K):
    mod = 10**9 + 7
    Q = []
    memo = [-1]*(_N+1)
    memo[1] = 0
    next = 1
    temp = len(_Nei[1])
    ans = _K
    for k in range(1,temp+1):
        ans = (ans*(_K-k))%mod
    for node in Nei[1]:
        memo[node] = 1
        Q.append(node)
    
    while True:
        temp = _K - 2
        for node in Nei[next]:
            if memo[node] == -1:
                Q.append(node)
                memo[node] = memo[next] + 1
                ans = (ans*temp)%mod
                temp -= 1

        if len(Q) == 0:
            return ans
        else:
            next = Q.pop(0)
print(bfs(N,Nei,K))

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

struct Cards{
    char suit, value;
};

void bubble(struct Cards A[], int N){
    for (int i = 0; i < N; ++i){
        for (int j = N - 1; j >= i + 1; --j){
            if (A[j].value < A[j-1].value){
                Cards t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Cards A[], int N){
    for (int i = 0; i < N; ++i){
        int minj = i;
        for (int j = i; j < N; ++j){
            if (A[j].value < A[minj].value) minj = j;
        }
        Cards t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Cards A[], int N){
    for (int i = 0; i < N; ++i){
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Cards C1[], struct Cards C2[], int N){
    for (int i = 0; i < N; ++i){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Cards C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i =0; i < N; ++i){
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; ++i) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}



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

typedef long long  ll;
int main(){
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  ll m=min(a, min(b, min(c, min(d, e ) ) ) );
  cout<<((n-1)/m) +5 <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	if(A >= B + 2){
		cout << 2 * A - 1 << endl;
	}else if(B >= A + 2){
		cout << 2 * B - 1 << endl;
	}else{
		cout << A + B << endl;
	}
}

Measured memory_bytes: 256
import numpy as np

h, w = map(int,input().split())
s = [input() for _ in range(h)]

dp = np.zeros((h, w), dtype = np.int64)
dp[0][0] = 1
mod = 10**9 + 7

for i in range(h):
	for j in range(w):
		if s[i][j] == ".":
			if j == 0:
				if i == 0:
					continue
				dp[i][j] = dp[i-1][j]
			else:
				if i == 0:
					dp[i][j] = dp[i][j-1]
				else:
					dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod
print(dp[h-1][w-1])

Measured memory_bytes: 35464
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))



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

    int n, m;
    s64 l;
    cin >> n >> m >> l;

    const s64 inf = 1e18;
    s64 d1[n][n], d2[n][n];
    rep (i, n) rep (j, n) d1[i][j] = d2[i][j] = inf;
    rep (i, n) d1[i][i] = d2[i][i] = 0;

    rep (i, m)
    {
        int a, b;
        s64 c;
        cin >> a >> b >> c;
        --a, --b;
        if (c <= l)
        {
            d1[a][b] = d1[b][a] = c;
        }
    }

    rep (k, n)
    {
        rep (i, n)
        {
            rep (j, n)
            {
                d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
            }
        }
    }

    rep (i, n)
    {
        rep (j, n)
        {
            if (d1[i][j] <= l) d2[i][j] = 1;
        }
    }

    rep (k, n)
    {
        rep (i, n)
        {
            rep (j, n)
            {
                d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    while (q--)
    {
        int s, t;
        cin >> s >> t;
        --s, --t;
        if (d2[s][t] == inf) cout << "-1\n";
        else cout << d2[s][t] - 1 << "\n";
    }

    return 0;
}



Measured memory_bytes: 5004
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n;
int inp[100'005];
int main(void) {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &inp[i]);
	}
	sort(inp, inp + n);
	int t = n / 2;
	int ans = inp[t] - inp[t - 1];
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define N 500500
#define SIGMA 26

string s;
int aib[SIGMA][N];
int x, n, q, i, task, l, r, ans, j, curr;
char c;

inline int zeros (int x){
    return x & (-x);
}

void update (int index, int poz, int x){
    for (int it = poz; it <= n; it += zeros(it))
        aib[index][it] += x;
}

int compute (int index, int poz) {
    int ans = 0;
    for (int it = poz; it > 0; it -= zeros(it))
        ans += aib[index][it];
    return ans;
}
int main()
{
    cin >> n >> s >> q;
    for (i = 0; i < n; ++i)
        update((int)(s[i] - 'a'), i + 1, 1);
    for (i = 0; i < q; ++i){
        cin >> task;
        if (task == 1){
            cin >> x >> c;
            update ((int)(s[x - 1] - 'a'), x, -1);
            s[x - 1] = c;
            update ((int)(s[x - 1] - 'a'), x, 1);
        }
        else{
            cin >> l >> r;
            ans = 0;
            for (j = 0; j < SIGMA; ++j){
                curr = compute (j, r) - compute(j, l - 1);
                if (curr > 0)
                    ++ans;
            }
            cout << ans << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 51716
import sys
input = lambda: sys.stdin.readline().rstrip()

MOD = 1000000007

X,Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
    exit()

def combination(n,r,mod):
    r = min(r, n-r)
    numer = denom = 1

    for i in range(r):
        numer = numer*(n-i)%mod
        denom = denom*(i+1)%mod
    return numer * pow(denom, mod-2, mod) % mod


tmp = (X+Y) // 3
m = X - tmp
n = Y - tmp
if m < 0 or n < 0:
    print(0)
    exit() 

ans = combination(m+n, m, MOD)
print(ans)

Measured memory_bytes: 38512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int N, M, Q;
vector<long long> A, B, C, D;
long long ans = 0;

void score(vector<int> seq) {
    long long tmp = 0;
    for (int i = 0; i < Q; i++) {
        if (seq[B[i]] - seq[A[i]] == C[i]) tmp += D[i];
    }
    if (tmp > ans) ans = tmp;
}

void dfs(vector<int> &seq) {
    if (seq.size() == N) {
        score(seq);
        return;
    }
    int prev_last;
    if (seq.size() == 0) prev_last = 0;
    else prev_last = seq.back();
    for (int i = prev_last; i < M; i++) {
        seq.push_back(i);
        dfs(seq);
        seq.pop_back();
    }
}

int main() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
        D.push_back(d);
    }

    vector<int> seq;
    dfs(seq);
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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

    vector<char> candidate = {'S', 'W', 'S', 'W'};
    vector<char> last_candidate = {'S', 'S', 'W', 'W'};
    string ans = "-1";
    rep(k, 4) {
        vector<char> a(N);
        char start = candidate[k];
        char last = last_candidate[k];
        a[0] = start;
        rep(i, N) {
            char prev = last;
            if (i > 0) prev = a[i - 1];
            int n_i = (i + 1) % N;

            if (a[i] == 'S' && s[i] == 'o') {
                a[n_i] = prev;
            } else if (a[i] == 'W' && s[i] == 'o') {
                if (prev == 'S') a[n_i] = 'W';
                else a[n_i] = 'S';
            } else if (a[i] == 'S' && s[i] == 'x') {
                if (prev == 'S') a[n_i] = 'W';
                else a[n_i] = 'S';
            } else {
                a[n_i] = prev;
            }
        }

        if (a[a.size() - 1] == last && a[0] == start) {
            ans = string(a.begin(), a.end());
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){

int no1, no2, no3;

scanf("%d %d %d", &no1, &no2, &no3);

if((no1 < no2) && (no2 < no3)){
printf("Yes\n");
}
else {
printf("No\n");
}

return 0;
}


Measured memory_bytes: 580
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int W = a.nextInt();
		int H = a.nextInt();
		int x = a.nextInt();
		int y = a.nextInt();
		int r = a.nextInt();
		if((x + r) > W || (x - r) < 0 || (y + r) > H || (y - r) < 0){
			System.out.println("No");
		}else{
				System.out.println("Yes");
			}
		}
	}

Measured memory_bytes: 17356
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c ;
    
    int A,B,C;
    A=min(a,min(b,c));
    B=max(a,max(b,c));
    C=a+b+c-A-B;
    
    cout << A <<" "<< C <<" "<< B << endl;
    
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  int t,a; cin>>t>>a;
  vector<double> temp(n);
  for(int i=0; i<n; ++i){
    double height; cin>>height;
    temp[i] = (double)t - height * 0.006;
  }
  double min_dist=abs(temp[0] - (double)a);
  int min_i = 1;
  for(int i=0; i<n; ++i){
    //cout << abs(temp[i] - (double)a) << endl;
    if( min_dist > abs(temp[i] - (double)a)){
      min_dist = abs(temp[i] - (double)a);
      min_i = i+1;
    }
  }
  cout << min_i << endl;
  return 0;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N; cin >> N;

    VI D(N);
    REP(i,N)
    {
        cin >> D.at(i);
    }
    SORT(D);

    int a=D.at(N/2-1), b=D.at(N/2);
    cout << b-a << endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    db a, b ;
    int m, f= 0 ;
    cin >> a >> b ;
    rep(i, 1, 1e7) {
        if(floor(i*0.08) == a && floor(i*0.1) == b) {f = 1; m =i; break ;}
    }
    if(f == 1) cout << m << endl ;
    else cout << -1 << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

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




int main()
{	
	ll n,k=0;
	cin>>n;
	
ll a[n-1],b[n];
  for(ll i=0;i<n-1;i++)
  {
    	cin>>a[i];
    
    	
  }
  b[0]=a[0];
  k+=a[0];
  for(ll i=1;i<n-1;i++)
  {
    b[i]=min(a[i],a[i-1]);
    k+=b[i];
  }
  b[n-1]=a[n-2];
  k+=b[n-1];
  cout<<k;
	
}

Measured memory_bytes: 256
// KnapS

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
	ll n,w;
	cin >> n >> w;

	ll wt[n];
	ll val[n];
	ll sum = 0;
	for(int i=0 ; i<n ; i++){
		cin >> wt[i] >> val[i];
		sum += val[i];
	}

	//cout << "s" << sum << "\n";
	ll dp[n+1][sum+1];
	ll ans = 0;
	for(ll i=0 ; i<=n ; i++){
		for(ll j=0 ; j<=sum ; j++){
			if(i==0 && j==0){
				dp[i][j] = 0;
			}
			else if(i==0 && j!=0){
				dp[i][j] = INT_MAX;
			}
			else if(i!=0 && j==0){
				dp[i][j] = 0;
			}
			else{
				if(j >= val[i-1]){
					dp[i][j] = min(dp[i-1][j],dp[i-1][j-val[i-1]] + wt[i-1]);	
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}
			if(dp[i][j] <= w){
				if(ans < j){
					ans = j;
				}
			}
		}
		//cout << "\n";
	}





	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int N; cin >> N;
  string S, T; cin >> S >> T;

  rep( i, 0, N ) cout << S[i] << T[i];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
     
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 700;
     
      
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  char s[32];
     
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
     
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
       
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a];
      A[a] = b;
      if(small[curr] >= b) {
        small[curr] = b;
      } else if(update) {
        small[curr] = INF;
        for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        if(ret > small[begin - 1]) for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        if(ret > small[end]) for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

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

int main(){
  int A, B, answer = 0;
  cin >> A >> B;
  if ((A + B) % 2 == 0){
    answer = (A + B)/2;
    cout << answer << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  //似ている整数列全体数
  ll all = 1;
  for (int i = 1; i <= N; i++) {
    all *= 3;
  }
  //このうち全部奇数のやつ
  ll kisu = 1;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A%2 == 1) {
      kisu *= 1;
    }
    else {
      kisu *= 2;
    }
  }
  
  cout << all - kisu << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)

double cal(vector<double> &v, string op){
    double right = v[v.size() - 1];
    double left = v[v.size() - 2];
    v.pop_back();
    v.pop_back();
    if(op == "+") return left + right;
    if(op == "-") return left - right;
    if(op == "*") return left * right;
    if(op == "/") return left / right;
}

int main(){
    string str;
    while(getline(cin, str)){
        stringstream ss(str);
        vector<double> v;
        while(ss >>str){
            if(str.length() != 1 && str[0] == '-') v.push_back( -1.0 * atoi(str.substr(1).c_str()) );
            else if(isdigit(str[0])) v.push_back( (double)(atoi(str.c_str())) );
            else v.push_back( cal(v, str) );
        }
        printf("%.7lf\n", v[0]);
    }
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int num, add, ans = 1;
	cin >> num >> add;
	for (int i = 0; i < num; i++)
	{
		ans = min(ans * 2, ans + add);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class AtCoderA
{
    static void Main()
    {
        int a;
        int b;
        int c;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
            c = int.Parse(words[2]);
        }

        if ((a == b && a != c) || (b == c && a != b) || (a == c && a != b))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

using namespace std;

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

  int n; 
  cin >> n;
  vector<double> val(n);
  for (auto &v : val) cin >> v;
  sort(val.begin(), val.end());
  double res = (val[0]+val[1])/2.;
  for (int i = 2; i < n; ++i) {
    res = (res + val[i]) / 2.;
  }
  cout << res << endl;
  

  return 0;
}



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

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	
	int n;
	cin>>n;
	
	int arr[n], x = 1;
	for(int i = 0; i < n; i++){
		arr[i] = x;
		x++;
	}
	
	long long sum = 0;
	for (int i=0; i<n; i++) 
    { 
        if ((i+1)%15 == 0)         
            continue;     
        else if ((i+1)%3 == 0)     
            continue;                  
        else if ((i+1)%5 == 0)                        
            continue;                  
        else             
            sum+=arr[i];                 
  
    } 
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 7488
n = int(input())
s = input()
R = []
G = []
B = []
cnt = 0

for i in range(n):
    if s[i] == 'R':
        R.append(i)
    elif s[i] == 'G':
        G.append(i)
    else:
        B.append(i)

ans = len(R) * len(G) * len(B)

for i in range(n-2):
    for j in range(i,n-1):
        k = 2 * j - i
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt += 1 

print(ans - cnt)

Measured memory_bytes: 9120
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := next()

	cntC := 0
	cntMini := 0
	for i := 1; i < len(s); i++ {
		if 'a' <= s[i] && s[i] <= 'z' {
			cntMini++
		} else if 3 <= i+1 && i+1 <= len(s)-1 && s[i] == 'C' {
			cntC++
		}
	}

	ok := false
	if s[0] == 'A' && cntC == 1 && cntMini == len(s)-2 {
		ok = true
	}

	if ok {
		puts("AC")
	} else {
		puts("WA")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

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

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
	li h, w;
	cin >> h >> w;
	string s[111];

	vector<bool> tate(w, true);
	vector<bool> yoko(h, true);
	rep(i, h) {
		cin >> s[i];
		rep(j, w) {
			if (s[i][j] == '#') {
				tate[j] = false;
				yoko[i] = false;
			}
		}
	}
	rep(i, h) {
		if (yoko[i])continue;
		rep(j, w) {
			if (tate[j])continue;
			cout << s[i][j];
		} cout << endl;
	}
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<long long int> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a[i];
  }
  list<long long int> b;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
    {
      b.push_back(a[i]);
    }
    else
    {
      b.push_front(a[i]);
    }
  }
  if (N % 2 != 0)
    b.reverse();
  for (auto itr = b.begin(); itr != b.end(); itr++)
  {
    cout << *itr << " ";
  }
  cout << endl;
}


Measured memory_bytes: 9984
fun main() {
    solve()
}

private fun solve() {
    val s = readLn()

    if (s.endsWith("s")) {
        println(s + "es")
    } else if (s.endsWith("s").not()) {
        println(s + "s")
    }
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

Measured memory_bytes: 37200
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define int ll


/* Driver program to test above functions */
int32_t main()
{

    int h, a;
    cin>>h>>a;
    int c = 0;
    while(h>0){
        h -= a;

        c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
import Data.Bool
import qualified Data.ByteString.Char8 as B
main=print.solve=<<B.getLine
solve s=minimum.(n:)$zipWith f[1..].B.zip s.B.tail$s where
  n=B.length s
  f i(a,b)=bool(max(n-i)i)n$a==b

Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=max(l,r),_m=min(l,r);i>=_m;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
#define MAX 100005
#define wa cout<<"wa"<<endl;
int irand(int lo, int hi){
	return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}

string toString(ll x) {
	stringstream ss;
	ss << x;
	return ss.str();
}

ll toNumber(string S) {
	ll ret;
	sscanf(S.c_str(),"%lld",&ret);
	return ret;
}

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main(){
	int n;
	int pangkat[10];
	pangkat[0] = 1;
	bool vis[105];
	memset(vis,false,sizeof vis);
	vis[1] = true;
	vis[0] = true;
	for(int i=1; i<=8; i++){
		pangkat[i] = pangkat[i-1]*2;
		vis[pangkat[i]] = true;
	}
	cin>>n;
	for(int i=n;i>=0;i--){
		if (vis[i]) {
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());

	double q = (v.at(0) + v.at(1)) / 2;
	for (int i = 2; i < N; i++) {
		q = (q + v.at(i)) / 2;
	}
	cout << q << endl;
}

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

int n, A[30];

int solve(int i, int m){
    int ans = 0;
    
    if(m == 0) return 1;
    if(i >= n || m < 0) return 0;
    
    ans = solve(i+1, m) || solve(i+1, m-A[i]);
    return ans;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    int q, m[210];
    cin >> q;
    
    for(int i = 0; i < q; i++){
        cin >> m[i];
        if(solve(0, m[i])) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
package main

import "fmt"

// c + t = x, 2c + 4t = y
// 2t = y - 2x <=> t = (y - 2x) / 2
// 2c = 4x - y <=> c = (4x - y) / 2
func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if (y-2*x)%2 == 0 && (4*x-y)%2 == 0 {
		turtle, crane := (y-2*x)/2, (4*x-y)/2
		if turtle >= 0 && crane >= 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
use std::cmp::min;

fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn main() {
    let (n, r) = input_pair::<usize>();
    println!("{}", r + 100 * (10 - min(10, n)));
}

Measured memory_bytes: 2116
import math
import sys

n=int(input())
s=int(input())

def digsum(b,n):
    if n<b:
        return n
    return digsum(b,n//b)+n%b

if n==s:
    print(n+1)
    sys.exit()

for i in range(2,int(math.sqrt(n))+5):
    if digsum(i,n)==s:
        print(i)
        sys.exit()

for i in range(int(math.sqrt(n)),0,-1):

    if s-i>=0 and n-(s-i)>=0 and (n-(s-i))%i==0 and (n-(s-i))//i>s-i:
        print((n-(s-i))//i)
        sys.exit()

print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){   
    string s; cin>>s;

    ll x = 0,o = 0;
    for(char c:s){
        if(c == 'x') x++;
        else o++;
    }
    ll n = s.length();

    ll z = 15 - x;

    if(z >= 8) cout<<"YES\n";
    else cout<<"NO\n";
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int max = 0;
		int[] A = new int[N];
		A[0] = sc.nextInt();
		for (int i = 1; i < N; i++) {
			A[i] = sc.nextInt();
			if (A[i] - A[i-1] > max) {
				max = A[i]-A[i-1];
			}
		}
		if (K-A[N-1]+A[0] > max) {
			max = K - A[N-1] + A[0];
		} 
		System.out.println(K-max);
	}
}

Measured memory_bytes: 66876
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
#start = time.clock()
#i = 0
#check = 'insert'
n=input()
a=set()
for x in xrange(n):
    (i,f)=map(str, raw_input().split())
    if i=='insert':
        a.add(f)
    else:
        if f in a:
            print 'yes'
        else:
            print 'no'

Measured memory_bytes: 25960
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    int n,m,a,b,rta=0;
    cin >> n >> m;
    int alturas[n+1];
    alturas[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> alturas[i];
    }
    priority_queue<int> adyacentes[n+1];
    for(int i=0;i<m;i++){
        cin >> a >> b;
        adyacentes[a].push(alturas[b]);
        adyacentes[b].push(alturas[a]);
    }
    for(int i=1;i<n+1;i++){
        if(adyacentes[i].empty() || adyacentes[i].top()<alturas[i]) rta++;
    }
    cout << rta << endl;
    return 0;
}


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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef long double dd;

const int MAX = 333;
int fav[MAX][MAX];
int at[MAX];

void Solve(ll test_num) {
  (void) test_num;
  int N, M;
  cin >> N >> M;
  VERA(i, 0, N) {
    VERA(j, 0, M) {
      cin >> fav[i][j];
      --fav[i][j];
    }
  }
  set<int> gone;
  int res = N;
  VERA(i, 0, N)at[i] = 0;
  VERA(m, 0, M) {
    vector<int> cnt(M, 0);
    VERA(i, 0, N)++cnt[fav[i][at[i]]];
    const int hig_sport = max_element(cnt.begin(), cnt.end()) - cnt.begin();
    res = min(res, cnt[hig_sport]);
    gone.insert(hig_sport);
    VERA(i, 0, N)while (at[i] < M && gone.count(fav[i][at[i]]))++at[i];
  }
  cout << res << endl;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll tests = 1;
//  cin >> tests;
  VERA(test, 1, tests + 1) {
    Solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Mountain> listMountain = new ArrayList<Mountain>(0);
		String input;
		while((input = br.readLine()) != null){
			listMountain.add(new Mountain(Double.parseDouble(input)));
		}
		sort(listMountain);
		System.out.println(getMaxHeightDifference(listMountain));
	}
	
	private static void sort(ArrayList<Mountain> listMountain){
		for(int lastIndex = listMountain.size() - 1; lastIndex > 0; lastIndex--){
			for(int currentIndex = 0; currentIndex < lastIndex;	currentIndex++){
				if(listMountain.get(currentIndex).getHeight() > listMountain.get(currentIndex + 1).getHeight()){
					Mountain high = listMountain.get(currentIndex);
					Mountain low = listMountain.get(currentIndex + 1);
					listMountain.set(currentIndex, low);
					listMountain.set(currentIndex + 1, high);
				}
			}
		}
	}
	
	private static double getMaxHeightDifference(ArrayList<Mountain> listMountain){
		return listMountain.get(listMountain.size() - 1).getHeight() - listMountain.get(0).getHeight();
	}
}

class Mountain{
	private final double height;
	
	Mountain(double height){
		this.height = height;
	}
	
	public double getHeight() {
		return this.height;
	}
}

Measured memory_bytes: 9756
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

W = ['Sunny', 'Cloudy', 'Rainy']
S = input().rstrip()
print(W[(W.index(S)+1)%3])

Measured memory_bytes: 2940
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        s:Chars
    }
    let mut buf = 0;
    for i in s {
        let z = i.to_string().parse::<usize>().unwrap();
        buf += z;
        buf %= 9;
    }
    if buf % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3024
#include <stdio.h>
main(){
  int a[4],b[4],s,t;
  scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]);
  scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
  s=a[0]+a[1]+a[2]+a[3];
  t=b[0]+b[1]+b[2]+b[3];
  if(s>t) printf("%d\n",s);
  else if(s<t) printf("%d\n",t);
  else printf("%d\n",t);
  return 0; 
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int t, cnt=0;
	int color[110]={0,};
	for(int i=1;i<=3;i++){
		scanf("%d",&t);
		color[t]=1;
	}
	for(int i=1;i<=100;i++)
		if(color[i]==1) cnt++;
	
	printf("%d",cnt);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  string s;
  cin >> s;
  int cnt0=0,cnt1=0;
  rep(i,s.size()){
    if(s[i]=='1'){
      cnt1++;
    }
    if(s[i]=='0'){
      cnt0++;
    }
  }
  cout << 2*min(cnt1,cnt0) << endl;
return 0;}

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

typedef long long ll;
ll n, s, num, a[100005];
int main()
{
	ll i;
	cin >> n;
	for (i = 1;i <= n; i++) {
		scanf ("%lld", &a[i]);
		if (a[i - 1] >= 1 && a[i] >= 1) {
			s++;
			a[i - 1]--;
			a[i]--;
		}
		s += a[i] / 2;
		a[i] %= 2;

//		num = (a[i] - 1) / 2;
//		s += num;
//		a[i] -= num * 2;
//		if (a[i - 1] >= 1 && a[i] >= 1) {
//			s++;
//			a[i - 1]--;
//			a[i]--;
//		}
	}
	for (i = 1; i <= n; i++) s += a[i] / 2;
	cout << s;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int n,i,a[1000],temp,j,o;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    printf("%d",a[i]);
    if(i!=n-1)
      printf(" ");
    }
    printf("\n");
    for(i=1;i<n;i++){
        temp=a[i];
        j=i-1;
        while(j>=0 && a[j]>temp){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=temp;
    for(o=0;o<n;o++){
        printf("%d",a[o]);if(o!=n-1)printf(" ");}
    printf("\n");
    }
 
    return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <stack>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i ++)
using ll = long long;
int N, K;
int A[101];
double dp[101][100001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    rep(j, K + 1) dp[0][j] = false;
    rep(i, N) {
        for (int j = 0; j < A[i]; j ++) {
            dp[i+1][j] = dp[i][j];
        }
        for (int j = A[i]; j <= K; j ++) {
            bool d = false;
            rep(k, i + 1) {
                d = d || (!dp[i + 1][j - A[k]]);
            }
            dp[i+1][j] = d;
        }
    }
    cout << (dp[N][K] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 82492