akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
	int n, i = 0, train[10];
	while((scanf("%d", &n)) != EOF) {
		if(n == 0) {
			i--;
			printf("%d\n", train[i]);
		} else {
			train[i] = n;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 1784
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}

			int A = nextInt();
			int B = nextInt();
			int C = nextInt();
			int X = nextInt();

			int[] Y = new int[N];
			for (int i = 0; i < Y.length; i++) {
				Y[i] = nextInt();
			}

			int k = 0;
			for (int i = 0; i < 10002; i++) {
				if (i == 10001) {
					System.out.println(-1);
					break;
				}

				if (Y[k] == X) {
					k++;
				}
				if (k == Y.length) {
					System.out.println(i);
					break;
				}

				X = (A * X + B) % C;

			}
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 19880
#include <bits/stdc++.h>
using namespace std;
inline void chmax (long long& a, long long b) {
  if (a < b) a = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> ivdif(2 * m + 1, 0);
  vector<int> fall(2 * m + 1, 0);
  long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    int crr = a[i];
    int nxt = a[i + 1];
    if (crr > nxt) nxt += m;
    ivdif[crr + 2]++;
    ivdif[nxt + 1]--;
    fall[nxt + 1] += nxt - crr - 1;
    sum += nxt - crr;
  }
  vector<long long> svg(2 * m + 1);
  long long tmp = 0;
  int ivs = 0;
  for (int i = 0; i <= 2 * m; i++) {
    ivs += ivdif[i];
    tmp += ivs - fall[i];
    svg[i] = tmp;
  }
  long long maxv = 0;
  for (int i = 1; i <= m; i++) {
    chmax(maxv, svg[i] + svg[i + m]);
  }
  long long ret = sum - maxv;
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 3840
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  n,a = readInts()
  
  X = readInts()
  
  X = list(map(lambda i: i-a, X))# lambda iに、 i - aという演算のもと Xから入れる
  # ここで、平均が8になるもの key = 0の時が答えになる。
  # だからこそ　答えで dp[0] - 1 するのはこのため
  
  dp = {0:1} 
  
  for i in X:
    for k,v in list(dp.items()): # key,valueをそれぞれ抽出
      dp[i+k] = dp.get(i+k, 0) + v
      #
      # get(なんか) なんかに入ってる辞書のvalueが返ってくる
      # 無かったら、get(なんか,〇)で、〇に入ってるので辞書が更新される
      # 
  # print(dp)
  #{0: 6, 1: 6, 2: 2, -1: 2}
  # 負の数にも対応している
  print(dp[0]-1)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3188
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

ll pow(ll x, int y, ll ub){
  ll r = 1;
  for(int i = 0; i < y; i++){
    r *= x;
    if(r > ub) return -1;
  }
  return r;
}

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

  ll n, p;
  cin >> n >> p;

  if(n == 1){
    cout << p << endl;
    return 0;
  }

  if(n >= 40){
    cout << 1 << endl;
    return 0;
  }

  ll ans = 1;
  for(ll i = 2; i * i <= p; i++){
    if(p % i != 0) continue;
    ll tmp = pow(i, (int)n, p);
    if(tmp < 0) break;
    if(p % tmp == 0) ans = max(ans, i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] s = new String[H];
        for(int i = 0;i < H;i++){
            s[i] = sc.next();
        }
        char[][] c = new char[H][W];
        for(int i = 0;i < H;i++){
            c[i] = s[i].toCharArray();
        }
        int[][] num = new int[H][W];
        int[] dx = {1,0,-1,0,1,-1,-1,1};
        int[] dy = {0,1,0,-1,1,1,-1,-1};
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(c[i][j] == '#'){
                    continue;
                }
                for(int k = 0;k < 8;k++){
                    int ni = i + dy[k];
                    int nj = j + dx[k];
                    if(ni < 0 || ni >= H){
                        continue;
                    }
                    if(nj < 0 || nj >= W){
                        continue;
                    }
                    if(c[ni][nj] == '#'){
                        num[i][j]++;
                    }
                }
            }
        }
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(num[i][j] == 0 && c[i][j] == '#'){
                    System.out.print('#');
                    continue;
                }
                System.out.print(num[i][j]);
            }
            System.out.println();
        }
    }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;

	vl a(n);
	FOR(i,0,n) cin >> a[i];

	ll sum = accumulate(all(a),0LL);
	
	ll cur = 0, res = oo;
	FOR(i,0,n) {
		cur += a[i];
		res = min(res,abs(sum-2*cur));
	}
	cout << res << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 1005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
char s[MAX];
char t[MAX];
int main()
{
    char c;
    int i,slen,tlen;
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!('a'<=c&&c<='z')) break;
        s[i]=c;
    }
    slen=i;
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!('a'<=c&&c<='z')) break;
        t[i]=c;
    }
    tlen=i;
    int j;
    int ans=tlen;
    int temp;
    for(i=0;i<=slen-tlen;i++)
    {
        temp=0;
        for(j=0;j<tlen;j++)
        {
            temp=temp+(s[i+j]!=t[j]);
        }
        ans=min(ans,temp);
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
bool occur[30];
str s,ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ans = "None";
    cin>>s;
    for(int i=0;i<s.size();i++){
        int d = numerize(s[i]);
        occur[d] = true;
    }
    for(int i=1;i<=26;i++){
        if(!occur[i]){
            ans = "";
            ans += char(i+96);
            break;
        }
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 512
package main

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

func main() {
	N := ReadInt()
	P := ReadInts(N)
	ans := 0
	min := 1 << 62
	for i := 0; i < N; i++ {
		if min > P[i] {
			ans++
			min = P[i]
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4880
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(let* ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
  (format t "~A~%" (lcm (car line) (cadr line))))


Measured memory_bytes: 12004
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 03 11:29:17 2015

@author: hirose
"""

n = map(int, raw_input().split())

a = n[0]
b = n[1]
c = n[2]

x = a
number = 0

while(1):
    if(c % x == 0):
        number += 1
    x += 1
    if(x > b):
        break
print number
exit(0)

Measured memory_bytes: 4216
import java.util.Scanner;

public class Main {

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

		int X = scan.nextInt();
		int sum = 0;
		
		int i=1;
		while(X > sum){
			sum += i;
			i++;
		}
		
		System.out.println(i-1);
		
	}

}

Measured memory_bytes: 23636
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

max = 0

(0..(n-1)).each do |i|
  if b[i] >= a[i] + a[i+1]
    max += a[i] + a[i+1]
    a[i+1] = 0
  elsif b[i] > a[i]
    max += b[i]
    a[i+1] = a[i+1] - (b[i] - a[i])
  else
    max += b[i]
  end
end
puts max

Measured memory_bytes: 15500
#include  <bits/stdc++.h>
#define ll long long
using namespace std;
 
int  main(){
    //freopen("inp.txt","r",stdin);
    ll n,res=0;
    cin>>n;
    while (n!=0){
        if (n%10==2) res++;
        n/=10;
    }
    cout<<res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll judge(ll m,ll l,ll k,ll j) {
  ll res=1;
  if(m==0&&l==1&&k==2) res=0;
  if(m==0&&l==1&&j==2) res=0;
  if(m==0&&k==1&&j==2) res=0;
  if(m==0&&l==2&&k==1) res=0;
  if(m==1&&l==0&&k==2) res=0;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<vector<mat>> dp(n+1,vector<mat> (4,mat(4,vec(4))));
  dp[0][0][0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<4;j++) {
      for(ll k=0;k<4;k++) {
        for(ll l=0;l<4;l++) {
          for(ll m=0;m<4;m++) {
            if(i<2) {
              (dp[i+1][m][l][k]+=dp[i][l][k][j])%=mod;
            }
            else if(i==2&&judge(m,l,k,-1)) {
              (dp[i+1][m][l][k]+=dp[i][l][k][j])%=mod;
            }
            else if(judge(m,l,k,j)) {
              (dp[i+1][m][l][k]+=dp[i][l][k][j])%=mod;
            }
          }
        }
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<4;i++) for(ll j=0;j<4;j++) for(ll k=0;k<4;k++) (ans+=dp[n][i][j][k])%=mod;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r;
	else cout << r + 100 * (10 - n);
		// r=x-100(10-n)
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	int sum=0;
	REP(i,n){
		int c;
		cin>>c;
		sum+=c;
	}
	if(sum%2==0)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 3640
inline fun <reified T> matrix2d(height: Int, width: Int, initialize: () -> T) =
        Array(height) {Array(width) {initialize()}}

fun getLect(k: Int, v: Int): Array<Pair<Int, Int>> {
    if (v>k) return arrayOf(Pair(0, v-k), Pair(v, 2*k))  // はみ出す
    return arrayOf(Pair(v, v+k))
} 

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val k2 = k*2
    var x: Int
    var y: Int
    var tile = matrix2d(k2+1, k2+1) {0}
    for (z in 1..n) {
        val (xc, yc, c) = readLine()!!.split(" ")
        x = xc.toInt() % k2
        y = yc.toInt() % k2
        if (c=="W") {
            x += k
            x %= k2
        }
        for (i in listOf(0, k)) {
            for ((xmin, xmax) in getLect(k, (x+i)%k2)) {
                for ((ymin, ymax) in getLect(k, (y+i)%k2)) {
                    tile[xmin][ymin] += 1
                    tile[xmax][ymin] -= 1
                    tile[xmin][ymax] -= 1
                    tile[xmax][ymax] += 1
                }
            }
        }
    } 

    for (i in 0..k2) {
        for (j in 1..k2) {
            tile[i][j] += tile[i][j-1]
        }
    }
    for (i in 1..k2) {
        for (j in 0..k2) {
            tile[i][j] += tile[i-1][j]
        }
    }
    var ans = 0
    for (i in 0..k2) {
        for (j in 0..k2) {
            if (tile[i][j]>ans) ans = tile[i][j]
        }
    }
    println(ans)
}

Measured memory_bytes: 162044
#include <iostream>
#include <string>
using std::cin;
using std::cout;

double ans;
int N;

int main(){
  ans = 0.0;
  cin >> N;
  for(int i = 0;i<N;++i){
    float tmp;
    std::string str;
    cin >> tmp >> str;
    if(str[0] == 'J'){
     ans += tmp; 
    }else{
     ans += tmp * 380000.0; 
    }
  }
  cout << ans << '\n';
  return 0; 
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	char s[16];
	char eigth[8] = {0, 1, 2, 3, 5, 7, 8, 9}; 
	int i;
	
	while (scanf("%d", &n), n != 0){
		
		sprintf(s, "%o", n);
		for (i = 0; s[i] != '\0'; i++){
			if (s[i] >= '5'){
				s[i] += 2;
			}
			else if (s[i] >= '4'){
				s[i]++;
			}
		}
		printf("%s\n",s);
	}
	return (0);
}

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

int main(void) {
    int N, K;
    cin >> N >> K;
    int sunuke[N] = {0};
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int okashi;
            cin >> okashi;
            sunuke[okashi - 1]++;
        }
    }
    int treat = 0;
    for (int i = 0; i < N; i++) {
        if (sunuke[i] == 0) {
            treat++;
        }
    }
    printf("%d\n", treat);
    return 0;
}

Measured memory_bytes: 3752
N,W = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

supremum = 10**5

dp = [float("inf") for i in range(supremum+1)]
dp[0] = 0

for i in range(N) :
    weight_i,value_i = L[i]    
    for value in range(supremum,value_i-1,-1) :
        if dp[value-value_i] + weight_i <= W :
            dp[value] = min(dp[value], dp[value-value_i] + weight_i)

for i in range(supremum,-1,-1) :
    if dp[i] < float("inf") :
        ans = i
        break

print(ans)


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

#define ll long long
using namespace std;
const int N = 1000 + 5, M = 12;
int n, m, k;
vector<pair<int, int> > cuts;
int a[M][N];
int tmp[M], total[M];
int ans = 2e9;
void solve(int row, int lst) {
    if (row == n - 1) {
        cuts.push_back({lst, row});
        int cost = cuts.size() - 1;
        memset(total, 0, sizeof total);
        for (int j = 0; j < m; j++) {
            memset(tmp, 0, sizeof tmp);
            for (int cut = 0; cut < cuts.size(); cut++) {
                int st = cuts[cut].first, en = cuts[cut].second;
                for (int i = st; i <= en; i++) {
                    tmp[cut] += a[i][j];
                }
            }
            bool bo = 0;
            for (int cut = 0; cut < cuts.size(); cut++) if (total[cut] + tmp[cut] > k) bo = 1;
            if (bo) cost++;
            for (int cut = 0; cut < cuts.size(); cut++) {
                if (bo) total[cut] = tmp[cut];
                else total[cut] += tmp[cut];
                if (total[cut] > k) cost = 1e9;
            }
        }
        cuts.pop_back();
        ans = min(ans, cost);
        return;
    }
    solve(row + 1, lst);
    cuts.push_back({lst, row});
    solve(row + 1, row + 1);
    cuts.pop_back();
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            if (c == '0') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }
    solve(0, 0);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

i = 1
c = 0
ans = 0

if 1 not in a:
  print(-1)
  quit()

while c < N:
  if a[c] == i:
    i += 1
  else:
    ans += 1
  
  c += 1

print(ans)

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

const int maxn = 1000 + 10;

int cnt[60][60];

int main(){
	int n;
	cin >> n;
	ll answer = 0;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		ll t = 0;
		int cnT = 9, dec = 0;
		for (int i = 0; i < s.size(); i++){
			if (s[i] == '.'){
				dec = 1;
				continue;
			}
			t = 10LL*t + (int)(s[i]-'0');
			cnT -= dec;
		}
		while (cnT --)
			t = 10LL*t;
		int a = 0, b = 0;
		while (t % 5 == 0){
			t /= 5;
			a ++;
		}
		while (t % 2 == 0){
			t /= 2;
			b ++;
		}
		assert(max(a,b) <= 55);
		for (int i = 0; i <= 55; i++)
			for (int j = 0; j <= 55; j++)
				if (min(i+b,j+a) >= 18)
					answer += cnt[i][j];
		cnt[b][a] ++;
	}
	cout << answer << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  ll H,W; cin >> H >> W;
  vector<ll> cnt(26,0);
  REP(i,H){
    string s; cin >> s;
    FOREACH(c,s) cnt[c-'a']++;
  }
  ll four = 0, two = 0, one = 0;
  REP(i,26){
    four += cnt[i]/4;
    cnt[i] %= 4;
    two += cnt[i]/2;
    cnt[i] %= 2;
    one += cnt[i];
  }
  
  if(four >= (H/2)*(W/2)){
    four -= (H/2)*(W/2);
    two += four * 2;
  }
  else no();

  if(H%2==1){
    if(two >= W/2) two -= W/2;
    else no();
  }

  if(W%2==1){
    if(two >= H/2) two -= H/2;
    else no();
  }

  one += 2*two;
  if(H%2==1 && W%2 == 1 && one == 0) no();
  yes();
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> xy;

int main() {
	int n;
	xy a, b, c, d;
	double delta = 1e-11;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a.real() >> a.imag();
		cin >> b.real() >> b.imag();
		cin >> c.real() >> c.imag();
		cin >> d.real() >> d.imag();

		xy s = a - b, t = c - d;
		if (abs((conj(s)*t).imag()) < delta) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;

}

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

typedef long long ll;
#define pii pair<int, int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

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


int main()
{
    _FastIO;
    ll n , ans = 0;
    cin >> n;
    for(ll x = 1; x <= n; x++){
        for(ll y = 1; y <= n; y++){
            for(ll z = 1; z <= n; z++){
                ans += gcd(gcd(x , y) , z);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[,] b = new int[a, 4];
        for(int i = 0; i < a; i++)
        {
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int j = 0; j < 3; j++)
                b[i, j] = c[j];
        }
        for(int i = 0; i < 3; i++)
        {
            int[] d = new int[a];
            int []f = new int[a];
            int z = 0;
            for(int j = 0; j < a; j++) {d[j] = b[j, i]; } 
            Array.Sort(d);
            for(int j = 0; j < a - 1; j++){if (d[j] == d[j + 1]) { f[z] = d[j]; z++; }}
            for(int j = 0; j < a; j++)
            {
                for(int x = 0; x < z; x++)
                {
                    if (b[j, i] == f[x]) goto stop;
                }
                b[j, 3] += b[j, i];
                stop:;
            }
        }
        for (int i = 0; i < a; i++)
        {
            Console.WriteLine(b[i, 3]);
        }
    }
}

Measured memory_bytes: 9884
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)1e6+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
int d[MAXN];

bool pairwise()
{
	map <int, bool> mp;

	for (int i = 0; i < n; ++i)
	{
		int t = d[i];
		int dv = 2;

		while(dv * dv <= t)
		{
			if(t % dv == 0)
			{
				if(mp[dv])
					return false;
				mp[dv] = 1;
				while(t%dv==0) t /= dv;
			}

			dv++;
		}

		if(t > 1)
		{
			if(mp[t])
				return false;
			mp[t] = 1;
		}
	}

	return true;
}

bool setwise()
{
	int gcd = d[0];
	
	for (int i = 1; i < n; ++i)
		gcd = __gcd(gcd, d[i]);

	return gcd == 1;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> d[i];

	if(pairwise())
		cout << "pairwise coprime\n";
	else if(setwise())
		cout << "setwise coprime\n";
	else
		cout << "not coprime\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 7568
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 5e3 + 10;

int wt[N];
ll dp[N][N];

int main() {
	fast_cin();
	int n, mod;
	cin >> n >> mod;
	int k = (n - 1) / 2;
	for (int i = 2; i <= n; ++i) {
		if (i < n - k + 1) {
			wt[i] = i - 1;
		} else {
			wt[i] = n + 2 - i;
		}
	}
	dp[1][n] = 1;
	for (int i = 1; i < n; ++i) {
		for (int val = n; val >= 1; --val) {
			dp[i + 1][val] += dp[i][val];
			dp[i + 1][val] %= mod;
			if (val > wt[i + 1]) {
				dp[i][val - wt[i + 1]] += dp[i][val];
				dp[i][val - wt[i + 1]] %= mod;
			}
			// dp[i][val] %= mod;
			// int max_x = val / wt[i + 1];
			// for (int x = 0; x <= max_x; ++x) {
			// 	dp[i + 1][val - x * wt[i + 1]] += dp[i][val];
			// }
		}
	}
	ll ans = 0;
	for (int val = 1; val <= n; ++val) {
		ans += val * dp[n][val];
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;

int main(){
    ll X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    V p(A),q(B),r(C);
    rep(i,A)cin>>p.at(i);
    rep(i,B)cin>>q.at(i);
    rep(i,C)cin>>r.at(i);
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    V hojoa,hojob;
    for(ll j=A-1;j>A-1-X;j--)hojoa.push_back(p.at(j));
    for(ll j=B-1;j>B-1-Y;j--)hojob.push_back(q.at(j));
    sort(hojoa.begin(),hojoa.end());
    sort(hojob.begin(),hojob.end());
    ll a=0,b=0;
    while(!r.empty()&&r.back()>min(hojoa.at(a),hojob.at(b))){
        if(hojoa.at(a)>hojob.at(b)){
            hojob.push_back(r.back());
            r.pop_back();
            b++;
        }
        else{
            hojoa.push_back(r.back());
            r.pop_back();
            a++;
        }
    }
    sort(hojoa.begin(),hojoa.end());
    sort(hojob.begin(),hojob.end());
    ll ans=0;
    ll z=hojoa.size();
    ll m=hojob.size();
    for(ll j=0;j<X;j++)ans+=hojoa.at(z-j-1);
    for(ll j=0;j<Y;j++)ans+=hojob.at(m-j-1);
    cout<<ans<<endl;

}


Measured memory_bytes: 5492
n, k = map(int, raw_input().split())
arr = [0] * (10**5+1)
for _ in range(n):
    a, b = map(int, raw_input().split())
    arr[a] += b
c = 0
for i in range(len(arr)):
    c += arr[i]
    if c >= k:
        print i
        break

Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n <= k) {
		cout << n * x << endl;
	} else {
		cout << k * x + (n - k) * y << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    char c;
    std::cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        std::cout << "vowel" << std::endl;
    } else {
        std::cout << "consonant" << std::endl;
    }
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, a, b;
    cin >> n >> a >> b;
    vi x(n);
    rep(i, n) cin >> x[i];
    vi d;
    rep(i, n - 1) {
        d.emplace_back(x[i + 1] - x[i]);
    }
    sort(all(d));

    int ans = inf;
    int t = 0;
    rep(i, n) {
        chmin(ans, (n - 1 - i) * b + t * a);
        if (i == n) break;
        t += d[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
}


Measured memory_bytes: 37364
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M = MI()

class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)
    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x


U = UnionFind(N)
for i in range(M):
    a,b = MI()
    U.unite(a,b)

A = U.par
for i in range(1,N+1):
    A[i] = U.find(A[i])

del A[0]


from collections import Counter

c = Counter(A)
B = c.most_common()
print(B[0][1])




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

import sys
from itertools import combinations, permutations

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

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

N, C = MAP()
table = build_grid(C, C, 0, int)
grid = build_grid(N, N, 0, int)

# mod3=0,1,2と色毎で数を集計
cnts = list2d(3, C, 0)
for i in range(N):
    for j in range(N):
        c = grid[i][j] - 1
        cnts[(i+j)%3][c] += 1

# 全色から3色選んで、0,1,2どこに使うかを全通り試す
ans = INF
for comb in combinations(range(C), 3):
    for perm in permutations(comb):
        sm = 0
        for i, to in enumerate(perm):
            for frm in range(C):
                cnt = cnts[i][frm]
                sm += table[frm][to] * cnt
        ans = min(ans, sm)
print(ans)


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

int main()
{
	int n;
	cin>>n;
	vector<int> a;
	vector<int> b;
	vector<int> c;
	a.resize(n);
	b.resize(n);
	c.resize(n);
	int i;
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	vector<int> a_1;
	vector<int> b_1;
	vector<int> c_1;
	a_1.resize(n);
	b_1.resize(n);
	c_1.resize(n);
	a_1[0] = a[0];
	b_1[0] = b[0];
	c_1[0] = c[0];

	for(i=1;i<n;i++)
	{
		a_1[i] = a[i] + max(b_1[i-1],c_1[i-1]);
		b_1[i] = b[i] + max(a_1[i-1],c_1[i-1]);
		c_1[i] = c[i] + max(b_1[i-1],a_1[i-1]);
	}
	int ans = max(a_1[n-1],max(b_1[n-1],c_1[n-1]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

LL f(LL a) {
	if (a & 1) {
		return a * 3 + 1;
	}
	else {
		return a / 2;
	}
}
void solve() {
	LL s;
	cin >> s;
	LL a = s;
	set<LL> A;
	A.insert(s);

	for (int i = 2;; ++i) {
		LL res = f(a);
		if (A.find(res) != A.end()) {
			cout << i << endl;
			return;
		}
		A.insert(res);
		a = res;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int n, ans;
	
	cin >> n >> ans;
	
	int num = ans;
	
	int a, b;
	
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		num = num + a - b;
		if(num > ans){
			ans = num;
		}
		if(num < 0){
			ans = 1 << 30;
		}
	}
	
	if(ans == 1 << 30){
		printf("0\n");
	}else{
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int d,g;
    cin>>d>>g;
    vector<int>p(d);
    vector<int>c(d);
    rep(i,d)cin>>p[i]>>c[i];
    int min_c=1e9;
    for(int bit=0;bit<(1<<d);++bit){
        int get_score=0,cnt=0,max=-1;
        rep(i,d){
            if(bit&(1<<i)){
                get_score+=100*(i+1)*p[i]+c[i];
                cnt+=p[i];
            }
            else{
                max=i;
            }
        }
        if(get_score<g){
            int p_cnt=0;
            int x=(g-get_score-1+100*(max+1))/(100*(max+1));
            if(x>p[max])cnt=1e9;
            else cnt+=x;
        }
        min_c=min(min_c,cnt);
    }
    cout<<min_c<<endl;
 
    return 0;
}

Measured memory_bytes: 256
// -_-
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long , long long> pll;
 
int main() 
{

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

    ll n, m;
    cin >> n >> m;
    vi vec;
    for(ll i = 1; i*i <= m; i++)
    {
    	if(m%i == 0)
    	{
    		if(m/i == i)
    		{
    			if(m/i >= n) vec.pb(i);
    		}
    		else
    		{
    			if(m/i >= n) vec.pb(i);
    			if(i >= n) vec.pb(m/i);
    		}
    	}
    }

    sort(vec.begin(), vec.end());
    cout << vec[vec.size()-1];


	return 0;
}

Measured memory_bytes: 256
k,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

if a[0]==0:
    a.append(k)
else:
    a.append(k+a[0])
l=[]
for i in range(len(a)-1):
    s = a[i+1]-a[i]
    if s<0:
        s=-s
    l.append(s)
max_value=max(l)
#max_index=l.index(max_value)
print(k-max_value)

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

int main() {
	int A,B;
	cin>>A>>B;
	if((A==1&&B==2)||(A==2&&B==1)) cout<<3<<endl;
	else if((A==1&&B==3)||(A==3&&B==1)) cout<<2<<endl;
	else                                cout<<1<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
L = N-K
M = min(K,L+1)
mod = 10**9+7

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

for i in range(1,K+1):
    if i <= M:
        print(combination(K-1,i-1,mod) * combination(L+1,i,mod) % mod)
    else:
        print(0)

Measured memory_bytes: 43868
#include <stdio.h>


int main(void){
    long int a,b,l=1;
    int i;
    
    while( scanf("%ld %ld",&a,&b) != EOF){
        for(i=2;0!=(a/i)*(b/i);i++){
            
            if(a%i + b%i==0){
                l*=i;
                a/=i;
                b/=i;
                i--;
            }
        }
        
        printf("%ld %ld\n",l,l*a*b);
        l=1;
    }
    
    return 0;
}

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

int main(){
    int n,q; cin  >> n >> q;
    vector<vector<int> > ki(n);
    vector<int> ans(n,0);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        ki[a-1].push_back(b-1);
        ki[b-1].push_back(a-1);
    }

    rep(i,q){
        int p,x; cin >> p >> x;
        ans[p-1]+=x;
    }
    queue<int> che;
    che.push(0);
    vector<int> visit(n,-1);

    while(!che.empty()){
        int i=che.front();
        che.pop();
        rep(j,ki[i].size()){
            if(visit[ki[i][j]]<0){
            ans[ki[i][j]]+=ans[i];
            che.push(ki[i][j]);
            }
        }
        visit[i]++;
    }

    rep(i,n) printf("%d ",ans[i]);
return 0;
}


Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;
 
typedef long long ll;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else 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;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
 
int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  int count=0;
  REP(i,n){
    if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T'){
        if(ans<count)ans=count;
        count=0;
        continue;
    }
    count++;
  }
  if(ans<count)ans=count;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125568
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const long long mod = 1e9 + 7;
long long dp[10001][101];
int main() {
	string K; int D; cin >> K >> D;
	reverse(K.begin(), K.end());
	for (int i = 0; i <= 9; i++) dp[0][i % D] += 1;
	for (int i = 1; i < K.size(); i++) {
		for (int j = 0; j < D; j++) {
			for (int k = 0; k <= 9; k++) {
				dp[i][(j + k) % D] = (dp[i][(j + k) % D] + dp[i - 1][j]) % mod;
			}
		}
	}
//	for (int i = 0; i < D; i++) cout << "dp[0][" << i << "] = " << dp[0][i] << endl;
	long long cnt = 0;
	long long acc = 0;
	for (int i = K.size() - 1; i >= 0; acc = (acc + K[i--] - '0') % D) {
		for (int j = 0; j < K[i] - '0'; j++) {
			if (i > 0) cnt = (cnt + dp[i - 1][(20 * D - acc - j) % D]) % mod;
			else cnt = (cnt + ((acc + j) % D == 0)) % mod;
		}
	}
	cnt = (cnt + (acc % D == 0) + mod - 1LL) % mod;
	cout << cnt << endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, a, b;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> a >> b;
	int req = b - 1;
	a--;
	cout << (req + a - 1) / a;
}	

	

Measured memory_bytes: 384