akhauriyash/Code-Regression huggingface dataset:
a,b,c,d = input()
answer = 'No'

if a ==b:
  if c ==d and a!=c:
    answer = 'Yes'
    
if b ==c:
  if d ==a and b!=d:
    answer = 'Yes'
    
if a == c:
  if b ==d and a!=b:
    answer = 'Yes'

print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans = 0;
ll n, m;
ll a[1005];
ll target[1005];
ll dp[1005][1005];
ll delta[1005];

ll chmin(ll &a, ll b) {
    a = min(a, b);
}
int main() {
    int times = 0;
    while(true) {
        cin >> n >> m;
        if(n == 0) break;
        times++;
        //cerr << times << endl;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            a[i] %= m;
        }
        for(int i = 1; i <= n; i++) {
            cin >> target[i];
            target[i] %= m;
            if(target[i] < a[i]) target[i] += m;
            delta[i] = target[i] - a[i];
        }
        for(int timer = 0; timer <= n; timer++) {
            dp[1][timer] = delta[1] + timer * m;
        }
        for(int index = 2; index <= n; index++) {
            for(int after = 0; after <= n; after++) {
                dp[index][after] = 1e18;
                for(int before = max(0, after - 2); before <= min((int)n, after + 2); before++) {
                    ll beforedelta = delta[index-1] + m * before;
                    ll afterdelta = delta[index] + m * after;
                   // cerr << index << " " << before << " " << after << " " << dp[index-1][before] << endl;
                    chmin(dp[index][after], dp[index-1][before] + max((ll)0, afterdelta - beforedelta));
                }
            }
        }
        ll ans = 1e18;
        for(int timer = 0; timer <= n; timer++) {
            chmin(ans, dp[n][timer]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 10968
#include <stdio.h>
#include <stdbool.h>

int main(void) {
  char S[5];
  scanf("%s", S);

  static char s[26];
  for(int i = 0; i < 4; i++) {
    s[S[i] - 'A']++;
  }
  bool flag = true;
  int num = 0;
  for(int i = 0; i < 26; i++) {
    if(s[i] != 0) {
      num++;
      if(s[i] != 2) {
	flag = false;
	break;
      }
    }
  }
  if(num != 2)
    flag = false;
  if(flag)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

const int maxn=105;

int a[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	int uk=0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		uk+=a[i];
	}
	sort(a, a+n);
	if((double)uk*(double)1/((double)4*m)>a[n-m]){
		cout << "No\n";
	}
	else{
		cout << "Yes\n";
	}
	return 0;
}

Measured memory_bytes: 888
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		BitSet[] S = new BitSet[M];
		for (int i = 0; i < M; i++) {
			int K = Integer.parseInt(sc.get());
			BitSet bs = S[i] = new BitSet();
			for (int j = 0; j < K; j++) {
				bs.set(Integer.parseInt(sc.get()) - 1);
			}
		}
		int[] P = new int[M];
		Arrays.setAll(P, $ -> Integer.parseInt(sc.get()));

		int count = 0;
		for (int i = 0; i < 1 << N; i++) {
			BitSet on = BitSet.valueOf(new long[]{i});
			int valve = 0;
			for (int j = 0; j < S.length; j++) {
				BitSet result = new BitSet();
				result.or(S[j]);
				result.and(on);
				if ((result.cardinality() % 2) == P[j]) valve += 1;
			}
			if (valve == M) count += 1;
		}
		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 28372
n=int(input())
a=list(map(int,input().split()))
co=[0]*(10**5)
s=sum(a)
for i in a:
  co[i-1]+=1
for i in range(int(input())):
  b,c=map(int,input().split())
  s=s+(c-b)*co[b-1]
  print(s)
  co[c-1]+=co[b-1]
  co[b-1]=0

Measured memory_bytes: 20880
H, W = map(int, input().split())
li = [["." for i in range(W+2)]]

for i in range(H):
    emp = ["."]
    S = input()
    for j in range(W):
        emp.append(S[j])
    emp.append(".")
    li.append(emp)

li1 = ["." for i in range(W+2)]
li.append(li1)

for i in range(1,H+1):
    stra = ""
    for j in range(1,W+1):
        ans = 0
        if li[i][j] == "#":
            stra += "#"
        else:
            if li[i-1][j-1] == "#":
                ans += 1
            if li[i-1][j] == "#":
                ans += 1
            if li[i-1][j+1] == "#":
                ans += 1
            if li[i][j-1] == "#":
                ans += 1
            if li[i][j+1] == "#":
                ans += 1
            if li[i+1][j-1] == "#":
                ans += 1
            if li[i+1][j] == "#":
                ans += 1
            if li[i+1][j+1] == "#":
                ans += 1
            stra += str(ans)
    print(stra)

Measured memory_bytes: 3064
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    int buf = 1;
    int ans = 0;

    while(buf <= n){
      buf *= k;
      ans += 1;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

	for (int n = 1; n <= N; n++) {
		int ans = 0;
		for (int x = 1; ; x++) {

			int x2 = pow(x, 2);
			if (x2 > n) break;

			for (int y = 1; pow(y, 2) <= n; y++) {

				int y2 = pow(y, 2);
				if (x2 + y2 + x * y > n) break;

				for (int z = 1; pow(z, 2) <= n; z++) {

					int z2 = pow(z, 2);
					int f = x2 + y2 + z2 + x * y + y * z + z * x;

					if (f == n) ans++;
					else if (f > n) break;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a,b,c,i,j,n;
	cin>>n;
	string ss,sk;
	cin>>ss>>sk;
	char ar[2*n];
	for(i=0;i<n;i++)
	{
		ar[2*i]=ss[i];
		ar[2*i+1]=sk[i];
	}
	for(i=0;i<2*n;i++)
	{cout<<ar[i];
	}
	

}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

namespace Wandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var f = Console.ReadLine().Split(' ');
            var a = double.Parse(f[0]);
            var b = double.Parse(f[1]);
            var c = double.Parse(f[2]);
            var h = b * Math.Sin(c / 180 * Math.PI);
            Console.WriteLine("{0}\n{1}\n{2}", a * h * 0.5, a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(c / 180 * Math.PI)), h);
        }
    }
}



Measured memory_bytes: 9192
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [a, b, c, d] = b - a - cc - dc + cdc
    where
        cc = count c $ minv c
        dc = count d $ minv d
        cdc = count (lcm c d) . minv $ lcm c d

        minv x 
            | m > 0 = (r + 1) * x
            | otherwise = a
            where
                (r, m) = a `divMod` x

        count v m = (b - m) `div` v

            

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
/*


*/
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <functional>
#define MAXIN 300000
#define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++)
typedef long long LL;
const int N=1e5+5;

int A[N];
char IN[MAXIN],*SS=IN,*TT=IN;

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-48,c=gc());
	return now;
}

int main()
{
	const int n=read();
	for(int i=1; i<=n; ++i) A[i]=read();
	std::sort(A+1,A+1+n,std::greater<int>());
	for(int i=1; i<=n; ++i)
		if(i+1>A[i+1])
		{
			int ans=0;
			for(int j=i+1; A[j]==i; ++j) ans^=1;
			ans|=A[i]-i&1;
			puts(ans?"First":"Second");
			return 0;
		}

	return 0;
}

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

using namespace std;

int main() {

	long h,w;
	cin >> h >> w;

	vector<vector<long long>> hw(h + 1,vector<long long>(w + 1,0));

	string s;
	for (long i = 1; i <= h; i++) {
		cin >> s;
		for (long j = 1; j <= w; j++) {
			if (s[j - 1] == '.') {
				hw[i][j] = 1;
			}
			else {
				hw[i][j] = 0;
			}
		}
	}

	hw[0][0] = 1;
	hw[0][1] = 1;
	for (long i = 1; i <= h; i++) {
		for (long j = 1; j <= w; j++) {
			hw[i][j] = ((hw[i - 1][j] + hw[i][j - 1])*hw[i][j])%1000000007;
		}
	}

	cout << hw[h][w] << endl;

	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
int main(){
    int temp,t,tot=0,ave=0,now=0;
    while(scanf("%d,%d",&temp,&t)!=EOF){
        if(temp==0)break;
        tot+=temp*t;
        ave+=t;
        now++;
    }
    printf("%d\n%d\n",tot,(int)((double)ave/now+0.5));
}

Measured memory_bytes: 2564
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j] == b[k]:
        a[i][j] = 0
ans = 'No'
for i in range(3):
  if a[i][0]+a[i][1]+a[i][2] == 0:
    ans = 'Yes'
  if a[0][i]+a[1][i]+a[2][i] == 0:
    ans = 'Yes'
if a[0][0]+a[1][1]+a[2][2] == 0 or a[2][0]+a[1][1]+a[0][2] == 0:
  ans = 'Yes'
print(ans)


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

ll ind[100000+100] = {};


int main (){
    ll n;
    cin >> n;
    ll a[n + 100];

    ll sum = 0;

    rep(i, n){
        cin >> a[i];
        ind[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    ll b, c;

    rep(i,q){
        cin >> b >> c;
        sum -= (ind[b] * b);
        ind[c] += ind[b];
        sum += (ind[b] * c);
        ind[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y,z;
    cin>>a>>b>>c;
    x=a+b;
    y=a+c;
    z=b+c;
    cout<<min(min(x,y),z)<<endl;
    return 0;
}


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

int main(){

  int N;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++){
    cin >> A[i];
    printf("%d",A[i]);
    if(i == N-1) printf("\n");
    else printf(" ");
  }

  for( int i = 1; i < N; i++){
    int v = A[i];
    int j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
    
    for( int k = 0; k < N; k++){
      printf("%d",A[k]);
      if(k == N-1) printf("\n");
      else printf(" ");
    } 

  }
  return 0;

}


Measured memory_bytes: 3224
N = int(input())
#真偽判定用の変数
approved = True
An = input().split(" ")

for i in range(N):
	A = int(An[i])
	if A % 2 == 0:
		if A % 3 != 0 and A % 5 != 0:
			approved = False
			
if approved:
	print("APPROVED")
else:
	print("DENIED")
	

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

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

    ll n,w;
    cin>>n>>w;

    ll wt[n], v[n];

    for(int i=0; i<n; i++) {
        cin>>wt[i]>>v[i];
    }

    ll dp[n+1][w+1];

    for(ll i=0; i<n+1; i++) {
        for(ll j=0; j<w+1; j++) {
            if(i==0 || j==0) {
                dp[i][j]=0;
            }
        }
    }

    for(ll i=1; i<n+1; i++) {
        for(ll j=1; j<w+1; j++) {
            if(wt[i-1]<=j)
                dp[i][j]=max(v[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }

    cout<<dp[n][w];
}

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

int main()
{
	int A, B,result=0,i;
	cin >> A >> B;
	for (i = 0; i<2; i++){
		if (A > B){
			result += A;
			A--;
		}
		else{
			result += B;
			B--;
		}
	}
	cout << result << endl;
	return 0;
}


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

#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")

#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;

const int N=100005;
int n,m;bool vi[N];
vector<int>e[N];
int dfs(int u,int fa){
    if(e[u].size()>2)return u;
    for(int v:e[u])if(v!=fa)return dfs(v,u);
    return u;
}

int main(){
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),u++,v++,e[u].pb(v),e[v].pb(u);
    fo(i,1,n)if(e[i].size()==1)vi[dfs(i,0)]=true,m++;
    fo(i,1,n)if(vi[i])m--;if(!m)m++;
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += i;
        if (sum >= n) {
            for (int j = 1; j <= i; ++j) {
                if (j != sum - n)
                    cout << j << '\n';
            }
            break;
        }
    }
}


Measured memory_bytes: 384
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,l,r,cnt=0
    character(:),allocatable:: c

    read*, n
    allocate(character(n):: c)
    read*, c(:)
    l=1; r=n
    do while (l < r)
        do while(c(l:l) == "R")
            l=l+1
            if (l > n) exit
        end do

        do while(c(r:r) == "W")
            r=r-1
            if (r < 1) exit
        end do

        if (l < r) then
            cnt=cnt+1
            l=l+1; r=r-1
        end if
    end do
    print'(i0)', cnt
end program main

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

namespace Abc086C
{
    class Program
    {
        static int N;
        static int[] t, x, y;

        internal static string SolveProblem(System.IO.TextReader reader) {
            N = int.Parse(Console.ReadLine());
            t = new int[N + 1];
            x = new int[N + 1];
            y = new int[N + 1];
            var isAvailable = true;

            for(var i = 1; i <= N; ++i) {
                var txy = Console.ReadLine().Split();
                t[i] = int.Parse(txy[0]);
                x[i] = int.Parse(txy[1]);
                y[i] = int.Parse(txy[2]);
            }
            for(var i = 1; i <= N; ++i) {
                var distance = Math.Abs((x[i] - x[i - 1]) + (y[i] - y[i - 1]));
                var time = t[i] - t[i - 1];
                if(time < distance  || (time - distance) % 2 == 1) {
                    isAvailable = false;
                    break;
                }
            }
            return isAvailable ? "Yes" : "No";
        }

        static void Main(string[] args) {
            Console.WriteLine(SolveProblem(Console.In));
        }
    }
}


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

int main() {
  ll N, M, Q; cin >> N >> M >> Q;
  ll a[N][N];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      a[i][j] = 0;
    }
  }
  for (ll i = 0; i < M; i++) {
    ll l, r; cin >> l >> r; l--; r--;
    a[l][r]++;
  }
  ll sumx[N][N+1];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N+1; j++) {
      sumx[i][j] = 0;
    }
  }
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      sumx[i][j+1] = sumx[i][j] + a[i][j];
    }
  }
  ll sum[N+1][N+1];
  for (ll i = 0; i < N+1; i++) {
    for (ll j = 0; j < N+1; j++) {
      sum[i][j] = 0;
    }
  }
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N+1; j++) {
      sum[i+1][j] = sum[i][j] + sumx[i][j];
    }
  }
  for (ll i = 0; i < Q; i++) {
    ll p, q; cin >> p >> q;
    cout << sum[q][q]-sum[p-1][q]-sum[q][p-1]+sum[p-1][p-1] << endl;
  }
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    int ans = 0;
    for (int i = N - 1; i >= N - K; i--){
        ans += vec[i];
    }
    cout << ans << endl;
}


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

int main() {
 long long int x[200000],y[200000],n,m,s=0;
 cin>>n;
 for (int i=0;i<n;i++)
 cin>>x[i];
 cin>>m;
 for(int i=0;i<m;i++)
 cin>>y[i];
 if (n<m)
 {cout<<"NO";
 return 0;}
 sort (x,x+n);
 sort (y,y+m);
 for (int i=0;i<n;i++)
 if((y[s]==x[i])&& s<m )
 s++;
 else if (s==m)
 {cout<<"YES";
 return 0;}
 
 else if (x[i]>y[s])
 {cout<<"NO";
 return 0;
 }
 
 
if (s==m)
 {cout<<"YES";
 return 0;}
 else 
 cout<<"NO";

return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOROFF(var, offset, max) for (ui (var) = (offset); (var) < ((max) + (offset)); ++(var))

using namespace std;

using ui = unsigned int;
using uc = unsigned char;

const static ui NMAX = 100000;
const static ui KMAX = 100000;

static ui N;
static ui K;

static uc Si[NMAX + 2];

ui count_happiness(void) {
  ui res = 0;
  FOROFF(i, 1, N) {
    if (Si[i] == 0) {
      res += (Si[i - 1] == Si[i]) ? 1 : 0;
    } else if (Si[i] == 1) {
      res += (Si[i + 1] == Si[i]) ? 1 : 0;
    }
  }
  return res;
}

void print_people(void) {
  FOROFF(i, 1, N) {
    cout << (Si[i] ? 'R' : 'L');
  }
  cout << endl;
}

ui solve(void) {
  ui res = count_happiness();
  res += K * 2;
  if (N - 1 < res) {
    return N - 1;
  }
  return res;
}

int main(int ac, char **av) {
  cin >> N >> K;
  Si[0] = 1;
  Si[N + 1] = 0;
  FOROFF(i, 1, N) {
    char c;
    cin >> c;
    if (c == 'L') {
      Si[i] = 0;
    } else if (c == 'R') {
      Si[i] = 1;
    }
  }
  cout << solve() << endl;
  return 0;
}


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

int n, q;
int cnt[101];

int main() {
	while (cin >> n >> q) {
		if (!n) break;
		int i, j;
		for (i = 0; i < 101; i++) cnt[i] = 0;
		for (i = 0; i < n; i++) {
			int m;
			cin >> m;
			for (j = 0; j < m; j++) {
				int day;
				cin >> day;
				cnt[day]++;
			}
		}
		
		int maxCnt = -1;
		int ans = -1;
		for (i = 0; i < 101; i++) {
			if (maxCnt < cnt[i]) {
				maxCnt = cnt[i];
				ans = i;
			}
		}
		if (maxCnt >= q) {
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
using namespace std;
int num[105];
int main()
{
	int k,t;
	cin >> k >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> num[i];
	}
	if (t != 1)
	{
		sort(num, num + t);
		int i = 0;
		while (1)
		{
			if (num[i] != 0 )
			{
				do {

					num[i]--;
					num[t - 1]--;
					k -= 2;
					sort(num, num + t);
				} while (num[i] > 0);

			}
		    if (i == t - 2) break;
			i++;
		}

	}
	if (k > 1)
		cout << k - 1 << endl;
	else
		cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> cnt(N);
    rep(i,N-1+M){
        int a,b;
        cin >> a >> b;
        --a,--b;
        G[a].push_back(b);
        ++cnt[b];
    }
    int root;
    rep(i,N) if (cnt[i]==0) root=i;
    vector<int> par(N,-1);
    queue<int> que;
    que.push(root);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for (auto nv:G[v]){
            --cnt[nv];
            if (cnt[nv]>0) continue;
            que.push(nv);
            par[nv]=v;
        }
    }
    rep(i,N) cout << par[i]+1 << endl;
}


Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

ll mod(ll n, ll r) {
	ll q = n % r;
	return (q < 0) ? q + r : q;
}

int dSum(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	ll sum = 0;
	FOR(i, 1, n + 1) {
		int t = dSum(i);
		if (a <= t && t <= b) {
			sum += i;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args)  throws IOException { 
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int [][]a=new int [2][n];
		for(int i=0;i<2;i++)
			for(int j=0;j<n;j++)
				a[i][j]=sc.nextInt();
		int ans=0;
		
		for(int right=0;right<n;right++)
		{
			int row=0;
			int c=0;
			for(int i=0;i<n;i++)
			{
				c+=a[row][i];
				if(i==right)
				{	
					row=1;
					c+=a[row][i];
				}	
			}
			ans=Math.max(c, ans);
		}
		System.out.println(ans);
		
		
		pw.flush();pw.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream S)
		{
			br=new BufferedReader(new InputStreamReader(S));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next()  throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(nextLine());
			return st.nextToken();
		}
		public int nextInt()  throws IOException
		{
			return Integer.parseInt(next());
		}
		public double nextDouble()  throws IOException
		{
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
		return positive ? x : -x;
}
int n,m;
const int N=400005;
int s1[N],s2[N],f[N];
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++){
		s1[i]=read();s2[i]=read();
		if(s1[i]==1)f[s2[i]]=1;
	}
	for(int i=1;i<=m;i++)if(s2[i]==n&&f[s1[i]]){
		puts("POSSIBLE"); return 0;
	}
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 3584
#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>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s[s.size()-1] != 's') s += 's';
    else s += "es";
    cout << s << endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    int H,W; char a;a='#';
    for(int i=0;i<300;i++){
        cin>>H>>W;
        if(W==0&&H==0){
            break;
        }
        for(int i=0;i<H; i++){
            
        
        for(int i=0;i<W; i++){
            cout<<a;
        }
        cout<<endl;
        }
        cout<<endl;
    }
    
}


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

int main() {
    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;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int r;
   cin >> r;
   if (r < 1200)
      cout << "ABC" << '\n';
   else if (r < 2800)
      cout << "ARC" << '\n';
   else
      cout << "AGC" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	if (c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500 >= 1000) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

bool solve (int mat[4][4], int *b, int n){
	vector<int> col(4, 0), lin(4, 0);
	int d1 = 0, d2 = 0;

	for (int i=0; i<n; i++){
		for (int j=0; j<3; j++){
			for (int k=0; k<3;  k++){
				if (mat[j][k] == b[i]){
					lin[j]++;
					col[k]++;
					if (j == k) d1++;
					if (j + k == 2) d2++;
				}
			}
		}
	}
	if (d1 == 3 || d2 == 3) return 1;

	for (int i=0; i<3; i++){
		if (lin[i] == 3 || col[i] == 3) return 1;
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	int mat[4][4], n, b[20];
	for (int i=0;i<3;i++){
		for (int j=0; j<3; j++){
			cin >> mat[i][j];
		}
	}
	cin >> n;

	for (int i=0; i<n; i++){
		cin >> b[i];
	}

	if (solve(mat, b, n)) cout << "Yes" << endl;
	else cout << "No" << endl;
}	



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

using namespace std;

int main(){
    vector<int> n(3);
    for(int i = 0; i < 3; i++){
        cin >> n[i];
    }
    sort(n.begin(), n.end());
    cout << n[0] + n[1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
static const double eps = 1e-7;

void solve()
{
	int m;
	while(cin >> m, m)
	{
		double s1 = 0.0;
		int radius = 360;
		for(int i = 0; i < m - 1; ++i)
		{
			int v;
			cin >> v;
			radius -= v;
			s1 += sin(M_PI * v / 180);
		}
		s1 += sin(M_PI * radius / 180);
		
		int n;
		cin >> n;
		double s2 = 0.0;
		radius = 360;
		for(int i = 0; i < n - 1; ++i)
		{
			int v;
			cin >> v;
			radius -= v;
			s2 += sin(M_PI * v / 180);
		}
		s2 += sin(M_PI * radius / 180);
		if(fabs(s1 - s2) < eps)
		{
			cout << 0 << endl;
		}
		else if(s1 > s2)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}
}

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

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N = 501;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int n,m;
int p[N][N],dis[N][N];
pii pos[N*N];
int xi[4] = {-1,0,1,0},yi[4] = {0,1,0,-1};

queue<pii> q1;

inline void update(int x,int y){
   fr(i,0,3){
      int nx = x+xi[i],ny = y+yi[i];
      if(nx == 0 || nx == n+1 || ny == 0 || ny == n+1)continue ;
      if(dis[x][y]+(p[x][y] > 0) < dis[nx][ny]){
         dis[nx][ny] = dis[x][y]+(p[x][y] > 0);
         update(nx,ny);
      }
   }
   return ;
}

int main(){
   scanf("%d",&n);
   fr(i,1,n*n){
      int x;
      scanf("%d",&x);
      pos[i] = pii((x-1)/n+1,(x-1)%n+1);
   }

   fr(i,1,n)
      fr(j,1,n)p[i][j] = 1;
   fr(i,1,n)
      fr(j,1,n)dis[i][j] = min(min(i-1,j-1),min(n-i,n-j));

   int sum = 0;
   fr(i,1,n*n){
      sum += dis[pos[i].first][pos[i].second];
      p[pos[i].first][pos[i].second] = 0;
      update(pos[i].first,pos[i].second);
   }
   printf("%d\n",sum);
   return 0;
}


Measured memory_bytes: 22752
n,m = map(int,input().split())
a = []
b = []
c = []
d = []
ansmin = 10**10
for i in range(n):
    tempa,tempb = map(int,input().split())
    a.append(tempa)
    b.append(tempb)
for j in range(m):
    tempc,tempd = map(int,input().split())
    c.append(tempc)
    d.append(tempd)

for i in range(n):
    ansindex = 10**10
    ansmin = 10**10
    for j in range(m):
        temp_min = abs(a[i]-c[j])+abs(b[i]-d[j]) 
        if temp_min < ansmin:
            ansindex = j+1
            ansmin = temp_min
    print(ansindex) 

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

using namespace std;

#define endl '\n'

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

const ll N = 3e3 + 5;
const ll INF = 1e10;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n;
double dp[N][N], p[N];
// dp[i][j] - probabylity to get j heads until this index


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j >= 0; j--) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
            if (j)
                dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
        }
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        if(i * 2 >= n) {
            ans += dp[n][i];
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 69120
// AOJ 1322 ASCII Expression
// 2018.3.5 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define M	2011
int  n, W;
char buf[22][85], *p;

int expr(int bs, int tp, int bm);

int powmod(int a, int n)
{
	int ans = 1;
	while (n) {
		if (n & 1) ans = (ans * a) % M;
		a = (a * a) % M;
		n >>= 1;
	}
	return ans;
}

int parse(int c, int tp, int bm)
{
	int bs;
	for ( ; c < W; c++) {
		for (bs = tp; bs < bm; bs++) if (buf[bs][c] != '.') goto done;
	}
done:
	p = buf[bs] + c;
	return expr(bs, tp, bm);
}

int primary(int bs, int tp, int bm)
{
	int x;
	if (*p == '(' && *(p+1) == '.') {
		p += 2, x = expr(bs, tp, bm), p += 2;
	} else x = *p++ & 0xf;
	return x;
}

int powexpr(int bs, int tp, int bm)
{
	int d;
	int x = primary(bs, tp, bm);
	if (tp <= bs-1 && *p > ' ' && isdigit(d=buf[bs-1][p-buf[bs]])) {
		x = powmod(x, d & 0xf), p++;
	}
	return x;
}

int factor(int bs, int tp, int bm)
{
	int x, c, si, bo;
	if (*p != '-') x = powexpr(bs, tp, bm);
	else {
		if (*(p+1) == '.') {
			p += 2;
			x = M - factor(bs, tp, bm);
			if (x >= M) x -= M;
		} else {
			c = p-buf[bs];
			si = parse(c, tp  , bs);
			bo = parse(c, bs+1, bm);
			p = buf[bs]+c;
			while (*p == '-') p++;
			x = (si * powmod(bo, M-2)) % M;
		}
	}
	return x;
}

int term(int bs, int tp, int bm)
{
	int x = factor(bs, tp, bm);
	while (*p == '.' && *(p+1) == '*' && *(p+2) == '.') {
		p += 3;
		x = (x * factor(bs, tp, bm)) % M;
	}
	return x;
}

int expr(int bs, int tp, int bm)
{
	char op;
	int x = term(bs, tp, bm), y;
	while (*p == '.' && (*(p+1) == '+' || *(p+1) == '-') && *(p+2) == '.') {
		op = *(p+1), p += 3;
		y = term(bs, tp, bm);
		if (op == '+') { x += y; if (x >= M) x -= M; }
		else           { x -= y; if (x < 0 ) x += M; }
	}
	return x;
}

int main()
{
	int r;

	while (fgets(p=buf[0], 10, stdin) && *p != '0') {
		n = atoi(buf[0]);
		for (r = 0; r < n; r++) {
			fgets(buf[r], 85, stdin);
			if (!r) { p = buf[0]; while (*p > ' ') p++; W = p-buf[0]; }
		}
		printf("%d\n", parse(0, 0, n));
	}
	return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
int a[maxn],dp[maxn];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
		dp[0]=0;
		dp[1]=0;
		for(int i=2;i<=n;++i)
			dp[i]=inf;
	for(int i=2;i<=n;++i)
		for(int j=1;j<=k;++j)
		if(i-j<1) break;
		else dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
	cout<<dp[n]<<endl;
	return 0;
} 

Measured memory_bytes: 1024
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
buf = 0

for xi, yi in zip(x, y):
    if xi == yi:
        buf += 1
    else:
        if buf > count:
            count = buf
        buf = 0

if buf > count:
    count = buf

if count >= 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long D[51][51][51], TD[51][51][51], Next[51][51][51][51], Mod = 1000000007, Res, F[52], InvF[52];
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r*a%Mod;
		a = a*a%Mod;
		b >>= 1;
	}
	return r;
}
void Go() {
	Res = (Res+D[n][0][0])%Mod;
	int i, j, k;
	for (i = 0; i <= n; i++) {
		for (j = 0; i + j <= n; j++) {
			for (k = 0; i + j + k <= n; k++) {
				if (!D[i][j][k])continue;
				int ii = j + k + i;
				if (ii > n || i==ii)continue;
				for (int jj = 0; jj <= n; jj++)for (int kk = 0; ii + jj + kk <= n; kk++) {
					TD[ii][jj][kk] = (TD[ii][jj][kk] + D[i][j][k] * Next[j][k][jj][kk]) % Mod;
				}
			}
		}
	}
	for (i = 0; i <= n; i++)for (j = 0; i + j <= n; j++)for (k = 0; i + j + k <= n; k++) {
		D[i][j][k] = TD[i][j][k];
		TD[i][j][k] = 0;
	}
}
void Calc(int x, int y){
	int i, j, k;
	if (x + y == 0)return;
	for (i = 0; i <= n; i++)for (j = 0; i+j+x+y <= n; j++) {
		k = x + j - i;
		if (k >= 0 && k <= x + y) {
			Next[x][y][i][j] = InvF[k] * InvF[x + y - k]%Mod;
		}
	}
}
int main() {
	int i, j, k;
	scanf("%d", &n);
	F[0] = InvF[0] = 1;
	for (i = 1; i <= 50; i++) {
		F[i] = F[i - 1] * i%Mod;
		InvF[i] = Pow(F[i], Mod - 2);
	}
	for (i = 0; i < n; i++) {
		D[1][(i + 1) / 2][i / 2] = 1;
	}
	for (i = 0; i <= n; i++)for (j = 0; i + j <= n; j++)Calc(i, j);
	for (i = 0; i <= n; i++) Go();
	printf("%lld\n", Res*F[n]%Mod);
}

Measured memory_bytes: 53248
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	string s;
	cin >> s;
	map<char, int>a;
	for (ll i = 0;i < s.length();i++) {
		a[s[i]]++;
	}
	if ((a['N'] > 0 && a['S'] > 0)) {
		if ((a['W'] == 0 && a['E'] == 0) || (a['W'] > 0 && a['E'] > 0))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if ((a['N'] == 0 && a['S'] == 0) && (a['W'] > 0 && a['E'] > 0))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;

	int ans;
	if (a + b <= 16) {
		
		if (a > 8 || b > 8) {
			cout << ":(";
		}
		else {
			cout << "Yay!";
		}

	}else {
		cout << ":(";
	}

}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
using namespace std;
#include <vector>
typedef long long ll;
//#include <stack>
//#include <queue>
/*
#include <math.h>
long long standerd = long long(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 


const int base = 100005;
bool visited[ base*2 ];
vector<int> bi_graph[base*2];

void dfs(ll cnt[],int ni){
    if(visited[ni]) return;
    visited[ni] = true;
    cnt[ni/base]++;
    for(int to: bi_graph[ni]){
        dfs(cnt,to);
    }
}


int main(){

    int N;    
    cin >> N;

    
    rep(ni,N){
        int x,y;
        cin >> x;
        cin >> y;
        y+=base;
        bi_graph[x].push_back(y);
        bi_graph[y].push_back(x);
    }

    ll ans=0;
    rep(ni,2*base){
        if(visited[ni]) continue;
        ll cnt[2]={};    
        dfs(cnt,ni);
        ans += (ll)cnt[0] * cnt[1];
    }
    cout << ans - N << endl;

    
}

Measured memory_bytes: 10240
import bisect,collections,copy,heapq,itertools,math,string
import sys
def li(): return map(int,sys.stdin.readline().rstrip().split())
def lf(): return map(float,sys.stdin.readline().rstrip().split())
def ls(): return sys.stdin.readline().rstrip().split()

n, k = li()
a = list(li())
print(math.ceil((n-1)/(k-1)))

Measured memory_bytes: 21384
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const int MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int h, w;
        cin >> h >> w;
        vector <vector <char> > grid(h + 1, vector <char> (w + 1));
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                cin >> grid[i][j];
            }
        }
        vector <vector <int> > dp(h + 1, vector <int> (w + 1, 0));
        dp[1][1] = 1;
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                if (i == 1 && j == 1) continue;
                if (grid[i][j] == '#') {
                    dp[i][j] = 0;
                    continue;
                }
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
        cout << dp[h][w] << endl;
    };
    Solve();
    
    return 0;
}



Measured memory_bytes: 5248
fn main() {
    let (n, m) = read_tuple::<i64>();    

    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2);
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



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

int main(){
    int k,a,b,s=0;
    cin >> k;
    cin >> a >> b;

    for(int i; i<100000; i++){
        if(a<=k*i && k*i<=b){
            s+=1;
        }
    }
    if(s>0){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

using Graph = vector<vector<int>>;

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

    ll N, M;
    cin >> N >> M;
    Graph G(N);
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    REP(i, M){
        ll u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    ll res = 0;
    REP(i, N){
        bool ok = true;
        for(auto next: G[i]){
            if(H[next]>=H[i]) ok = false;
        }
        if(ok){
            //dump(i)
            res++;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9252
#!/usr/bin/env python3
import sys
import copy

line = sys.stdin.readline() 

faces = []

def anydup(thelist): 
    seen = set() 
    for x in thelist: 
        if x in seen: 
            return True 
        seen.add(x) 
    return False

while(True):
    line = sys.stdin.readline() 
    if not line:
        break
    line = line.rstrip('\r\n')
    faces.append(line.split())

for i in range(5):
    face  = faces[-1]
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
else:
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]
for i in range(5):
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
for i in range(5):
    if face[0] != face[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]

for j in range(len(faces) - 1):
    face  = faces[j]
    face2 = faces[-1]
    for i in range(5):
        if face[1] == face2[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    else:
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    for i in range(5):
        if face[1] == face2[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    for i in range(5):
        if face[0] == face2[0]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]

#for f in faces:
#    print(f)

if any(faces.count(x) > 1 for x in faces):
    print("No")
else:
    print("Yes")





Measured memory_bytes: 6320
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

s = [0] * (N + 1)
for i in range(1, N + 1):
    s[i] = s[i-1] + i

ans = 0
for n in range(K, N + 2):
    mn = s[n-1] - s[0]
    mx = s[N] - s[max(N-n, 0)]
    count = mx - mn + 1
    ans += count
    ans %= MOD
print(ans)

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

int a,b,c,d;

signed main()
{
  cin >> a >> b >> c >> d;
  int minx = min(a,b);
  int maxx = max(a,b);
  int miny = min(c,d);
  int maxy = max(c,d);
  int res = -1e18-1;
  //cout << res << '\n';
  res = max(res,minx*miny);
  res = max(res,minx*maxy);
  res = max(res,maxx*miny);
  res = max(res,maxx*maxy);
  cout << res;
    return 0;
}


Measured memory_bytes: 3616
// A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 110;

int n, k;
char str[MAX_N], T[MAX_N];

int main()
{
    scanf("%s%d", str + 1, &k), n = strlen(str + 1);
    memcpy(T, str, sizeof(T));
    int scnt = 0;
    for (int i = 1; i < n; i++)
        if (str[i] == str[i + 1])
            scnt++, str[i + 1] = '$';
    int tcnt = 1;
    T[1] = '$';
    for (int i = 1; i < n; i++)
        if (T[i + 1] == T[i])
            tcnt++, T[i + 1] = '$';
    if (str[1] != str[n])
        printf("%lld\n", 1LL * scnt * k);
    else if (str[1] != T[n])
        printf("%lld\n", 1LL * (tcnt + scnt) * (k >> 1) + 1LL * (k & 1) * scnt);
    else
        printf("%lld\n", scnt + 1LL * (k - 1) * tcnt);
    return 0;
}

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

using namespace std;

long long n , cur , zero;
const long long mod=1e18;
int main(){
	cin>>n;
	vector<long long> a(n);

	for(int i=0;i<n;i++){
		cin >> a[i];
		zero|=!a[i];
	}
	if(zero){
		cout<<0;
		return 0;
	}
	cur = 1 ;

	for(int i = 0 ; i  < n;i++){
		if(a[i]<=mod/cur){
			cur*=a[i];
		}
		else{
			cout<<-1;
			return 0;
		}
	}
	cout<<cur;
}

Measured memory_bytes: 3944