akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int K,N;
  cin>>K>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int ans=0;
  vector<int>B(N);
  for(int i=0;i<N;i++){
    if(i==0){
      B[i]=K-A[N-1]+A[i];
    }
    else{
      B[i]=A[i]-A[i-1];
    }
  }
  sort(B.begin(), B.end());
  for(int i=0;i<N-1;i++){
    ans+=B[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n;
  int k;
  int array[100005];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  int times=1;
  while((k-1)*times+1<n){
    times++;
  }
  cout<<times<<endl;
  return(0);
}


Measured memory_bytes: 640
N=int(input())
la=list(map(lambda x:[int(x),0],input().split()))
lb=list(map(lambda x:[int(x),1],input().split()))
lc=list(map(lambda x:[int(x),2],input().split()))
l=la+lb+lc
l.sort(key=lambda x:(x[0],-x[1]))
na=0
sumb=0
ans=0
for i in range(3*N):
    if l[i][1]==0:
        na+=1
    elif l[i][1]==1:
        sumb+=na
    else:
        ans+=sumb
print(ans)


Measured memory_bytes: 72092
<?php
$input_array = array();
$input_array[] = trim(fgets(STDIN)); //500
$input_array[] = trim(fgets(STDIN)); //100
$input_array[] = trim(fgets(STDIN)); //50
$input_array[] = trim(fgets(STDIN)); //6000とか
$num_500 = $input_array[3] / 500;
$ans = 0;
for ($i = 0; $i <= $num_500; $i++) {
    $leftover1 = $input_array[3] - 500 * $i;
    $num_100 = $leftover1 / 100;
    for ($j = 0; $j <= $num_100; $j++) {
        $leftover2 = $leftover1 - 100 * $j;
        $num_50 = $leftover2 / 50;
        if ($num_50<=$input_array[2] && $j<=$input_array[1] && $i<=$input_array[0]) {
            $ans = $ans + 1;
        }
    }
}
echo($ans);

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a+w<b){
        cout<<b-a-w<<endl;
    }
    else if(b+w<a){
        cout<<a-b-w<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
def main():
    owner_num = 753
    s = input()
    min_diff = int(s[0:3])
    for i in range(3,len(s)+1):
        runrun_num = int(s[(i-3):i])
        if abs(owner_num - runrun_num) < abs(owner_num - min_diff):
            min_diff = runrun_num
    print(abs(owner_num - min_diff))



if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include<stdio.h>
int main(void)
{
	int H=1,W=1,i,j;

	while((H!=0)||(W!=0))
	{
		scanf("%d%d",&H,&W);
		
		if((H!=0)||(W!=0))
		{	
			for(i=0;i<H;i++)
			{
				for(j=0;j<W;j++)
				{
				
					if((i>0)&&(i<H-1)&&(j>0)&&(j<W-1))
					{
						printf(".");
					}
					else
					{
						printf("#");
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2040
using System;
using System.Linq;

namespace AtCoder2
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var l = s.Length;
			var b = Enumerable.Repeat(1, l).ToArray();

			for (int i = 0; i < l - 2; i++)
			{
				if (s[i] == 'R' && s[i + 1] == 'R')
				{
					b[i + 2] += b[i];
					b[i] = 0;
				}
			}

			for (int i = l - 1; i > 0; i--)
			{
				if (s[i] == 'L' && s[i - 1] == 'L')
				{
					b[i - 2] += b[i];
					b[i] = 0;
				}
			}

			Console.WriteLine(String.Join(' ', b));
		}
	}
}


Measured memory_bytes: 28212
local n, m = io.read("*n", "*n")
local t = {}
for i = 1, m do
  z = io.read("*n")
  t[i] = {}
  for j = 1, z do
    table.insert(t[i], io.read("*n"))
  end
end
local p = {}
for i = 1, m do
  p[i] = io.read("*n")
end
local ret = 0
local tot = 1
for i = 1, n do tot = tot * 2 end
local use = {}
for i = 0, tot - 1 do
  local ti = i
  for j = 1, n do
    use[j] = ti % 2
    ti = ti // 2
  end
  local v = true
  for j = 1, m do
    local q = 0
    for k = 1, #t[j] do
      q = q + use[t[j][k]]
    end
    if q % 2 ~= p[j] then v = false break end
  end
  if v then ret = ret + 1 end
end
print(ret)


Measured memory_bytes: 760
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        
        String[] s = sc.next().split("");
        
        if(!s[A].equals("-")){
            System.out.println("No");
            return;
        }
        
        for(int i=0; i<A; i++){
            if(s[i].equals("-")){
                System.out.println("No");
                return;
            }
        }
        
        for(int i=1; i<=B; i++){
            if(s[i + A].equals("-")){
                System.out.println("No");
                return;
            }
        }
        
        System.out.println("Yes");
    }
}

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

typedef struct {
	int x;
	int y;
  int check;
} S_POINT;

int cmpR(const void * n1, const void * n2)
{
	if (((S_POINT *)n1)->y > ((S_POINT *)n2)->y)
	{
		return -1;
	}
	else if (((S_POINT *)n1)->y < ((S_POINT *)n2)->y)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int cmpB(const void * n1, const void * n2)
{
	if (((S_POINT *)n1)->x > ((S_POINT *)n2)->x)
	{
		return 1;
	}
	else if (((S_POINT *)n1)->x < ((S_POINT *)n2)->x)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  int n;
  scanf("%d", &n);
  S_POINT red[n],blue[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &red[i].x, &red[i].y);
    red[i].check = 0;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &blue[i].x, &blue[i].y);
    blue[i].check = 0;
  }
  qsort(red, n, sizeof(S_POINT), cmpR);
  qsort(blue, n, sizeof(S_POINT), cmpB);
  int pairs = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (red[j].check == 0 && red[j].x < blue[i].x && red[j].y < blue[i].y) {
        red[j].check = 1;
        pairs++;
        break;
      }
    }
  }
  printf("%d\n", pairs);

  return 0;
}

Measured memory_bytes: 128
import sys
 
patterns = ( 'S', 'H', 'C', 'D' )
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in patterns }
for i in range( n ):
    pattern, num = sys.stdin.readline().split( " " )
    cards[ pattern ][ int( num )-1 ] = True
 
for pattern in patterns:
    for i in range( 13 ):
        if not cards[ pattern ][ i ]:
            print( "{:s} {:d}".format( pattern, i+1 ) )

Measured memory_bytes: 7688
n, m = map(int, input().split())

lis = []
for _ in range(m):
    new = list(map(int, input().split()))
    lis.append(new[1:])

plist = list(map(int, input().split()))

res = 0
for i in range(2**n):
    cou = [0 for k in range(m)]
    binary = '0'*(n - len(bin(i)[2:])) + bin(i)[2:]
    for j in range(n):
        if binary[j] == '1':
            for k in range(len(lis)):
                if j + 1 in lis[k]:
                    cou[k] += 1 
    if all((cou[x] - plist[x])%2 == 0 for x in range(m)):
        res += 1
print(res)

Measured memory_bytes: 3064
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e5+5;
const ll INF = 1e18+5;

int block;
bool cmp(pair<pii,int> a,pair<pii,int> b)
{
	if((a.first.first-1)/block==(b.first.first-1)/block)
	{
		return a.first.second<b.first.second;
	}
	else return (a.first.first-1)/block<(b.first.first-1)/block;
}

int main()
{
	fastio
	int n,q;
	cin>>n>>q;
	vl A(n+1);
	block=sqrt(n);
	take(A,1,n);
	vector<pair<pii,int>> Q(q);
	
	for(int i=0;i<q;i++)
	{
		int l,r;
		cin>>l>>r;
		Q[i].first.first=l;
		Q[i].first.second=r;
		Q[i].second=i;
	}
	sort(all(Q),cmp);
	
	int start=0;
	int end=0;
	vi F(n+1);
	vi Ans(q);
	int ans=0;
	for(auto query:Q)
	{
		while(start>query.first.first)
		{
			start--;
			F[A[start]]++;
			if(F[A[start]]==1) ans++;
		}
		while(end<query.first.second)
		{
			end++;
			F[A[end]]++;
			if(F[A[end]]==1) ans++;
		}
		while(start<query.first.first)
		{
			if(start!=0) F[A[start]]--;
			if(F[A[start]]==0) ans--;
			start++;
		}
		while(end>query.first.second)
		{
			F[A[end]]--;
			if(F[A[end]]==0) ans--;
			end--;
		}
		Ans[query.second]=ans+1;
	}
	for(int i=0;i<q;i++)
	{
		cout<<Ans[i]<<endl;
	}
	
}

Measured memory_bytes: 17396
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
int ans;
int main(){
	int sum=0;
	while(true){
		char c;
		c=getchar();
		if(c==' '||c=='\r'||c=='\n'||c=='\0'||c==EOF)break;
		if(c=='R')++sum;
		else sum=0;
		ans=std::max(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3760
from sys import stdin
import numpy as np
N, M = [int(x) for x in stdin.readline().rstrip().split()]
C = np.zeros(N)
Rmin = N
Lmax = 1
for i in range(M):
    L, R = [int(x) for x in stdin.readline().rstrip().split()]
    if R < Rmin:
        Rmin = R
    if L > Lmax:
        Lmax = L
if Lmax > Rmin:
    print(0)
else:
    print(N-(Lmax-1)-(N-Rmin))

Measured memory_bytes: 27204
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
double n,k,s=0;
int q(int x)
{
    double ans=1,base=2;
    while(x*ans<k)
    {
            ans*=base;
    }
    return ans;
}
int main()
{
    int i;
    scanf("%lf%lf",&n,&k);
    for(i=1;i<=n;i+=1)
    {
        if(i>=k)
            break;
        s+=(1.0/q(i));
    }
    s=(s+n-i+1)/n;
    printf("%.12lf\n",s);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define PP std::pair<int,int>
int whx[90010];
int why[90010];
int cost[90010];
int main() {
	int H, W, D;
	std::cin >> H >> W >> D;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int tmp;
			std::cin >> tmp;
			whx[tmp] = i;
			why[tmp] = j;
		}
	}
	for (int i = 1; i <= D;i++) {
		int j = 1;
		while ((i + j*D) < 90001) {
			cost[i + D*j] = cost[i + D*(j - 1)] + std::abs(whx[i + D*j] - whx[i + D*(j - 1)]) + std::abs(why[i + D*j] - why[i + D*(j - 1)]);
			j++;
		}

	}
	int Q;
	std::cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R;
		std::cin >> L >> R;
		std::cout << cost[R]-cost[L] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

vector<vector<int>> A(9,vector<int>(0));
int N;
int dfs(vector<int>& memo,int now,int numcnt){

  if(numcnt==N)return 1;
  int ans=0;
  for(int i=0; i<A[now].size(); i++){
    if(memo[A[now][i]]==0){
      memo[A[now][i]]=1;
      ans+=dfs(memo,A[now][i],numcnt+1);
      memo[A[now][i]]=0;
    }
  }
  return ans;
}
int main() {

  int M;
  cin>>N>>M;
  vector<int> memo(9);
  for(int i=0; i<M; i++){
    int a,b;
    cin>>a>>b;
    A[a].push_back(b);
    A[b].push_back(a);
  }
memo[1]=1;
cout<<dfs(memo,1,1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
int c = 0, mx = -1;
for (int i = 0; i < s.size(); i++)
{
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G')
    c++;
    else
    c = 0;
    mx = max (mx, c);
}
cout << mx;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

a = [[0 for j in range(m)] for i in range(n)]
for i in range(n):
    a[i]= list(map(int, input().split()))

b = list()
for j in range(m):
    b.append(int(input()))

for k in range(n):
    print(int(sum(list(map(lambda x,y: x*y, a[k], b)))))


Measured memory_bytes: 6032
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int L, R; cin >> L >> R;
	int minn = 2019;
	if (L / 2019 != R / 2019) {
		cout << 0 << endl;

	}
	else {
		for (int i = L % 2019; i < R % 2019;i++) {
			for (int j = i + 1; j < R % 2019+1; j++) {
				minn = min(minn, (i * j) % 2019);
			}
		}
		cout << minn << endl;
	}

	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;cin>>s;
  int n = stoi(s);
  int l = 0,a=n;
  while(a!=0){
    l+=a%10;
    a/=10;
  }
  if(n%l==0){
    cout<<"Yes"<<endl;
  }else{
    cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int x[101], y[101];
ll h[101];

ll tmp[101];

pair<ll, ll> p[101];

int get_height(int cx, int cy, int n){
  int i = 0;
  for(; h[i] == 0; i++){}
  int ch = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
  REP(i, n) if(h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0)) return 0;
  //REP(i, n) if(h[i] != ch - abs(x[i] - cx) - abs(y[i] - cy)) return 0;

  return ch;
}

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

  int n;
  cin >> n;
  REP(i, n) cin >> x[i] >> y[i] >> h[i];
  
  REP(cy, 101) REP(cx, 101) {
    int ch = get_height(cx, cy, n);
    if(ch > 0) {cout << cx << ' ' << cy << ' ' << ch << endl; return 0;}
  }
   
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var A = _[0]; var B = _[1];
        double H = _[2]; double M = _[3];
        var minOfHours = M + H * 60;
        var radLong = PI / 2 - PI * M / 30;
        var radShort = PI / 2 - PI * minOfHours / 360;
        radLong %= PI * 2;
        radShort %= PI * 2;
        var sx = Cos(radShort) * A;
        var sy = Sin(radShort) * A;
        var lx = Cos(radLong) * B;
        var ly = Sin(radLong) * B;
        var res = Sqrt(Pow(sx - lx, 2) + Pow(sy - ly, 2));
        print(res);
    }


    public static long SumAtoB(long a, long b) { var length = b - a + 1; return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0); }
    public static long PowLite(long n, long p, int mod = (int)1e9 + 7) { long ans = 1; long now = n; for (; p > 0; p >>= 1) { if ((p & 1) == 1) { ans *= now; ans %= mod; } now *= now; now %= mod; } return ans; }
    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
    public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable { var a = new List<T>(array).ToArray(); var res = new List<T[]>(); res.Add(new List<T>(a).ToArray()); var n = a.Length; var next = true; while (next) { next = false; int i; for (i = n - 2; i >= 0; i--) { if (a[i].CompareTo(a[i + 1]) < 0) break; } if (i < 0) break; var j = n; do { j--; } while (a[i].CompareTo(a[j]) > 0); if (a[i].CompareTo(a[j]) < 0) { var tmp = a[i]; a[i] = a[j]; a[j] = tmp; Array.Reverse(a, i + 1, n - i - 1); res.Add(new List<T>(a).ToArray()); next = true; } } return res; }
}


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

int main() {
  string S;
  cin >> S;
  
  bool A = false, B = false;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'A') A = true;
    if (S.at(i) == 'B') B = true;
  }

  if (A && B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int64_t ans=0; 
    for(int i=0;i<(1<<(s.size()-1));i++){
        bitset<10> t(i);
        t<<=1;
        t.set(0);
        int64_t sum=0;
        int x=0;
        for(int j=0;j<s.size();j++){
            if(t.test(j)) x=0;
            char k=s.at(s.size()-j-1);
            sum+=(k-'0')*powl(10,x);
            x++;
        }
        ans+=sum;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	if (a != 2 && b != 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long d = Integer.parseInt(sc.next());
    long d2 = d * d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      long x = Integer.parseInt(sc.next());
      long y = Integer.parseInt(sc.next());
      if (d2 >= x * x + y * y) {
        ans++;
      }
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 57820
N = int(input())
v = list(map(int, input().split()))

for i in range(N-1):
	min1 = min(v)
	v.remove(min1)
	min2 = min(v)
	v.remove(min2)
	a = (min1 + min2) / 2
	v.append(a)
print(v[0])


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

int main(){
	vector<string> s(3);
	for(int i=0; i<3; i++){
		cin >> s.at(i);
	}
	for(int i=0; i<3; i++){
		cout << s.at(i).at(0);
	}
	cout << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;https://mobomovie1.top/series/%D8%AF%D8%A7%D9%86%D9%84%D9%88%D8%AF-%D8%B3%D8%B1%DB%8C%D8%A7%D9%84-%D9%81%D8%B1%DB%8C%D9%86%D8%AC-fringe-2008-2013-%D8%A8%D8%A7-%D8%B2%D9%8A%D8%B1%D9%86%D9%88%D9%8A%D8%B3-%D9%81%D8%A7%D8%B1/
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon
const int N=3000;

ll dp[N][N][2];

ll a[N];

int32_t main(){
    string s;
    cin >> s;
    ll ans=0;
    ll n=s.size();
    while(s.size()){
        ans++;
        char c=s[n-1];
        while(n>0 && s[n-1]==c){
            s.pop_back();
            n--;
        }
    }
    cout << ans-1;
}
















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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,max;
    string s;
    cin>>n;
    map<string,ll> m;
    for(ll i=0;i<n;++i)
    {
        cin>>s;
        m[s]++;
    }
    max=-1;
    for(auto itr=m.begin();itr!=m.end();++itr)
    {
        if(itr->second>max)max=itr->second;
    }
    for(auto itr=m.begin();itr!=m.end();++itr)
    {
        if(itr->second==max)cout<<itr->first<<"\n";
    }
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n * a, b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int d[3];
    cin >> d[0] >> d[1] >> d[2];
    sort(d, d+3);
    out(d[0]+d[1]);
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf")]*n
dp[0] = 0
for i in range(n):
  for j in range(1,k+1):
    if i+j < n:
      dp[i+j] = min(dp[i]+abs(h[i+j]-h[i]),dp[i+j])
print(dp[-1])

Measured memory_bytes: 55600
local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]={}
    for j=1,n do
        a[i][j]=io.read("n")
    end
end

local mod=1000000007
local function mulmatrix(a,b)
    local A=#a
    local B=#b
    local C=#b[1]
    local c={}
    for i=1,A do
        c[i]={}
        for j=1,C do
            c[i][j]=0
        end
    end
    for i=1,A do
        for k=1,B do
            for j=1,C do
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod
            end
        end
    end
    return c
end

local function powmatrix(a,k)
    local A=#a
    local b={}
    for i=1,A do
        b[i]={}
        for j=1,A do
            b[i][j]=i==j and 1 or 0
        end
    end
    while k>0 do
        if k&1>0 then
            b=mulmatrix(b,a)
        end
        a=mulmatrix(a,a)
        k=k>>1
    end
    return b
end

local A=powmatrix(a,k)
local total=0
for i=1,n do
    for j=1,n do
        total=(total+A[i][j])%mod
    end
end
print(total)

Measured memory_bytes: 3912
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


ll gcd(ll a, ll b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}

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

	string s;
	cin >> s;

	map<char, vector<int>> pos;
	rep(i, s.size())
	{
		pos[s[i]].push_back(i);
	}
	
	ll count = 0;

	rep(i, N)
	{
		repl(j, i + 1, N)
		{
			if (s[i] == s[j]) continue;

			int k = 2 * j - i;

			char c;

			if (
				s[i] == 'R' && s[j] == 'G'
				||
				s[j] == 'R' && s[i] == 'G'
				)
			{
				c = 'B';
			}else if (
				s[i] == 'G' && s[j] == 'B'
				||
				s[j] == 'G' && s[i] == 'B'
				)
			{
				c = 'R';
			}
			else if (
				s[i] == 'B' && s[j] == 'R'
				||
				s[j] == 'B' && s[i] == 'R'
				)
			{
				c = 'G';
			}

			auto& v = pos[c];

			auto lb = lower_bound(all(v), k);
			auto ub1 = upper_bound(all(v), j);
			auto ub2 = upper_bound(all(v), k);

			count += distance(ub1, lb);
			count += v.size() - distance(v.begin(), ub2);
		}
	}

	cout << count << endl;

    return 0;
}

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

using ll = long long;
using P = pair<int, int>;
#define reps(i,n) for (int i=1; i<=n; i++)
#define zarray(x,n) x[n+1]; reps(i,n) {x[i]=0;} 
#define zarray2(x,n,m) x[n+1][m+1]; reps(i,n) { reps(j,m) {x[i][j]=0;}}

int main() {
    int n;
    cin >> n;
    map<int,pair<ll,ll>> l;
    reps(i,n) {
        int height;
        cin >> height;
        l[i+height].first++;
        l[i-height].second++; 
    }

    ll ans=0;
    for (auto p : l) {
        ans += p.second.first * p.second.second;
    }
    cout << ans << endl;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

class graph {
public:
	class neighbor {
	public:
		ll e;
		ll d;
		neighbor(ll e0, ll d0) : e(e0), d(d0) {}
	};

	vector<vector<neighbor>> g;
	graph(ll n) {
		g = vector<vector<neighbor>>(n);
	}

	void add(ll edge1, ll edge2, ll distance) {
		g[edge1].push_back(neighbor(edge2, distance));
		g[edge2].push_back(neighbor(edge1, distance));
	}
};

graph tree(0);
bool ret[100000];

void f(ll current, ll prev, ll distance) {
	cerr << current + 1 << ", " << prev + 1 << ", " << distance << endl;
	ret[current] = (distance % 2 == 0) ? ret[prev] : !ret[prev];
	for(auto x : tree.g[current]) {
		if(x.e == prev) continue;
		f(x.e, current, x.d);
	}
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	tree = graph(n);

	rep(i, n-1) {
		ll u, v, w;
		cin >> u >> v >> w;
		debug(w);
		tree.add(u-1, v-1, w);
		debug(i);
/*
		if(u == 0) {
			if(v == 0) {
				if(w % 2 == 0) {
					ret[u] = v;
					ret[v] = u;
				} else {
					ret[u] = -v;
					ret[v] = -u;
				}
			} else {
				if(w % 2 == 0) {
					ret[u] = v;
				} else {
					ret[u] = -v;
				}
			}
		} else {
			if(v == 0) {
				if(w % 2 == 0) {
					ret[v] = u;
				} else {
					ret[v] = -u;
				}
			} else {
				if(w % 2 == 0) {
					ret[v]
				}
			}
		}
*/
	}

	ret[0] = false;

	for(auto x : tree.g[0]) {
		f(x.e, 0, x.d);
	}

	debug(n);

	rep(i, n) {
		debug(ret[i]);
		cout << ret[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 9344
import math
 
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
 
input()
d = 0
u = set()
for x in map(int, input().split()):
  d = math.gcd(d, x)
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print((r, 'not')[d > 1], 'coprime')


Measured memory_bytes: 179416
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x=INTM()
    l=LIST()
    ct=1
    temp=0
    for i in range(n):
        temp+=l[i]
        if temp<=x:
            ct+=1
        else:
            break
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <stdio.h>
typedef struct{
    double x,y;
}point;
int main(){
    int n,t=0;
    point p[50];
    while(1){
        scanf("%d",&n);
        double s=0;
        if(n==0) return 0;
        t++;
        for(int i=0;i<n;i++) scanf("%lf %lf",&p[i].x,&p[i].y);
        for(int i=1;i<n-1;i++){
            s+=(p[0].x*(p[i].y-p[i+1].y)+p[i].x*(p[i+1].y-p[0].y)+p[i+1].x*(p[0].y-p[i].y))/2;
        }
        printf("%d %.1f\n",t,-s);
    }
}

Measured memory_bytes: 1084
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    string s;
    int dp[1000005][2];
    
    cin >> s;

    reverse(s.begin(), s.end());

    rep(i, s.size() + 1) {
        rep(j, 2) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0, dp[0][1] = -1;

    rep(i, s.size()) {
        if (dp[i][0] != -1) {
            chmin(dp[i + 1][0], dp[i][0] + (int)(s[i] - '0'));
            chmin(dp[i + 1][1], dp[i][0] + ((int)10 - (int)(s[i] - '0')) + 1);
        }
        if (dp[i][1] != -1) {
            chmin(dp[i + 1][0], dp[i][1] + (int)(s[i] - '0'));
            chmin(dp[i + 1][1], dp[i][1] + ((int)10 - (int)(s[i] - '0')) - 1);
        }
    }

    /*rep(i, s.size() + 1) {
        rep(j, 2) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << min(dp[s.size()][0], dp[s.size()][1]) << endl;

    return 0;
}


Measured memory_bytes: 17052
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	/*
	int n = 0;
	cin >> n;
	int* a = new int[n];
	
	for (int i = 0; i < n; i++) {
	}*/
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(N)]
cd = [list(map(int, input().split())) for x in range(M)]

for x in range(N):
    d1 = 999999999999999999
    for y in range(M):
        d = abs(ab[x][0] - cd[y][0]) + \
            abs(ab[x][1] - cd[y][1])
        if d < d1:
            d1 = d
            ans = y + 1
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int main()
{
    ll i,j,n,x,m;
    cin>>n>>x>>m;
    ll ans = x;
    ll cnt = -1;
    unordered_map<ll,ll> mp;
    mp[x] = 0;
    vector<ll> v;
    v.push_back(x);
    ll cur;
    for(i=1;i<n;i++)
    {
        cur = (v.back()*v.back())%m;
        if(mp.find(cur)!=mp.end()) 
        {
            if(cur==0)
            {
                cout<<ans<<"\n";
                return 0;
            }
            cnt = i;
            break;
        }
        ans+=cur;
        v.push_back(cur);
        mp[cur] = i;
    }
    if(cnt==-1) cout<<ans;
    else
    {
        for(i=mp[cur]+1;i<v.size();i++)
        {
            v[i]+=v[i-1];
        }
        ll sz = cnt - mp[cur];
        ll q = (n-cnt)/sz;
        ll r = (n-cnt)%sz;
        ll res = ans;
        ans = res + (q*v.back());
        if(r!=0) ans+=v[mp[cur]+r-1];
        cout<<ans;
    }
}

Measured memory_bytes: 5556
# 回答見て

S_list = list(input())
n = len(S_list) - 1
answers = []
total_sum = 0
for i in range(2 ** n):
    # 足し算の位置を決める '1+25'に直す
    ans_str = S_list[0]
    for j in range(n):
        if ((i >> j) & 1):
            ans_str += '+'
            ans_str += S_list[j+1]
        else:
            ans_str += S_list[j+1]
    
    # '1+25'を＋で分割➡足す
    ans_list = ans_str.split('+')
    ans = 0
    for num in ans_list:
        ans += int(num)
    total_sum += ans
print(total_sum)

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

int main()
{
	int n = 0, q = 0, k = 0, max = 0, min = 0;
	long t = 0;

	cin >> n;
	vector<long> S(n);

	for (int i = 0; i < n; i++)
		cin >> S[i];		

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> t;
		max = n - 1;
		min = 0;
		
		while (max >= min) {
			if (t > S[(min + max) / 2])
				min = (min + max) / 2 + 1;
			else if (t < S[(min + max) / 2])
				max = (min + max) / 2 - 1;
			else {
				k++;
				break;
			}
		}
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 3472
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  string ans="Yay!";
  if(e-a>k) ans=":(";
cout<<ans<<endl;
}


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

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int A,B,C;
  cin >> A >> B >> C;
  cout << max(0,C-A+B);
    


}

/*



 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).*begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int INF = 150000000;
const long long M = 1000000007;


typedef string::const_iterator State;
int number(int&);
int term(int&);
int expression(int&);

string s;

// ??°??????????????????????????????????????°????????????
int number(int &i) {
    int ret = 0;

    while (isdigit(s[i])) {
        ret *= 10;
        ret += s[i] - '0';
        i++;
    }

    return ret;
}


// ?????????????????????????????????????????????????????????????????????
int term(int &i) {
    if (s[i] == 'S') {
        i+=2;
        long long ret = expression(i);
        i++;
        return ret * ret % M;
    } else {
        return number(i);
    }
    return INF;
}

// ?????????????????????????????????????????????????????????????????????
int expression(int &i) {
    int ret = term(i);

    while(i < s.size() - 2){
        if (s[i] ==  '>' && s[i + 1] == '>' && s[i + 2] != '>'){
            i+=2;
            ret = ret >> min(term(i), 31);
        } else {
            return ret;
        }
    }

    return ret;
}

inline void deleteSpace(string &a){
    size_t pos;
    while((pos = a.find_first_of(" ")) != string::npos){
        a.erase(pos, 1);
    }
}

int main(){
    std::ifstream ifs("/Users/noy/Downloads/2570_in1.txt.html");
    while(getline(cin,s),s != "#"){
        //deleteSpace(s);
        string tmp;
        for(auto it:s){
            if(it != ' ') tmp+=it;
        }
        s = tmp;
        int i = 0;
        cout << expression(i) << endl;
    }
}

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

int main()
{
        int n,x,ans=100;
        cin>>n;
        while(n--)
        {
            cin>>x;
            int i;
            for(i=0;i<32;i++)
            {
                if(x&1<<i)
                {
                    break;
                }
            }
            ans=min(i,ans);
        }
        cout<<ans;

}



Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
ll two[70],a,b,ans,x,y,u,v;
int i,j,k,l,t,n,m,d;
int main(){
    scanf("%lld%lld",&a,&b);
    swap(a,b);
    two[0]=1;
    fo(i,1,62)two[i]=(ll)two[i-1]<<1;
    fd(i,62,0){
        if((a&two[i])!=(b&two[i]))break;
        if((a&two[i])>0){
            a^=two[i];
            b^=two[i];
        }
    }
    if(a==b){
        printf("1\n");
        return 0;
    }
    d=i;
    fd(k,i-1,-1)
        if(k==-1||(a&two[k])>0)break;
    x=b;y=two[d]+two[k+1]-1;
    u=two[d]+b;v=two[d+1]-1;
    ans=y-x+1;
    if(u>y)ans+=v-u+1;
    else if(u<=y&&v>y)ans+=v-y;
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    // a[i]/sum < 1/4m
    // a[i] * 4m < sum
    int c = 0;
    rep(i, n) {
        if (a[i] * 4 * m >= sum) {
            c ++;
        }
    }
    yorn (c >= m) 
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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

  ll n,k;
  cin >> n >> k;
  VLL a(4*n);
  rep(i,n){
    cin >> a[i];
    a[i+n] = a[i];
    a[i+2*n] = a[i];
    a[i+3*n] = a[i];
  }

  if(n == 1){
    if(k % 2 == 1) cout << a.back() << endl;
    return 0;
  }

  VLL last((ll)(2e5)+100);
  VLL r(2*n);

  // 遷移先が記載された配列を埋める
  for(ll i = n*4-1; i >= 0; i--){
    if(i < 2*n){
      r[i] = last.at(a[i]);
    }
    last[a[i]] = (i+1) % (2*n);
  }

  VVLL go(60,VLL(2*n));
  VVLL add(60,VLL(2*n));

  rep(i,2*n){
    go[0][i] = r[i];
    if(r[i] < i) add[0][i] = abs(i - 2*n - r[i]);
    else add[0][i] = abs(r[i] - i);
  }

  for(int log = 1; log < 60; log++){
    rep(i,2*n){
      ll i2 = go[log-1][i];
      go[log][i] = go[log-1][i2];
      add[log][i] = min<ll>(2e17+10,add[log-1][i] + add[log - 1][i2]);
    }
  }
  
  ll cur = 0;
  ll pref = 0;

  for(int log = 60 - 1; log >= 0; log--){
    if(cur + add[log][pref] <= n * k){
      cur += add[log][pref];
      pref = go[log][pref];
    }
  }

  if(cur == n*k) return 0;

  while(cur<=n*k){
    // cout << n*k << endl;
    while( (cur + add[0][pref]) <= n*k){
      // cout << "pref: " << pref << ", cur:" << cur << "," << n*k << endl;
      cur += add[0][pref];
      pref = go[0][pref];
    }
    // cout << "cur: " << cur << endl;
    if(cur==n*k) break;
    cout << a[pref] << " ";
    cur++;
    (pref += 1) %= (2*n);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 391672
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	while(true){

		int n,c;
		cin >> n;
		if(n==0) break;

        vector<int>T(2*n); vector<int>H(2*n);
        rep(i,2*n){ T[i]=0; H[i]=i+1;}

		rep(i,n){
		cin >> c;
        T[c-1]=c;
        H[c-1]=0;
		}

		int card=0;
		int t=n;
		int h=n;

		for(;;){

		bool f=false;
		rep(i,2*n){

			if(T[i]>card){

			card=T[i];
			T[i]=0;
			t--;
			f=true;
			break;
			}
		}
			if(!f) card=0;
			if(t==0) break;


		bool g=false;
		rep(i,2*n){

		if(H[i]>card){

			card=H[i];
			H[i]=0;
			h--;
			g=true;
			break;
			}
		}
			if(!g) card=0;
			if(h==0) break;

		}

        cout << h << endl;
        cout << t << endl;

	}

        return 0;
}

Measured memory_bytes: 1196
import math


def distance(x, y):
    return math.sqrt(x**2 + y**2)


def solve():
    N, D = map(int, input().split())
    points = [list(map(int, input().split())) for _ in range(N)]

    count = 0
    for p in points:
        if distance(p[0], p[1]) <= D:
            count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 45260
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using P = pair<int, int>;

int main() {
	int N;
	cin >> N;
	int T, A;
	cin >> T >> A;
	vector<double> H(N);
	for (int i = 0; i < N; ++i) { cin >> H[i]; }

	int res = 0;
	double t = 1e8;
	for (int i = 0; i < N; ++i) {
		double x = T - H[i] * 0.006;

		if (t > abs((double)A - x)) { 
			res = i + 1;
			t = abs((double)A - x);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define endl '\n'
#define int ll
#define gcd __gcd

void solve(){
    double n , d;
    cin >> n >> d;
    double x , y;
    int ans = 0;
    while(n--){
        cin >> x >> y;
        double temp = (double)(x*x + y*y);
        temp = pow(temp , 0.5);
        // cerr << temp << endl;
        if (temp <= d) ans++;
    }
    cout << ans <<endl;
}


int32_t main(){

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

    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 

    int t = 1;
    // cin >> t;
    while(t--){
        solve();
        // cout << "Case #" << (tt+1) <<":" << endl;
    }
}

Measured memory_bytes: 4492