akhauriyash/Code-Regression huggingface dataset:
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let mut ans = 0;
    for &c in s {
    	if c == b'+' {
        	ans += 1;
        } else {
        	ans -= 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    A = tuple(map(int, input().split()))
    ans = 0
    total = sum(A)
    for a in A:
        if a >= total/(4*m):
            ans += 1
    print("Yes") if ans >= m else print("No")

if __name__ == '__main__':
    main()



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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> x(n), y(n); rep(i, n) cin >> x[i] >> y[i];

	int ans = n;
	rep(i, n) rep(j, n) {
		if (i == j) continue;
		int p = x[i] - x[j];
		int q = y[i] - y[j];
		int cost = 0;
		rep(k, n) rep(l, n) {
			if (x[l] - x[k] == p and y[l] - y[k] == q) cost++;
		}
		ans = min(ans, n - cost);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.cnt()/1e6 << endl;
*/
long double pi= (long double)6.28318530717958623200;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(25);
    cout<<pi*r;
}


Measured memory_bytes: 3808
/*input
10 3
3 6
5 7
6 9
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool comp(pii a, pii b){
	return a.s < b.s;
}
signed main() {
	IOS;
	int n,m;
	cin>>n>>m;
	int a[n+1];
	memset(a,0,sizeof(a));
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a[x-1]--;
		a[y]++;
	}
	for(int i=n-1;i>=1;i--){
		a[i]+=a[i+1];
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(a[i]==m)ans++;
	}
	cout << ans << endl ; 
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end() 
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
int dp[100001];
signed main(){
    speed;
    int n; cin >> n;
    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        if(dp[i] != INT_MAX) {
            for(int j = 1; j <= 5; j++) {
                if(i + j <= n) {
                    dp[i + j] = min(dp[i + j], dp[i] + j);
                }
            }
            for(int j = 1; j < 6; j++) {
                if(i + pow(9, j) <= n) {
                    dp[i + pow(9, j)] = min(dp[i + pow(9, j)], dp[i] + 1);
                }
            }
            for(int j = 1; j < 7; j++) {
                if(i + pow(6, j) <= n) {
                    dp[i + pow(6, j)] = min(dp[i + pow(6, j)], dp[i] + 1);
                } 
            }
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 4412
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[MAXn][3];
ll d[MAXn][3];

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP1(i,n)REP(j,3)cin>>d[i][j];
    REP1(i,n)REP(j, 3)REP(k, 3)if(j != k)dp[i][j] = max(dp[i][j], dp[i-1][k] + d[i][j]);
    cout<<max({dp[n][0], dp[n][1], dp[n][2]});
}


Measured memory_bytes: 4992
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)

	ans := p[len(p)-1] / 2
	for i := 0; i < N-1; i++ {
		ans += p[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

a = n1()

print(a + a**2 + a**3)

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

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


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int count(int a)
{
	return a == 0 ? 0 : count(a >> 1) + (a & 1);
}

void f(int n, int a, int b, int mask)
{
	if(count(mask) == n - 1)
	{
		printf("%d %d ", a, b);
		return;
	}

	int i, j;
	FOR(i, 0, n)
		if ((a & (1 << i)) != (b & (1 << i)))
			FOR(j, 0, n)
				if(j != i && (mask & (1 << j)) == 0)
				{
					f(n, a, a ^ (1 << j), mask ^ (1 << i));
					f(n, a ^ (1 << i) ^ (1 << j), b, mask ^ (1 << i));
					return;
				}

	throw 0;
}

int main()
{
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if (count(a ^ b) % 2 == 0) printf("NO\n");
	else
	{
		printf("YES\n");
		f(n, a, b, 0);
	}


	return 0;
};


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long int h,n;
long long int f[2000005];
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	f[0]=0;	
	for(int i=1;i<=2000000;i++){
		f[i]=0x7ffffffffffffff;
	}
	cin>>h>>n;
	long long int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(int j=1;j<=n;j++){
		for(int i=a[j];i<=20000;i++){
			f[i]=min(f[i-a[j]]+b[j],f[i]);
		}
	}
	long long int minv=0x7ffffffffffffff;
	for(int i=h;i<=20000;i++){
		if(f[i]<minv){
			minv=f[i];
		}
	}
	cout<<minv;
}


Measured memory_bytes: 15872
X=int(input())
n=100005
prime = [True for i in range(n + 1)] 
p = 2
while (p * p <= n): 
    if (prime[p] == True): 
        for i in range(p * 2, n + 1, p): 
            prime[i] = False
    p += 1
prime[0]= False
prime[1]= False
for p in range(X,n+1): 
    if prime[p]: 
        print(p)
        break

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
int N=0, Y=0, i=0, j=0;
cin >> N >> Y;
bool ari=false, esc=false;
for(i=0; i<=N; i++){
    for(j=0; j<=N-i; j++){
        if(10000*i+5000*j+1000*(N-i-j)==Y){
            ari=true; esc=true; break;
        }
    }
    if (esc) break;
}
if(ari) cout << i << " " << j << " " << N-i-j << endl;
else cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,n;
	scanf("%d %d",&a,&b);
	if(a>0)puts("Positive");
	else if(a<=0&&b>=0)puts("Zero");
	else{
		n=b-a+1;
		if(n%2)puts("Negative");
		else puts("Positive");
	}
	return 0;
}

Measured memory_bytes: 128
n, m = [int(i) for i in input().strip().split(" ")]
if n >= m:
    result = 0
else:
    xs = sorted([int(i) for i in input().strip().split(" ")])
    ls = []
    for i in range(m-1):
        ls.append(xs[i+1] - xs[i])
    ls = sorted(ls)
    result = sum(ls[:m - n])

print(result)




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

int main() {
	int month,day,time,M;
    int month_l =12;
    int day_l	=31;
    int time_l  =24; 
	month =12;
    day	  =30;
  	cin >> M;
    time = M; 
	cout << (month_l-month)*30*24+(day_l-day)*24+(time_l-time)*1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int hoge(int x[]) {
    
    for (int j=9; j>0; j--) {
        for (int i=0;i<j; i++) {
            x[i] = (x[i] + x[i+1]) % 10;
        }
    }
	
    return x[0];
}

int main() {
    char a[15];
    
    while (~scanf("%s",a)) {
        int c[10];
        for (int i=0; i<10; i++) {
            c[i] = a[i] - '0';
        }
        
        c[0] = hoge(c);
        printf("%d\n",c[0]);
    }
    return 0;
}

Measured memory_bytes: 964
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans=-1;
  rep(i,n)for(j=i+1;j<n;j++){
    int t=a[i]*a[j];
    string s="";
    while(t){
      s+=(t%10+'0');
      t/=10;
    }
    bool c=true;
    rep(k,s.size()-1)
      if(s[k]-1!=s[k+1])c=false;
    if(c)ans=max(ans,a[i]*a[j]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3196
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 = a-b*2;
        if(c<=0){
            System.out.println(0);
        }else{
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(void){
    char tp[4];
    cin >> tp;
    
    int i;
    int price = 700;
    for(i= 0; i < 3; i++){
        if(tp[i] == 'o') price +=100;
    }
    cout << price << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 1000000007
using namespace std;
int main(){
	int n;
	vector<long long> a,s;
	map<long long, long long> m;
	cin>>n;
	long long su=0;
	m[0]++;
	 for(int i=0;i<n;i++){
		long long x;
		cin>>x;
		su+=x;
		s.push_back(su);
		m[su]++;
	}
	long long ans=0;
	for(int i=0;i<n;i++){
		if(m[s[i]]>=1){
		ans+=m[s[i]]*(m[s[i]]-1)/2;
		m[s[i]]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14320
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,K;
    ll A,B,C;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C>>K;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==K)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	unsigned long int n;
	cin >> n;
	vector<unsigned long int> a(3 * n);
	for (int i = 0; i < 3 * n; i++) cin >> a.at(i);

	sort(a.begin(), a.end());

	unsigned long int ans = 0;
	for (int i = n; i < 3 * n; i += 2) {
		ans += a.at(i);
	}

	cout << ans << endl;

 	return 0;
}

Measured memory_bytes: 2560
# coding: utf-8

yet_to_submit = [0]
for i in range(1,31):
	yet_to_submit.append(1)

for i in range(28):
	person = int(raw_input())
	yet_to_submit[person] = 0

for i in range(len(yet_to_submit)):
	if yet_to_submit[i] == 1:
		print i

Measured memory_bytes: 4644
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
signed main() {
	ll n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0 && n / i <= 9) {
			puts("Yes");
			ggr
		}
	}
	puts("No");
	ggr
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]); a[i]--;
    }
    int cnt=0;
    for(i=0; i<n; i++) {
        if(a[a[i]]==i) cnt++;
    }
    printf("%d\n", cnt/2);

    return 0;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: usize = read();
    let mut bef: i32 = read();
    let mut count: i32 = 0;
    for _i in 1..n{
	let num:i32 = read();
	if bef == num {
	    count+=1;
	    bef = -1;
	}else{
	    bef = num;
	}
    }
    println!("{}",count);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
    int a, b, c, k, y;
    int maior, v[3], soma=0;
    
    scanf("%d %d %d %d", &a, &b, &c, &k);
    
    maior=a;
    v[0]=a;
    v[1]=b;
    v[2]=c;
    
    for(int i=0; i<k; i++){
        soma=0;
        
        for(int j=0; j<3; j++){
            soma+=v[j];
            
            if(v[j]>maior){
                maior=v[j];
                y=j;
            }
        }
        
        v[y]=maior*2;
        soma=soma-maior+maior*2;
       
    }
    
    printf("%d\n", soma);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[100005];
int n,v[105],ww;
ll w[105];
int main(){
	cin>>n>>ww;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<100005;i++) dp[i] = 1e18;
	dp[0] = 0;
	for(int i=1;i<=n;i++){
		for(int j=100000;j>=v[i];j--){
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	ll ans = 0;
	for(int i=100000;i>=0;i--) if(dp[i] <= ww) ans=max(ans,1LL*i);
cout<<ans<<endl;}

Measured memory_bytes: 1024
# coding: utf-8

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


def main():
    x1, y1, x2, y2 = map(int, input().split())

    v12 = (x2-x1, y2-y1)
    v23 = (-v12[1], v12[0])
    v34 = (-v23[1], v23[0])
    v41 = (-v34[1], v34[0])

    x3, y3 = x2+v23[0], y2+v23[1]
    x4, y4 = x3+v34[0], y3+v34[1]

    print("{} {} {} {}".format(x3, y3, x4, y4))


main()
# print(main())


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    const ll mod=1000000007;
    vector<ll> dp(n+1,0);
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=i-3;j>=0;j--) dp[i]=(dp[i]+dp[j])%mod;
    }
    cout << dp[n] << "\n";
    return 0;
}


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

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

    if (N < 1000)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ABD" << endl;
    }

    return (0);
}

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

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 1; i <= n; i++)
            a[i - 1] = sc.nextInt() - i;
        Arrays.sort(a);
        int b = (n % 2 == 0) ? (a[n / 2] + a[n / 2 - 1]) / 2 : a[n / 2];
        long ans = 0;
        for (int i = 1; i <= n; i++)
            ans += Math.abs(a[i - 1] - b);
        System.out.println(ans);

	}

		//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 66940
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; string s;
    cin >> k >> s;
    if ((int)s.size() <= k) cout << s << '\n';
    else cout << s.substr(0, k) << "...\n";
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int p[30005]={0},a[30005]={0},b[30005]={0};
int main()
{	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	a[1]=100000;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+30000;
	for(int i=1;i<=n;i++)b[n-i+1]=a[i];
	for(int i=1;i<=n;i++)b[p[i]]+=i;
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<'\n';
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
	return 0;
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> field(505,vector<int> (505));
	rep(i,h) rep(j,w) cin >> field[i][j];
	int n = 0;
	vector<tuple<int,int,int,int>> ans(0);
	rep(i,h){
		rep(j,w){
			if(i == h-1 && j == w - 1) continue;
			if(field[i][j] % 2){
				int x, y, x_, y_;
				n++;
				y = i, x = j; 
				//右か下に送る
				if(j == w - 1){ // 下に送る
					x_ = j, y_ = i+1;
				} else {
					// 右に送る
					y_ = i; x_ = j+1;
				}
				// ansにぶち込む
				field[y][x] ++;
				field[y_][x_] ++;
				y++, x++, y_++, x_++;
				ans.push_back(make_tuple(y,x,y_,x_));
			} else {
				// 何もしなあい
			}
		}
	}

	// 答えの出力
	cout << n << endl;
	rep(i,n){
		int y, x, y_, x_;
		tie(y, x, y_, x_) = ans[i];
		printf("%d %d %d %d\n",y ,x, y_, x_);
	}
}


Measured memory_bytes: 5232
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int m, n, k;
char maze[1010][1010];
int cj[1010][1010], co[1010][1010], ci[1010][1010];

int main() {
	cin >> m >> n >> k;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> maze[i][j];
		}
	}

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			cj[i][j] = cj[i - 1][j - 1] + (cj[i - 1][j] - cj[i - 1][j - 1]) + (cj[i][j - 1] - cj[i - 1][j - 1]) + (maze[i][j] == 'J' ? 1 : 0);
			co[i][j] = co[i - 1][j - 1] + (co[i - 1][j] - co[i - 1][j - 1]) + (co[i][j - 1] - co[i - 1][j - 1]) + (maze[i][j] == 'O' ? 1 : 0);
			ci[i][j] = ci[i - 1][j - 1] + (ci[i - 1][j] - ci[i - 1][j - 1]) + (ci[i][j - 1] - ci[i - 1][j - 1]) + (maze[i][j] == 'I' ? 1 : 0);
		}
	}
	int a, b, c, d;
	for (int i = 0; i < k; i++) {
		cin >> a >> b >> c >> d;
		cout << cj[c][d] - cj[a - 1][d] - cj[c][b - 1] + cj[a - 1][b - 1] << " "
			<< co[c][d] - co[a - 1][d] - co[c][b - 1] + co[a - 1][b - 1] << " "
			<< ci[c][d] - ci[a - 1][d] - ci[c][b - 1] + ci[a - 1][b - 1] << endl;
	}
}

Measured memory_bytes: 15784
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (3000)
#define MAX 100000
int main() {
	ll a, b, c;
	scanf("%lld%lld", &a, &b);
	c = a % b;
	c = min(abs(c - b), c);
	printf("%lld\n", c);
	return 0;
}

Measured memory_bytes: 128
import itertools
import math
n = int(input())
s = []
for i in range(n):
    x,y = map(int,input().split())
    s.append([x,y])
s = list(itertools.permutations(s))
ans = 0
for i in s:
    for j in range(n-1):
        ans += math.sqrt((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)
print(ans/len(s))

Measured memory_bytes: 45296
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N=5002;
int n,a,b,p[N];
LL f[N],g[N][N],h[N][N];
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>a>>b;
    for (int i=1;i<=n;i++) cin>>p[i];
    p[n+1]=n+1;
    for (int i=0;i<n;i++)
    for (int j=i+2;j<=n+1;j++)
    {
        g[i][j]+=g[i][j-1];
        if (p[i]>p[j-1]) g[i][j]+=b;
    }
    for (int i=2;i<=n+1;i++)
    for (int j=i-2;j>=0;j--)
    {
        h[j][i]+=h[j+1][i];
        if (p[i]<p[j+1]) h[j][i]+=a;
    }
    //cout<<g[0][2]<<"\n";
    for (int i=1;i<=n+1;i++) f[i]=1e18;
    for (int i=1;i<=n+1;i++)
    {
        int mx=-1;
        for (int j=i-1;j>=0;j--)
        if (p[i]>p[j]&&p[j]>mx)
        {
            mx=p[j];
            f[i]=min(f[i],f[j]+g[j][i]+h[j][i]);
            //cout<<i<<" "<<j<<" "<<f[i]<<"\n";
        }
    }
    cout<<f[n+1];
    return 0;
}


Measured memory_bytes: 389632
N = int(input())
al=[chr(ord('a') + i) for i in range(26)]
out = []
while N>=1:
    X = N%26
    out.append(X-1)
    if X==0:
        N = (N-26)//26
    else:
        N = (N-X)//26
S = ""
for i in range(len(out)):
    S += al[out[len(out)-1-i]]
print(S)


Measured memory_bytes: 61932
#include <stdio.h>

int main(){

    int x,y;

    scanf("%d %d",&x,&y);

    while(x!=0||y!=0){
        if(x>y)printf("%d %d\n",y,x);
        else printf("%d %d\n",x,y);
        scanf("%d %d",&x,&y);
    }
}


Measured memory_bytes: 2032
#include <stdio.h>
#define NUM1 10000
#define NUM2 10000
int main(void)
{
	int num[NUM1];
	int num1[NUM2];
	int tmp;
	int i = 0;
	int j = 0;

	while (1){
		scanf("%d %d", &num[i], &num1[i]);
		if (num[i] == 0 && num1[i] == 0)break;
		i++;
	}

	while (1){
		if (num[j] > num1[j]){ 
			tmp = num[j]; 
			num[j] = num1[j]; 
			num1[j] = tmp; 
		}
		if (num[j] == '\0'&& num1[j] == '\0')break;
		printf("%d %d\n", num[j], num1[j]);
		j++;
	}
	return 0;
}

Measured memory_bytes: 624
DBG = true
n = gets.to_i
a,b = gets.split.map{|x| x.to_i}
p = gets.split.map{|x| x.to_i}
n1 = 0
n2 = 0
n3 = 0
for i in p
  if i <= a
    n1 += 1
  elsif i <= b
    n2 += 1
  else
    n3 += 1
  end
end
print [n1,n2,n3].min 


Measured memory_bytes: 1788
#include <iostream>
#define MAX 1000000

using namespace std;
int binarySearch(int);
int A[MAX];
int n;

int main(){
  int i,q;
  int key,result = 0;
  //scanf("%d",&n);
  cin >> n;
  for(i = 0; i < n; i++){
    //scanf("%d",&A[i]);
    cin >> A[i];
  }
  //scanf("%d",&q);
  cin >> q;
  for( i = 0; i < q; i++){
    //scanf("%d",&key);
    cin >> key;
    if(binarySearch(key)){ /**/
      result++;
    }
  }
  //printf("%d\n",result);
  cout << result << endl;
  return 0;
}

int binarySearch(int key){
  int left = 0, right = n;
  int mid;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]){
      return 1;
    }
    if(key > A[mid]){
      left = mid + 1;
    }
    else if(key < A[mid]){
      right = mid;
    }
  }
  return 0;
}

Measured memory_bytes: 3472
#include <iostream>
#include <vector>
#include <complex>
using namespace std;
 
#define X real()
#define Y imag()
#define EPS (1e-10)
 
typedef complex<double> P;
typedef P Vec;
 
double dot(Vec v1, Vec v2) {
  return (v1*conj(v2)).X;
}
 
double cross(Vec v1, Vec v2) {
  return (v1*conj(v2)).Y;
}
 
enum { COUNTER_CLOCKWISE, CLOCKWISE, ONLINE_FRONT, ONLINE_BACK, ON_SEGMENT};
 
int ccw(P p0, P p1, P p2) {
  Vec a = p1 - p0;
  Vec b = p2 - p0;
  if(cross(a, b) > EPS) return CLOCKWISE;
  if(cross(a, b) < -EPS) return COUNTER_CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(norm(a) < norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}
 
void putResult(int x) {
  if(x == COUNTER_CLOCKWISE) cout << "COUNTER_CLOCKWISE" << endl;
  if(x == CLOCKWISE) cout << "CLOCKWISE" << endl;
  if(x == ONLINE_FRONT) cout << "ONLINE_FRONT" << endl;
  if(x == ONLINE_BACK) cout << "ONLINE_BACK" << endl;
  if(x == ON_SEGMENT) cout << "ON_SEGMENT" << endl;
}
 
int main() {
  double x, y;
  P p0, p1;
   
  cin >> x >> y; p0 = P(x, y);
  cin >> x >> y; p1 = P(x, y);
   
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    P p2 = P(x, y);
     
    putResult( ccw(p0, p1, p2) );
  }
   
  return 0;
}

Measured memory_bytes: 1240
mod = 10**9 + 7
S = int(input())
dp = [-1]*2001
ans = 0
dp[0] = 0
dp[1] = 0
dp[2] = 0
dp[3] = 1
dp[4] = 1
dp[5] = 1

def reg(N):
    if dp[N] != -1:
        return dp[N]
    else:
        t = 0
        for j in range(3, (N-2)):
            t += reg(j) % mod
        t += 1
        t %= mod
        dp[N] = t
        return t
reg(2000)
print(dp[S])


Measured memory_bytes: 68196
$n,$y = gets.chomp.split(" ").map(&:to_i)

arr = []

($n+1).times do |n|
  ($n+1 - n).times do |n2|
    arr << [n,n2,($n-n-n2)]
  end
end


arr.each do |ar|
  if ar[0]*10000 + ar[1]*5000 + ar[2]*1000 == $y
    puts ar.join(" ")
    exit
  end
end

puts "-1 -1 -1"

Measured memory_bytes: 112508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

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

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

int main(void){
  ios_base::sync_with_stdio(0);
  int n;
  while(cin >> n, n){
    vector< vector<int> > vec(n + 1, vector<int>(n + 1, 0));
    for(int i = 0; i < n; i++){
      int sum = 0;
      for(int j = 0; j < n; j++){
        cin >> vec[i][j];
        sum += vec[i][j];
      }
      vec[i][n] = sum;
    }

    for(int i = 0; i <= n; i++){
      int sum = 0;
      for(int j = 0; j <= n; j++){
        sum += vec[j][i];
      }
      vec[n][i] = sum;
    }
    for(int i = 0; i <= n; i++){
      for(int j = 0; j <= n; j++){
        printf("%5d", vec[i][j]);
      }
      printf("\n");
    }
  }
  return 0; 
}

Measured memory_bytes: 1236
/*
userid- rakeshpavan333
contest - Practice
*/
#include<bits/stdc++.h>

using namespace std;
#define ll long long 
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define MXN  2000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
ll M=1e9+7;
ll n,fr[2][MXN],ans=0;
int main()
{
    fastio;
    memset(fr,0,sizeof(fr));
    cin>>n;
    ll a[n+1];
    pii p[2][2];
    memset(p,0,sizeof(p));
    
    for(int i=0;i<n;++i)
        cin>>a[i],fr[i%2][a[i]]++;
    for(int i=0;i<n;++i)
    {
        if(fr[i%2][a[i]]>p[i%2][1].f)swap(p[i%2][1],p[i%2][0]),p[i%2][1]=mp(fr[i%2][a[i]],a[i]);
        else if(fr[i%2][a[i]]>p[i%2][0].f && a[i]!=p[i%2][1].s)p[i%2][0]=mp(fr[i%2][a[i]],a[i]);
    }
    if(p[0][1].s != p[1][1].s)ans += (n/2-p[0][1].f+n%2)+(n/2 - p[1][1].f);
    else
    {
        ans = (n/2 - p[0][1].f + n%2 ) + ( n/2 - p[1][0].f );
        ans = min(ans,(n/2 - p[0][0].f + n%2 ) + ( n/2 - p[1][1].f ));
    }
    cout<<ans<<"\n";
    return 0;
}

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

const int Max = 1e5+10, mod = 1e9+7;
vector<int> adj[Max];
int memo[2][Max] = {0};

void dfs(int node, int par) {
    memo[0][node] = 1;
    memo[1][node] = 1;
    for(int to : adj[node]) {
        if(to == par) continue;
        dfs(to, node);
        memo[0][node] *= memo[0][to] + memo[1][to];
        memo[1][node] *= memo[0][to];
        memo[0][node] %= mod;
        memo[1][node] %= mod;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int u,v;
    for(int i = 0; i < n-1; ++i) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,1);
    cout << (memo[0][1] + memo[1][1])%mod << '\n';
    return 0;
}


























Measured memory_bytes: 14208
n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    b.append([i + 1, a[i]])
b.sort(key=lambda x:x[1])

for i in range(n - 1):
    print(b[i][0], end=" ")
print(b[n - 1][0])


Measured memory_bytes: 22312
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int x[55];
int y[55];
signed main(){
    
    int n,k;
    cin >> n >> k;
    if(k == 1)cout << 0 << endl;
    else cout << n-k << endl;
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://diverta2019-2.contest.atcoder.jp/tasks/diverta2019_2_b

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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int m, f = 0;
	char s[101];
	scanf("%s", s);
	m = strlen(s);
	REP(i, 8) {
		char a[8] = { 0 };
		strncpy(a, s, i);
		strcat(a, &s[i + m - 7]);
		if (strcmp(a, "keyence") == 0) f = 1;
	}
	YES(f);
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

// Data structures.
struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point(const Point& p) : x(p.x), y(p.y) {}

    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }

    bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; }
    bool operator==(const Point& p) const { return fabs(x - p.x) < 1e-10 && fabs(y - p.y) < 1e-10; }

    static double norm(const Point& p) { return sqrt(p.x * p.x + p.y * p.y); }
    static double dot(const Point& p1, const Point& p2) { return p1.x * p2.x + p1.y * p2.y; }
    static double cross(const Point& p1, const Point& p2) { return p1.x * p2.y - p1.y * p2.x; }
};
struct Segment {
    Point s, t;
    Segment(const Point& s, const Point& t) : s(s), t(t) {}
    Segment(const Segment& seg) : s(seg.s), t(seg.t) {}
};

typedef vector<Point> Polygon;

int ccw(const Point& p1, const Point& p2, const Point& p) {
    double cr = Point::cross(p2 - p1, p - p1);
    if (cr > 0) return 1;
    if (cr < 0) return -1;
    // p, p1, p2.
    if (Point::dot(p2 - p1, p - p1) < 0) { return 2; }
    // p1, p2, p.
    if (Point::dot(p - p2, p1 - p2) < 0) { return -2; }
    // p is in [p1, p2].
    return 0;
}

bool intersect(const Segment& s1, const Segment& s2) {
    bool ok1 = ccw(s1.s, s1.t, s2.s) * ccw(s1.s, s1.t, s2.t) <= 0;
    bool ok2 = ccw(s2.s, s2.t, s1.s) * ccw(s2.s, s2.t, s1.t) <= 0;
    return ok1 && ok2;
}

int contains(Polygon g, Point p) {
    int n = g.size();
    bool x = false;
    for (int i = 0; i < n; i++) {
        Point a = g[i] - p, b = g[(i + 1) % n] - p;
        if (ccw(g[i], g[(i + 1) % n], p) < EPS) { return 1; }
        if (a.y > b.y) swap(a, b);
        if (a.y < EPS && EPS < b.y && Point::cross(a, b) > EPS) x = !x;
    }
    return (x ? 2 : 0);
}

int check_containment(const Polygon& poly, const Point p) {
    int n = poly.size();
    bool ans = false;

    rep(i, 0, n) {
        Point s(poly[i]), t(poly[(i + 1) % n]);
        if (ccw(s, t, p) == 0) { return 1; }
        if (s.y > t.y) { swap(s, t); }
        if (s.y < p.y + EPS && p.y + EPS < t.y && Point::cross(s - p, t - p) > EPS) { ans = !ans; }
    }
    return ans ? 2 : 0;
}

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

    int n;
    cin >> n;

    Polygon poly(n);
    rep(i, 0, n) { cin >> poly[i].x >> poly[i].y; }

    int q;
    cin >> q;
    rep(i, 0, q) {
        Point p;
        cin >> p.x >> p.y;
        cout << check_containment(poly, p) << endl;
    }

    return 0;
}


Measured memory_bytes: 3280
#include"iostream"
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n > 17 || n == 4 || n == 7 || n == 8 || n == 11 || n == 12 || n == 14 || n == 15 || n == 16)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[110];
int main(){
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='C'){
			for(int j=i;j<strlen(a);j++){
				if(a[j]=='F'){
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int i;
	int sum = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for (i = 0; i < b; i++)
	{
		if ((b - i) < a)
		{
			break;
		}
		
		if (c % (b - i) == 0)
		{
			sum += 1;
		}
	}
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18


ll n,m,x;
vector<vector<ll>> c;

ll cal(ll f){
	vector<ll> cnt(m+1);
	REP(i,n){
		ll tmp=f%2;
		f/=2;
		if(tmp==1){
			REP(j,m+1){
				cnt[j]+=c[i][j];
			}
		}
	}
	FOR(i,1,m+1){
		if(cnt[i]<x){
			return INF;
		}
	}
	return cnt[0];
}
int main(){
	cin>>n;
	cin>>m;
	cin>>x;
	c.resize(n);
	REP(i,n){
		c[i].resize(m+1);
		REP(j,m+1){
			cin>>c[i][j];
		}
	}
	ll end=1<<n;
	ll min=INF;
	REP(i,end){
		//cout<<i<<endl;
		ll tmp=cal(i);
		if(min>tmp)min=tmp;
	}
	if(min==INF){
		cout<<-1<<endl;
		return 0;
	}
	cout<<min<<endl;
	return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  vector<vector<int>> A(3, vector<int>(3, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> B(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      bool flag = false;
      for (int k = 0; k < N; k++) {
        if (A[i][j] == B[k]) {
          flag = true;
        }
      }
      if (flag)
        A[i][j] = 1;
      else
        A[i][j] = 0;
    }
  }
  for (int i = 0; i < 3; i++) {
    bool flag1 = true;
    bool flag2 = true;
    for (int j = 0; j < 3; j++) {
      if (A[i][j] == 0) {
        flag1 = false;
      }
      if (A[j][i] == 0) {
        flag2 = false;
      }
    }
    if (flag1 || flag2) {
      cout << "Yes" << endl;
      return;
    }
  }
  if (A[0][0] == 1 && A[1][1] == 1 && A[2][2] == 1) {
    cout << "Yes" << endl;
    return;
  } else if (A[2][0] == 1 && A[1][1] == 1 && A[0][2] == 1) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pf          push_front
#define endl    '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll a[100005],p[100004];
void seive()
{
  ll i,j;
  p[2]=0;
  for(i=4;i<100003;i+=2)p[i]=1;
  for(i=3;i<100005;i+=2)
  {
    if(!p[i])
    {
      p[i]=0;
      for(j=2*i;j<100005;j+=i)p[j]=1;
    }
  }
}
int main()
{
  ios
  ll i,j,q,x,y;
  seive();p[1]=1;
  for(i=3;i<100002;i+=2)
  {
    if(p[i]==0&&p[(i+1)/2]==0)a[i]=1;
  }
  for(i=1;i<=100003;i++)a[i]=a[i]+a[i-1];
  cin>>q;
  while(q--)
  {
    cin>>x>>y;
    cout<<a[y]-a[x-1]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 2176