akhauriyash/Code-Regression huggingface dataset:
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val n = Scanner.nextLong
  val a = Array.fill(5)(Scanner.nextLong)

  val narrow = a.min
  val result = if (n%narrow == 0){
    n/narrow + 4
  } else {
    n/narrow + 1 + 4
  }

  println(result)
}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
    int n;
    cin>>n;
  	if(n%10==2 ||n%10==4||n%10==5||n%10==7||n%10==9)puts("hon");
  	else if(n%10==3)puts("bon");
  	else puts("pon");
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 998244353
#define pb push_back
using namespace std;
int main(){
	int d,n;
	cin>>d>>n;
	if(n==100)n=101;
	for(int i=0;i<d;i++){
		n*=100;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

#n = int(input())
a, b, c = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

print(max(0,c-(a-b)))

Measured memory_bytes: 2940
//
//  main.cpp
//  ITP1-9-A
//
//  Created by h3037153 on 2017/08/28.
//  Copyright ?? 2017??´ h3037153. All rights reserved.
//
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
    string W,T[1000];
    int i=0,counter=0,ii=0,len;
    char ch ={};
    cin>>W;
    while(cin>>T[i]){
        if(T[i] == "END_OF_TEXT"){
            break;
        }
        len = T[i].length();
        for(ii=0;ii<len;ii++){
            if(isupper(T[i][ii])){
                ch = tolower(T[i][ii]);
                T[i][ii] = ch;
            }
        }
        if(T[i] == W){
            counter++;
        }
        else i++;
    }
    cout<<counter<<endl;
    return 0;
}

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

using namespace std;

int nxt(int cur,char c)
{
	if(cur==0)
	{
		if(c=='A')
			return 1;
		if(c=='G')
			return 2;
		return 0;
	}
	if(cur==1)
	{
		if(c=='G')
			return 3;
		if(c=='T')
			return 4;
		if(c=='C')
			return 5;
		return 1;
	}
	if(cur==2)
	{
		if(c=='A')
			return 9;
		if(c=='G')
			return 2;
		return 0;
	}
	if(cur==3)
	{
		if(c=='A')
			return 9;
		if(c=='G')
			return 6;
		if(c=='T')
			return 7;
		if(c=='C')
			return 10;
	}
	if(cur==4)
	{
		if(c=='G')
			return 8;
		if(c=='A')
			return 1;
		return 0;
	}
	if(cur==5)
	{
		if(c=='G')
			return 10;
		if(c=='A')
			return 1;
		return 0;
	}
	if(cur==6)
	{
		if(c=='C')
			return 10;
		if(c=='G')
			return 2;
		if(c=='A')
			return 9;
		return 0;	
	}
	if(cur==7)
	{
		if(c=='C')
			return 10;
		if(c=='G')
			return 2;
		if(c=='A')
			return 1;
		return 0;
	}
	if(cur==8)
	{
		if(c=='C')
			return 10;
		if(c=='G')
			return 2;
		if(c=='A')
			return 9;
		return 0;
	}
	if(cur==9)
	{
		if(c=='C')
			return 10;
		if(c=='A')
			return 1;
		if(c=='G')
			return 3;
		if(c=='T')
			return 4;
	}
}

const int mod=1e9+7;

int main()
{
	cin.tie(0),ios::sync_with_stdio(0);
	int n;
	cin>>n;
	long long dp[105][11]={};
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
		{
			dp[i][j]%=mod;
			dp[i+1][nxt(j,'A')]+=dp[i][j];
			dp[i+1][nxt(j,'T')]+=dp[i][j];
			dp[i+1][nxt(j,'C')]+=dp[i][j];
			dp[i+1][nxt(j,'G')]+=dp[i][j];
		}
	}
	long long ans=0;
	for(int i=0;i<10;i++)
		ans+=dp[n][i];
	cout<<ans%mod<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n, k;
vector<int> vec[10];
vector<int> sumvec[10];
int dp[11][2001];

int main(int argc, char const* argv[])
{
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    b--;
    vec[b].pb(a);
  }
  for(int i = 0; i < 10; i++){
    if(vec[i].size() == 0)continue;
    sort(vec[i].begin(), vec[i].end(), greater<int>());
    sumvec[i].pb(vec[i][0]);
    for(int j = 1; j < vec[i].size(); j++){
      sumvec[i].pb(vec[i][j] + sumvec[i][j-1]);
    }
  }
  for(int i = 0; i < 10; i++){
    for(int j = 0; j <= k; j++){
      dp[i+1][j] = dp[i][j];
      for(int l = 1; l <= vec[i].size(); l++){
        if(j >= l)dp[i+1][j] = max(dp[i+1][j], dp[i][j-l] + sumvec[i][l-1] + l * (l-1));
      }
    }
  }
  cout << dp[10][k] << endl;
	return 0;
}



Measured memory_bytes: 3200
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
gi = lambda : list(map(int,input().strip().split()))
a, b = gi()
if (a + b)%2:
	print("IMPOSSIBLE")
	exit()
print((a + b)//2)

Measured memory_bytes: 2940
/*
 * ID: 3026
 * Problem: ai1333
 */

#include <stdio.h>

int main(void)
{
    int year;
    scanf("%d", &year);

    printf("ai1333");
    int i;
    for (i = 0; i < year; i += 100)
        putchar('3');
    printf("\n");

    return 0;
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 10 == 9 || n / 10 == 9)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    string n;
    cin >> n;
	
  	if(n[0] == n[1] && n[1] == n[2])
    	cout << "Yes" << endl;
  	else if(n[1] == n[2] && n[2] == n[3])
    	cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    long long int k;
    cin>>k;
    queue <long long int>q;
    for(int i=1;i<=9;i++)
    q.push(i);
    long long int a;
    for(int i=1;i<=k;i++)
    {
        long long int ans=q.front();q.pop();
        a=ans;
        if(a%10==0)
        {
            q.push(a*10+0);
            q.push(a*10+1);
        }
        else if(a%10==9)
        {
            q.push(a*10+8);
            q.push(a*10+9);
        }
        else
        {
            q.push(a*10+a%10-1);
            q.push(a*10+a%10);
            q.push(a*10+a%10+1);
        }
    }
    cout<<a<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define ifMeetBoundaryCondition(x,xMax,xMin,y,yMax,yMin) if(x < xMax && x >= xMin &&y < yMax && y >= yMin)
#define INF pow(10,9)
using namespace std;

int dx[] = {1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	long N,A,B,ans;
	cin >> N >> A >> B;
	ans = A * (N/(A+B));
	if(N%(A+B) >= A)ans += A;
	else ans += N%(A+B);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int can = 0;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(i%2 == 0 && s[i] == '1') ans++;
        else if(i%2 == 1 && s[i] == '0') ans++;
    }    
    for(int i = 0; i < n; i++){
        if(i%2 == 1 && s[i] == '1') can++;
        else if(i%2 == 0 && s[i] == '0') can++;
    }
    ans = min(ans,can);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
void print(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 


 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector <int> A(n);
    for (int i=0;i<n;i++) {cin>>A[i];}
    vector <int> D(n,-1);
    vector <int> M(n,-1);
    for (int i=n-2;i>=0;i--) {
		int j=i+1;
		while (j<n && (M[i]==-1 || D[i]==-1)) {
			if (A[j]<=A[i] && A[j]>=A[i]-k && M[i]==-1) {M[i]=j;}
			if (A[j]>=A[i] && A[j]<=A[i]+k && D[i]==-1) {D[i]=j;}
			j++;
			}
		}
	vector <int> Ats(n,1);
	for (int i=n-2;i>=0;i--) {
		if (M[i]>=0) {Ats[i]=max(Ats[i],Ats[M[i]]+1);}
		if (D[i]>=0) {Ats[i]=max(Ats[i],Ats[D[i]]+1);}
		}
	int m=0;
	for (int i=0;i<n;i++) {m=max(m,Ats[i]);}
	//print(M);
	//print(D);
	//print(Ats);
	cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 7948
def tot(lookup, n):
    print(n - len(lookup.keys()))

if __name__ == "__main__":
    import sys
    from collections import defaultdict as DD
    lookup = DD(list)
    n, k = [int(_) for _ in input().split()]
    for i in range(k):
        di = int(input())
        ss = [int(_) for _ in input().split()]
        for s in ss:
            lookup[s].append(i)
    tot(lookup, n)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  vi abc;
  REP(i, 3) { abc.PB(read()); }
  sort(ALL(abc));
  print(abc[0] * abc[1] / 2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

using weight = int;

struct edge {
    int from, to;
    weight cost;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, weight cost) {
    g[from].push_back(edge{from, to, cost});
}

std::vector<weight> bfs01(graph const& g, int s) {
    std::vector<weight> d(g.size(), inf<weight>);
    d[s] = 0;
    deque<pair<weight, int>> que;
    que.push_back(make_pair(d[s], s));
    while(!que.empty()) {
        weight cur_d = que.front().first;
        int v = que.front().second;
        que.pop_front();
        if(d[v] < cur_d) {
            continue;
        }
        for(auto& e : g[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                if(e.cost == 1) {
                    que.emplace_back(d[e.to], e.to);
                } else {
                    que.emplace_front(d[e.to], e.to);
                }
            }
        }
    }
    return d;
}

int main() {
    ll K;
    cin >> K;
    graph g(K);
    for(int i = 0; i < K; ++i) {
        add_edge(g, i, (i + 1) % K, 1);
        add_edge(g, i, (i * 10) % K, 0);
    }
    auto res = bfs01(g, 1);
    cout << res[0] + 1 << endl;
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
    char a;
    bool small = false;
    cin >> a;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    for(int i = 0; i < 26; i++){
        if(a == alp[i]){
            small = true;
            break;
        }
    }
    if(small) cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3620
fn main() {
    let s = read::<String>();

    if s == "AAA" || s == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9
#define W_MAX 1e5
int WV[101][2] = {};
ll dp[int(W_MAX) * 2 + 1] = {};
int main()
{
	int n;
	int w;
	cin >> n >> w;
	rep(i, n) {
		cin >> WV[i][0] >> WV[i][1];
	}
	rep(i, n) {
		for (int j = w; j >= 0; j--) {
			dp[j + WV[i][0]] = max(dp[j + WV[i][0]], dp[j] + WV[i][1]);
		}
	}
	ll mx = 0;
	rep(i, w + 1) {
		mx = max(mx, dp[i]);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        n: usize,
        d: usize,
        a: isize,
        x: [(usize, isize); n],
    }
    let mut x = x;
    x.sort();
    let mut q: VecDeque<(usize, isize)> = VecDeque::new();
    let mut dm = 0;
    let mut ans = 0;
    for i in 0..n {
        let t = x[i].0;
        let h = x[i].1;
        while !q.is_empty() && t >= q.get(0).unwrap().0{
            let p = q.pop_front().unwrap();
            dm -= p.1 * a;
        }
        if dm >= h{
            continue;
        }
        let c = (h - dm + a - 1) / a;
        ans += c;
        dm += c * a;
        q.push_back((x[i].0 + 2 * d + 1, c));
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
testCase = Array.new
i = 0
STDIN.each_line do |line|
  testCase[i], testCase[i+1] = line.split(" ").map(&:to_i)
  i += 2
end
measure = String.new
temp = 0
temp2 = testCase.length/2
j = 0
temp2.times do
  temp = testCase[j]+testCase[j+1]
  measure=temp.to_s
  j += 2
  puts measure.length
end

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

using visited = std::vector<std::vector<bool>>;
using marine_map = std::vector<std::vector<int>>;

int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int w, h, c;

void dfs(int x, int y, visited& v, marine_map& m, int& c) {
    if (v[y][x]) {
        return;
    }
    v[y][x] = true;
    for (int p = 0; p < 8; p++) {
        int cy = y + dy[p];
        int cx = x + dx[p];
        if (cx < 0 || cx >= w || cy < 0 || cy >= h || m[cy][cx] != 1) {
            continue;
        }
        dfs(cx, cy, v, m, c);
    }
}


int main() {
    while (true) {
        std::cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }
        c = 0; // reset counter for new map;
        std::vector<std::vector<int>> vec(h, std::vector<int>(w, 0));
        std::vector<std::vector<bool>> bools(h, std::vector<bool>(w, false));
        for (int i = 0; i < h; i++) {
            for (int p = 0; p < w; p++) {
                std::cin >> vec[i][p];
            }
        }
        for (int i = 0; i < h; i++) {
            for (int p = 0; p < w; p++) {
                if (vec[i][p] == 1 && !bools[i][p]) {
                    c++;
                    dfs(p, i, bools, vec, c);
                }
            }
        }
        std::cout << c << std::endl;
    }
}



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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 450555;
const int L = 21;
const int M = 1155;

ll a[N];
void solve(){
    int n;
    ll k;
    cin >> k >> n;

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

    ll mn = LINF;
    for (int i = 1; i <= n; i++){
        mn = min(mn, a[n+i-1] - a[i]);
    }

    cout << mn;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    long L = scanner.nextLong();

    final long INF = 1_000_000_000_000_000L;
    long[][] dist = new long[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j) dist[i][j] = INF;
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      int c = scanner.nextInt();
      dist[a][b] = dist[b][a] = c;
    }

    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    long[][] dist2 = new long[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j) dist2[i][j] = INF;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        dist2[i][j] = dist2[j][i] = dist[i][j] <= L ? 1 : INF;
      }
    }

    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          dist2[i][j] = Math.min(dist2[i][j], dist2[i][k] + dist2[k][j]);
        }
      }
    }

    int Q = scanner.nextInt();
    for (int q = 0; q < Q; q++) {
      int s = scanner.nextInt() - 1;
      int t = scanner.nextInt() - 1;
      if (dist2[s][t] >= INF) System.out.println(-1);
      else System.out.println(dist2[s][t] - 1);
    }
  }
}


Measured memory_bytes: 90176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> list (H, vector<char>(W));

  bool dele;

  for(int i = 0; i<H; i++){
    dele = true;
    for(int j = 0; j<W; j++){
      cin >> list.at(i).at(j);
      if(list.at(i).at(j)=='#') dele = false;
    }
    if(dele==true){
      i--;
      H--;
    }
  }

  vector<bool> flug(W);

  for(int j = 0; j<W; j++){
    dele = true;
    for(int i = 0; i<H; i++){
      if(list.at(i).at(j)=='#') {
        dele = false;
        break;
      }
    }
    flug.at(j) = dele;
  }

  for(int i = 0; i<H; i++){
    for(int j = 0; j<W; j++){
      if(flug.at(j)==false) {
        cout << list.at(i).at(j);
      }
    }
    cout << endl;
  }
}

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 100000;
int n,W,w[100005],v[100005];
ll dp[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>W;
    for(int i =0; i<=MAXN; ++i)
        dp[i] = W+5;
    dp[0]=0;
    for(int i =0 ; i<n; ++i){
        cin>>w[i]>>v[i];
        for(int j=MAXN; j>=0; j--){
            if(j>=v[i]){
                dp[j]  = min(dp[j],dp[j-v[i]]+w[i]);
            }
        }
    }
    for(int i = MAXN; i>=0; i--){
        if(dp[i]<=W){
            cout<<i<<"\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll a,b;

/* add your algorithm here */

int main() {
  cin >> a >> b;
  int s = a - b + 1;
  cout << s << endl;
}


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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	string N;
	SINT64 M = 0;

	cin >> N;
	cin >> M;

	
	for (SINT32 i = 0; i < N.length(); i++) {
		if (N[i] != '1') {
			cout << N[i];
			return 0;
		}
		if (i >= M-1) {
			break;
		}
	}

	cout << '1' << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct SegmentTree {
  vint data;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz <<= 1;
    resz(data, 2*sz-1, -inf);
  }
  void set(int k, int x) {
    k += sz-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = max(data[2*k+1], data[2*k+2]);
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return -inf;
    if(a <= l && r <= b) return data[k];
    int vl = query(a, b, 2*k+1, l, (l+r)/2);
    int vr = query(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

int N, Q;
vint b, l, r;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  resz(b, N);
  rep(i, N) cin >> b[i];
  cin >> Q;
  resz(l, Q);
  resz(r, Q);
  rep(i, Q) cin >> l[i] >> r[i], --l[i];

  vint one(N+1);
  rep(i, N) one[i+1] = one[i] + b[i];

  auto get = [&one](int l, int r) {
    return (one[r]-one[l]);
  };

  vector<Pi> q;
  rep(i, Q) q.emplace_back(l[i], r[i]);
  sort(all(q));

  vint dp(N+1, -inf);
  SegmentTree seg(N+1);
  rep(i, N+1) seg.set(i, -one[i]);
  dp[0] = 0;
  int p = 0;
  rep(i, Q) {
    int l, r;
    tie(l, r) = q[i];
    while(p < l) {
      chmax(dp[p+1], dp[p]+1-b[p]);
      ++p;
      seg.set(p, dp[p]-one[p]);
    }
    chmax(dp[r], seg.query(l, r)+one[r]);
    seg.set(r, dp[r]-one[r]);
  }
  while(p < N) chmax(dp[p+1], dp[p]+1-b[p]), ++p;
  cout << N-dp[N] << endl;

  return 0;
}


Measured memory_bytes: 16236
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        int w;
        int h;
        cin >> w >> h;
        vector<vector<bool>> v(static_cast<size_t>(h));
        for_each(begin(v), end(v), [w](auto& r) { r.resize(w); });
        for (int i = 0; i < n; ++i) {
            int x;
            int y;
            cin >> x >> y;
            v[y - 1][x - 1] = true;
        }
        int s;
        int t;
        // width, height
        cin >> s >> t;
        int maximum{-1};
        for (size_t i = 0; i < v.size() - t + 1; ++i) {
            for (size_t j = 0; j < v[i].size() - s + 1; ++j) {
                int count{0};
                for (auto y = i; y < i + t; ++y) {
                    for (auto x = j; x < j + s; ++x) {
                        if (v[y][x]) {
                            ++count;
                        }
                    }
                }
                maximum = max(maximum, count);
            }
        }
        cout << maximum << endl;
    }
}

Measured memory_bytes: 3068
from sys import stdin
input = stdin.readline

def Judge(S, T):
    ls = len(S)
    lt = len(T)
    m = 0
    for i in range(ls-lt+1):
        tmp = 0
        for j in range(lt):
            if S[i+j] == T[j]:
                tmp += 1
        if m < tmp:
            m = tmp
    return lt - m

S = input().strip()
T = input().strip()

print(Judge(S, T))

Measured memory_bytes: 9076
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

const ll INF = 100100100100;

ll dp[101][301][101];

vector<ll> w, v;

int main()
{
    ll N, W;

    cin >> N >> W;

    w.resize(N + 1);
    v.resize(N + 1);

    ll offset;

    cin >> offset >> v[1];
    w[1] = 0;

    for (int i = 2; i <= N;i++)
    {
        cin >> w[i] >> v[i];
        w[i] -= offset;
    }

    for (int i = 0; i <= 100;i++)
    {
        for (int j = 0; j <= 300;j++)
        {
            for (int k = 0; k <= 100;k++)
            {
                dp[i][j][k] = -INF;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= 300; j++)
        {
            for (int k = 0; k <= i; k++)
            {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j - w[i] >= 0 && W >= k * offset + j && dp[i - 1][j - w[i]][k - 1] != -INF && k-1 >= 0)
                {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - w[i]][k-1] + v[i]);
                }
            }
        }
    }

    ll ans = 0;

    for (int j = 0; j <= 300; j++)
    {
        for (int k = 0; k <= N; k++)
        {
            ans = max(ans, dp[N][j][k]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24192
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


void prime(vector<bool> &isprime) {
	ll i, j;
	isprime[0] = isprime[1] = false;
	for (i = 2; i < isprime.size(); i++) {
		if (isprime[i]) {
			for (j = 2; i*j < isprime.size(); j++) {
				isprime[i*j] = false;
			}
		}
	}
}


int main(){
  int n;
  cin >> n;
  vector<bool> isprime(60000, true);
  prime(isprime);
  vi ans;
  int i = 0;
  while (ans.size() < n) {
    if (isprime[5*i + 1]) {
      ans.push_back(5*i + 1);
    }
    i++;
  }
  rep (i, n) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
  
            
                         


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.trim().toLong()
        if (n == 0L) return
        println(n.toDec())
    }
}
fun Long.toDec(): Long {
    return if (this in 0 until 10) this else ((this % 10 + 10) % 10).let{last -> last + ((this - last) / -10).toDec() * 10}
}


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

int main()
{
  const int64_t inf = 100000000000;
  int a, b, q;
  cin >> a >> b >> q;
  vector<int64_t> s(a + 2), t(b + 2), x(q);

  for (int i = 1; i <= a; i++) cin >> s[i];
  for (int i = 1; i <= b; i++) cin >> t[i];
  for (int i = 0; i < q; i++) cin >> x[i];

  s[0] = t[0] = -inf;
  s[a + 1] = t[b + 1] = inf;

  for (int i = 0; i < q; i++) {
    auto s_itr = lower_bound(begin(s), end(s), x[i]);
    auto t_itr = lower_bound(begin(t), end(t), x[i]);
    int64_t s1 = x[i] - *(s_itr - 1);
    int64_t s2 = *s_itr - x[i];
    int64_t t1 = x[i] - *(t_itr - 1);
    int64_t t2 = *t_itr - x[i];
    int64_t d = inf;
    d = min(d, s1 > t1 ? s1 : t1);
    d = min(d, s2 > t2 ? s2 : t2);
    d = min(d, s1 > t2 ? s1 + t2 * 2 : s1 * 2 + t2);
    d = min(d, t1 > s2 ? t1 + s2 * 2 : t1 * 2 + s2);
    cout << d << endl;
  }
}


Measured memory_bytes: 3712
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7
N = int(input())
A = inpl()
S = sum(A) % MOD
T = sum(a*a % MOD for a in A) % MOD
U = S*S - T
if U % 2:
    U += MOD
ans = (U//2) % MOD

print(ans)


Measured memory_bytes: 105008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(),vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl;

ll gcd(ll x, ll y){
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x * y / gcd(x, y);
}

ll how_many(ll a, ll b, ll c){
    return b / c - (a-1) / c;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll cnt = 0;
    //debug(how_many(a, b, lcm(c, d)));
    cnt += how_many(a, b, c) + how_many(a, b, d) - how_many(a, b, lcm(c, d));
    cout << b - a + 1 - cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

void selection_sort(int* A, int N);
void print_array(int* A, int N);
void swap(int* A, int* B);

int main() {
    int n;
    int i;
    int* A;
    scanf("%d", &n);
    A = (int*)malloc(sizeof(int)*n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
    }
    
    selection_sort(A, n);
    
    free(A);
    return 0;
}

void selection_sort(int* A, int N) {
    int i,j;
    int minj;
    int count = 0;
    for ( i = 0; i < N; i++ ) {
        minj = i;
        for ( j = i; j < N; j++ ) {
            if ( A[j] < A[minj] ) {
                minj = j;
            }
        }
        if ( minj != i ) {
            swap(&A[i], &A[minj]);
            count++;
        }
    }
    
    print_array(A, N);
    printf("%d\n", count);
}

void print_array(int* A, int N) {
    int i;
    for ( i = 0; i < N; i++ ) {
        if ( i != N-1 ) {
            printf("%d ", A[i]);
        } else {
            printf("%d", A[i]);
        }
    }
    printf("\n");
}

void swap(int* A, int* B ) {
    int temp = *A;
    *A = *B;
    *B = temp;
}

Measured memory_bytes: 604
#include <algorithm>
#include <deque>
#include <iostream>


int main()
{
	using namespace std;

	deque<int> nums;
        int tmp = 0;
	for (int i=0; i<10; ++i){
             cin >> tmp;
             nums.push_back(tmp);
        }

	// ソート実行
	sort( nums.begin(), nums.end(), greater<int>() );

	// 結果を出力
	deque<int>::iterator it = nums.begin();
        int n=0;
	while(( it != nums.end() ) && (n<3))
	{
		cout << *it << endl;
		++it;
                ++n;
	}

	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, m;
  int a[30] = {};
  cin >> n >> m;
  REP(i, n)
  {
    int k;
    cin >> k;
    REP(j, k)
    {
      int t;
      cin >> t;
      a[t - 1]++;
    }
  }

  int result = 0;
  REP(i, m)
  {
    if (a[i] == n)
    {
      result++;
    }
  }
  cout << result << endl;
}


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

int main() {
  std::string S;
  std::cin >> S;
  size_t N{S.length()};

  int res{0};
  for (size_t i = 0; i < N; i++) {
    int c{0};
    size_t j{i};
    while (S[j] == 'A' || S[j] == 'T' || S[j] == 'G' || S[j] == 'C') {
      ++j;
      ++c;
    }
    res = (res > c) ? res : c;
  }
  std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
bool search(int* t,int n,int num) {
	for (int i = 0; i < n;i++) {
		if (t[i]==num) {
			return true;
		}
	}
	return false;
}
int solve(int num,int x) {
	if (num==0) {
		return 0;
	}
	stack<int> s;
	while (num) {
		s.push(num % 10);
		num /= 10;
	}
	for (int i = 0; i < x-1;i++) {
		s.pop();
	}
	return s.top();
}
int main() {
	std::ios::sync_with_stdio(false);
	int s[10];
	int c[10];
	//cout << solve(702, 2) << endl;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m;i++) {
		cin >> s[i] >> c[i];
	}
	bool flag = false;
	int ans;
	if (n==1) {
		for (int i = 0; i < 10;i++) {
			bool f = true;
			for (int j = 0; j < m; j++) {
				if (solve(i, s[j]) != c[j]) {
					f = false;
					break;
				}
			}
			if (f) {
				ans = i;
				flag = true;
			}
			if (flag) {
				break;
			}
		}
	}
	if (n==2) {
		for (int i = 10; i < 100;i++) {
			bool f = true;
			for (int j = 0; j < m; j++) {
				if (solve(i, s[j]) != c[j]) {
					f = false;
					break;
				}
			}
			if (f) {
				ans = i;
				flag = true;
			}
			if (flag) {
				break;
			}
		}
	}
	if (n==3) {
		for (int i = 100; i < 1000;i++) {
			bool f = true;
			for (int j = 0; j < m; j++) {
				if (solve(i, s[j]) != c[j]) {
					f = false;
					break;
				}
			}
			if (f) {
				ans = i;
				flag = true;
			}
			if (flag) {
				break;
			}
		}
	}
	if (flag) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc101


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 1
    N -= K
    if N % (K-1) == 0:
        ans += N // (K-1)
    else:
        ans += N // (K-1) + 1
    
    return ans


print(main())


Measured memory_bytes: 13880
/*　|＼＿／|
　　|―　―|
　　∧_∧_ノ_＿＿／/
　 (･ω･`)ﾆｬｰ　　　/
　 O旦⊂|　 ＿　　ヽ
　 ＯＯノ_／｣/_／＼｣
 */

#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    set<int> st;
    int tourist = 0;

    rep(i, n) {
        int a;
        cin >> a;
        int c = a / 400;
        if (c >= 8) tourist++;
        else st.insert(c);
    }
    if (st.size() == 0) {
        cout << 1 << " " << n << endl;
    } else {
        cout << st.size() << " " << (int) st.size() + tourist << endl;
    }
    return 0;
}



Measured memory_bytes: 256
n=int(input())
i=1
S=[1,2,3,4,5,6,7,8,9,10,11,12,13]
H=[1,2,3,4,5,6,7,8,9,10,11,12,13]
C=[1,2,3,4,5,6,7,8,9,10,11,12,13]
D=[1,2,3,4,5,6,7,8,9,10,11,12,13]

def delete(l_name,num):
    if l_name=="S":
        del S[S.index(int(num))]
    if l_name=="H":
        del H[H.index(int(num))]
    if l_name=="C":
        del C[C.index(int(num))]
    if l_name=="D":
        del D[D.index(int(num))]

while i<=n:
    l_name,num=input().split()
    delete(l_name,num)
    i+=1
for s_n in range(len(S)):
    print("S "+str(S[s_n]))
for h_n in range(len(H)):
    print("H "+str(H[h_n]))
for c_n in range(len(C)):
    print("C "+str(C[c_n]))
for d_n in range(len(D)):
    print("D " + str(D[d_n]))



Measured memory_bytes: 5612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		a,b,c,ans = 0;
	
	scanf("%d %d %d", &a,&b,&c);

	if ((a<b)&&(b<c)) printf("Yes\n");
	else printf("No\n");

	return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int height = sc.nextInt();
        int width = sc.nextInt();
        while(height != 0 || width != 0){
            StringBuilder ceilingFloorStr = new StringBuilder();
            StringBuilder roomStr = new StringBuilder("#");
            for(int w = 0; w < width; w++){
                ceilingFloorStr.append('#');
            }
            for(int w = 1; w < width - 1; w++){
                roomStr.append('.');
            }
            System.out.println(ceilingFloorStr);
            for(int h = 1; h < height - 1; h++){
                System.out.println(roomStr.toString() + '#');
            }
            System.out.println(ceilingFloorStr + System.lineSeparator());
            height = sc.nextInt();
            width = sc.nextInt();
        }
    }
}



Measured memory_bytes: 28072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mem(a, b) memset(a, b, sizeof(a))
#define INF 0X3f3f3f3f
const ll MAXN = 300000 + 7;
const ll MOD = 1e9 + 7;
//-------------------------------------------//
char s[MAXN];
int ans=0;
int main()
{
    scanf("%s",s);
    for(int i=1;s[i]!='\0';i++)
    {
        if(s[i]==s[i-1])
        {
            s[i]=!(s[i-1]-'0')+'0';
            ans++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

struct D {
	int b; double a;
	bool operator < (D x) const {return a < x.a;};
};

int main() {
	for (int n; (n = in());) {
		int y {in()};
		D a {};
		while (n--) {
			int b {in()}, r {in()};
			a = max(a, {b, in() - 1 ? pow(1 + r / 100., y) : 1 + y * (r / 100.)});
		}
		outl(a.b);
	}
}


Measured memory_bytes: 2676