akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		new AOJ0266().doIt();
	}
	
	class AOJ0266{
		boolean[] input;
		int n;
		City[] citys;
		void doIt(){
			citys = new City[6];
			citys[0] = new City(1, 2);
			citys[1] = new City(-1, 3);
			citys[2] = new City(1, -1);
			citys[3] = new City(4, 5);
			citys[4] = new City(5, 2);
			citys[5] = new City(2, 1);
			while(true){
				String a = in.next();
				if(a.equals("#"))return;
				input = new boolean[a.length()];
				n = a.length();
				for(int i=0;i<n;i++)input[i] = a.charAt(i)=='1';
				int currentCity = 0;
				for(int i=0;i<n;i++){
					currentCity = citys[currentCity].nextIndex(input[i]);
					if(currentCity==-1)break;
				}
				System.out.println(currentCity==5? "Yes":"No");
			}
		}
		
		class City{
			int a,b;
			public City(int a,int b){//0,1
				this.a = a;
				this.b = b;
			}
			int nextIndex(boolean code){
				return code? b:a;
			}
		}
		
	}
	
}

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

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else if (A + B < C + D)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }
    return (0);
}

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

using namespace std;

typedef long long ll;
const int MAX = 1e6+5;
bool isPrime[MAX];

int main(){

	ll n,p;
	cin >> n >> p;
	if(n==1){
		cout << p;
		return 0;
	}
	vector<int> primes;
	for(int i=0;i<MAX;i++){
		isPrime[i] = true;
	}
	isPrime[0] = false;
	isPrime[1] = false;
	primes.push_back(2);
	for(int i=2;i<MAX;i++){
		if(!isPrime[i]) continue;
		primes.push_back(i);
		for(int j=i+i;j<MAX;j+=i){
			isPrime[i] = false;
		}
	}
	vector<int> ans(primes.size(),0);
	for(int i=0;i<primes.size();i++){
		if(p<primes[i])
			break;
		while(p%primes[i]==0){
			ans[i]++;
			p/=primes[i];
		}
	}
	ll res=1;
	for(int i=0;i<ans.size();i++){
		res*=pow(primes[i],ans[i]/n);
	}
	cout << res;

}

Measured memory_bytes: 9324
#include<stdio.h>
int main()
{
	char a,b,c,d,e,f;
	scanf("%c %c %c\n%c %c %c",&a,&b,&c,&d,&e,&f);
	if (a==f&&b==e&&c==d)
	printf("YES\n");
	else
	printf("NO\n");
	 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 5e3 + 5;
using namespace std;
ll m,n,k;
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	double ans = 0;
	rep(i, 1, n) {
		double x;
		cin >> x;
		ans += 1 / x;
	}
	cout << 1 / ans << endl;
	cin >> n;

}

/*

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b;
	cin >> n >> a >> b;
	a = a*n;
	cout << min(a,b) << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		int n = sc.nextInt();
		int cnt = 0;
		while (1 < n) {
			while (n % 3 != 0) {
				n++;
			}
			n /= 3;
			cnt++;
		}

		System.out.println(cnt);
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

Measured memory_bytes: 17044
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 (b<a) { a=b; return 1; } return 0; }

int main() {
	int H,W,N;
	cin >> H >> W >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	int h = 0;
	int cc = 1;
	int cnt = 0;
	while(h < H) {
		string s = "";
		int w = 0;
		while(w < W) {
			if(h % 2 == 0) {
				s = s + ' ' + to_string(cc);
			}
			else {
				s = to_string(cc) + ' ' + s;
			}
			w++;
			cnt++;
			if(cnt == A[cc-1]) {
				cc++;
				cnt = 0;
			}
		}
		cout << s << endl;
		h++;
	}

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define ll long long
int main() {
//     // 20 11 9 24
// // int a=9^11;
// // a=a^20;
// // a=a^24;
// int a=20^14;
// cout<<a<<endl;
ios_base::sync_with_stdio(false);
 cin.tie(NULL);
    int n;
    cin>>n;
     int ans;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
     cin>>arr[i];   
        if(i==1)
        ans=arr[i];
        else
        ans=ans^arr[i];
    }
    for(int i=1;i<=n;i++)
    {
        int a=ans^arr[i];
        cout<<a<<" ";
    }
    
    
	return 0;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A),q(B),r(C);
  rep(i,A) cin >> p[i];
  rep(i,B) cin >> q[i];
  rep(i,C) cin >> r[i];
  vector<ll> ans;
  sort(RALL(p));
  sort(RALL(q));
  ll sum = 0;
  ll sumr = 0;
  ll sumg = 0;
  rep(i,X)
  {
    ans.pb(p[i]);
  }
  rep(i,Y)
  {
    ans.pb(q[i]);
  }
  sort(ALL(ans));
  sort(RALL(r));
  ll D = min(C,X+Y);
  rep(i,D)
  {
    if(ans[i]<r[i])
    {
      swap(ans[i],r[i]);
    }
  }
  rep(i,X+Y)
  {
    sum += ans[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 7720
#include<bits/stdc++.h>
#define maxn 1005050
using namespace std;
char s[maxn],t[maxn];
int n,m,h,w,x,y,xx,yy;
int u,d,l,r;

int main(){
    cin >> h >> w >> n;
    cin >> xx >> yy;
    scanf("%s",s+1);
    scanf("%s",t+1);
    bool f=0;
    x=xx; y=yy;
    for (int i=1;i<=n;i++){
        if (s[i]=='U') x--;
        if (x<1) f=1;
        if (t[i]=='D') x++;
        if (x>h) x=h;
    }
    x=xx; y=yy;
    for (int i=1;i<=n;i++){
        if (s[i]=='D') x++;
        if (x>h) f=1;
        if (t[i]=='U') x--;
        if (x<1) x=1;
    }
    x=xx; y=yy;
    for (int i=1;i<=n;i++){
        if (s[i]=='L') y--;
        if (y<1) f=1;
        if (t[i]=='R') y++;
        if (y>w) y=w;
    }
    x=xx; y=yy;
    for (int i=1;i<=n;i++){
        if (s[i]=='R') y++;
        if (y>w) f=1;
        if (t[i]=='L') y--;
        if (y<1) y=1;
    }
    if (f) puts("NO"); else puts("YES");
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),ans=0;long long m=read();
    m=m*m;
    for(int i=1;i<=n;i++)
    {
    	long long x=read(),y=read();
    	if(x*x+y*y<=m)ans++;
    }pr2(ans);
    return 0;
}

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

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

    int A[N], sum = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
        if (i == 0) {
            sum += std::abs(A[i]);
        } else {
            sum += std::abs(A[i] - A[i-1]);
        }
    }
    sum += std::abs(A[N-1]); 

    int B[N];
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            B[i] = std::abs(A[i+1] - 0) - (std::abs(A[i] - 0) + std::abs(A[i+1] - A[i]));
        } else if (i == (N - 1)) {
            B[i] = std::abs(0 - A[i-1]) - (std::abs(0 - A[i]) + std::abs((A[i] - A[i-1])));
        } else {
            B[i] = std::abs(A[i+1] - A[i-1]) - (std::abs(A[i+1] - A[i]) + std::abs(A[i] - A[i-1]));
        }
    }

    for (int i = 0; i < N; ++i) {
        std::cout << sum + B[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1004535809;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int f[16][16];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			f[i][j]=2;
		}
	}
	int t=0;
	int x,y;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		for(int j=1;j<=t;j++)
		{
			cin>>x>>y;
			f[i][x]=y;
		}
	}
	int mx=0;
	int bl=0;
	int g=0;
	for(int i=0;i<(1<<15);i++)
	{
		bl=1;
		g=0;
		for(int j=1;j<=n;j++)
		{
			if((i>>(j-1))&1)
			{
				g++;
				for(int k=1;k<=n;k++)
				{
					if(f[j][k]==2)continue;
					if(f[j][k]!=((i>>(k-1))&1))bl=0;
				}
			}
		}
		if(bl)mx=max(mx,g);
	}
	cout<<mx;
	return 0;
}

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

int main() 
{
    long n;
    cin>>n;
    for(int i=n;;i++)
    {int flag=0;
        for(int j=2;j<=i/2;j++)
        {
            if(i%j==0)
            {
                flag=1;
                break;
            }
            
        }
        if(flag==0)
        {
            cout<<i;
            break;
        }
    }
    
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 100000000

int main() {
    int H, W;
    int A[1000][1000];
    char ch;
    cin >> H >> W;
    REP(i, H) REP(j, W) {
        cin >> ch;
        A[i][j] = ch == '#' ? 0 : INF;
    }

    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> q;
    REP(i, H) REP(j, W) if (A[i][j] == 0)  {
        A[i][j] = 1;
        q.push({0, {i, j}});
    }
    int dh[4] = {1, 0, -1, 0}, dw[4] = {0, 1, 0, -1};
    while (true) {
        vector<pair<int, pii>> v;

        while (!q.empty()) {
            auto p = q.top(); q.pop();
            int h = p.second.first;
            int w = p.second.second;
            int c = p.first;
            if (A[h][w] <= c) continue;
            A[h][w] = c;

            REP(i, 4) {
                int nh = h + dh[i], nw = w + dw[i];
                if (0 <= nh && nh < H && 0 <= nw && nw < W) {
                    if (A[nh][nw] > c) v.push_back({c + 1, {nh, nw}});
                }
            }
        }

        if (v.empty()) break;
        for (auto p : v) q.push(p);
    }
    
    int ans = 0;
    REP(i, H) REP(j, W) ans = max(A[i][j], ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 52324
#include <stdio.h>
long long pre[100005];
long long find_root(long long x)
{
    if(pre[x] == x)
        return x;
    return find_root(pre[x]);
}
int main()
{
    long long n, q;
    while(scanf("%lld%lld", &n, &q), n || q)
    {
        pre[1] = 1;
        for(long long i = 2; i <= n; i++)
            scanf("%lld", &pre[i]);
        char a;
        long long b;
        long long ans = 0ll;
        while(q--)
        {
            scanf(" %c%lld", &a, &b);
            if(a == 'Q')
                ans += find_root(b);
            else
                pre[b] = b;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1808
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a,b=  map(int,input().split())

if a%3==0 or b%3 == 0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 2940
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}   
int main(){
  int n,i,j,k,max=0,d[210][210]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)scanf("%1d",&d[i][j]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i==j)d[i][j]=0;
      else if(d[i][j]==0)d[i][j]=1e9;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(k=0;k<n;k++)d[j][k]=MIN(d[j][k],d[j][i]+d[i][k]);
    }
  }
  for(i=0;i<n;i++){
    k=(d[0][0]+d[i][0])%2;
    for(j=0;j<n;j++){
      if((d[0][j]+d[i][j])%2-k)goto END;
      if(max<d[i][j])max=d[i][j];
    }
  }
  printf("%d\n",max+1);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}


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

using namespace std;

int main(void){

    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;

    int count = 0;
    count += max({a, b, c}) - a;
    count += max({a, b, c}) - b;
    count += max({a, b, c}) - c;

    if(count % 2 == 0){
        ans += count / 2;
    }else{
        ans += (++count) / 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define ll long long
#define ls(_o) (_o << 1)
#define rs(_o) ((_o << 1) | 1)
#define abs(_o) ((_o < 0) ? -(_o) : _o)
using namespace std;
    
inline int get() 
{ 
	int n = 0;char c;
    while ((c = getchar()) || 23333) 
	{
        if (c >= '0' && c <= '9')break;
        if (c == '-')goto s;
    }
    n = c - '0';
    while ((c = getchar()) || 23333) 
	{
        if (c >= '0' && c <= '9')n = n * 10 + c - '0';
        else return (n);
    }
    s:
    while ((c = getchar()) || 23333) 
	{
        if (c >= '0' && c <= '9')n = n * 10 - c + '0';
        else return (n);
    }
}
ll min1[1000001], min2[1000001], adds[1000001];
int x[200001];
inline void down(int tree) 
{
    if (!adds[tree])return;
    ll c = adds[tree];
    adds[tree] = 0;
    adds[ls(tree)] += c;
    adds[rs(tree)] += c;
    min1[ls(tree)] += c;
    min2[ls(tree)] += c;
    min1[rs(tree)] += c;
    min2[rs(tree)] += c;
}
inline void up(int tree) 
{
    min1[tree] = min(min1[ls(tree)], min1[rs(tree)]);
    min2[tree] = min(min2[ls(tree)], min2[rs(tree)]);
}
void setpt(int l, int r, int tree, int pt, ll num) 
{
    if (l == r) 
	{
        min1[tree] = min(min1[tree], num - l);
        min2[tree] = min(min2[tree], num + l);
        return;
    }
    int mid = (l + r) >> 1;down(tree);
    if (pt <= mid)setpt(l, mid, ls(tree), pt, num);
    else setpt(mid + 1, r, rs(tree), pt, num);
    up(tree);
}
ll query1(int rl, int rr, int l, int r, int tree) 
{
    if (rl == l && rr == r)return (min1[tree]);
    int mid = (l + r) >> 1;down(tree);
    if (rl > mid)return (query1(rl, rr, mid + 1, r, rs(tree)));
    if (rr <= mid)return (query1(rl, rr, l, mid, ls(tree)));
    return (min(query1(rl, mid, l, mid, ls(tree)), query1(mid + 1, rr, mid + 1, r, rs(tree))));
}
ll query2(int rl, int rr, int l, int r, int tree) 
{
    if (rl == l && rr == r)return (min2[tree]);
    int mid = (l + r) >> 1;down(tree);
    if (rl > mid)return (query2(rl, rr, mid + 1, r, rs(tree)));
    if (rr <= mid)return (query2(rl, rr, l, mid, ls(tree)));
    return (min(query2(rl, mid, l, mid, ls(tree)), query2(mid + 1, rr, mid + 1, r, rs(tree))));
}
ll query(int l, int r, int tree) 
{
    if (l == r)return (min1[tree] + l);
    int mid = (l + r) >> 1;down(tree);return (min(query(l, mid, ls(tree)), query(mid + 1, r, rs(tree))));
}
int main() 
{
//	freopen("2558.in","r",stdin);
    int n = get(), q = get(), a = get(), b = get();
    x[0] = a;
    memset(min1, 0x3f, sizeof(min1));
    memset(min2, 0x3f, sizeof(min2));
    setpt(1, n, 1, b, 0);
    for (register int i = 1; i <= q; i++) 
	{
        x[i] = get();
        ll cjr = min(query1(1, x[i], 1, n, 1) + x[i], query2(x[i], n, 1, n, 1) - x[i]);
        adds[1] += abs(x[i] - x[i - 1]);
        min1[1] += abs(x[i] - x[i - 1]);
        min2[1] += abs(x[i] - x[i - 1]);
        setpt(1, n, 1, x[i - 1], cjr);
    }
    printf("%lld\n",query(1,n,1));
    return (0);
}

Measured memory_bytes: 22400
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
result = 0

for i in range(N):
    sum = 0
    for (a,b) in zip(B,A[i]):
        sum += a*b
    if sum + C > 0:
        result += 1
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N; cin >> N;
	int p[200000];
	int m[200000];
	int mm = INF;
	rep(i, N) {
		cin >> p[i];
		mm = min(mm, p[i]);
		m[i] = mm;
	}
	int cnt = 0;
	rep(i, N) {
		if (m[i] == p[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int x,y,a,b,c;
	// nyuryoku
	cin >> x >> y >> a >> b >> c;
	long long p[a],q[b],r[c];
	for(int i=0;i<a;i++){
		cin >> p[i];
	}
	for(int i=0;i<b;i++){
		cin >> q[i];
	}
	for(int i=0;i<c;i++){
		cin >> r[i];
	}
	LL ans = 0;
	sort(p,p+a,greater<LL>());
	sort(q,q+b,greater<LL>());
	sort(r,r+c,greater<LL>());
	// keisan
	LL s[x+y+c],iter = 0;
	for(int i=0;i<x;i++){
		s[iter] = p[i];
		iter++;
	}
	for(int i=0;i<y;i++){
		s[iter] = q[i];
		iter++;
	}
	for(int i=0;i<c;i++){
		s[iter] = r[i];
		iter++;
	}
	LL t = x + y + c; 
	sort(s,s+t,greater<LL>());
	for(int i=0;i<x+y;i++){
		ans += s[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 8088
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int d[100000];
int main()
{
	int num, a, b;
	scanf("%d%d%d", &num, &a, &b);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]);
	if (num == 1)printf("%d\n", abs(b - d[0]));
	else printf("%d\n", max(abs(b - d[num - 1]), abs(d[num - 2] - d[num - 1])));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define inf 1e9
#define pp pop_back
#define pii pair<int,int>
#define vec vector<int>
#define mp make_pair
using namespace std;
int a[100001],b[100001],c[100001];
int dp[100001][4];
int ans(int n,int x)
{
  if(n==0)
     return 0;
  if(dp[n][x]!=-1)
    return dp[n][x];
  if(x==0)
    return dp[n][x]=max(a[n]+ans(n-1,1),max(b[n]+ans(n-1,2),c[n]+ans(n-1,3)));
  else if(x==1)
    return dp[n][x]=max(b[n]+ans(n-1,2),c[n]+ans(n-1,3));
  else if(x==2)
    return dp[n][x]=max(a[n]+ans(n-1,1),c[n]+ans(n-1,3));
  else
    return dp[n][x]=max(a[n]+ans(n-1,1),b[n]+ans(n-1,2));
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    cout<<ans(n,0);
  }
}


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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    long long n;
    cin >> n;
    int k = 1;
    long long p = 26;
    while (n > p) {
        n -= p;
        ++k;
        p *= 26;
    }
    --n;
    stack<int> s;
    for (int i = 0; i < k; ++i) {
        s.push(n%26);
        n /= 26;
    }
    string ans = "";
    while (!s.empty()) {
        ans.push_back('a'+s.top());
        s.pop();
    }
    cout << ans+"\n";
    return 0;
}


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

int n;
int l[1234];

int main(){
    ios_base::sync_with_stdio(0);
    //ifstream in ("input.txt");

    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>l[i];
    }
    sort(l,l+2*n);
    long long res = 0;
    for(int i=0;i<n;i++){
        res+=l[2*i];
    }
    cout<<res;
}


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

button=[[],
        ['.',',','!','?'," "],
        ['a','b','c'],
        ['d','e','f'],
        ['g','h','i'],
        ['j','k','l'],
        ['m','n','o'],
        ['p','q','r','s'],
        ['t','u','v'],
        ['w','x','y','z'],
        ]


for i in range(N):
    S=str(input())
    S=[i + " " for i in S]
    moji=""
    for i in S:
        moji+=i
    S=list(map(int,moji.split()))
    #print(S)
    forward=[0,0]
    for i in S:
        if forward[0]==i and forward[0]!=0:
            forward[1]+=1
            if forward[1]>len(button[i])-1:
                forward[1]=0

        if i==0 and forward!=[0,0]:
            print(button[forward[0]][forward[1]],end="")
            forward[1]=0
        forward[0]=i
        #print(forward)
    print("\n",end="")
            



Measured memory_bytes: 5656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

set<string> st;

void dfs(string s, int N) {
    if(s.size() == N) {
        st.insert(s);
        return;
    } else {
        int i = 0;
        for(int j=0; j<s.size(); j++) {
            i = max(i, s[j]-'a');
        }
        for(int j=0; j<=i+1; j++) {
            s.push_back('a'+j);
            dfs(s, N);
            s.pop_back();
        }
    }
}

int main(void) {
    int N;
    cin >> N;
    dfs("a", N);
    for(auto e: st) {
        cout << e << endl;
    }
    cerr << st.size() << endl;
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;

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

  cin >> N;
  vector< int > a(N);
  int f, t, o;
  f = t = o = 0;
  REP(i, N) {
    cin >> a[i];
    if (a[i] % 4 == 0) f++;
    else if (a[i] % 2 == 0) t++;
    else o++; 
  }

  bool ok = false;
  if (t == 0) {
    if (o > f + 1) ok = false;
    else ok = true;
  } else {
    if (o > f) ok = false;
    else {
      if (o > f) ok = false;
      else ok = true;
    }
  }

  OK(ok);
  

  return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, long long X, std::vector<long long> A){
    int ans = 0;
    REP(i, N) {
        if(A[i] < X) ans++;
        else break;
    }

    cout << min(ans, (int)A.size() - ans) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int n){
//     if(){
//         return;
//     }
    
//     return;
// }
 
int solve() {fastio
    
    ll n,m;
    cin>>n>>m;
    ll a[n],s=0;

    for (ll i = 0; i < n; ++i)
    {
        /* code */
        cin>>a[i];
        s+=a[i];
    }
    if(s%(4*m)==0){
        s = s/(4*m);
    }
    else s = s/(4*m)+1;
    ll ans=0;
    for (ll i = 0; i < n; ++i)
    {
        /* code */
        if(a[i]>=s)ans++;
        if(ans==m){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    

    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

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

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
int main(void){
    // Your code here!
    int n, i, j, tp=0, hp=0;
    char taro[101], hana[101];
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++){
        scanf("%s %s", taro, hana);
        
        for(j=0;;j++){
            if(taro[j]>hana[j]){
                tp += 3;
                break;
            }
            else if(taro[j]<hana[j]){
                hp += 3;
                break;
            }
            else if(taro[j]+hana[j]==0){
                tp++;
                hp++;
                break;
            }
        }
    }
    printf("%d %d\n", tp, hp);
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
using namespace std;
int n,a,sum;

int isPrime(int x){
    if(x<2) return 0;
    if(x==2) return 1;
    if(x%2==0) return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0) return 0;
    }
    return 1;
}

int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a;
        sum+=isPrime(a);
        
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3100
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int ret = 0;
            switch (str)
            {
                case "SUN":
                    ret = 7;
                    break;
                case "MON":
                    ret = 6;
                    break;
                case "TUE":
                    ret = 5;
                    break;
                case "WED":
                    ret = 4;
                    break;
                case "THU":
                    ret = 3;
                    break;
                case "FRI":
                    ret = 2;
                    break;
                case "SAT":
                    ret = 1;
                    break;
            }
            //出力
            Console.WriteLine(ret);

        }
    }

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

string n;

int main()
{
	cin>>n;
	
	for(int i=0; i<3; i++)
	{
		if(n[i]=='1') cout<<'9';
		else if(n[i]=='9') cout<<'1';
	}
	cout<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    ll cnt4 = 0, cnt2 = 0, cnt = 0;
    REP(i, n){
        ll a; cin >> a;
        if(a%4 == 0) cnt4++;
        else if(a%2 == 0) cnt2++;
        else cnt++;
    }

    if(cnt2 == 0){
        if(cnt4 >= cnt - 1) Yes();
        else No();
    }
    else{
        if(cnt4 >= cnt) Yes();
        else No();
    }
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define pb push_back
#define maxn 200005
int n,m,a,b,c,x,y,z,i,j,k;

void solve(){
    string str ;
    cin >> str ;
    int x ;
    x = str[2]-'0' ;
    x = x*10 + (str[3]-'0') ;
    int y = str[0]-'0' ;
    y*=10 ;
    y += str[1]-'0' ;
    if(x==0 && y==0)
        cout << "NA" ;
    else if(x==0 && y>12){
        cout << "NA" ;
    }
    else if(x==0 && y<=12)
        cout << "MMYY" ;
    else if(y==0 && x<=12)
        cout << "YYMM" ;
    else if(x>12 && y==0)
        cout << "NA" ;
    else if(x>12 && y>12){
        cout << "NA" ;
    }
    else if(x>12 && y<=12){
        cout << "MMYY" ;
    }
    else if(x<=12 && y>12){
        cout << "YYMM" ;
    }
    else cout << "AMBIGUOUS" ;
}
signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int n, x;
  cin >> n >> x;
  vector<int> l(n), d(n + 1);
  rep(i, n) cin >> l[i];
  for (int i = 1; i <= n; i++)
  {
    d[i] = d[i - 1] + l[i - 1];
    if (d[i] <= x)
      ans++;
  }
  pr(ans + 1);
  return 0;
}


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

const string mon[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main(){
	string s;
	cin >> s;
	int tmp;
	for(int i=0;i<7;i++) {
		if(s == mon[i]) {
			tmp = i+1;
			break;
		}
	}
	cout << 8 - tmp << endl;
}

Measured memory_bytes: 256
def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)

    for d in divs:
        if d == 1:
            print(d)
            return
        diff_n = [a % d for a in A if a % d != 0]
        diff_n.sort()
        diff_p = [d - dn for dn in diff_n]
        S_n = list(accumulate([0] + diff_n))
        S_p = list(accumulate([0] + diff_p))
        M = len(S_n) - 1
        if any(max(S_n[i], S_p[M] - S_p[i]) <= K for i in range(1, M)):
            print(d)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75180
#include <iostream>
using namespace std;
int main()
{
  int X;
  cin >> X;
  int ans = 0;
  int ang = 0;
  for (;;) {
    ang = (ang + X) % 360;
    ans++;
    if (ang == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#pragma region pre
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
#include <set>
#include <deque>
using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MOD{ 1000000000 + 7 };
#define rep(i,n) for (int i = 0; i < n; ++i)
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };

//constexpr int div_ru(int a, int b)
//{
//    return (a - b + 1) / b;
//}
//ll pow_mod(ll b, ll e, ll m)
//{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
//    ll r = 1;
//    for (; e > 0; e >>= 1)
//    {
//        if (e & 1)
//            r = (r * b) % m;
//        b = (b * b) % m;
//    }
//    return r;
//}
//class UnionFindTree
//{
//private:
//    vector<int> par_;
//    vector<int> rank_;
//
//public:
//    UnionFindTree(int);
//    ~UnionFindTree();
//    int root(int);
//    bool same(int, int);
//    void unite(int, int);
//};
//
//UnionFindTree::UnionFindTree(int n) : par_(n), rank_(n)
//{
//    iota(par_.begin(), par_.end(), 0);
//}
//
//UnionFindTree::~UnionFindTree()
//{
//}
//
//int UnionFindTree::root(int x)
//{
//    return par_[x] == x ? x : par_[x] = root(par_[x]);
//}
//
//bool UnionFindTree::same(int x, int y)
//{
//    return root(x) == root(y);
//}
//
//void UnionFindTree::unite(int x, int y)
//{
//    x = root(x);
//    y = root(y);
//    if (x == y)
//        return;
//    else if (rank_[x] < rank_[y])
//        par_[x] = y;
//    else
//    {
//        par_[y] = x;
//        if (rank_[x] == rank_[y])
//            rank_[x]++;
//    }
//}

#pragma endregion

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

    int n, k;
    cin >> n >> k;

    int ans = n - k;
    if (k == 1)
        ans = 0;

    cout << ans << endl;

    return 0;

}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int SIZE=100005;
int n;
long long a[SIZE],b[SIZE],c[SIZE];

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];
	long long ans=0;
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	int p=0,q=0;
	for(int i=0;i<n;i++){
		int cur=b[i];
		while(p<n && a[p]<b[i]){
			p++;
		}
		while(q<n && c[q]<=b[i]){
			q++;
		}
		ans+=((long long)p)*((long long)(n-q));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int digit(int N)
{
    int res;
    for(res=0; N>0; N/=10, res++);
    return res;
}

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

    int res = 0;
    for(int ni=1; ni<=N; ni++){
        if(digit(ni)%2 == 1){
            res++;
        }
    }
    printf("%d\n", res);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1'000'000'007;

string N;
ll K;
ll dp[101][4][2];

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

    repn(i,N.size()) dp[i][0][0]=1;
    dp[1][1][0]=N[0]-'0'-1;
    dp[1][1][1]=1;
    repn(i,N.size()-1){
        repn(j,K){
            if(N[i]!='0') dp[i+1][j][1]=dp[i][j-1][1];
            else dp[i+1][j][1]=dp[i][j][1];
            dp[i+1][j][0]+=dp[i][j-1][0]*9;
            dp[i+1][j][0]+=dp[i][j][0];
            dp[i+1][j][0]+=dp[i][j-1][1]*max(0,N[i]-'0'-1);
            if(N[i]!='0') dp[i+1][j][0]+=dp[i][j][1];
        }
    }

    int ans=dp[N.size()][K][0]+dp[N.size()][K][1];

    cout<<ans<<endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input;
            int N, M;

            Input = Console.ReadLine();
            N = int.Parse(Input.Split(' ')[0]);
            M = int.Parse(Input.Split(' ')[1]);

            if (N == M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
typedef long long     ll;
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
using namespace std;
map<ll,ll>mp;
int main()
{
    int k;
    string s;
    cin>>k>>s;
    if(s.size()>k)
    {
        com(i,k) cout << s[i];
        cout << "..." << endl;
    }
    else
        cout << s << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll mod=1e9+7;
    map<ll,ll> factor;
    for(ll i=1; i<=n; i++){
        ll x=i;
        for(ll j=2; x>1; j++){
            while(x%j==0) {factor[j]++; x/=j;}
        }
    }
    ll res=1;
    for(ll i=1; i<=n; i++){
        res*=factor[i]+1;
        res%=mod;
    }
    cout<<res%mod<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	int front = 0;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'A')
		{
			front = i - 1;
			break;
		}
	}
	
	int back = 0;
	for(int i = s.size() - 1; i >= 0; i--)
	{
		if(s[i] == 'Z')
		{
			back = i;
			break;
		}
	}
	
	cout << back - front << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, m;
  int a, b;
  pair<int,int> p[SIZE];

  scanf("%d%d", &n, &m);

  for(int i=0;i<m;i++){
    scanf("%d%d", &a, &b);
    p[i] = {min(a,b), max(a,b)};
  }

  sort(p, p+m, [](auto a, auto b){return a.second < b.second;});

  int max_b = -1;
  int ans = 0;
  
  for(int i=0;i<m;i++){
    if(p[i].first >= max_b){
      ans++;
      max_b = max(max_b, p[i].second);
    }
  }

  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <typeinfo>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    vector<int> d(n);
    int ai;
    for(int i=0; i<n; i++){
        cin >> ai;
        d[ai-1] = i+1;
    }
    for(int i=0; i<n; i++){
        cout << d[i] << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

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

    vector<int> l(n), ans(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
        ans[l[i]-1] = i+1;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
n=int(input())
h=[0]+[int(i) for i in input().split()]+[0]
c=0
while sum(h)>0:
    z=[i for i,x in enumerate(h) if x==0]
    for i in range(len(z)-1):
        l=z[i]
        r=z[i+1]
        if r-l>1:
            m=min(h[l+1:r])
            c+=m
            for j in range(l+1,r):
                h[j]-=m
print(c)

Measured memory_bytes: 39280
#include <stdio.h>
 
int main() {
	int N, K, A;
	char nama [52];

	scanf("%d %d %d", &N, &K, &A);
	scanf ("%s", &nama);
	A = K-1 ;
	nama [A] = nama [A] + 32 ;

	printf("%s", nama ) ;
	
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(void){
    int n, i, x[100]={}, y[100]={};
    long double  D1=0, D2=0, D3=0,D4=0, proD4;
    cin >> n;
    
    for(i=0; i<n; i++){
        cin >> x[i];
    }
    for(i=0; i<n; i++){
        cin >> y[i];
    }
    
    for(i=0; i<n; i++){
        D1 += abs(x[i] - y[i]);
        D2 += pow((x[i] - y[i]), 2);
        D3 += pow(fabs(x[i] - y[i]), 3); 
        proD4 = abs(x[i] - y[i]);
        if(D4 < proD4) D4 = proD4;
    }
    
    D2 = sqrt(D2);
    D3 = pow(D3, pow(3, -1));
    
    cout << fixed << setprecision(8) << D1 << endl << D2 << endl << D3 << endl << D4 << endl;
    return 0;
    
}



Measured memory_bytes: 3580