akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC179
{
    class Program
    {
        static void Main(string[] args)
        {
            var NXM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NXM[0]; var X = NXM[1]; var M = NXM[2];

            // make array
            var array = new long[M + 100];
            var a_ = X;
            array[0] = a_;
            for (int i = 1; i < M; i++)
            {
                a_ = (a_ * a_) % M;
                array[i] = a_;
            }

            //Console.WriteLine(string.Join(" ", array));

            var t = Program.cycle_finding(array);
            var s = t.Item1; var e = t.Item2; var len = t.Item3;
            //Console.WriteLine("{0}, {1}", s, e);

            N -= s;
            var ans = 0L;
            for (int i = 0; i < s; i++)
            {
                ans += array[i];
            }

            var a = N / len;
            var b = N % len;

            var sum = 0L;
            for (long i = s; i <= e; i++)
            {
                sum += array[i];
            }

            ans += a * sum;

            for (int i = 0; i < b; i++)
            {
                ans += array[s + i];
            }

            Console.WriteLine(ans);


        }

        // 循環開始・終了位置
        static Tuple<long, long, long> cycle_finding(long[] a)
        {
            var x_length = new long[a.Length].Select(x => x = -1).ToArray();
            var s = 0L;
            var e = 0L;

            var len = 0;
            var index = 0;
            for (int i = 0; x_length[a[i]] == -1; i++)
            {
                x_length[a[i]] = len;
                len++;
                index = i;
            }
            var cycle_length = len - x_length[a[index + 1]];

            s = x_length[a[index + 1]];
            e = x_length[a[index]];
            //Console.WriteLine("{0}, {1}", s, e);
            //Console.WriteLine(string.Join(" ", x_length));

            var tuple = Tuple.Create(s, e, cycle_length);
            return tuple;
        }

    }
}


Measured memory_bytes: 29556
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(0,n-k+1):
    a.append(min(abs(l[i])+abs(l[i]-l[i+k-1]),abs(l[i+k-1])+abs(l[i]-l[i+k-1])))
print(min(a))

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int nums = stoi(s);
  int p = nums/100;
  int q = nums%100;
  if(1<=p && p<=12 && 1<=q && q<=12){
    cout<<"AMBIGUOUS"<<endl;
  }
  else if(1<=q && q<=12){
    cout<<"YYMM"<<endl;
  }
  else if(1<=p && p<=12){
    cout<<"MMYY"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
		int N;
		cin >> N;
		int A[N];
		for (int i = 0; i < N; i++) cin >> A[i];
		sort(A, A+N);

		int x = 0, t = 0, ans = 0;
		for (int i = 0; i < N; i++) {
				if (x == A[i]) {
						if (t == 1) t = 0;
						else t = 1;
				} else {
						ans += t;
						t = 1;
						x = A[i];
				}

				if (i == N-1) ans += t;
		}

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


Measured memory_bytes: 640
n,d= map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]

import numpy as np    

ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        x = np.array(X[i])
        y = np.array(X[j])
        z = sum(np.power((x - y), 2)) ** 0.5
        
        if z % 1 == 0:
            ans += 1
    
print(ans)

Measured memory_bytes: 13488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int arr[N];
int main(){
  int n,x; scanf("%d%d",&n,&x);
  REP(i,n) scanf("%d",&arr[i]);
  ll ans=0;
  REP(i,n-1){
    if(arr[i]+arr[i+1]>x){
      ll d= min(arr[i]+arr[i+1]-x,arr[i+1]);
      ans+=d; arr[i+1]-=d;
      if(arr[i]+arr[i+1]>x){
        ans+=arr[i]+arr[i+1]-x;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
  int H, W, M;
  cin >> H >> W >> M;
  vector<int> h(M), w(M);
  vector<int> row(H+1,0), col(W+1,0);
  for(int i=0; i<M; i++){
    cin >> h.at(i) >> w.at(i);
    row.at(h.at(i))++;
    col.at(w.at(i))++;
  }
  int maxrow=row.at(1), maxcol=col.at(1);
  int rown=0, coln=0;
  for(int i=1; i<=H; i++){
    if(maxrow==row.at(i)){
      rown++;
    }else if(maxrow<row.at(i)){
      maxrow=row.at(i);
      rown=1;
    }
  }
  for(int j=1; j<=W; j++){
    if(maxcol==col.at(j)){
      coln++;
    }else if(maxcol<col.at(j)){
      maxcol=col.at(j);
      coln=1;
    }
  }
  int x=0;
  for(int i=0; i<M; i++){
    if(row.at(h.at(i))==maxrow 
       && col.at(w.at(i))==maxcol){
      x++;
    }
  }
  cout << maxcol+maxrow-(rown*coln==x);
  return 0;
}

Measured memory_bytes: 7952
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	if(x<y)
	{
		int temp=x;
		x=y;
		y=temp;
	}
	while(y!=0)
	{
		int s=x%y;
		x=y;
		y=s;
	}
	printf("%d\n",x);
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
  long x;
  cin >> x;
  int amari;
  amari = x % 500;
  int uresisa;
  uresisa = (x / 500) * 1000;
  uresisa += (amari / 5) * 5;

  cout << uresisa;

  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int ans = 0;
            int ans2 = 0;
            var s = ReadLine().Split(' ');
            int X = int.Parse(s[0]);
            int N = int.Parse(s[1]);
            if (N == 0)
            { ans = X; }
            else
            {
                s = ReadLine().Split(' ');
                int[] p = new int[N];

                bool a = false;
                for (int i = 0; i < N; i++)
                { p[i] = int.Parse(s[i]); }

                for (int i = 0; i < 100; i++)
                {
                    a = true;
                    for (int j = 0; j < N; j++)
                    {
                        if (p[j] == X - i)
                        {
                            a = false;
                            break;
                        }
                        ans2 = X - i;
                    }
                    if (a == true)
                    { break; }
                }
                for (int i = 0; i < 100;i++)
                {
                    a = true;for (int j = 0; j < N; j++)
                    {
                        if (p[j] == X + i)
                        {
                            a = false;
                            break;
                        }
                        ans = X + i;
                    }
                    if (a == true)
                    { break; }
                }
            }
            if (Abs(X - ans2) <= Abs(X - ans))
            { ans = ans2; }
            WriteLine(ans);
        }

    }

    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return Factorical(n) / Factorical(n - m); }
        public static long Combination(long n, long m)
        { return Permutation(n, m) / Factorical(m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }

}

Measured memory_bytes: 17880
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){

    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    int ans = 1;
    int D = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
  
    for (int i = 0; i < N; i++) {
        D = D + L[i];
        if (D <= X) {
            ans += 1;
        }else{
            break;
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}

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

using namespace std;
typedef long long ll;
bool b_asc(pair<int, int> l, pair<int, int> r) {
    if(l.second != r.second) {
        return l.second < r.second;
    } else {
        return l.first < r.first;
    }
}

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

    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }

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

    ll sum = 0;
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        sum += a[i].first;

        if(sum > a[i].second) {
            f = false;
        }
    }

    string ans = f ? "Yes" : "No";

    cout << ans << "\n";

}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	ll sum_a = 0, sum_b = 0;
	rep(i, n){
		sum_a += a[i];
		sum_b += b[i];
	}
	
	ll count_a = 0;
	ll count_b = 0;
	rep(i, n){
		if(a[i] < b[i]){
			count_a += (b[i] - a[i] + 1) / 2;
		} else{
			count_b += a[i] - b[i];
		}
	}
	
	if(count_a <= sum_b - sum_a && count_b <= sum_b - sum_a){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> v(10,vector<int> (10,0));
  vector<int> o(10);
  vector<int> on(10,0);
  for (int i=0;i<m;i++){
    int k; cin >> k;
    for (int j=0;j < k;j++){
      int id;
      cin >> id;
      v[i][id-1]=1;
    }
  }
  for (int i=0;i <m;i++) cin >> o[i];
  int ans=0;
  for (int bit=0; bit < (1 << n);bit++){
    for (int j=0;j < n;j++){
      if (1 << j & bit){
        for (int i=0;i < m;i++){
          if (v[i][j]==1) {
            on[i]+=1;
            on[i]%=2;
          }
        }
      }
    }
    for (int w=0;w < m;w++){
      if (on[w]!=o[w]){
        break;
      }
      else if (w==m-1){
        ans++;
      }
    }
    for (int e=0;e < m;e++) on[e] = 0;
  }
  cout << ans << endl;
  
  return 0;
}



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

const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

int main(){
    int h,w;
    cin >> h >> w;
    int si, sj;
    cin >> si >> sj;
    int ti,tj;
    cin >> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    const int INF = 1e9;
    vector<vector<int>> dist(h, vector<int>(w,INF));
    deque<P> q;
    q.emplace_front(si,sj);
    dist[si][sj] = 0;
    while(!q.empty()){
        int ci = q.front().first;
        int cj = q.front().second;
        q.pop_front();
        int d = dist[ci][cj];
        rep(v,4){
            int x,y;
            x = ci + di[v];
            y = cj + dj[v];
            if(x < 0 || x >= h || y < 0 || y >= w) continue;
            if(s[x][y] == '#') continue;
            if(dist[x][y] <= d) continue;
            dist[x][y] = d;
            q.emplace_front(x,y);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int x,y;
                x = ci + ei;
                y = cj + ej;
                if(x < 0 || x >= h || y < 0 || y >= w) continue;
                if(s[x][y] == '#') continue;
                if(dist[x][y] <= d+1) continue;
                dist[x][y] = d+1;
                q.emplace_back(x,y);
            }
        }
    }

    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0; 
}



Measured memory_bytes: 9512
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if (a>b) {
        if (a-(v*t)>=0&&b-(w*t)>=0) {
            if (a-(v*t)>=b-(w*t)) {
                cout<<"YES"<<endl;
            } else {
                cout<<"NO"<<endl;
            }
        } else if (a-(v*t)>=0&&b-(w*t)<0) {
            cout<<"NO"<<endl;
        } else if (a-(v*t)<0&&b-(w*t)>=0) {
            cout<<"YES"<<endl;
        } else {
            if (a-(v*t)<=b-(w*t)) {
                cout<<"YES"<<endl;
            } else {
                cout<<"NO"<<endl;
            }
        }
    } else {
        if (a+(v*t)>=0&&b+(w*t)>=0) {
            if (a+(v*t)>=b+(w*t)) {
                cout<<"YES"<<endl;
            } else {
                cout<<"NO"<<endl;
            }
        } else if (a+(v*t)<0&&b+(w*t)>=0) {
            cout<<"NO"<<endl;
        } else if (a+(v*t)>=0&&b+(w*t)<0) {
            cout<<"YES"<<endl;
        } else {
            if (a+(v*t)>=b+(w*t)) {
                cout<<"YES"<<endl;
            } else {
                cout<<"NO"<<endl;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')ans += 100;
	}
	print(ans);




	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll N, M;
	
	cin >> N >> M;

	if (M <= 2*N)
	{
		cout << M / 2 << endl;
	}
	else
	{
		ll remainder = M - 2 * N;
		cout << N + remainder / 4 << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long m = sc.nextLong();
		long n = sc.nextLong();
		System.out.println(modPow(m, n));
	}
	static long modPow(long m, long n) {
		if (n == 1) {
			return m;
		}
		if (n % 2 == 0) {
			return modPow(m * m % MOD, n / 2) % MOD;
		} else {
			return modPow(m * m % MOD, n / 2) * m % MOD;
		}
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 24304
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	int count2=0;
	for(int i=1;i<=n;i++)
	{
		int count1=0;
		for(int j=1;j<=i;j++)
		{
			if(i%j==0&&j%2)
			{
				count1++;
			}
		}
		if(count1==8)
		{
			count2++;
		}
	}
	cout<<count2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
int main(){
FASTIO
int n,m;
cin>>n>>m;
vector<int> h(n);
for(int i=0;i<n;i++)
  cin>>h[i];
vector<vector<int> > v(n);
for(int i=0;i<m;i++){
   int a,b;
   cin>>a>>b;
   v[a-1].pb(b-1);
   v[b-1].pb(a-1);
}
int ans=0;
for(int i=0;i<n;i++){
  bool is=true;
  for(int j=0;j<v[i].size();j++){
    if((h[v[i][j]])>=(h[i])){
      is=false;
      break;
    }
  } 
  if(is){
    ans++;
  }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 8760
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 100000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    vector<bool>cnt(55560,true);
    cnt[0] = false;cnt[1] = false;
    for(int i = 2; i <= 55555; i++) {
        if(!cnt[i]) {
            continue;
        }
        for(int j = i*2; j <= 55555; j+=i) {
            cnt[j] = false;
        }
    }
    int N;
    cin >> N;
    while(N) {
        for(int i = 1; i <= 55555; i+=5) {
            if(cnt[i]) {
                if(i != 11) {
                    cout << " ";
                }
                cout << i;
                N--;
                if(N == 0) {
                    break;
                }
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3604
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

def mins(x, y):
    x = min(x, y)

def maxs(x, y):
    x = max(x, y)

while(True):
    try:
        n = int(input())
        a = []
        a.append(n)
        while(True):
            x = 3 * a[len(a) - 1] + 1 if a[len(a) - 1] % 2 else int(a[len(a) - 1] / 2)
            if x in a:
                print(len(a) + 1)
                break
            a.append(x)
    except EOFError:
        exit()



Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int op[8][3] = { {0, 0, 0},
                     {0, 0, 1},
                     {0, 1, 0},
                     {0, 1, 1},
                     {1, 0, 0},
                     {1, 0, 1},
                     {1, 1, 0},
                     {1, 1, 1}
                   };
    char A, B, C, D;
    cin >> A >> B >> C >> D;
    int a, b, c, d;
    a = A - '0';
    b = B - '0';
    c = C - '0';
    d = D - '0';
    for (int i = 0; i < 8; i++) {
        int res = 0;
        res += a;
        if (op[i][0] == 0) {
            res += b;
        } else {
            res -= b;
        }
        if (op[i][1] == 0) {
            res += c;
        } else {
            res -= c;
        }
        if (op[i][2] == 0) {
            res += d;
        } else {
            res -= d;
        }
        if (res == 7) {
            cout << A;
            if (op[i][0] == 0)
                cout << '+';
            else
                cout << '-';
            cout << B;
            if (op[i][1] == 0)
                cout << '+';
            else
                cout << '-';
            cout << C;
            if (op[i][2] == 0)
                cout << '+';
            else
                cout << '-';
            cout << D << "=7" <<  endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int n=sc.nextInt();
            int r=sc.nextInt();
            if(n>=10)System.out.println(r);
            else System.out.println(r+100*(10-n));
        }
    }


Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

bool isYYMM(int N) {
  int MM = N % 100;
  return (MM >= 1 && MM <= 12);
}

bool isMMYY(int N) {
  int MM = N / 100;
  return (MM >= 1 && MM <= 12);
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    if (isYYMM(N) && isMMYY(N)) {
      cout << "AMBIGUOUS" << endl;
    } else if (isYYMM(N)) {
      cout << "YYMM" << endl;
    } else if (isMMYY(N)) {
      cout << "MMYY" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
  char s[20], t[20];
  scanf("%s%s", s, t);
  t[strlen(s)]=0;
  if(strcmp(s,t)==0) {
    puts("Yes");
  } else {
    puts("No");
  }
}
    


Measured memory_bytes: 1616
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, a, b, k1, k2, k3, k4, k5, cnt = 0;

    std::cin >> n >> a >> b;

    for(int i = 1;i <= n;i++){    
        k1 = i / 10000;
        k2 = i / 1000 - k1 * 10;
        k3 = i / 100 - k1 * 100 - k2 * 10;
        k4 = i / 10 - k1 * 1000 - k2 * 100 - k3 * 10;
        k5 = i - k1 * 10000 - k2 * 1000 - k3 * 100 - k4 * 10;
        if(k1 + k2 + k3 + k4 + k5 >= a && k1 + k2 + k3 + k4  + k5 <= b){
            cnt += i;
        }
    }

    std::cout << cnt;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int L; string s, t;
int main() {
	cin >> L >> s >> t;
	if (s > t) swap(s, t);
	if (t.substr(0, s.size()) != s) {
		if (s > t) swap(s, t);
	}
	else {
		string ca = s, cb = t;
		while (ca.size() < 10000000) ca += s;
		while (cb.size() < 10000000) cb += s;
		if (ca > cb) swap(s, t);
	}
	int b = 0, bb = 0;
	for (int i = 0; i <= L; i += s.size()) {
		if ((L - i) % t.size() == 0) {
			b = i / s.size();
			bb = (L - i) / t.size();
		}
	}
	for (int i = 0; i < b; i++) cout << s;
	for (int i = 0; i < bb; i++) cout << t;
	cout << endl;
	return 0;
}

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

const int M = 1e9+7;
int n, u, v;
ll dp[2][100005];
vector<int> g[100005];
void add_self(ll &a, ll b){
    a+=b;
    if(a>=M)
        a-=M;
}
void mul_self(ll &a, ll b){
    a*=b;
    a%=M;
}
ll go(int x, int p, int c){
    if(dp[c][x])
        return dp[c][x];
    dp[c][x]=1LL;
    for(int y : g[x]){
        if(y==p)continue;
        ll z = go(y,x,c^1);
        if(c==0)
            add_self(z,go(y,x,c));
        mul_self(dp[c][x],z);
    }
    return dp[c][x];

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i =0; i<n-1; ++i){
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    go(0,0,1);
    go(0,0,0);
    ll ans = dp[0][0]+dp[1][0];
    //error(dp[1][1]);
    if(ans>=M)
        ans-=M;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
int main() {
  int h, w; cin >> h >> w;
  vector<vector<int>> d(h+2, vector<int>(w+2));
  queue<int> q;
  for (int i = 0; i < h; i++) {
    string s; cin >> s;
    for (int j = 0; j < w; j++) {
      if (s[j] == '#') q.push((w+2)*(i+1)+j+1);
      else d[i+1][j+1] = 1e9;
    }
  }
  int res = 0;
  while (q.size()) {
    int p = q.front(); q.pop();
    int r = p / (w+2);
    int c = p % (w+2);
    int dr[] = {-1, 0, 1, 0};
    int dc[] = {0, 1, 0, -1};
    int i = 4;
    while (i--) {
      int nr = r + dr[i];
      int nc = c + dc[i];
      if (d[nr][nc] == 1e9) {
        res = d[nr][nc] = d[r][c] + 1;
        q.push((w+2)*nr+nc);
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

long long mod_pow(long long x, long long n){
	if(n == 0) return 1;
	long long res = mod_pow(x*x % mod, n / 2);
	if(n & 1) res = res*x % mod;
	return res;
}

map<int, int> prime_factor(int n){
	map<int, int> res;
	for(int i = 2; i * i <= n; i++){
		while(n % i == 0){
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n]++;
	return res;
}

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n){
		cin >> a[i];
	}
	int L = 1;
	map<int, int> pf;
	rep(i, 0, n){
		map<int, int> tmp = prime_factor(a[i]);
		for(auto j : tmp){
			pf[j.first] = max(pf[j.first], j.second);
		}
	}
	for(auto i : pf){
		L = (L * mod_pow(i.first, i.second) % mod) % mod;
	}
	int ans = 0;
	rep(i, 0, n){
		ans += L * mod_pow(a[i], mod - 2) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

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

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

  for (int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if (a[j]==i) {
        cout<<j<<" ";
        if(i==n){
          cout<<endl;
        }
        break;
    }
  }
}
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    bool ok = true;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    for(ll i=n-1;i>0;i--){
        if(h[i-1]-h[i]>=2){
            ok = false;
            break;
        }else if(h[i-1]-h[i]==1){
            h[i-1]--;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
//Tsundoku

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,m,k;cin>>n>>m>>k;
    deque<int>t(n),b(m);
    rep(i,0,n)cin>>t[i];
    rep(i,0,m)cin>>b[i];
    reverse(range(t));
    int s=accumulate(range(t),0LL),ans=0;
    t.pb(0);
    while(true){
        bool flag=false;
        while(s>k){
            if(t.front()==0)flag=true;
            if(flag==true&&t.front()!=0)break;
            s-=t.front();
            t.pop_front();
        }
        if(flag==true&&t.front()!=0)break;
        ans=max(ans,(int)t.size()-1);
        if(b.size()<1)break;
        t.pb(b.front());
        s+=b.front();
        b.pop_front();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6888
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s, t;
	cin >> s >> t;
	int t_len = t.length(), s_len = s.length();
	rep(i, 0, s_len) {
		string a;
		if (s_len - i < t_len) {
			a = s.substr(i, s_len);
			string b = s.substr(0, abs(s_len - i - t_len));
			a += b;
		}
		else {
			a = s.substr(i, t_len);
		}
		if (a == t) { cout << "Yes" << endl;return 0; }
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    // int n, m;
    // cin >> n >> m;
    // int p[m], y[m];
    // vector<set<pii>> s(n+1);
    // rep(i, m) {
    //     cin >> p[i] >> y[i];
    //     s[p[i]].insert({y[i], i});
    // }
    // vector<string> ans(m);
    // rep(i, n+1) {
    //     if (i > 0) {
    //         int cnt = 0;
    //         for (pii x : s[i]) {
    //             string t1 = to_string(i);
    //             while ((int)t1.size() < 6) {
    //                 t1 = '0' + t1;
    //             }
    //             string t2 = to_string(++cnt);
    //             while ((int)t2.size() < 6) {
    //                 t2 = '0' + t2;
    //             }
    //             ans[x.second] = t1 + t2;
    //         }
    //     }
    // }
    // rep(i, m) {
    //     cout << ans[i] << endl;
    // }
    int n, m;
    cin >> n >> m;
    map<int, pii> year;
    map<int, int> pref;
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        year[y] = {p, i};
    }
    vector<string> ans(m);
    for (auto x : year) {
        string t1 = to_string(x.second.first);
        while ((int)t1.size() < 6) {
            t1 = '0' + t1;
        }
        string t2 = to_string(++pref[x.second.first]);
        while ((int)t2.size() < 6) {
            t2 = '0' + t2;
        }
        ans[x.second.second] = t1 + t2;
    }
    rep(i, m) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 17108
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char S[11]; cin >> S;
	char T[11];
	int p = 0;

	rep(i, 0, 11) {
		if (S[i] == '\0') {
			T[p] = '\0';
			break;
		}
		if (S[i] == 'B') {
			p--;
			if (p < 0) {
				p = 0;
			}
			T[p] = '\0';
		}
		else {
			T[p++] = S[i];
		}
	}
	cout << T << endl;
	return 0;
}

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

int main() {
  int A, B, count = 0;
  cin >> A >> B;
  for(; B >= A;B--) {
    int x = B / 10000;
    int y = B / 10;
    if(x != B - y * 10) continue;
    if(B / 1000 - x * 10 != y - B / 100 * 10) continue;
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
ll C;
vll X;
vi V;

int main() {
    cin >> N >> C;
    X.resize(N + 2);
    V.resize(N + 2);
    rep(i, 1, N + 1) {
        cin >> X[i] >> V[i];
    }
    X[0] = 0; X[N + 1] = C;

    vll clockwise_oneway(N + 2), clockwise_twoway(N + 2);
    {
        ll now_ow = 0, now_tw = 0;
        rep(i, 1, N + 1) {
            now_ow += V[i] - (X[i] - X[i - 1]);
            now_tw += V[i] - (X[i] - X[i - 1]) * 2;
            clockwise_oneway[i] = max(clockwise_oneway[i - 1], now_ow);
            clockwise_twoway[i] = max(clockwise_twoway[i - 1], now_tw);
        }
    }
    vll countercw_oneway(N + 2), countercw_twoway(N + 2);
    {
        ll now_ow = 0, now_tw = 0;
        for (int i = N; i > 0; --i) {
            now_ow += V[i] - (X[i + 1] - X[i]);
            now_tw += V[i] - (X[i + 1] - X[i]) * 2;
            countercw_oneway[i] = max(countercw_oneway[i + 1], now_ow);
            countercw_twoway[i] = max(countercw_twoway[i + 1], now_tw);
        }
    }

    ll ans = 0;
    rep(i, 0, N + 1) {
        chmax(ans, clockwise_oneway[i] + countercw_twoway[i + 1]);
        chmax(ans, clockwise_twoway[i] + countercw_oneway[i + 1]);
    }
    write(ans);
}

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

int main(){
  ll x,a,b;
  cin >> x >> a >> b;
  if(b<=a){
    cout << "delicious" << endl;
  }
  else if(b-a<=x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}
  


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

public class Remainder
{
    static int[] PrimeFactors;

    static public void Main()
    {
        var N = int.Parse(Console.ReadLine());
        PrimeFactors = new int[N+1];
        var L = new List<long>();
        //それぞれの数について素因数を辞書に登録する
        for (int i = 2; i <= N; i++)
        {
            PublicFactorization(i);
        }
        
      
        var count3 = PrimeFactors.Count(n => n >= 2);
        var count5 = PrimeFactors.Count(n => n >= 4);
        var count15 = PrimeFactors.Count(n => n >= 14);
        var count25 = PrimeFactors.Count(n => n >= 24);
        var count75 = PrimeFactors.Count(n => n >= 74);
      
        var sum = 0L;
      
        //75個の約数がある場合をカウント
        sum += count75;
      
        //5と15のペアをカウント
        if(count5 > 0){
          sum += (count5-1)*count15;
        }
      
        //3と25のペアをカウント
        if(count3 > 0){
          sum += (count3-1)*count25;
        }
      
        //3,5,5のペアをカウント
        if(count5 >= 2){
          sum += (count5*(count5-1)/2)*(count3-2);
        }
        

        Console.WriteLine(sum);

    }

    static void PublicFactorization(int n)
    {
        int i = 2;
        int tmp = n;

        while(i*i <= n)
        {
            if(tmp % i == 0)
            {
                tmp /= i;
                PrimeFactors[i]++;
            }
            else
            {
                i++;
            }
        }

        if(tmp != 1)
        {
            PrimeFactors[tmp]++;
        }
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
        sort(arr,arr+n);
        ll sum=0,curr;curr=n-1;
        sum+=arr[n-1];curr--;
        for(ll i=n-3;i>=0;i-=2){
            if(i-1>=0)
            sum+=2*arr[curr];
            else
            sum+=arr[curr];
            curr--;
        }
        cout<<sum;


}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else cout<<"No";
	
	
	}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	if(_gcd!=1)cerr<<"WA";
	else return mpow(a,mod-2,mod);
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

//int dc[]={1,0,-1,0,1,1,-1,-1};
//int dr[]={0,-1,0,1,1,-1,-1,1};

/*void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}*/
int n,k;
int main(){reduce200ms;
cin>>n>>k;
rep(i,0,n){
	int temp;cin>>temp;
}
int cnt=1;
n-=k;
cout<<cnt+(int)ceil((ld)n/(k-1));
return 0;
}



Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace ABC126_1
{

    class D
    {
        public struct Edge
        {
            public int to;
            public int weight;
            public Edge(int t, int w) { to = t; weight = w; }
        }
        static List<Edge>[] Nodes;
        static bool[] seen;
        static long[] Res;
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            Nodes = new List<Edge>[n].Select(x => x = new List<Edge>()).ToArray();
            seen = new bool[n];
            Res = new long[n];
            for (int i = 0; i < n - 1; i++)
            {
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Nodes[a[0] - 1].Add(new Edge(a[1], a[2] % 2));
                Nodes[a[1] - 1].Add(new Edge(a[0], a[2] % 2));
            }

            dfs(1, 0);
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(Res[i]);
            }
        }

        static void dfs(int v, int count)
        {
            seen[v - 1] = true;
            Res[v - 1] = count % 2;
            foreach (var next_v in Nodes[v - 1])
            {
                if (seen[next_v.to - 1]) continue;
                dfs(next_v.to, count + next_v.weight);
            }
        }
    }
}


Measured memory_bytes: 36080
#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()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n + 1, 0);
    int m = 2019;
    int ten = 1;
    for (int i = n - 1; i >= 0; i--) {
        int d = (s[i] - '0') * ten % m;
        a[i] = (a[i + 1] + d) % m;
        ten *= 10;
        ten %= m;
    }
    ll ans = 0;
    vector<ll> cnt(m, 0);
    for (int i = n; i >= 0; i--) {
        ans += cnt[a[i]];
        cnt[a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  	int N, D, X;
  	cin >> N >> D >> X;
  	vector<int> A(N);
  	for(int i = 0; i < N; i++){
      	cin >> A.at(i);
    }
  	int s = X + N;
  	for(int i = 0; i < N; i++){
      	int d = 1;
      	for(; d + A.at(i) <= D; ){
        	s++;
          	d += A.at(i);
        }
    }
  	cout << s;
  	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	s := getRunes()

	pins := make([]int, 1000)
	for pNum := range pins {
		pin := []rune(fmt.Sprintf("%03d", pNum))
		cursor := 0
		for i := 0; i < n; i++ {
			if s[i] == pin[cursor] {
				cursor++
			}

			if cursor == 3 {
				pins[pNum] = 1
				break
			}
		}
	}

	ans := sum(pins...)
	fmt.Fprintln(wr, ans)
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <utility>
#include <cstdint>
 
using namespace std;
 
uint64_t N;
int8_t L[100000],_L[100000];
 
int main(void)
{
    cin >> N;
    int t;
    for(int i = 0;i < N;i++)
    {
        cin >> t;
        L[i] = t;
    }
    L[N] = -1;
    bool loop = true;
    uint64_t itr1 = 0,itr2 = 0;
    uint64_t result = 0;
    while(loop)
    {
        while(L[itr1] != L[itr1 + 1] && itr1 < N - 1)
        {
            itr1++;
        }
        itr2 = itr1 + 1;
        while(L[itr2] != L[itr2 + 1] && itr2 < N - 1)
        {
            itr2++;
        }
        memcpy(_L,L,sizeof(int8_t[100000]));
        for(uint64_t i = itr1 + 1;i <= itr2;i++)
        {
            if(L[i] == 0)
                _L[i] = 1;
            else if(L[i] == 1)
                _L[i] = 0;
        }
        uint64_t upper = itr1,downer = itr1,count = 1;
        while(upper > 0 && _L[upper] != _L[upper - 1])
        {
            upper--;
            count++;
        }
        while(downer < N - 1 && _L[downer] != _L[downer + 1])
        {
            downer++;
            count++;
        }
        result = max(result,count);
        itr1++;
        if(itr2 >= N - 1)
        {
            loop = false;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
using namespace std;
#include<string>
int main()
{
	int i,m,n,c=0;
	string a,b[100+1];
	cin>>a;
	cin>>m;
	for(i=0;i<m;i++)
	{
		cin>>b[i];
		b[i]=b[i]+b[i];
	}
	for(i=0;i<m;i++)
	{
		n=0;
		n=b[i].find(a);
		if(n>=0)
		{
			c++;
		}
	}
	cout<<c<<endl;
	
}

Measured memory_bytes: 3176
n = int(input())
t, a = map(float, input().split())

h = [0] * n

h = input().split()

mini = abs((t - float(h[0]) * 0.006) - a)

ans = 1

for i in range(2, n + 1):
  diff = abs((t - float(h[i - 1]) * 0.006) - a)
  if diff < mini:
    ans = i
    mini = diff

print(ans)



Measured memory_bytes: 3060