akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
 
int main(){
  int i,n,R[200000],min,max;
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
    if(R[i]<1 || R[i]>1000000000){
      exit(8);
    }
  }
 
  max=R[1]-R[0];
  min=R[0];
 
  for(i=1;i<n;i++){
    if(max<R[i]-min){
      max=R[i]-min;
    }
    if(min>R[i]){
      min=R[i];
    }
  } 
 
  printf("%d\n",max);
 
  return 0;
}



Measured memory_bytes: 2548
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	long long w, h;
	cin >> w >> h;
	vector<long long> p, q;
	vector<long long> all;
	long long ans = 0;
	REP(i, w) {
		int tmp;
		cin >> tmp;
		all.push_back(tmp);
		p.push_back(tmp);
	}
	REP(i, h) {
		int tmp;
		cin >> tmp;
		all.push_back(tmp);
		q.push_back(tmp);
	}
	sort(all.begin(), all.end());
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	long long top = w+1;
	long long bot = h+1;
	int p_ite = 0;
	int q_ite = 0;
	for (int i = 0;i < all.size();i++) {
		if (p_ite != w) {
			if (p[p_ite] == all[i]) {
				ans += bot * p[p_ite];
				p_ite++;
				top--;
				goto ok;
			}
		}
		ans += top * q[q_ite];
		q_ite++;
		bot--;
	ok:;
	}
	cout << ans << endl;
	return 0;
}

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

int cnt[1005];
int x[1005];
int huix[1005];
int a[1000000];

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

    sort(x + 1, x + n + 1);

    int it = 1;
    for (int i = 1; i <= n; i++)
    {
        int k = a[x[i]];
        for (int j = 1; j < k; j++)
        {
            while(a[it] != 0) it++;
            a[it] = k;
        }
    }

    it = 1;
    for (int i = 1; i <= n; i++)
    {
        int k = a[x[i]];
        for (int j = n; j > k; j--)
        {
            while(a[it] != 0) it++;
            a[it] = k;
        }
    }

    for (int i = 1; i <= n*n; i++)
    {
        int k = a[i];
        cnt[k]++;
        if (cnt[k] == k && i != huix[k])
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i <= n*n; i++) cout << a[i] << " ";

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

long long dfs(int i, string S) {
    int j, length = 0;
    for (j = 0;; j++) {
        if(S[j] != '+') length++;
        if(S[j] == '\0') {
            length--;
            break;
        }
    }
    //cout << "length:" << length << endl;
    if(i == length - 1) {
        //cout << "ans:" << S << endl;
        int i, numc = 1;
        long long num[30] = {};
        num[0] = stoll(S);
        for (i = 0;; i++) {
            if (S[i] == '+') {
                num[numc] = stoll(S.substr(i + 1));
                numc++;
            }
            if (S[i] == '\0') break; 
        }
        long long ans = 0;
        for (i = 0; i < 30; i++) {
            ans += num[i];
        }
        return ans;
    } else {
        string Splus = S;
        int count;
        for (j = 0, count = 0;; j++) {
            if(count == i) {
                if(S[j] == '+') Splus.insert(j + 2, "+");
                else Splus.insert(j + 1, "+");
                break;
            }
            if(S[j] != '+') count++;
        }
        //cout << Splus << endl;
        return dfs(i + 1, Splus) + dfs(i + 1, S);
    }
}

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

    cout << dfs(0, S) << endl;

    return 0;
}

Measured memory_bytes: 256
K, Q = map(int, input().split())
D = [int(a) for a in input().split()]
for _ in range(Q):
    N, X, M = map(int, input().split())
    if N <= K + 1:
        A = [0] * N
        A[0] = X % M
        ans = 0
        for i in range(N-1):
            A[i+1] = (A[i] + D[i]) % M
            if A[i+1] > A[i]:
                ans += 1
        print(ans)
        continue
    ans = N - 1
    t = X%M
    for i in range(K):
        d = (D[i]-1) % M + 1
        a = (N-i-2) // K + 1
        t += d * a
    ans -= t // M
    print(ans)

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

int n, i;

int main() {
    cin >> n;
    for (i = 0; i < n; i++) {
        int x = i + 1;
        int y = i + 1;
        int z = i + 1;
        x /= 10;
        y /= 100;
        z /= 1000;
        if ((i + 1) % 3 == 0) {
            cout << " " << i + 1;
        } else if ((i + 1) % 10 == 3) {
            cout << " " << i + 1;
        } else if (x % 10 == 3) {
            cout << " " << i + 1;
        } else if (y % 10 == 3) {
            cout << " " << i + 1;
        } else if (z % 10 == 3) {
            cout << " " << i + 1;
        }
        
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	long double A, B;
	cin >> A >> B;
	cout << (ll)(A * B) << "\n";
	return 0;
}


Measured memory_bytes: 3740
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      
      // 整数の取得
	  int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      
      int sum = A+B+C;
      
      if(sum>=22){
        System.out.println("bust");
      }else{
        System.out.println("win");
      }
    }
}

Measured memory_bytes: 35648
import math

D = int(input())
c = list(map(int, input().split()))
S = []
for i in range(D):
    S.append(list(map(int, input().split())))

nocontest = [1 for i in range(26)]
count_nocontest = [1 for i in range(26)]
for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    #print(contest)
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for j in range(26):
        if j == ans:
            nocontest[j] = 1
            count_nocontest[j] = 1
        else:
            nocontest[j] += count_nocontest[j]
            count_nocontest[j] += 1
    #print(nocontest)

Measured memory_bytes: 9524
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  ll n=read();
  write(n*n*n);
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer[]> alArrFinalPos = new ArrayList<Integer[]>();

		while(true) {
			String[] arrStrHW = buffReader.readLine().split(" ");
			int h = Integer.parseInt(arrStrHW[0]);
			int w = Integer.parseInt(arrStrHW[1]);

			if(h == w && h == 0) break;

			String[][] arrHWWay = new String[h][w];
			for(int i = 0; i < h; i++) arrHWWay[i] = getStringCharArr(buffReader.readLine());

			int hPos = 0;
			int wPos = 0;

			ArrayList<Integer[]> alArrPosWay = new ArrayList<Integer[]>();
			walkWall:while(true) {
				switch (arrHWWay[hPos][wPos]) {
					case ">": wPos++; 	break;
					case "<": wPos--; 	break;
					case "^": hPos--; 	break;
					case "v": hPos++; 	break;
					default:			break;
				}

				if(arrHWWay[hPos][wPos].equals(".")) {
					Integer[] arrFinalPos = new Integer[2];
					arrFinalPos[0] = hPos;
					arrFinalPos[1] = wPos;
					alArrFinalPos.add(arrFinalPos);
					break;
				} else {
					for(Integer[] arrSearchBasePosition: alArrPosWay) {
						if(hPos== arrSearchBasePosition[0] && wPos == arrSearchBasePosition[1]) {
							alArrFinalPos.add(null);
							break walkWall;
						}
					}
				}

				Integer[] arrPos = new Integer[2];
				arrPos[0] = hPos;
				arrPos[1] = wPos;

				alArrPosWay.add(arrPos);
			}
		}

		for(Integer[] arrFinalPos: alArrFinalPos) {
			System.out.println(arrFinalPos == null ? "LOOP" : arrFinalPos[1] + " " + arrFinalPos[0]);
		}
	}

	public static String getStringCharAt(String str, int position) {
		return String.valueOf(str.charAt(position));
	}

	public static String[] getStringCharArr(String str) {

		String[] arrResult = new String[str.length()];

		for(int i = 0; i < str.length(); i++) arrResult[i] = getStringCharAt(str, i);

		return arrResult;
	}
}

Measured memory_bytes: 27232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			System.out.println(gcd(a,b)+" "+lcm(a,b));
		}
	}

	private static long gcd(int a,int b){
		int max=Math.max(a, b);
		int min=Math.min(a, b);

		int amari=max%min;
		if(amari==0)return min;
		return gcd(min,amari);
	}

	private static int lcm(long a,long b){
		return (int) (a*b/gcd((int)a,(int)b));
	}
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r;
    cin>> r;
cout << r*r<<endl;
    return 0;
}


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

ll dfs(int K, const vector<vector<int>> &edge, int now, int from) {
	ll can_use_color_n;
	// 最初(now分使えない)
	if(from == -1) {
		can_use_color_n = K - 1;
	} else {
		// fromとnow分使えない
		can_use_color_n = K - 2;
	}

	// 自分自身以外の隣接する点の数が, 自分自身以外の濡れる個数より大きいとき色を塗ることができない
	if(K - 1 < edge[now].size()) {
		return 0;
	}

	ll case_n = 1;
	// 隣接点に色を分配
	for(auto &next : edge[now]) {
		if(next == from) continue;

		case_n *= can_use_color_n;
		case_n %= MOD;
		can_use_color_n--;
	}

	for(auto &next : edge[now]) {
		if(next == from) continue;
		case_n *= dfs(K, edge, next, now);
		case_n %= MOD;
	}
	return case_n;

}

int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<int>> edge(N);
	for(int i=0;i<N-1;i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	ll ans = K*dfs(K, edge, 0, -1);
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 11520
#define mm(a) memset(a,0,sizeof(a));
#define max(x, y) (x)>(y)?(x):(y)
#define min(x, y) (x)<(y)?(x):(y)
#define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
#define rep(i, a, b) for(int i=(a);i<=(b);i++)
#define per(i, b, a) for(int i=(b);i>=(a);i--)
#define PII pair<ll,ll>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;


int main() {
    ll n,m;
    while(~scanf("%lld%lld",&n,&m)){
        if((n+m)%2==0)printf("%lld\n",(n+m)/2);
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}


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


def dfs(acc):
    if int(acc) > N:
        return 0
    is_hichigosan_num = False
    if '7' in acc and '5' in acc and '3' in acc:
        is_hichigosan_num = True

    return sum([
        1 if is_hichigosan_num else 0,
        dfs(acc + '7'),
        dfs(acc + '5'),
        dfs(acc + '3')
    ])


print(dfs('0'))


Measured memory_bytes: 2940
from sys import exit
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
np = {i for i in range(0, 102)} - set(map(int, input().split()))
t = len(np)
d = 100
for _ in range(t):
    i = np.pop()
    if d > abs(x - i):
        d = abs(x - i)
        ans = i
print(ans)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    vector<int>taka(N);
    for(int i=0;i<N;i++){
        int t;
        cin>>t;
        taka[i]=t;
    }
    int c=0;
    for(int i=0;i<N;i++){
        if(taka[i]>=K){
            c++;
        }
    }
    cout <<c<<endl;
    
}


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

public class Main {
    int n;
    int[] as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        Arrays.sort(as);
        int ans = 0;
        int count = 0;
        for (int i = 1; i < n; i++) {
            count++;
            if (as[i - 1] < as[i]) {
                if (count < as[i - 1]) {
                    ans += count;
                } else {
                    ans += count - as[i - 1];
                }
                count = 0;
            }
        }
        count++;
        if (count < as[as.length - 1]) {
            ans += count;
        } else {
            ans += count - as[as.length - 1];
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 39080
#include <set>
#include <iostream>

using namespace std;

int main() {
  set<string> A;
  int n; // 命令回数
  cin >> n;

  for (int i {}; i < n; i++) {
    string order;
    cin >> order;

    if (order == "insert") {
      string word;
      cin >> word;
      A.insert(word);
    }
    else if (order == "find") {
      string word;
      cin >> word;
      if (A.count(word)) {
        cout << "yes" << endl;
      }
      else {
        cout << "no" << endl;
      }
    }
  }
}


Measured memory_bytes: 32148
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  string s;
  cin >> s;
  set<char> c;
  rep(i,3) c.emplace(s[i]);
  cout << (c.size()==3?"Yes":"No") << endl;
}


Measured memory_bytes: 256
import math
n = int(input().strip())
a = int(input().strip())
b = int(input().strip())
c = int(input().strip())
d = int(input().strip())
e = int(input().strip())
l = [a,b,c,d,e]
x = min(l)
if n > x:
        ans = math.ceil(n/x) + 5 - 1
else:
        ans = 5
print(ans)



Measured memory_bytes: 38384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NX = Sarray();
            var N = NX[0];
            var x = NX[1];
            var Ai = Sarray();
            var ans = 0L;
            for (var i = 0; i < N - 1; ++i) 
            {
                if (x < Ai[i])
                {
                    ans += Ai[i] - x;
                    Ai[i] = x;
                }
                var sum = Ai[i] + Ai[i + 1];
                if (x < sum)
                {
                    var dec = sum - x;
                    Ai[i + 1] -= dec;
                    ans += dec;
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 33500
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    ll right = s.size()-1;
    ll res = 0;
    for(ll i=s.size()-1;i>=0;i--){
        if(s.at(i) == 'B'){
            res += right - i;
            right--;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,m; cin>>n>>m;
vi arr(n);
rep(i,0,n)cin>>arr[i];
vector<bool>vis(n,true);
rep(i,0,m)
{
    ll x,y; cin>>x>>y;
    --x,--y;
    if(arr[x]>arr[y])vis[y] = false;
    else if(arr[x]<arr[y])vis[x] = false;
    else vis[x] = vis[y] = false;
}

ll cnt = 0;
rep(i,0,n)if(vis[i])cnt++;
cout<<cnt<<endl;

return 0;

}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


int main() {
    int a,b,c,d;
    string s,t,u;
    cin>>a>>b>>c;

    cout<<b/c-(a-1)/c<<endl;


    return 0;
}


Measured memory_bytes: 3624
n = int(input())
A = list(map(int,input().split()))
ans = 0
step = 0
for i in range(1,n):
    if A[i-1] + step > A[i]:
        step = A[i-1] + step - A[i]
        ans += step
    else:
        step = 0
print(ans)
        

Measured memory_bytes: 32332
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    string s, t;
    cin >> s >> t;

    sort(ALL(s));
    sort(rALL(t));

    for (int i = 0; i < min(s.size(), t.size()); i++) {
        if (s.at(i) < t.at(i)) {
            cout << "Yes" << endl;
            return 0;
        }
        else if (s.at(i) > t.at(i)) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (s.size() < t.size()) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n+1); for(auto&&i:a)cin>>i;
	vector<int>b(n); for(auto&&i:b)cin>>i;
	int64_t sum=0;
	for(int i=0;i<n;++i){
		int mn=min(a.at(i),b.at(i));
		a.at(i)-=mn,b.at(i)-=mn;
		int mnn=min(a.at(i+1),b.at(i));
		a.at(i+1)-=mnn;
		sum+=mn+mnn;
	}
	cout<<sum<<"\n"s;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
	unordered_set<string> ss;
	string s1, s2;
	rep(i, 0, n) {
		cin >> s1 >> s2;
		if(s1 == "insert") {
			ss.emplace(s2);
		} else {
			P(ss.find(s2) != ss.end() ? "yes" : "no");
		}
	}
	return 0;
}

Measured memory_bytes: 29636
N = int(input())

l = []
for i in range(N):
  v = int(input())
  l.append(v)
  
v = l[0]
ans = 1
while v != 2 and v != -1:
  tmp = l[v-1]
  l[v-1] = -1
  v = tmp
  ans += 1
  
if v == 2:
  print(ans)
else: 
  print(-1)

Measured memory_bytes: 12948
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long min = Long.MAX_VALUE;
        long rootN = (long) Math.sqrt(N);
        for(long i =  2; i <= rootN; i++){
            if(N % i == 0){
                long n = N / i;
                min = Math.min(min, (n-1)+ (i - 1));
            }
        }
        if(min > N){
            min = N -1;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 23124
let () =
  let n, h = Scanf.scanf "%d %d\n" (fun n h -> n, h) in
  let abs = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b)) in
  let max_a = List.fold_left max 0 @@ List.map fst abs in
  try
    List.map snd abs
    |> List.sort (fun a b -> compare b a)
    |> List.filter (( <= ) max_a)
    |> List.fold_left (fun (n, h) b ->
        if h <= b then (Printf.printf "%d\n" (n + 1); raise Not_found)
        else (n + 1, h - b)) (0, h)
    |> (fun (n, h) -> n + (h + max_a - 1) / max_a)
    |> Printf.printf "%d\n"
  with Not_found -> ()

Measured memory_bytes: 16640
m,k=map(int,input().split())

if m == 1 and k == 0:
    print("0 0 1 1")
    quit()
k += (2**(m) == 2 and k == 1)
if k< 2**(m):
    l = list(range(2**(m)))
    r = l[::-1]
    tep = [k]
    res=l[:k] + l[k+1:] +tep + r[:2**m-k-1] + r[2**m-k:] + tep
    s = ""
    for j in res:
        s+=str(j)+" "
    print(s[:-1])
else:
    print(-1)

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    if (n > 0)
        cnt++;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
from collections import deque
dq = deque()
append, popleft = dq.append, dq.popleft
try:
    while True:
        a = [[0]*14] + [[0]+list(map(int,input()))+[0] for _ in [0]*12] + [[0]*14]
        result = 0
        for y in range(1, 13):
            for x in filter(lambda x: a[y][x], range(1, 13)):
                result += 1
                a[y][x] = 0
                dq.clear()
                append((x, y))
                while dq:
                    cx, cy = popleft()
                    for dx, dy in ((0, -1), (1, 0), (0, 1), (-1, 0)):
                        if a[cy+dy][cx+dx]:
                            a[cy+dy][cx+dx] = 0
                            append((cx+dx, cy+dy))
        print(result)
        input()

except EOFError:
    pass


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll W,H,x,y; cin >> W >> H >> x >> y;
    cout << fixed << setprecision(6) << W*H/2.0 << " ";
    cout << ((x*2==W && y*2==H)?1:0) << endl;
    return 0;
}

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

int N;

struct alpha_t {
  int value;
  char index;
  bool operator<(const alpha_t& other) const{
    return value < other.value;
  }
};

typedef pair<char, int> P;

vector<int> tokuhyou(26);

P check() {
  priority_queue<alpha_t> que;
  for(int i = 0; i < 26; i++) {
    alpha_t tmp;
    tmp.value = tokuhyou[i];
    tmp.index = (char) i + 'A';
    que.push(tmp);
  }
  alpha_t tmp1, tmp2;
  tmp1 = que.top(); que.pop();
  tmp2 = que.top(); que.pop();
  //  cout << tmp1.index << " " << tmp1.value << endl;
  return P(tmp1.index, tmp1.value - tmp2.value);
}


int main() {
  while(true) {
    cin >> N;
    bool flag = false;
    if(N == 0) break;
    for(int i = 0; i < 26; i++) tokuhyou[i] = 0;
    for(int count = 0; count < N; count++){
      char hito;
      cin >> hito;
      tokuhyou[(int)(hito - 'A')]++;
      //      cout << "debug: " << check().second << " " << N - count - 1<< endl; 
      if(check().second > N - count - 1) {
        if(flag == false) cout << check().first << " " << count + 1<< endl;
        flag = true;
      }
    }
    if(flag == true) continue;
    else if (check().second == 0) cout << "TIE" << endl;
    else cout << check().first << " " << N + 1<< endl;
  }
}

Measured memory_bytes: 3088
def wa(L,cnt):
    for i in range(1,cnt/2+1):
        L[i][0]+=L[i-1][0]
        for j in range(1,len(L[i])-1):
            L[i][j]+=max(L[i-1][j-1],L[i-1][j])
        j=len(L[i])-1
        L[i][j]+=L[i-1][j-1]
L=[]
cnt=0
while True:
    try:
        L.append(map(int,raw_input().split(",")))
        cnt+=1
    except EOFError:
        break

wa(L,cnt)
wa(L[::-1],cnt)
print max(L[cnt/2])

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    sort(begin(s),end(s));
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        string s,t;
        cin>>s>>t;
        int cnt=0;
        int minn=INT_MAX;
        int n=s.length();
        int m=t.length();
        loop(i,0,n-m+1)
        {
            cnt=0;
            loop(j,i,i+m)
            {
                // cout<<s[j]<<" "<<t[j-i]<<"\n";
                if(s[j]!=t[j-i])
                {
                    cnt++;
                }
            }
            minn=min(minn,cnt);
        }
        cout<<minn<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


    int t = 1;
    //    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3512
from sys import stdin

S = stdin.readline().rstrip()[::-1]

result = ''

while True:
    if 'remaerd' == S[:7]:
        S = S[7:]
    elif 'maerd' == S[:5]:
        S = S[5:]
    elif 'esare' == S[:5]:
        S = S[5:]
    elif 'resare' == S[:6]:
        S = S[6:]
    else:
        if len(S) == 0:
            result = 'YES'
        else:
            result = 'NO'
        break;
print(result)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll div = (a[n-1]+1)/2;
  ll no = lower_bound(a.begin(),a.end(),div)-a.begin();
  double ans = 1,ans1=1;
  cout<<a[n-1]<<" ";
  if(a[no]-div<div-a[no-1]){
    cout<<a[no]<<endl;
  }
  else cout<<a[no-1]<<endl;


  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

const int MOD = int(1E9) + 7;

inline int add(int x, int y) {return (x + y >= MOD ? x + y - MOD : x + y);}
inline int sub(int x, int y) {return (x - y < 0 ? x - y + MOD : x - y);}
inline int mul(int x, int y) {return 1LL * x * y % MOD;}

bool check(int s) {return (s & 1) + ((s >> 1) & 1) == 2;}
int lowbit(int x) {return (x & -x);}

int f[1 << 15], g[1 << 15], bts[1 << 15], lg[1 << 15], pw2[20];

int G[15], N, M, S;
int main() {
	scanf("%d%d", &N, &M), S = (1 << N);
	for(int i=1;i<=M;i++) {
		int x, y; scanf("%d%d", &x, &y), x--, y--;
		G[x] |= (1 << y);
	}
	f[0] = pw2[0] = 1;
	for(int i=0;i<N;i++) lg[1 << i] = i;
	for(int i=1;i<=N;i++) pw2[i] = mul(2, pw2[i-1]);
	for(int s=1;s<S;s++) bts[s] = bts[s >> 1] + (s & 1);
	for(int s=0;s<S;s++) {
		for(int s2=s;s2;s2=s&(s2-1)) {
			if( check(s2) ) continue;
			int s3 = (s ^ s2), p = s2, del = f[s3];
			while( p ) {
				int q = lowbit(p);
				del = mul(del, pw2[bts[G[lg[q]] & s3]]);
				p ^= q;
			}
			p = s3;
			while( p ) {
				int q = lowbit(p);
				del = mul(del, sub(pw2[bts[G[lg[q]] & s2]], 1));
				p ^= q;
			}
			f[s] = add(f[s], del);
		}
	}
	printf("%d\n", f[S - 1]);
}

Measured memory_bytes: 384
s = input()
t = input()

flg = 0
y = s[::-1]
z = t[::-1]
result = []
for j,x in enumerate(range(0,len(y))):
    result = []
    for i,k in enumerate(y[x:x+len(t)]):
        if (k == z[i])|(k=="?"):
            result.append(True)
    if all(result)&(len(result)==len(t)):
        flg = 1
        break
if flg == 1:
    print((s[:len(s)-j-len(t)]+t+s[len(s)-j:]).replace("?","a"))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
cat <<EOS|gcc -xc - -o abc
#include <stdio.h>
int main() {
	int a1, a2, a3;
    scanf("%d %d %d", &a1, &a2, &a3);
    printf("%s", a1+a2+a3 < 22 ? "win" : "bust");
}
EOS
./abc
:

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    LLI l, r;
    cin >> l >> r;
    LLI mi = INF;
    for(LLI i = l; i < min(r, l + 2019); i++) {

        for(LLI j = i + 1; j <= min(r, l + 2019); j++) {
            if(j <= i)
                continue;
            chmin(mi, (i * j) % 2019);
        }
    }
    cout << mi;
    return 0;
}

Measured memory_bytes: 256
a = list(map(int, "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")))
print(a[int(input())-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  ll A, B, Q;
  cin >> A >> B >> Q;
  vll s(A), t(B), x(Q);
  for(int i = 0; i < A; i++){
    cin >> s.at(i);
  }
  for(int i = 0; i < B; i++){
    cin >> t.at(i);
  }
  vll ans(0);
  for(int i = 0; i < Q; i++){
    ll x;
    cin >> x;
    ll s1 = INF, s2 = INF, t1 = INF, t2 = INF;

    auto ites = lower_bound(ALL(s), x);
    if(ites != s.end()) s2 = *ites - x;
    if(ites != s.begin()){
      ites--;
      s1 = x - *ites;
    }

    auto itet = lower_bound(ALL(t), x);
    if(itet != t.end()) t2 = *itet - x;
    if(itet != t.begin()){
      itet--;
      t1 = x - *itet;
    }
    ll result = INF;
    chmin(result, max(t2, s2));
    chmin(result, max(t1, s1));
    chmin(result, 2*t1 + s2);
    chmin(result, t1 + 2*s2);
    chmin(result, 2*s1 + t2);
    chmin(result, s1 + 2*t2);
    ans.push_back(result);
  }
  for(auto x: ans) cout << x << endl;
}

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
bool pri( int k)
{ if( k == 1) return false;
    for(int i = 2; i * i <= k; i++)
    {

        if( k % i == 0) return false;
    }
    return true;
}
int main()
{
    long long ans = 0;
    long long n , a , b;
    cin >> n >> a >> b;
    long long x[n];
  //  int ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];

    }
    for(int i =0 ; i < n - 1; ++i)
    {
        ans += min( (abs( x[i + 1] - x[i] )) * a , b);

    }
    cout << ans;
}


Measured memory_bytes: 1024
n = int(input())
taroP, hanaP = 0, 0
for match in range(n):
    taro, hanako = input().split()
    if taro == hanako:
        taroP += 1
        hanaP += 1
    elif taro > hanako:
        taroP += 3
    else:
        hanaP += 3
print(taroP, hanaP)
        
    

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

using namespace std;

#define mod 1000000007
#define inf 1e18
#define ll long long
#define PI 3.1415926536


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

  char a;
  cin >> a;

  if (a >= 65 && a <= 90 )
    cout << "A" << endl;
  else
    cout << "a" << endl;
  return 0;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <queue>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <functional>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iterator>
#include <algorithm>
#include <iostream>

#define aLL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXISt(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MAX 100000000
#define PI 3.14159265258979
#define pb push_back
#define mp make_pair
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

int sttoi(std::string str) {
	int ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

int gcd(int a, int b){
	if (b > a)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a%b);
}

void solve() {
	int a, b, c, d, e, f;
	double x, y;
	while (scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != -1){
	y = (double)(d*c - a*f) / (double)(b*d - a*e);
	x = (double)(c - b*y) / (double)a;
	x *= 1000;
	y *= 1000;
	x = round(x);
	y = round(y);
	x /= 1000;
	y /= 1000;
	cout << setprecision(3) << fixed << x << " " << y << endl;
	}
}

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

Measured memory_bytes: 1284
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n, k; cin >> n >> k;
    if(k == 1) cout << 0 << endl;
    else cout << n-k << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(void){
	int N,*A,i,count=0;
	scanf("%d",&N);
	A = malloc(N * sizeof(int));
	for(i=0;i<N;i++) scanf("%d",&A[i]);

	while(1){
		for(i=0;i<N;i++){
			if(A[i]%2 == 1){
			 	free(A);
			 	printf("%d\n",count);
				return 0;
			}
			A[i] = A[i]/2;
		}
		count++;
	}
	free(A);
	return 0;
}

Measured memory_bytes: 1688
#import sys
#import math
import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a=int(input())
li0=[int(x) for x in input().split()]
count=0
ju=ans=mis=0
half=0
count=sum(li0)//2
for i in range(len(li0)):
  ju+=li0[i]
  if ju>=count:
    half=i
    break
if sum(li0[0:half])>=sum(li0[half+1:]):
  print(np.absolute(sum(li0[0:half])-sum(li0[half:])))
else:
  print(np.absolute(sum(li0[0:half+1])-sum(li0[half+1:])))



Measured memory_bytes: 12436
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

_int used[2001][2001];
_int mem[2001][2001];
vector<vector<Int> >Idx(30);
string s;
Int dfs(Int l, Int r){
  if(l > r) return 1;
  if(l == r) return 2;
  if(used[l][r]++) return mem[l][r];

  Int res = 1;
  for(Int i=0;i<26;i++){
    Int idxl = lower_bound(Idx[i].begin(), Idx[i].end(), l) - Idx[i].begin();
    Int idxr = upper_bound(Idx[i].begin(), Idx[i].end(), r) - Idx[i].begin();
    idxr--;
    
    if(idxl >= (int)Idx[i].size() || idxr >=(int)Idx[i].size()) continue;
    if(idxl < 0 || idxr < 0) continue;
    int nl = Idx[i][idxl];
    int nr = Idx[i][idxr];
    if((nl > nr)) continue;
    if(!(l <= nl && nr <= r)) continue;
    if(s[nl] != i + 'a' || s[nr] != i + 'a') continue;
    res = (res + 1) % mod;
    if(nl != nr) res = (res + dfs(nl+1, nr-1)) % mod;
  }
  return mem[l][r] = res;
}

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

  cin>>s;
  int n = s.size();
  for(Int i=0;i<(Int)s.size();i++) Idx[s[i] - 'a'].push_back(i);

  int ans = dfs(0, n-1) - 1;
  cout<<ans<<endl;
  return 0;
}



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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  ll d = pow(10, 9) + 7;
  ll ans = 0;
  ll sum1 = 0;
  ll sum2 = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] > A[j]) sum1++;
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i] < A[j]) sum2++;
    }
  }
  
  ans += K * sum1 % d;
  ans += (K * (K - 1) / 2) % d * (sum2);
  ans %= d;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    char a[103][103];
    cin>>h>>w;
    for(int i =0;i<h+2;i++)
    {
        for(int j=0;j<w+2;j++)
            a[i][j]='#';
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<h+2;i++)
    {
        for(int j=0;j<w+2;j++)
            cout<<a[i][j];
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
vector<int> vec[100010], ans;
bool used[100010];
void dfs(int s) {
	used[s] = true;
	ans.push_back(s);
	for (int i : vec[s]) {
		if (!used[i]){
			dfs(i);
			return;
		}
	}
}
signed main() {
	int n, m, a, b;
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs(1);
	reverse(ans.begin(), ans.end());
	for (int i : vec[1]) {
		if (!used[i]) {
			dfs(i);
			break;
		}
	}
	cout << ans.size() << endl;
	rep(i, ans.size() - 1)cout << ans[i] << " ";
	cout << ans.back() << endl;
	return 0;
}

Measured memory_bytes: 10100