akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

Long INF = 1LL<<52;

Long N;
vector<int> xs;

bool input() {
    cin >> N;
    xs.resize(N);
    for (int i = 0; i < N; i++) cin >> xs[i];
    return true;
}

Long C(map<int, Long>& L, Long x) {
    map<int, Long>::iterator it = L.lower_bound(x);
    if (it == L.begin()) return 0;
    it--;
    return it->second;
}

void D(map<int, Long>& L, Long x) {
    map<int, Long>::iterator it1 = L.find(x);
    assert(it1 != L.end());
    map<int, Long>::iterator it = it1;
    vector< int > del;
    if (it != L.begin()) {
        it1--;
        if (it1->second >= it->second) {
            del.push_back(it->first);
        }
    }
    it1 = it;
    it1++;
    while (it1 != L.end() && it->second >= it1->second) {
        del.push_back(it1->first);
        it1++;
    }
    //cout << "del: " << del.size() << endl;
    for (int i = 0; i < del.size(); i++) {
        L.erase(del[i]);
    }
}

void solve() {
    map<int, Long> dp;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        map<int, Long>::iterator it = dp.lower_bound(xs[i]);
        Long r = C(dp, xs[i]) + xs[i];
        //cout << xs[i] << ": " << r << endl;
        dp[xs[i]] = r;
        D(dp, xs[i]);
    }
    Long Ans = 0;

    map<int, Long>::iterator it = dp.end();
    it--;
    Ans = max(Ans, it->second);

    /*
    for (map<int, Long>::iterator it = dp.begin(); it != dp.end(); it++) {
        cout << "(" << it->first << ", " << it->second << ")";
    }
    cout << endl;
    */

    cout << N * (N + 1) / 2 - Ans << endl;
}

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

Measured memory_bytes: 7604
n = int(input())
a = [0,0]
a[0] = list(map(int,input().split()))
a[1] = list(map(int,input().split()))
ans = 0
ruiseki_upper = [0]
ruiseki_downer = [0]
for i in range(n):
    ruiseki_upper.append(a[0][i] + ruiseki_upper[i])
    ruiseki_downer.append(a[1][i] + ruiseki_downer[i])
for i in range(n+1):
    candy = ruiseki_upper[i] + (ruiseki_downer[-1]-ruiseki_downer[i-1])
    ans = max(ans,candy)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 405;
#ifndef LOCAL
#define cerr if(0)cout
#endif
int dp[MAXN][MAXN];
int A[MAXN];
int sum[MAXN];

int rsq(int x, int y) { return sum[y]-sum[x-1]; }

int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,1,n)cin>>A[i];
	FOR(i,1,n)sum[i]=sum[i-1]+A[i];
	DEC(i,n,1) {
		dp[i][i]=0;
		FOR(j,i+1,n) {
			// range is from i to j
			dp[i][j]=oo;
			FOR(k,i,j-1) {
				chmin(dp[i][j], dp[i][k]+dp[k+1][j] + rsq(i,j));
			}
		}
	}
	cout << dp[1][n];
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	string s;
	cin>>n>>s;
	int o = 0, c = 0;
	for(auto ch : s){
		if(ch == '(')o++;
		else if(o)o--;
		else c++;
	}
	string ret = "";
	while(c--)ret += '(';
	ret += s;
	while(o--)ret += ')';
	cout<<ret<<'\n';

	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = list(map(int, input().split()))
    s_1 = str(n) * m
    s_2 = str(m) * n
    if s_1 <= s_2:
        print(s_1)
    else:
        print(s_2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
package main

import "fmt"

func main() {

	var m, f, r int

	for {
		fmt.Scan(&m, &f, &r)
		if m==-1 && f==-1 && r==-1 {
			break
		}
		if m==-1 || f==-1 || m+f<30 {
			fmt.Println("F")
			continue
		}
		if m+f >= 80 {
			fmt.Println("A")
		} else if m+f >= 65 {
			fmt.Println("B")
		} else if m+f >= 50 {
			fmt.Println("C")
		} else if r >= 50 {
			fmt.Println("C")
		} else {
			fmt.Println("D")
		}
	}
}


Measured memory_bytes: 1132
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n + 1]; 
		for(int i = 0; i < n; i++){
		    p[i] = sc.nextInt();
		    q[p[i]] = i + 1;
		}
		
		// 計算
		long result = 0;
		TreeSet<Integer> ts = new TreeSet<Integer>();
		ts.add(-1);
		ts.add(0);
		ts.add(n + 1);
		ts.add(n + 2);
		ts.add(q[n]);
		for(int i = n - 1; i >= 1; i--){
		    // l2 l1 x h1 h2
		    int x = q[i];
		    int h1 = (int)ts.higher(x);
		    int h2 = (int)ts.higher(h1);
		    if(h2 == n + 2) h2--;
		    int l1 = (int)ts.lower(x);
		    int l2 = (int)ts.lower(l1);
		    if(l2 == -1) l2++;
		    result = result + (long)((h1 - x)*(l1 - l2) + (h2 - h1)*(x - l1)) * i;
		    ts.add(x);
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 58648
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    int a,b;
    cin>>a>>b;
    int tmp=b;
    int x=1;
    while(tmp)
        x*=10,tmp/=10;
    a*=x;
    a+=b;
    if((int)sqrt(a)*(int)sqrt(a)==a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

namespace ABC081 {
	class ABC081_A {
		static void Main(string[] args) {
			var input = Console.ReadLine();
			var sum = 0;
			foreach (var c in input) {
				sum += Convert.ToInt32(c) - '0';
			}
			Console.WriteLine(sum.ToString());
		}
	}
}


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

int gcd(int A,int B){
  if(B==0){
    return A;
  }
  return gcd(B,A%B);
}
int main(){
  long long A,B;
  cin >> A >> B;
  long long C=A/gcd(A,B)*B;
  cout << C << endl;
}

Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()

    println(abc097b(x))
}

private fun abc097b(x: Int): Int {
  val ansList = mutableListOf<Int>()
  ansList.add(1)

  for (i in 2..31) {
    var tmp = i * i
    while (tmp <= x) {
      ansList.add(tmp)
      tmp *= i
    }
  }

  return ansList.max()!!
}


Measured memory_bytes: 31400
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{



  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long mod=1000000007l;
  static int INF=10000000;

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes()); }
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //
  static long cnt;
  static TreeSet<Integer> ans;
  static int n,m;
  static int[][] dp;
  static HashMap<Pair,Boolean> arrl;
  static Stack<Integer> stk;
  static Queue<Integer> queue;
  static HashSet<Integer> mtrnode;
  static ArrayList<Pair> arrlans;
  static int[] ff;


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    long[] a=new long[n];
    scanl(a,n);
    long ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    nl(ans);

    out.flush();
  }

}

class Pair{
  int x; int y;
  Pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}


Measured memory_bytes: 63564
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);

	int max = 0;
	int max2 = 0;
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		a.at(i) = a_in;
		if (a_in >= max) {
			max2 = max;
			max = a_in;
		} else if (a_in >= max2) {
			max2 = a_in;
		}
	}

	for (int i = 0; i < n; i++) {
		int ans;
		if (a.at(i) == max) {
			ans = max2;
		} else {
			ans = max;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}


Measured memory_bytes: 27072
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((in (split (read-line) #\Space))
       (head (char (string-upcase (aref in 1)) 0)))
  (format t "A~AC~%" head))

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

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500]);

int main()
{
	int n,m,Recipies[500][500]={0},MAX[500],min_del_Recipies,c,flag,*p,count;
	
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		min_del_Recipies=-1;
		for(int i=0;i<m;i++) MAX[i]=0;
		for(int i=0;i<n;i++)
		{
			for(int t=0;t<m;)
			{
				Recipies[i][t]=getchar();
				if(Recipies[i][t] != '\n'&& Recipies[i][t] != ' ')
				{
					Recipies[i][t]-='0';
					MAX[t]+=Recipies[i][t];
					t++;
				}
			}
		}
		flag=1;
		//作る際に必要な材料数がすべての材料で2で割り切れたなら、その時のレシピ数になる
		for(int t=0;t<m;t++)
		{
			if(MAX[t]%2)
			{
				flag=0;
				break;
			}
		}
		if(flag) min_del_Recipies=0;
		else
		{
			p=(int*)malloc(m*sizeof(int));
			//すべて作った時に必要な材料からレシピを減らしていく
			//減らしていく数を順に増やしていき、その減らす数の時のすべての減らし方を試す
			
			for(int del=1;del<n;del++)//何個引くか del個 引いた個数 count
			{
				for(int i=0;i<m;i++) p[i]=MAX[i];
				count=0;
				flag=del_Recipies(del,count,n,m,p,Recipies);//何個引くか del個 引いた個数 count
				//del個減らしたときにすべての材料が2で割り切れるものがあったら 1を返す なかったら 0を返す
				if(flag)
				{
					min_del_Recipies = del;//delで割り切れたとき
					break;
				}
			}
			if(min_del_Recipies==-1)min_del_Recipies=n;//どれも割り切れなかったとき
			free(p);
		}
		printf("%d\n",n-min_del_Recipies);//全体から割り切れるまでに引いた個数を引くと求まる
	}
	return 0;
}

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500])
{
	//引く個数=del 引いた個数=count何種類目 i
	int flag=1;
	for(;count<n && n-count>=del;count++)
	{
		
		if(del==1)
		{
			flag=1;
			for(int t=0;t<m;t++)
			{
				p[t]-=Recipies[count][t];
				if(p[t]%2!=0)
				{
					flag=0;
					p[t]+=Recipies[count][t];
					break;
				}
				p[t] += Recipies[count][t];
			}
			if(flag) return 1;
			else continue;
		}
		else 
		{
			//残りの引く個数が1になるまで再起
			//pから今回引くRecipiesを引いてから次に渡す
			for(int t=0;t<m;t++) p[t]-=Recipies[count][t];
			//引く個数delを一つ減らす　引いた個数countを一つ増やす
			if(del_Recipies(del-1,count+1,n,m,p,Recipies)) return 1;
			for (int t = 0; t<m; t++) p[t] += Recipies[count][t];
		}
		
	}
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<1000;i++){
        int c[3]={i/100,(i/10)%10,i%10};
        int f=0;
        rep(j,n){
            if(('0'+c[f])==s[j]) f++;
            if(f==3) {
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N-2; i++) {
    if (S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C') {
      ans++;
    }
  }
  cout << ans << endl;
}

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

using ll = long long;
#define NL '\n'
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int mxx = 1e5+9;
int n, k, a[mxx], dp[mxx];

int fun(int pos){
	if(pos + 1 == n) return 0;
	if(dp[pos] == -1){
		dp[pos] = INT_MAX;
		rep(i, 1, k+1){
			if(pos + i < n) dp[pos] = min(dp[pos], (abs(a[pos+i]-a[pos]) + fun(pos + i)));
		}
	}
	return dp[pos];
}

int main(){
	_fastIO();
	rep(i, 0, mxx) dp[i] = -1;
	cin >> n >> k; rep(i, 0, n) cin >> a[i];
	cout << fun(0) << NL;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    COMinit();

    i64 ans = 0;
    for(int i = 1; i <= N-K+1; i++){
        ans = (ans + A[N - i] * COM(N-i, K - 1)) % MOD;
        ans = (ans - A[i -1] * COM(N - i, K - 1)) % MOD;
        if(ans < 0) ans += MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12928
A,B = map(int, input().split())

import math

la = []
lb = []
for i in range(1001):
    if math.floor(0.08*i) == A:
        la.append(i)
    else:
        continue

for i in range(1001):
    if math.floor(0.1*i) == B:
        lb.append(i)
    else:
        continue

lab = set(la) & set(lb)

if not lab:
    print(-1)
else:
    print(min(lab))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  vector<int> p(n), q(n), v(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> q[i];
    v[i] = i + 1;
  }

  int a = 0, b = 0, j = 0;
  do {
    if (p == v) {
      a = j;
    }
    if (q == v) {
      b = j;
    }
    ++j;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(a - b) << '\n';

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  int MIN=a[0];
  int count=0;
  rep(i,n){
    if(a[0]==a[i])count++;
  }
  int p=n-count;
  int q=k-1;
  cout<<(p+q-1)/q<<endl;
}

Measured memory_bytes: 640
// 4/29
// Greedyな過去問攻略

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
// using vector<vector<int>> 

const int MAX_N = 2010;
int dist[MAX_N][MAX_N];

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;

    memset(dist, -1, sizeof(dist));

    // for (int i = 0; i < N; i++) {
    //     // 一旦、バイパスがない場合の距離を置く
    //     for (int j = i + 1; j < N; j++) {
    //         // cout << dist[i][j] << endl;

    //         dist[i][j] = j - 1;
    //     }

    //     // 次に、バイパスの分岐を書く
    //     for (int j = i + 1; j < N; j++) {
    //         if (j == X) {
    //             // Yから右側へ探索
    //             for (k = 0; k < )
    //         }
    //     }
    // }

    int ans[MAX_N] = {0};

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int dist;
            int min_dist;  //  = MAX_N;

            // 直接つなぐ場合。
            // min_dist = min(min_dist, j - i);
            min_dist = j - i;

            // i → X → Y → jの順につなぐ場合
            dist = abs(X - i) + 1 + abs(j - Y);
            min_dist = min(min_dist, dist);

            // i → Y → X → jの順につなぐ場合
            dist = abs(Y - i) + 1 + abs(j - X);
            min_dist = min(min_dist, dist);

            ans[min_dist]++;
        }
    }

    for (int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 16000
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include <map>
#include <set>

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

typedef long long ll;
typedef pair<int, int> P;

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

int main(void){
    int n;
    cin >> n;
	ll array[90];
    array[0] = 2;
    array[1] = 1;
    if(n > 1){
        for(int i=2; i<=n; i++){
            array[i] = array[i-1] + array[i-2];
        }
    }

    cout << array[n] << "\n";
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val list = readLine()?.split(" ")?.map(String::toLong)?: return
    val res = mutableListOf<Long>()
    res.add(list[0] * list[2])
    res.add(list[0] * list[3])
    res.add(list[1] * list[2])
    res.add(list[1] * list[3])
    res.max()?.let { print(it) }
}


Measured memory_bytes: 36480
N,K = map(int,input().split())
l = []
for i in range(N):
  l.append( list(map(int,input().split())) )
l.sort()
  
a = [0]
b = [0]
for i in range(N):
  [x,y] = l[i]
  a.append(x)
  b.append(y)

cnt = 0
for i in range(1,N+1):
  cnt += b[i]
  if cnt >= K:
    ans = a[i]
    break
print(ans)

Measured memory_bytes: 30044
n=int(input())
s=[]
t=[0]*101
for _ in range(n):
    si=input()
    if si not in s:s.append(si)
    t[s.index(si)]+=1
m=int(input())
for _ in range(m):
    si=input()
    if si in s:t[s.index(si)]-=1
print(max(0,max(t)))




Measured memory_bytes: 62504
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>

typedef long long ll;

#define debug(x) cerr << #x << ": " << x << "\n";
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

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

  vector<vector<int> > G(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> ans(N,-1);

  queue<int> q;
  q.push(0);
  
  while(!q.empty()){
    int s = q.front();
    q.pop();
    rep(i,G[s].size()){
      if(ans[G[s][i]] == -1){
  	 ans[G[s][i]] = s;
  	 q.push(G[s][i]);
      }
    }
  }

  bool ok = true;
  rep(i,N-1)
    if(ans[i+1] == -1) ok = false;

  if(ok){
    cout << "Yes" << endl;
    rep(i,N-1)
      cout << ans[i+1] + 1 << endl;
  }
  else cout << "No" << endl;
  
}

Measured memory_bytes: 10072
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;

typedef long long ll;
int n;

bool solve() {
    vector<int> vec;
    unordered_map<int,int> u_map;
    int count = 0;

    int a;

    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (u_map.find(a) == u_map.end()) {
            if (count == 3) {
                return false;
            }
            u_map[a] = 1;
            vec.push_back(a);
            count++;
        } else {
            u_map[a]++;
        }
    }
    sort(vec.begin(), vec.end());
    if (count == 3) {
        if (n % 3) {
            return false;
        }
        for (auto x : vec) {
            if (u_map[x] != (n/3)) {
                return false;
            }
        }

        if ((vec[0] ^ vec[1]) == vec[2]) {
            return true;
        }

        return false;
    } 
    if (count == 2) {
        if (vec[0] != 0) {
            return false;
        }
        if (u_map[vec[1]] == 2*u_map[0]) {
            return true;
        }

        return false;

    }
    if (vec[0] == 0) return true;
    return false;
}

int main() {   
    cin >> n;
    bool a = solve();
    if (a) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
   
}

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

int main() {
    string S,T;
    //int64_t N;
    cin >> S >> T;
    if(S == T.erase(T.size()-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int C[3];
string s[100005];
int ans[100005];
void no(){
    printf("No\n");
    exit(0);
}
int i;
int n;
void AB(){ ans[i] = 1; C[0]--; C[1]++; }
void BA(){ ans[i] = 0; C[1]--; C[0]++; }
void AC(){ ans[i] = 2; C[0]--; C[2]++; }
void CA(){ ans[i] = 0; C[2]--; C[0]++; }
void BC(){ ans[i] = 2; C[1]--; C[2]++; }
void CB(){ ans[i] = 1; C[2]--; C[1]++; }
long long x;
void solve(){
    printf("Yes\n");
    for (i = 0; i < n; i++){
        printf("%c\n",ans[i]+'A');
    }
    exit(0);
}
int main(){
    scanf("%d%d%d%d",&n,&C[0],&C[1],&C[2]);
    x = (long long)C[0]+(long long)C[1]+(long long)C[2];
    for (i = 0; i < n; i++){
        cin >> s[i];
    }
    if (x == 0ll){
        printf("No\n");
        return 0;
    }
    if (x == 1ll){
        for (i = 0; i < n; i++){
            if (s[i] == "AB"){
                if (C[0] == 1) AB();
                else if (C[1] == 1) BA();
                else no();
            }
            if (s[i] == "AC"){
                if (C[0] == 1) AC();
                else if (C[2] == 1) CA();
                else no();
            }
            if (s[i] == "BC"){
                if (C[1] == 1) BC();
                else if (C[2] == 1) CB();
                else no();
            }
        }
        solve();
        return 0;
    }
    if (s[0] == "AB" && C[0] == 0 && C[1] == 0) no();
    if (s[0] == "BC" && C[1] == 0 && C[2] == 0) no();
    if (s[0] == "AC" && C[0] == 0 && C[2] == 0) no();
    for (i = 0; i < n; i++){
        if (s[i] == "AB"){
            if (C[0] == 0) BA();
            else if (C[1] == 0) AB();
            else if (x == 2ll && C[0] == 1 && C[1] == 1){
                if (i == n-1 || s[i+1] == s[i]){
                    if (C[1] > C[0]) BA();
                    else AB();
                }
                else if (s[i+1] == "BC") AB();
                else BA();
            }
            else if (C[1] > C[0]) BA();
            else AB();
        }
        if (s[i] == "AC"){
            if (C[0] == 0) CA();
            else if (C[2] == 0) AC();
            else if (x == 2ll && C[0] == 1 && C[2] == 1){
                if (i == n-1 || s[i+1] == s[i]){
                    if (C[0] > C[2]) AC();
                    else CA();
                }
                else if (s[i+1] == "BC") AC();
                else CA();
            }
            else if (C[0] > C[2]) AC();
            else CA();
        }
        if (s[i] == "BC"){
            if (C[1] == 0) CB();
            else if (C[2] == 0) BC();
            else if (x == 2ll && C[1] == 1 && C[2] == 1){
                if (i == n-1 || s[i+1] == s[i]){
                    if (C[1] > C[2]) BC();
                    else CB();
                }
                else if (s[i+1] == "AB") CB();
                else BC();
            }
            else if (C[1] > C[2]) BC();
            else CB();
        }
        assert(C[0] >= 0 && C[1] >= 0 && C[2] >= 0);
    }
    solve();



}


Measured memory_bytes: 7204
def d_grid_components(A, B):  # 白マス,黒マスの連結成分の個数
    H, W = 100, 100  # グリッドの縦と横。入力に関わらず定数(条件の最大値)とする
    # 100x100グリッドの上半分を黒で、下半分を白で塗りつぶす
    grid = [['#'] * W for _ in range(50)] + [['.'] * W for _ in range(50)]
    # 黒いゾーンに1マスおきに1x1白マスを置いていく(A-1個)
    white = A - 1
    for h in range(1, 50, 2):
        for w in range(1, W, 2):
            if white > 0:
                grid[h][w] = '.'
                white -= 1
            else:
                break
        else:
            continue
        break
    # 白いゾーンに1マスおきに1x1黒マスを置いていく(B-1個)
    black = B - 1
    for h in range(51, 100, 2):
        for w in range(1, W, 2):
            if black > 0:
                grid[h][w] = '#'
                black -= 1
            else:
                break
        else:
            continue
        break
    ans = '100 100\n'
    for h in range(H):
        ans += ''.join(grid[h][:]) + '\n'
    return ans[:-1]
A,B = [int(i) for i in input().split()]
print(d_grid_components(A, B))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int n;
  cin >> n;
  vector<ll> num_depth(n-1, 0);
  ll max_d = 0;
  rep(i, n) {
    ll d;
    cin >> d;
    if (i == 0) {
      if (d != 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    num_depth[d]++;
    chmax(max_d, d);
  }

  if (num_depth[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  mint ans = 1;
  for (int i = 1; i <= max_d; i++) {
    mint a = num_depth[i-1];
    ans *= a.pow(num_depth[i]);
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll



int main(){
  ll n,p;cin>>n>>p;
  ll ans = 1;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  repd(i,2,sqrt(p)+2){
    ll a = 0;
    while(!(p%i)){
        p /= i;
        a++;
    }
    while(a>=n){
      ans *= i;
      a -= n;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# Acceptance of input

import sys

f_i = sys.stdin

V, E = map(int, f_i.readline().split())

adj_sets = [set() for i in range(V)]

for l_i in f_i:
    s, t = map(int, l_i.split())
    adj_sets[s].add(t)
    adj_sets[t].add(s)


# dfs traverse

prenum = [0] * V
parent = [0] * V
lowest = [V] * V

import collections

path = collections.deque()
path.append(0)

cnt = 0

while path:
    u = path[-1]
    adj_v = adj_sets[u].copy()
    v_candidate = adj_v.difference(path)
    if v_candidate:
        v = v_candidate.pop()
        cnt += 1
        prenum[v] = cnt
        parent[v] = u
        path.append(v)
        adj_sets[u].remove(v)
        adj_sets[v].remove(u)
    else:
        l = min(prenum[u], lowest[u])
        for v in adj_v:
            l = min(l, prenum[v])
            adj_sets[u].remove(v)
            adj_sets[v].remove(u)
        lowest[u] = l
        p = parent[u]
        lowest[p] = min(l, lowest[p])
        path.pop()


# output

ans = set()

for u in range(1, V):
    p = parent[u]
    if prenum[p] <= lowest[u]:
        ans.add(p)

if parent.count(0) >= 3:
    ans.add(0)
else:
    ans.discard(0)

ans = list(ans)
ans.sort()

if ans:
    print(*ans, sep = '\n')

Measured memory_bytes: 18208
/*author  ADITYA BANSAL
             //~ MNNIT ALLAHABAD     */
    #include<bits/stdc++.h>
    //#include <boost/multiprecision/cpp_int.hpp> 
    //using namespace boost::multiprecision; 
    using namespace std;
    #define db double
    #define ll long long
    #define ull unsigned long long
    ll power(ll,ll);
    ll ncr(ll,ll);
    void seive();
    void fact();
    const ll M=5;
    void powmat(ll B[M][M], ll A[M][M], ll n);
     void matrix_multi(ll A[M][M],ll B[M][M]);
    ll mul(ll a,ll b);
    #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
    #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define fi(a,b) for(ll i=a; i<b; i++)
    #define fk(a,b) for(ll k=a; k<b; k++)
    #define fri(a,b) for(ll i=a; i>=b; i--)
    #define fj(a,b) for(ll j=a; j<b; j++)
    #define ffi(a,b) for(ll i=a;i*i<=b;i++)
    #define mp make_pair
    #define ff first 
    #define  tc ll t; cin>>t; while(t--)
    #define all(v) (v).begin(),(v).end()
    #define ss second
    #define pb push_back
    #define mem(v,a) memset((v),a,sizeof(v));
    #define pll pair<ll,ll>
    #define mll map<ll,ll>
    #define mcl map<char,ll>
    #define sll set<ll>
    #define vll vector<ll>
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    #define ad(a,b)  (a%mod+b%mod+mod)%mod
    #define pob pop_back
    #define nl endl
    const int mod=1e9+7;
    const ll  N=100002LL;
    
    ll fac[N+2];
    ll prime[N+3];
    vll primes;
    ll inv[N+2];
   
    signed main(){  fast
//~ seive();
 // tc
{ 
 ll n;
 cin>>n;
 ll x=0,tp;
 fi(0,n)cin>>tp,x^=tp;
if(x==0)
cout<<"Yes";
else cout<<"No";
}
        return 0;
    }
     
     
    /******************************************************************************/
     
    ll mul(ll a,ll b){
        return ((a)*(b))%(mod);
    }
     
    void seive() 
    {
ffi(2,N){
if(!prime[i])	
{
for(ll j=i*i;j<=N;j+=i)
prime[j]=1;	
}
    }
    fi(2,N+1) if(!prime[i]) primes.pb(i);
 }
     
    ll power(ll a,ll n){
      ll res=1;
      while(n){
          if(n&1) res= mul(res,a);
         n>>=1; 
         a= mul(a,a);
      }
        return res;
    }
    void fact(){
    inv[0]=fac[0]=1;
    fi(1,N){
    fac[i]=mul(fac[i-1],i);
    inv[i]=power(fac[i],mod-2);
    }
    }
     
    ll ncr(ll r,ll n){
    
    if(r>n) return 0;
    ll e=fac[n];
    e=mul(e,inv[r]);
    e=mul(e,inv[n-r]);
    return e;
    }
    

    void matrix_multi(ll A[M][M],ll B[M][M]){
    ll C[M][M];
    
    for(ll i=0;i<M;i++){
        
        for(ll j=0;j<M;j++){
            
            C[i][j]=0;
            for(ll k=0;k<M;k++){
                C[i][j]=ad(C[i][j],mul(A[i][k],B[k][j]));
            }  }    }
            
             for(ll i=0;i<M;i++){
        
        for(ll j=0;j<M;j++){
            A[i][j]=C[i][j]%(mod);
        }
             }
            
}
void powmat(ll B[M][M], ll A[M][M], ll n)
{
     while(n){
         if(n&1)
         matrix_multi(B,A);
         matrix_multi(A,A);
         n>>=1;
     }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var KS = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var K = KS[0];
            var S = KS[1];
            var ans = 0;

            for (var x = 0; x <= K; x++)
            {
                for (var y = 0; y <= K; y++)
                {
                    var z = S - x - y;
                    if (0 <= z && z <= K)
                        ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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


using namespace std;

//#define push_back pb
int main()
{
  string s,v;
  cin>>v>>s;
  int dp[s.length()+1][v.length()+1];
  for(int i=0;i<=s.length();i++)
  for(int j=0;j<=v.length();j++)
  { if(i==0||j==0)
      dp[i][j]=0;
   else if(s[i-1]==v[j-1])
     dp[i][j]=dp[i-1][j-1]+1;
  else
    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}

  int index=dp[s.length()][v.length()];
     int i=s.length(),j=v.length();
  char lcs[index+1];
  lcs[index]='\0';
  while(i>=0 && j>=0){
    if(s[i-1]==v[j-1])
    {
      lcs[index-1]=s[i-1];
      i--;
      j--;index--;
    }
    else if(dp[i-1][j]>dp[i][j-1])
      i--;
    else
      j--;
  }
    
  cout<<lcs;
  return 0;
  
}

Measured memory_bytes: 35456
from collections import defaultdict
v = defaultdict(list)
mod = 10**9+7

N, K = map(int, input().split())
for _ in range(N-1):
    a, b = map(int, input().split())
    v[a].append(b)
    v[b].append(a)

visited = [False]*(N+1)
ans = 1

q = [(1, 0, 0)]
while q:
    pos, parent, score = q.pop()
    visited[pos] = True
    ans *= (K-score)
    ans %= mod 
   
    a = 1 if pos==1 else 2
    b = 0

    for i in v[pos]:
        if visited[i]:continue
        q.append((i, pos, a+b))
        b += 1

print(ans)

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

int main()
{
    int a[2], b[2];
    cin >> a[0] >> a[1];
    cin >> b[0] >> b[1];
    if (a[0] > b[0]) {
        swap(a, b);
    }
    int ans = min(max(a[1] - b[0], 0), b[1] - b[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
flg = True
h_i = 0
for i in range(n):
    if i == n-1:
        continue
    h_i = h[i]
    if   h[i+1] - h_i >= 1:
        h[i+1] -= 1
    elif h[i+1] - h_i < 0:
        flg=False
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
def main():
    import sys
    input = sys.stdin.readline

    mod = 1000000007
    nmax = 2 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        ret = finv[r]
        for i in range(r):
            ret = (ret * (n-i))%mod
        return ret
    N, a, b = map(int, input().split())
    print((pow(2, N, mod) - 1 - comb(N, a) - comb(N, b))%mod)


if __name__ == '__main__':
    main()


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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long

vector <P> v[25];
int n, m, x, y, res;

int js(int x)
{
	int cnt = 0;
	while(x > 0)
	{
		cnt += x&1;
		x >>= 1;
	}
	return cnt;
}

bool check(int perm)
{
	//permutation
	int tmp[20] = {0};
	for(int i = 0; i < n; i++)
	{
		if( (perm >> i) & 1) tmp[i+1] = 1;
		else tmp[i+1] = 0;
	}
	// for(int i = 1; i <= n; i++)
	// 	cout << tmp[i];
	// cout << '\n';

	for(int i = 1; i <= n; i++)
	{
		if(tmp[i])
		{
			// if (perm == 4)
			// 	cout << i << ":"<< v[i].size() << '\n';
			for (auto x : v[i])
			{
				if (tmp[x.F] != x.S)
					return false;
			}
		}
	}
	return true;
}


int main()
{
	while(cin >> n)
	{
		for(int i = 1; i <= n; i++)
		{
			cin >> m;
			for(int j = 1; j <= m; j++)
			{
				cin >> x >> y;
				v[i].PB(MP(x,y));
			}
		}
		// cout << v[1].size();

		res = 0;
		for (int i = 0; i < (1 << n); i++)
		{
			if (check(i))
				res = max(res, js(i));
		}
		for(int i = 0; i < 25; i++)
			v[i].clear();

		cout << res << '\n';

	}
	return 0;
}

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

class MyClass
{
    public static void Main(string[] args)
    {
        var n = 0;
        while ((n=int.Parse(Console.ReadLine())) != 0)
        {
            var a = new int[n+1, n+1];
            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split();
                a[i, n] = 0;
                for (int j = 0; j < n; j++)
                {
                    a[i, j] = int.Parse(input[j]);
                    a[i, n] += a[i, j];
                }
            }

            for (int j = 0; j <= n; j++)
            {
                a[n, j] = 0;
                for (int i = 0; i < n; i++)
                {
                    a[n, j] += a[i, j];
                }
            }

            for (int i = 0; i <= n; i++)
            {
                for (int j = 0; j <= n; j++)
                {
                    Console.Write("{0,5}", a[i, j]);
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 15876
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	cout << n / 3 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
      int a,x,y,z;
      scanf("%d", &a);
      if(a>=1 && a<=10)
     {

       x=a*a;
       y=a*a*a;
       z=a+x+y;
     
             printf("%d",z);
   

     }  
      return 0;
}

Measured memory_bytes: 2124
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, Y = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

i=0
j=0
k=0

ans="-1 -1 -1"
sum=0

for i in range(N+1):
    for j in range(N-i+1):
        k=N-i-j
        sum = 10000*i + 5000*j + 1000*k
        if sum==Y:
            ans = str(i) + " " + str(j) + " " + str(k)
            break

print(ans)


Measured memory_bytes: 3060
#include "stdio.h"

int main(void){
  int x,y,i,j,k;
  for(i = 0; i <10000;i++){
    scanf("%d %d", &x, &y);
    if((x == 0) && (y == 0))break;
    for(j = 0; j < x; j++){
      for(k = 0; k < y;k++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K, Q;
int A[MAX_N];

void solve() {
	cin >> N >> K >> Q;
	rep(i, 0, N) cin >> A[i];
	int res = (1 << 30);
	rep(i, 0, N) {
		int mv = A[i];
		vi vec, tmp;
		rep(i, 0, N) {
			if(A[i] >= mv) tmp.pb(A[i]);
			else {
				if(sz(tmp) >= K) {
					sort(all(tmp));
					rep(i, 0, sz(tmp) - K + 1) vec.pb(tmp[i]);
				}
				tmp.clear();
			}
		}
		if(sz(tmp) >= K) {
			sort(all(tmp));
			rep(i, 0, sz(tmp) - K + 1) vec.pb(tmp[i]);
		}
		// debug(vec, tmp);
		sort(all(vec));
		if(sz(vec) >= Q) {
			MIN(res, vec[Q - 1] - mv);
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    string s;
    cin>>s;
    int ans = 0;

    REP(i,s.size()) {
        if(s[i] == '2') {
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
int n;
int h[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=n;i>1;i--){
		if(h[i-1]-h[i]>1){
			cout<<"No"<<endl;
			return 0;
		}
		if(h[i-1]>h[i])
			h[i-1]--;
	} 
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    long long N, ans, f, b, fb;
  	cin >> N;
    ans = N*(N+1) / 2;
    f = N/3;
    b = N/5;
    fb = N/15;
    ans = ans - 3*f*(f+1)/2 - 5*b*(b+1)/2 + 15*fb*(fb+1)/2;
    cout << ans;
}

Measured memory_bytes: 3588