akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

int sy, sx;
int gy, gx;

using namespace std;

int main(){
    char c;

    cin >> c;

    if(c == 'A') cout << "T" << endl;
    else if(c == 'T') cout << "A" << endl;
    else if(c == 'C') cout << "G" << endl;
    else if(c == 'G') cout << "C" << endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int result = 0;
    for (int i = 1; i <= n; i++) {
      int a = sc.nextInt();
      if (i % 2 != 0 && a % 2 != 0) {
        result++;
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 27048
#include<bits/stdc++.h>
#include<vector>
#define N 200005
#define oo (1<<30)
#define LL long long
#define PAIR pair<LL,LL>
using namespace std;
vector<PAIR> A[N];
PAIR a[N],b[N],c[N]; LL d[N];
int n,la,lb,lc,son[N][2],w[N][2];
void dfs(int t)
{
	if(!son[t][0]) return ;
	d[son[t][0]]=d[t]+w[t][0];
	d[son[t][1]]=d[t]+w[t][1];
	dfs(son[t][0]);
	dfs(son[t][1]);
}
void dp(int t,LL x)
{
	int i,p,q,e;
	if(!son[t][0]){
		A[t].push_back(PAIR(d[t],d[t]));
		return ;
	  }
	dp(son[t][0],x);
	dp(son[t][1],x);
	p=son[t][0];
	q=son[t][1];
	if(A[p].size()>A[q].size()) swap(p,q);
	e=A[q].size()-1,la=lb=lc=0;
	for(i=0;i<A[p].size();i++){
		while(e>=0&&A[q][e].first+A[p][i].first-2*d[t]>x) e--;
		if(e>=0){
			a[++la]=PAIR(A[q][e].second,A[p][i].second);
			b[++lb]=PAIR(A[p][i].second,A[q][e].second);
		  }
	  }
	p=1,q=lb;
	while(p<=la||q){
		if(p>la){ c[++lc]=b[q--]; continue;}
		if(q==0){ c[++lc]=a[p++]; continue;}
		if(a[p]<b[q]) c[++lc]=a[p++];
		else c[++lc]=b[q--];
	  }
	p=0;
	for(i=1;i<=lc;i++)
		if(!p||c[i].second<c[p].second)
			A[t].push_back(c[i]),p=i;
}
bool Tell(LL x)
{
	int i;
	for(i=1;i<=n;i++) A[i].clear();
	dp(1,x);
	if(A[1].size()) return 1;
	else return 0;
}
int main()
{
	int i,x,y,o; LL l,r,mid; 
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		scanf("%d %d",&x,&y);
		o=(son[x][0] ? 1 : 0);
		son[x][o]=i,w[x][o]=y;
	  }
	dfs(1);
	l=-1,r=(LL)(1e10);
	while(r-l>1){
		mid=(l+r)>>1;
		if(Tell(mid)) r=mid;
		else l=mid;
	  }
	cout<<r;
	return 0;
}


Measured memory_bytes: 40440
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pr pair<int,int>
#define ff first
#define ss second
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;

void solve(int ans=0) {
    //cin>>n;
    switch(n%10) {
    case 0:case 1:case 6:case 8:
        cout<<"pon"<<endl;
        break;
    case 3:
        cout<<"bon"<<endl;
        break;
    default:
        cout<<"hon"<<endl;
    }
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    while(cin>>n)
        solve();
}


Measured memory_bytes: 3628
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	ll x;
	cin >> x;
	ll cur = 100;
	int ans = 0;
	while(cur < x)
	{
		ans++;
		cur = cur + cur / 100;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
  cin>>a;
  n=753;
  s=MAX;
  for(i=0;i<=a.SZ-3;i++)
  {
      l=0;
      for(j=i;j<i+3;j++)
      {
          l=(l*10)+(a[j]-'0');
      }
      o=abs(n-l);
      if(o<s)
      {
          s=o;
          k=l;
      }
  }
  cout<<s<<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;

int main() {
    string c;
    int m;
    while (cin >> c, c != "-") {
        queue<char> q;
        REP(i, c.size()) q.push((char)c[i]);
        cin >> m;
        int n;
        REP(i, m) {
            cin >> n;
            REP(j, n) {
                q.push(q.front());
                q.pop();}}
        REP(i, c.size()) {
            cout << q.front();
            q.pop();}
        cout << endl;
    }
}

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

using namespace std ;

const int MAX = 1e5 + 5 ;

int in[MAX], arr[MAX] , vis[MAX];

vector< vector<  pair<int , int> > >adj(MAX) ;

void dfs(int node)
{
	vis[node] = 1 ;
	for(auto &child : adj[node])
	{
		if(vis[child.first] == 1)
		{
			if(arr[node] + child.second != arr[child.first])
			{
				cout<<"No\n";
				exit(0) ;
			}
			continue ;
		}
		arr[child.first] = arr[node] + child.second ;
		dfs(child.first) ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , m;
	cin>>n>>m ;
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y , z ;
		cin>>x>>y>>z ;
		in[y]++ ;
		adj[x].push_back({y , z}) ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		if(in[i])
			continue ;
		arr[i] = 0 ;
		dfs(i) ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		if(!vis[i])
			return cout<<"No\n" , 0 ;
	}
	return cout<<"Yes\n" , 0 ;
}

Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			int n = sc.nextInt();
			calc(n);
		}
	}
	public void calc(int n){
		if(n < 10) System.out.println(0);
		else{
			int[] retsu = new int[(int)Math.pow(10, 6) + 1];
			retsu[n] = 1;
			iter(n, 0, retsu);
		}
	}
	
	public void iter( int n, int count, int[] retsu){
		if(n < 10){
			System.out.println(count);
		}
		else{
			int max = 0;
			for(int i = 1; i <= 6; i++){
				int t = (int) Math.pow(10, i);
				if(n >= t){
					int a = n / t;
					int b = n - (a * t);
					if(a * b > max) max = a * b;
				}
			}
			if(retsu[max] == 1) System.out.println(-1);
			else{
				retsu[max] = 1;
				iter(max, count+1, retsu);
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 151000
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  int n;
  while(true)
  {
    cin >> n;
    if (n == 0) return 0;
    int* s = new int[n];

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

    double avg;
    int sum = 0;
    for (int i=0; i<n; i++)
    {
      sum += s[i];
    }
    avg = sum / (double)n;

    double sigma = 0.0;
    for (int i=0; i<n; i++)
    {
      sigma += (s[i]-avg)*(s[i]-avg);
    }
    delete[] s;

    double alpha = sqrt( sigma/(double)n );

    printf("%.8lf\n", alpha);
  }
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <ctype.h>
#include <string.h>
   
int main(void) {
    int i;
    char string[1200];
    fgets(string,sizeof(string),stdin);
    for (i=0; i<strlen(string); i++) {
        if (isalpha(string[i])) {
            if (islower(string[i])) {
                printf("%c",toupper(string[i]));
            } else {
                printf("%c",tolower(string[i]));
            }
        } else {
            printf("%c",string[i]);
        }
    }
    return 0;
}


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

using namespace std;

using i64 = long long int;
using ui64 = unsigned long long int;

////////

int main(){
    int n;
    const vector<int> tanku = {5,7,5,7,7};
    while(cin >> n,n){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            string s;
            cin >> s;
            a[i] = s.length();
        }
        int res = -1;
        for(int i=0;i<n;i++){
            int id = 0;
            vector<int> p = tanku;
            for(int j=i;j<n;j++){
                // cerr << i << " " << j << " " << a[j] << " " << p[id] << endl;
                if(a[j] < p[id])p[id] -= a[j];
                else if(a[j] == p[id])id++;
                else if(a[j] > p[id]){
                    // cerr << i << ": " <<  id << endl;
                    break;
                }
                if(id==p.size()){
                    res = i + 1;
                    goto output;
                }
            }
        }
output:
        cout << res << endl;
    }
}



Measured memory_bytes: 3128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 100005;
int r[N], t[N], a[N];
int x;

pair<PII, PII> upd(PII l, PII u, int t, bool down) {
	PII ret_l, ret_u;
	if (down) {
		ret_l = MP(min(l.first + max(t - l.second, 0), u.first), max(l.second - t, 0));
		ret_u = MP(u.first, max(u.second - t, 0));
	}
	else {
		ret_l = MP(l.first, min(l.second + t, x));
		ret_u = MP(max(u.first - max(t - (x-u.second), 0), l.first), min(u.second + t, x));
	}
	return MP(ret_l, ret_u);
}

int main() {
	int k, qq;
	scanf("%d%d", &x, &k);
	REP(i, k)scanf("%d", &r[i]);
	r[k++] = 1e9 + 5;
	scanf("%d", &qq);
	PII u = MP(x, x), l = MP(0, 0);
	REP(q, qq) scanf("%d%d", &t[q], &a[q]);
	int pt = 0;
	for (int i = 0, j = 0; i < k, j < qq; i++) {
		while (j < qq && t[j] <= r[i]) {
			int dt = t[j] - pt;
			auto tmp = upd(l, u, dt, (~i) & 1);
			auto tl = tmp.first;
			auto tu = tmp.second;
			if (tl.first >= a[j]) printf("%d\n", tl.second);
			else if (tu.first <= a[j])printf("%d\n", tu.second);
			else printf("%d\n", a[j]-tl.first+tl.second);
			j++;
		}
		auto tmp = upd(l, u, r[i] - pt, (~i) & 1);
		l = tmp.first;
		u = tmp.second;
		pt = r[i];
	}
	return 0;
}

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

int main()
{
    double pi = 3.14159265358979323846264338327950L;
    double A, B, H, M, ans;
    cin >> A >> B >> H >> M;
    ans = (A * A) + (B * B) - 2 * A * B * cos(abs((30 * H + 0.5 * M) - 6*M) * pi / 180.0);
    cout << fixed << setprecision(15) << sqrt(ans) << endl;
    return 0;
}


Measured memory_bytes: 4228
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
res = False
if B > A:
    A = A + V*T
    B = B + W*T
    if A >= B:
        print('YES')
    else:
        print('NO')
else:
    A = A - V*T
    B = B - W*T
    if A <= B:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    int n;
    cin >> n;
    vector<ll> t(n + 2, 0), v(n + 2, 0);
    vector<ll> l(n + 2, 0), r(n + 2, 0);
    for (int i = 1; i <= n; i++){
        ll _t;
        cin >> _t;
        _t *= 2;
        t[i] = _t;
    }
    for (int i = 1; i <= n; i++){
        ll _v;
        cin >> _v;
        _v *= 4;
        v[i] = _v;
    }

    for (int i = 2; i < n + 2; i++) l[i] = l[i - 1] + t[i - 1];
    for (int i = 1; i < n + 2; i++) r[i] = r[i - 1] + t[i];

    vector<ll> sv;
    for (ll x = 0; x <= r[n + 1]; x++) {
        ll mn = numeric_limits<ll>::max();
        for (int i = 0; i < n + 2; i++) {
            if (x < l[i]) mn = min(mn, v[i] + 2 * (l[i] - x));
            if (l[i] <= x && x <= r[i]) mn = min(mn, v[i]);
            if (r[i] < x) mn = min(mn, v[i] + 2 * (x - r[i]));
        }
        sv.push_back(mn);
    }

    double ans = 0;
    for (int i = 1; i < sv.size(); i++) {
        ans += 0.25 *  0.25 * (sv[i] + sv[i - 1]);
    }

    printf("%lf", ans);

    return 0;
}


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

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

    const long  double PI = 3.14159265358979323846;
    long double ax = cos(PI / 180.0 * (90.0 - h * 30.0 - m / 2.0)) * a;
    long double ay = sin(PI / 180.0 * (90.0 - h * 30.0 - m / 2.0)) * a;
    long double bx = cos(PI / 180.0 * (90.0 - m * 6.0)) * b;
    long double by = sin(PI / 180.0 * (90.0 - m * 6.0)) * b;

    //printf("(%lf, %lf) (%lf, %lf)", ax, ay, bx, by);

    long double ans = sqrt(powl(ax - bx, 2) + powl(ay - by, 2));

  	cout << fixed << setprecision(20);
    cout << ans << endl;
}

Measured memory_bytes: 4168
ans = 'APPROVED'

N = int(input())
A = input().split()

for i in range(N):
    if (int(A[i])%2 == 0) and (int(A[i])%3 != 0) and (int(A[i])%5 != 0):
        ans = 'DENIED'
        break

print(ans)


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

int main() {
    string S;
    cin >> S;
    // if (S.at(0) == S.at(1)) {
    //     cout << "Bad" << endl;
    // } else if (S.at(1) == S.at(2)) {
    //     cout << "Bad" << endl;
    // } else if (S.at(2) == S.at(3)) {
    //     cout << "Bad" << endl;
    // } else {
    //     cout << "Good" << endl;
    // }

    bool judge = true;

    for (int i = 0; i < 3; i = i + 1) {
        if (S.at(i) == S.at(i + 1)) {
            cout << "Bad" << endl;
            judge = false;
            break;
        }
    }

    if (judge) {
        cout << "Good" << endl;
    }
}

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

using namespace std;

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

	int num = 0;
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] == '#') {
			num++;
		}
		else if (S[i] == '.' && num > 0) {
			ans++;
			num--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter wr = new PrintWriter(System.out);
        String str = br.readLine().trim();
        StringTokenizer stk = new StringTokenizer(str);
        int n = Integer.parseInt(stk.nextToken());
        int[] a = new int[n];
        str = br.readLine().trim();
        stk = new StringTokenizer(str);
        for(int i=0;i<n;i++) {
        	a[i] = Integer.parseInt(stk.nextToken());
        }
        Arrays.sort(a);
        int alice=0,bob=0;boolean flag=true;
        for(int i=n-1;i>-1;i--) {
        	if(flag==true) {
        		alice+=a[i];flag=false;
        	}
        	else if(flag==false) {
        		bob+=a[i];flag=true;
        	}
        }
        System.out.println(alice-bob);

	}

}


Measured memory_bytes: 21332
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560

"""
import sys
from sys import stdin
input = stdin.readline


def solve(M, N, K, field):
    dp_J = [[0] * (N+1) for _ in range(M+1)]
    dp_O = [[0] * (N+1) for _ in range(M+1)]
    dp_I = [[0] * (N+1) for _ in range(M+1)]
    for y in range(M):
        t_J = [0] * (N+1)
        t_O = [0] * (N+1)
        t_I = [0] * (N+1)
        for x in range(N):
            land = field[y][x]
            if land == 'J':
                t_J[x+1] = t_J[x] + 1
                t_O[x+1] = t_O[x]
                t_I[x+1] = t_I[x]
            elif land == 'O':
                t_J[x+1] = t_J[x]
                t_O[x+1] = t_O[x] + 1
                t_I[x+1] = t_I[x]
            else:
                t_J[x+1] = t_J[x]
                t_O[x+1] = t_O[x]
                t_I[x+1] = t_I[x] + 1

        for x in range(1, N+1):
            dp_J[y+1][x] = dp_J[y][x] + t_J[x]
            dp_O[y+1][x] = dp_O[y][x] + t_O[x]
            dp_I[y+1][x] = dp_I[y][x] + t_I[x]

    for _ in range(K):
        result = [0, 0, 0]
        y1, x1, y2, x2 = map(int, input().split())
        result[0] = dp_J[y2][x2] - dp_J[y1-1][x2] - dp_J[y2][x1-1] + dp_J[y1-1][x1-1]
        result[1] = dp_O[y2][x2] - dp_O[y1-1][x2] - dp_O[y2][x1-1] + dp_O[y1-1][x1-1]
        result[2] = dp_I[y2][x2] - dp_I[y1-1][x2] - dp_I[y2][x1-1] + dp_I[y1-1][x1-1]
        print(' '.join(map(str, result)))


def solve4(M, N, K, field):
    dp = [[[0, 0] for _ in range(N+1)] for _ in range(M+1)]

    for y in range(1, M+1):
        for x in range(1, N+1):
            land = field[y-1][x-1]
            if land == 'J':
                dp[y][x][0] = dp[y-1][x][0] + dp[y][x-1][0] - dp[y-1][x-1][0] + 1
                dp[y][x][1] = dp[y-1][x][1] + dp[y][x-1][1] - dp[y-1][x-1][1]
            elif land == 'O':
                dp[y][x][0] = dp[y-1][x][0] + dp[y][x-1][0] - dp[y-1][x-1][0]
                dp[y][x][1] = dp[y-1][x][1] + dp[y][x-1][1] - dp[y-1][x-1][1] + 1
            else:
                dp[y][x][0] = dp[y-1][x][0] + dp[y][x-1][0] - dp[y-1][x-1][0]
                dp[y][x][1] = dp[y-1][x][1] + dp[y][x-1][1] - dp[y-1][x-1][1]

    for _ in range(K):
        result = [0, 0, 0]
        y1, x1, y2, x2 = map(int, input().split())
        result[0] = dp[y2][x2][0] - dp[y1-1][x2][0] - dp[y2][x1-1][0] + dp[y1-1][x1-1][0]
        result[1] = dp[y2][x2][1] - dp[y1-1][x2][1] - dp[y2][x1-1][1] + dp[y1-1][x1-1][1]
        result[2] = (x2 - x1 + 1) * (y2 - y1 + 1) - result[0] - result[1]
        print(' '.join(map(str, result)))


def main(args):
    M, N = map(int, input().split())
    K = int(input())
    field = [input().strip() for _ in range(M)]
    solve4(M, N, K, field)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 174272
import sys
n=int(input())
d=list(map(int,input().split()))
mod=998244353
if d[0]!=0:
    print(0)
    sys.exit()
d.sort()
if d[1]==0:
    print(0)
    sys.exit()
else:
    lst=[0]*(n+1)
    for i in range(0,n):
        lst[d[i]]+=1
    ans=1
    for i in range(1,d[-1]+1):
        ans=(ans*pow(lst[i-1],lst[i],mod))%mod
    print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    int h,w,k,ans=0;
    cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    for(int bit1=0;bit1<(1<<h);++bit1){
        for(int bit2=0;bit2<(1<<w);++bit2){
            vector<string> l=s;
            rep(i,h){
                if(bit1&(1<<i)){
                    rep(j,w){
                        l[i][j]='.';
                    }
                }
            }
            rep(i,w){
                if(bit2&(1<<i)){
                    rep(j,h){
                        l[j][i]='.';
                    }
                }
            }
            int cnt=0;
            rep(i,h){
                rep(j,w){
                    if(l[i][j]=='#')cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 998244353
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,k,diff=INT_MAX;	cin>>n>>k;
	int a[n];
	FOR(i,0,n)	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<=n-k;i++){
		int d=a[i+k-1]-a[i];
		diff=min(diff,d);
	}
	cout<<diff<<'\n';
	
	return 0;
}


Measured memory_bytes: 640
N = int(input())
array = []
for i in range(N):
    a = int(input())-1
    array.append(a)

c = 0
now = 0
for i in range(N):
    now = array[now]
    c += 1
    if now == 1:
        break
if c == N and now != 1:
    print(-1)
else:
    print(c)

Measured memory_bytes: 7084
#include<iostream>
#include<vector>
int main(){
  std::vector<std::vector<int> >a(3,std::vector<int> (3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      std::cin>>a[i][j];
    }
  }
  int N;
  std::cin>>N;
  std::vector<int>b(N);
  for(int i=0;i<N;i++){
    std::cin>>b[i];
  	for(int j=0;j<3;j++){
    	for(int k=0;k<3;k++){
      		if(a[j][k]==b[i]){
              a[j][k]=0;
            }
    	}
  	}  
  }
  if((a[0][0]==0&&a[0][1]==0&&a[0][2]==0)||(a[0][0]==0&&a[1][1]==0&&a[2][2]==0)||(a[0][0]==0&&a[1][0]==0&&a[2][0]==0)||(a[0][1]==0&&a[1][1]==0&&a[2][1]==0)||(a[0][2]==0&&a[1][2]==0&&a[2][2]==0)||(a[0][2]==0&&a[1][1]==0&&a[2][0]==0)||(a[1][0]==0&&a[1][1]==0&&a[1][2]==0)||(a[2][0]==0&&a[2][1]==0&&a[2][2]==0)){
    std::cout<<"Yes"<<std::endl;
  }else std::cout<<"No"<<std::endl;
  return 0;
}
  
  




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	map<string, int>A;
	int Q;
	cin >> Q;
	int a, x;
	string key;
	rep(i, Q) {
		cin >> a;
		if (a == 0) {
			cin >> key >> x;
			A[key] = x;
		}
		else if (a == 1) {
			cin >> key;
			if (A.count(key)) {
				cout << A[key] << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
		else if (a == 2) {
			cin >> key;
			A.erase(key);
		}
	}
}




Measured memory_bytes: 27732
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;



int par[100001];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}
//木の根を求める
int root(int x) {
	if (par[x] == x)
		return x;
	else {
		return par[x] = root(par[x]);
	}
}
//find
bool same(int x, int y) {
	return root(x) == root(y);

}
//union
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;
	if (x < y) {
		par[y] = x;
	}
	else {
		par[x] = y;
	}
}


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N, Y, Z, K,x,y,z;
	sum = 0;
	cin >> N >> K;
	double ans,cnt;
	ans = 0;
	if (K <= N) {
		ans += (double)(N - K + 1) / (double)N;
		for (i = 1; i < K; i++) {
			cc = 0;
			j = i;
			k = 1;
			cnt = (double)1 / (double)N;
			while (j < K) {
				j *= 2;
				k *= 2;
			}
			ans += cnt / (double)k;


		}
	}
	else {
		for (i = 1; i <=N; i++) {
			cc = 0;
			j = i;
			k = 1;
			cnt = (double)1/(double)N;
			while (j < K) {
				j *= 2;
				k *= 2;

			}
			ans += (double)cnt / (double)k;
		}
	}
	cout << setprecision(11) <<ans<< endl;


	return 0;
}








Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j;
	int N = 0;
	int M = 0;
	vector<int> p(100003) ;
	vector<string> S(100003);
	vector<int> flag(100003,0);//0→WA,1→AC,数字変わる→1
	vector<int> pena_flag(100003,0);
	int ans = 0;
	int	ng = 0;
	cin >> N >> M;
	for (i = 0; i < M; ++i) {
		cin >> p[i] >> S[i];
	}
	
	for (i = 0; i < M; ++i) {
		if (flag[p[i]] == 0) {
			if (S[i] == "WA") {
				++ng;
				pena_flag[p[i]] = 1;
			}
			else if (S[i] == "AC") {
				++ans;
				flag[p[i]] = 1;
				pena_flag[p[i]] = 0;
			}
		}
	}

	for (i = 0; i < M; ++i) {
		if (pena_flag[p[i]] == 1) {
			--ng;
		}
	}

	cout << ans << " " << ng << endl;
	


}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s; cin>>s;
    ll ans=0;
    rep(i,s.size()) ans += s[i]=='o';
    if(ans+15-s.size() >=8) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3588
int main(void) {
	int a = 0,b = 0;
	int i = 0;
	int j = 0;
	scanf("%d %d",&a,&b);
	for (j = 0; j< 2; j++){
		if (a >= b)
		{
			i = i +a;
			a = a-1;
		}
		else{
			i = i +b;
			b = b-1;
		}
	}
	
	printf("%d",i);
	
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
   int t;
   while(cin>>t)
   {
       int sum=0;
       for(int i=1;i<=t;i++)
        sum+=i;
       cout<<sum<<endl;
   }

}


Measured memory_bytes: 256
import itertools

s = 119
X = int(input())

l = [i ** 5 for i in range(-1 * s, s)]

for i, j in itertools.permutations(l, 2):
    if(i + j == X):
        print (l.index(i) - s, l.index(j) - s)
        exit(0)

    if(i - j == X):
        print (l.index(i) - s, l.index(j) - s)
        exit(0)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long X){
    ll ans=0;
    ans+=X/500*1000;
    X%=500;
    ans+=X/5*5;
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

ll n,m,a[100][100],fix[1000],i,j,k,x,ans;

int main()
{

	ios::sync_with_stdio(0);
	
	cin>>n>>m;
	
	for(i=1;i<=n;i++)
	{
		cin>>k;
		while(k--)
		{
			cin>>x;
			fix[x]++;
		}
	}
	
	for(i=1;i<=m;i++)
	{
		if(fix[i]==n)ans++;
	}
	cout<<ans<<endl;

return 0;
}






Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;

	let text = read::<String>(s);
	print!("{}", text);
	let bytes = text.as_bytes();
	if bytes[bytes.len()-1] == 's' as u8 {
		println!("{}","es");
	}
	else { 
		println!("{}", "s");
	}

	
}



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

int main()
{
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    double ans=1.000000;
  	

    ans*=W*H/2;
    printf("%f ",ans);

    if(W/2==x && H/2==y){
        puts("1");
    }else{
        puts("0");
    }

}

Measured memory_bytes: 256
/* Everything happens for a reason.
Be patient, things will be at their rightful place.
It was meant to happen this way, accept it.
And now decide what you can do about it.
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("Yes\n");
}

void no()
{
    printf("No\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll n;
    sc(n);
    vpp vec;
    fo(i,0,n)
    {
        ll x,y;
        sc(x);
        sc(y);
        vec.pb({x,y});
    }
   // bool c =0;
    
    fo(i,0,n-2)
    {
        if(vec[i].ff==vec[i].ss and vec[i+1].ff==vec[i+1].ss and vec[i+2].ff==vec[i+2].ss)
        {
            yes();
            return;
        }
    }
    
    no();
    
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
 //   sc(t);
    while(t--) solve();
}





Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

class UnionFind {
  public:
  // 親の番号を格納。ルートだった場合は-(その集合のサイズ)
  vector<ll> parents;

  UnionFind(ll N) {
    parents = vector<ll>(N, -1);
  }

  // iがどのグループに属しているか
  ll root(ll i) {
    if (parents[i] < 0) {
      return i;
    } else {
      return parents[i] = root(parents[i]);
    }
  }

  // iが属しているグループの大きさ
  ll size(ll i) {
    return -parents[root(i)];
  }

  // root(a)とroot(b)を接続する
  bool connect(ll a, ll b) {
    ll rootA = root(a);
    ll rootB = root(b);
    if (rootA == rootB) {
        return false;
    } else {
      // 大きいほう(a)に小さいほう(b)をくっつける
      // 大小が逆の場合はスワップ
      if (size(rootA) < size(rootB)) {
        swap(rootA, rootB);
      }

      // aグループのサイズを増やす
      parents[rootA] += parents[rootB];
      // bの親をaのルートに変更する
      parents[rootB] = rootA;

      return true;
    }
  }

};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (ll i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  vector<ll> ans(M);
  // 橋が全部崩落した
  ans[M-1] = N*(N-1)/2;

  UnionFind Uni(N);
	for (int i = M - 1; i >= 1; i--) {
		ans[i - 1] = ans[i];

		//繋がってなかったのが繋がった時
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] -= Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}
  for (ll i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long a[40];
vector <long long> coin_num_to_value[21];
int main(void){
  int N;
  int K;
  long long L;
  long long R;

  cin >> N >> K >> L >> R;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  int first_half = N / 2;
  int second_half = N - first_half;

  for(int bitset = 0; bitset < (1 << second_half); bitset++){
    long long cur_value = 0;
    int cur_coin_num = 0;
    for(int i = 0; i < second_half; i++){
      if(((bitset >> i) & 1) == 1){
        cur_coin_num ++;
        cur_value += a[first_half + i];
      }
    }
    coin_num_to_value[cur_coin_num].push_back(cur_value);
  }

  for(int i = 0; i <= second_half; i++){
    sort(coin_num_to_value[i].begin(), coin_num_to_value[i].end());
  }

  long long ans = 0;
  for(int bitset = 0; bitset < (1 << first_half); bitset++){
    long long cur_value = 0;
    int cur_coin_num = 0;
    for(int i = 0; i < first_half; i++){
      if(((bitset >> i) & 1) == 1){
        cur_coin_num ++;
        cur_value += a[i];
      }
    }
    if(cur_coin_num > K || cur_coin_num + second_half < K){
      continue;
    }
    int coin_num_target = K - cur_coin_num;
    long long lb = L - cur_value;
    long long ub = R - cur_value;
    auto it_l = lower_bound(coin_num_to_value[coin_num_target].begin(), coin_num_to_value[coin_num_target].end(), lb);
    auto it_r = lower_bound(coin_num_to_value[coin_num_target].begin(), coin_num_to_value[coin_num_target].end(), ub + 1);
    ans += (it_r - it_l);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12336
//Name: Circle and Points
//Level: 3
//Category: 幾何,円
//Note:

/*
 * 半径が固定なので，円周上に2点が乗っているときが境界状態．
 * すべての2点の組み合わせについて中心の来る場所（2点）を求め，内包判定を行う．
 * N=1のケースと，全ての点が互いに距離2以上離れているケースに注意．
 *
 * オーダーは O(N^3)．
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <utility>

using namespace std;

typedef complex<double> Point;

bool inCircle(const Point &p, const Point &center, double radius) {
    double dist2 = norm(p-center);
    double rad2 = radius*radius;
    return dist2 < rad2+1e-9;
}

int check(const Point &center, const vector<Point> &points) {
    const int N = points.size();
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        if(inCircle(points[i], center, 1)) ++cnt;
    }
    return cnt;
}

int test(int a, int b, const vector<Point> &points) {
    const Point v(points[a]-points[b]);
    if(abs(v) >= 2) return 1;
    const double hlen = abs(v)/2;

    const double plen = sqrt(1 - hlen*hlen);
    Point perp = v*Point(0, 1);
    perp /= abs(perp);
    const Point mid = points[b] + v/2.0;
    return max(check(mid + perp*plen, points), check(mid - perp*plen, points));
}

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

    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        vector<Point> points(N);
        for(int i = 0; i < N; ++i) {
            cin >> points[i].real() >> points[i].imag();
        }
        int ans = 0;
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < i; ++j) {
                ans = max(ans, test(i, j, points));
            }
        }
        if(N == 1) ans = 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    vii a(n);
    rep(i, 0, n) cin >> a[i];
    cout << ceil((double)(n-1) / (double)(k-1)) << endl;
    return 0;
}


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

int main( void )
{
    int a[100];
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ )
    {
        cin >> a[n-i-1];
    }
    
    cout << a[0];
    for ( int i = 1; i < n; i++ )
    {
        cout << " " << a[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <queue>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n, Q;
llint q[100005];
vector<llint> vec;
llint ans[100005], dif[100005];

int main(void)
{
	cin >> n >> Q;
	for(int i = 1; i <= Q; i++) cin >> q[i];
	q[0] = n;
	
	llint mn = 1000000000000000009;
	for(int i = Q; i >= 0; i--){
		if(mn > q[i]){
			vec.push_back(q[i]);
			mn = q[i];
		}
	}
	Q = vec.size();
	
	priority_queue<P> pq;
	pq.push(make_pair(vec[0], 1));
	
	for(int i = 1; i < Q; i++){
		llint sum = 0;
		while(pq.top().first > vec[i]){
			llint x = pq.top().first, m = pq.top().second;
			pq.pop();
			sum += x / vec[i] * m;
			pq.push(make_pair(x%vec[i], m));
		}
		pq.push(make_pair(vec[i], sum));
	}
	
	while(pq.size()){
		llint x = pq.top().first, m = pq.top().second;
		pq.pop();
		dif[0] += m;
		dif[x] -= m;
	}
	llint sum = 0;
	for(int i = 0; i < n; i++){
		sum += dif[i];
		ans[i] = sum;
	}
	
	for(int i = 0; i < n; i++) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
vector<int> v;
int k,n;
bool check(int m){
    int k0=0; 
    rep(i,0,v.sz){
      if(v[i]<=m)continue;
      k0+=(v[i]-1)/m;
    }
    return (k0<=k);
}
int32_t main(){
  cin>>n>>k;
  rep(i,0,n){
    int t; cin>>t;
    v.pub(t);
  }
  int l=1,r=1e9;
  while(l<r){
    int mid=(l+r)/2;
    if(check(mid))r=mid;
    else l=mid+1;
  }
  cout<<l<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read question. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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


int main(int argc, char const *argv[])
{
	int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    int acum=0;
    for(int i=1;i<=k;i++){
    	int maxi=max(a,max(b,c));
	    if(maxi==a){a=2*a;acum=a+b+c;		}
	    else if (maxi==b){b=b*2;acum=a+b+c;}
	    else {c=c*2;acum=a+b+c;}
	}
    cout<<acum;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll a,b,c,left,right,temp;
    cin >> a >> b >> c;
    left = a*b*4;
    right = (c-a-b)*(c-a-b);
    if(c-a-b < 0 ){
        cout << "No" << endl;
    }else{

        if(left<right){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

  int h,w;
  char maze[1010][1010];
  bool used[1010][1010];
  int d[1010][1010];
  set<pair<int,int>> st1,st2;

  int dh[4] = {0,0,1,-1};
  int dw[4] = {1,-1,0,0};

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

  cin >> h >> w;
  REP(i,h) cin >> maze[i];

  queue<pair<pair<int,int>,int>> q;
  int mx = 0;
  REP(i,h) REP(j,w) {
    if (maze[i][j] == '#') {
      q.push({{i,j},0});
      used[i][j] = 1;
    }
    d[i][j] = inf;
  }

  while (!q.empty()) {
    int dd = q.front().se;
    mx = max(mx,dd);
    pair<int,int> tp = q.front().fi;
    q.pop();

    REP(i,4) {
      int th = tp.fi + dh[i];
      int tw = tp.se + dw[i];

      if (th < 0 || th >= h || tw < 0 || tw >= w) continue;
      if (used[th][tw]) continue;

      used[th][tw] = 1;
      q.push({{th,tw},dd+1});

    }
  }

  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 18320
#include <bits/stdc++.h>
using namespace std;
int n;
struct Edge{int to, id;};
vector<int> ans;
vector<vector<Edge>> g;

int main(void){
    // Your code here!
    cin>>n;
    g.resize(n);
    ans.resize(n-1);
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;a--;b--;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    int mx=0;
    for(int i=0;i<n;i++){
        mx = max(mx,(int)g[i].size());
    }
    cout<<mx<<endl;
    queue<int> que;
    que.push(0);
    bool used[n];//訪れた頂点を突っ込んでいく
    fill(used,used+n,false);
    used[0]=true;
    vector<int> pre(n,-1);
    while(que.size()>0){
        int v = que.front();que.pop();
        //まだ決まっていない色のうち使える色を昇順で塗っていく
        //int p = pre[v];
        int c = -1;
        for(int i=0;i<g[v].size();i++){
            int u=g[v][i].to,ei=g[v][i].id;
            if(used[u])c=ans[ei];
        }
        int k = 1;
        for(int i=0;i<g[v].size();i++){
            int u = g[v][i].to,ei = g[v][i].id;
            if(used[u])continue;
            if(k==c)k++;
            ans[ei] = k;k++;
            que.push(u);
            used[u] = true;
        }
        //cout<<"!!"<<endl;
    }
    for(int i=0;i<n-1;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7424
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

string s;

int main() {
    fast_io; cout_precision;
    cin >> s;
    cout << s.find_last_of('Z') - s.find_first_of('A') + 1 << endl;
}

Measured memory_bytes: 720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Panasonic2020
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            long a = abc[0];
            long b = abc[1];
            long c = abc[2];
            long val = (c - a - b) * (c - a - b) - 4 * a * b;
            if (c > a + b && val > 0)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140