akhauriyash/Code-Regression huggingface dataset:
S = input()

a = S[:2]
b = S[2:]

a = int(a)
b = int(b)

x = False
y = False

if 0 < a and a < 13:
    x = True

if 0 < b and b < 13:
    y = True

if x and y:
    print("AMBIGUOUS")
elif x:
    print("MMYY")
elif y:
    print("YYMM")
else:
    print("NA")

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
    ll N;
    double d;
    cin >> N>>d;
    ll a,b,c;
    c=0;
    rep(i,N){
        cin >> a >> b;
        if(sqrt(a*a+b*b)<=d){
            c++;
        }
    }
    cout << c;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3804
#include <stdio.h>
int main(void){
    // Your code here!
  int a,b,i;
  
  scanf("%d%d",&a,&b);
  
  if(a<b){
      for(i=0;i<b;i++)
        printf("%d",a);
  }else if(b<a){
      for(i=0;i<a;i++)
        printf("%d",b);
  }else{
      for(i=0;i<a;i++)
        printf("%d",a);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX=1e6+5;
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  vector<bool> ch(MAX,true);
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a.begin(),a.end());
  for(int i=1;i<MAX;i++){
    if(ch[i]&&mp.find(i)!=mp.end()){
      if(mp[i]==1){
        ans++;
      }
      for(int j=i;j<MAX;j+=i){
        ch[j] = false;
      }
    }
  }
  cout << ans << endl;
}


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

#define ll long long int
#define vi vector<int>

int main() {

    ll a, b;
    cin >> a >> b;

    if (a == b) {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
        cout << endl;
    }
    else if (a < b) {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
        cout << endl;
    }
    else {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
using namespace std;
typedef long long ll;
ll dp[N][N];
ll d[N][N];
int h,w,n;
 
int main(){
  while(1){
    cin>>h>>w>>n;
    if(!h&&!w&&!n)break;
    memset(dp,0,sizeof(dp));
    dp[0][0]=n-1;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
    cin>>d[i][j];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    ll cnt=dp[i][j],a,b;
    a=b=cnt/2;
    if(cnt%2){
      if(d[i][j])b++;
      else a++;
    }
    dp[i+1][j]+=a;
    dp[i][j+1]+=b;
      }
    }
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
    d[i][j]=(d[i][j]+dp[i][j])%2;
    int y=0,x=0;
    while(y<h&&x<w){
      if(d[y][x])x++;
      else y++;
    }
    cout<<y+1<<' '<<x+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 16952
N,M = map(int, input().split())

Lm = -1
Rm = float('inf')

for _ in range(M):
    L,R = map(int, input().split())
    Lm = max(L, Lm)
    Rm = min(R, Rm)

print(max(Rm - Lm + 1, 0))

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);
    int x;
    cin >> x;
    int curr = x;
    int ans = 1;
    while (curr != 0) {
        ans++;
        curr += x;
        curr %= 360;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  for (;;) {
    int H = rint();
    if (!H)
      break;
    int board[H][6] = {};
    dotimes(i, H)
      dotimes(j, 5)
        board[H-i-1][j] = rint();
    int r = 0;
    for (;;) {
      int t = r;
      dotimes(i, H) {
        int s = board[i][0], c = 1;
        dotimes(j, 5) {
          if (board[i][j+1] == s)
            c++;
          else {
            if (s && c >= 3) {
              r += c * s;
              dotimes(k, c)
                board[i][j-k] = 0;
            }
            s = board[i][j+1];
            c = 1;
          }
        }
      }
      if (r == t)
        break;
      dotimes(j, 5) {
        int k = 0;
        dotimes(i, H)
          if (board[i][j])
            board[k++][j] = board[i][j];
        while (k < H)
          board[k++][j] = 0;
      }
    }
    wint(r);
  }
  return 0;
}



Measured memory_bytes: 2672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    vector<Int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];

    Int first_max = 0;
    Int second_max = 0;
    for(int i = 0; i < n; i++)
    {
        if(first_max < A[i])
        {
            first_max = A[i];
        }
        else if(second_max < A[i])
        {
            second_max = A[i];
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(first_max == A[i])
        {
            cout << second_max << endl;
        }
        else
        {
            cout << first_max << endl;
        }
        
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main()
{
	int n,a;
	int amax = 0;
	int amin = 1000;
	cin >> n;
	
	for (int i=0; i<n; i++){
		cin >> a;
		if (a<amin){
			amin = a;
		}
		if(a>amax){
			amax = a;
		}
	}
	
	cout << amax-amin << "\n";
}

Measured memory_bytes: 256
def d_partition(N, M):
    if N == 1:
        return M  # a_1 = M とする他なく、これが最大公約数

    def divisor_list(n):
        # n の正の約数のリスト
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.extend([k, n // k])
        ret.sort()
        return ret

    divisor_m = divisor_list(M)
    ans = -1
    for d in divisor_m:
        if d <= M // N:
            ans = d
        else:
            break
    return ans

N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import math
import itertools

# 入力
N = int(input())
S = str(input())

dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

ans = ""
for i in range(len(S)) :
  for j in range(len(dic)) :
    if S[i] == dic[j] :
      ans += dic[j+N]
      break

print (ans)

Measured memory_bytes: 3060
N = int(input())
s = [int(input()) for i in range(N)]

s.sort()
check = 0
for i in s:
    if i % 10 != 0:
        check = i
        break

ans = sum(s)
if ans % 10 == 0:
    if check:
        ans -= check
    else:
        ans = 0

print(ans)

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

vector<int> v;

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

	for(int i = 0; i < n; i++){
		int in; cin >> in;
		v.push_back(in);
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	vector<long long> edge;
	for(int i = 1; i < (int)v.size(); i++){
		if(v[i] == v[i - 1]){
			edge.push_back(v[i]);
			i++;
		}
		if((int)edge.size() == 2) break;
	}

	if((int)edge.size() < 2) cout << 0 << endl;
	else cout << edge[0] * edge[1] << endl;

	return 0;
}


Measured memory_bytes: 892
#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=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
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, m, ans;
bool g[100][100], d[100];

void dfs(int p) {
    d[p] = true;
    bool all_visited = true;
    rep(i, 0, n) if (!d[i]) {
        all_visited = false;
        break;
    }
    if (all_visited) {
        ans++;
        return;
    }

    rep(i, 0, n) {
        if (g[p][i] && !d[i]) {
            d[i] = true;
            dfs(i);
            d[i] = false;
        }
    }
    return;
}

int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b; 
        a--, b--;
        g[a][b] = g[b][a] = true;
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String n = in.next();
            int ans = 0;

            for (int i = 0; i < 4; i++) {
                if (n.charAt(i) == '2') ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



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

signed main(void)
{
	int n, ans, cnt;
	string s;
	cin >> n >> s;
	int cnt_w[n], cnt_e[n];

	rep(i, n)
	{	
		cnt_w[i] = 0;
		cnt_e[i] = 0;
	}
	rep(i, n)
	{
		if (s[i] =='W')
			cnt_w[i]++;
		else if (s[i] == 'E')
			cnt_e[i]++;
	}
	rep(i, n - 1)
	{	
		cnt_e[i + 1] += cnt_e[i];
		cnt_w[i + 1] += cnt_w[i];
	}
	ans = (int)1e9;
	rep(i, n)
	{
		cnt = 0;
		cnt += cnt_e[n - 1] - cnt_e[i];
		if (i - 1 >= 0)
			cnt += cnt_w[i - 1];
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<ll> a(n);  rep(i, 0, n) cin >> a.at(i);
  
  vector<ll> b = a;
  sort(all(b));
  
  vector<ll> c(n, 0);//数字が何個あるかを保持する配列
  rep(i, 0, n) {
    auto x = lower_bound(all(b), i+1);
    auto y = upper_bound(all(b), i+1);
    c.at(i) = y-x;
  }
  
  ll ans = 0;
  rep(i, 0, n)
    ans += (c.at(i)*(c.at(i)-1))/2;    
  
  rep(i, 0, n) {
    ll lo = ans;
    ll y = a.at(i) -1;
    lo -= ((c.at(y)-1)*c.at(y))/2;
    lo += ((c.at(y)-1)*(c.at(y)-2))/2;
    
    cout << lo << "\n";
  }

}


Measured memory_bytes: 7296
def ReadMap(n, m):
  Map = [0] * m
  for i in range(m):
    a = raw_input()
    b = list(a)
    if a.count('&')>0:
      j = a.index('&')
      PosCas = [j, i]
      b[j] = '.'
    Map[i] = b
  return Map, PosCas

def fill(SP, c1, c2):
  for x, y in SP:
    try:
      if Map[y][x] != c1: continue
    except: continue
    if x in [0, n-1] or y in [0, m-1]: return 1
    Map[y][x] = c2
    SP += [[x+1, y], [x-1, y], [x, y+1], [x, y-1]]
  return 0

while 1:
  n, m = map(int, raw_input().split())
  if n == m == 0: break
  Map, PosCas = ReadMap(n, m)
  c = 0
  while 1:
    SP = [PosCas]
    if fill(SP, '.', '#'): break
    c += 1
    if fill(SP, '#', '.'): break
  print c

Measured memory_bytes: 12476
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn f(n: i32) -> i32 {
    if n % 2 == 0 {
        n/2
    } else {
        3*n+1
    }
}
fn main() {
    input! { s: i32 }
    const N : usize = 1000000+9;
    let mut a = [0; N];
    for i in 0..N {
        if i==0 {
            a[i] = s;
        } else {
            a[i] = f(a[i-1]);
        }
    }

    if s == 1 || s == 2 { println!("{}", 4); }
    else {
        println!("{}", a.iter().enumerate().find(|&(i,v)| *v==4).unwrap().0+4);
    }
}

Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){	
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	

	cout << (H-h) * (W-w) << '\n';

	return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) = {

  val Input = readLine.split(" ").map(_.toInt)
  val a:Int = Input(0)
  val b:Int = Input(1)
   
  val s = a * b
  val l = (a*2) + (b*2)
   
  println(s + " " + l )
  
  }
}

Measured memory_bytes: 43840
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	int n;
	cin >> n;
	vector<double> a(n);

	rep(i, n)
	{
		cin >> a[i];

	}


	double bunbo = 0;
	
	rep(i, n)
	{
		bunbo += 1 / a[i];
	}


	double ans = 1 / bunbo;

	cout<<setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
inline int up(R int x){return x<0?x+P:x;}
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
typedef pair<int,int> pi;
const int N=505;
pi st[N];int c[N],a[N],dp[N],top,n,res;
inline int f(R int x,R int y){R int r=0;while(r<(n<<1)&&r*r+y*y<x*x)++r;return r;}
inline int g(R int x,R int y){R int r=0;while(r<(n<<1)&&r*r+y*y<=x*x)++r;return r;}
int main(){
	scanf("%d%d",&n,&P);
	fp(i,0,n-1)st[++top]=pi(f(n,i),-i);
	fp(i,n,(n<<1)-1)st[++top]=pi(g(n<<1,i),1);
	fp(i,0,n-1)c[i]=g(n<<1,i);
	sort(st+1,st+1+top);
	fp(k,0,n){
		memset(dp,0,(k+1)<<2);
		dp[0]=1;
		int s1=0,s2=0;
		fp(p,1,top)if(st[p].se==1){
			fp(i,0,s2)dp[i]=mul(dp[i],up(st[p].fi-s1-i));
			++s1;
		}else{
			fd(i,s2,0){
				upd(dp[i+1],mul(dp[i],up(st[p].fi-s1-i)));
				dp[i]=mul(dp[i],up(c[-st[p].se]-(n+k+s2-i)));
			}
			++s2;
		}
		upd(res,(k&1)?P-dp[k]:dp[k]);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int A, B;

  cin >> A >> B;

  int ans = (B-1 + A-2) / (A-1);

  cout << ans << endl;

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> numbers(n);
	for (int i=0; i<n; i++){
		cin >> numbers[i];
	}
	for(int i=n; i>1; i--){
		cout << numbers[i-1] << ' ';
	}
	cout << numbers[0] << endl;

	return 0;
}

Measured memory_bytes: 3036
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    char c;
    cin >> c;
    write((char)(c + 1));
}

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

using namespace std;

int main(){
  int n, k;
  vector<int> nums;

  cin >> n >> k;
  for(int i=0; i<n; i++){
    int temp = 0;
    cin >> temp;
    nums.push_back(temp);
  }

  sort(nums.begin(), nums.end(), greater<int>());

  int ans = 0;
  for(int i=0; i<k; i++){
    ans += nums.at(i);
  }

  cout << ans;

  return 0;
}


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

int main(void){
    int N; cin >> N;
    int F[N][10]; int P[N][11];
    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++) cin >> F[i][j];
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<11; j++) cin >> P[i][j];
    }


    int profit=-pow(10,9);
    for(int i=1; i<pow(2,10); i++){ //iは各曜日各時間帯でいつ営業するかをもつビット列

        int sameDay[N];
        int tmpProfit=0;
        for(int j=0; j<N; j++) sameDay[j]=0; //初期化

        for(int j=0; j<N; j++){ //各お店に対して
            for(int k=0; k<10; k++){ //各時間帯に対して
                if((((1<<k)&i)!=0) && F[j][k]==1){ //どちらも営業しているならば
                    sameDay[j]++;
                }
            }
            tmpProfit+=P[j][sameDay[j]];

        }
        profit=max(profit,tmpProfit);
    }

    cout << profit << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 2e5;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n; LL T; cin >> n >> T;
	LL curr = 0;
	LL ans = 0;
	for(int i = 0; i < n; i++)
	{
		LL t; cin >> t;
		if(t > curr)
			ans += T;
		else
			ans += T-(curr-t);
		curr = t+T;
	}
	cout<<ans<<endl;
	
	cout<<flush;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>

using namespace std;

string rot(string);

int main(void){
	string str;

	while(getline(cin,str)){
		while(str.find("the")==string::npos && str.find("that")==string::npos && str.find("this")==string::npos)
			str=rot(str);
		cout << str << endl;
	}
}

string rot(string str){
	for(int i=0;i<str.size();i++)
		if(str[i]>='a'&&str[i]<='z')
			str[i]=str[i]=='z'?'a':str[i]+1;

	return str;
}

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

template <typename T, typename E>
struct SegmentTree {
    typedef function<T(T, T)> F;
    typedef function<T(T, E)> G;
    int n;
    F f;
    G g;
    T d1;
    vector<T> nodes;

    SegmentTree(int n_, F f, G g, T d1, const vector<T>& v=vector<T>()) {
        this->f = f;
        this->g = g;
        this->d1 = d1;
        nodes_init(n_);
        if (n_ == (int)v.size()) build(n_, v);
    }

    void nodes_init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        nodes.clear();
        nodes.resize(2 * n - 1, d1);
    }

    void build(int n_, const vector<T>& v) {
        for (int i = 0; i < n_; i++) {
            nodes.at(i + n - 1) = v.at(i);
        }
        for (int i = n - 2; i >= 0; i--) {
            nodes.at(i) = f(nodes.at(i * 2 + 1), nodes.at(i * 2 + 2));
        }
    }

    void update(int idx, E value) {
        int node_idx = idx + n - 1;
        nodes.at(node_idx) = g(nodes.at(node_idx), value);
        int current_idx = node_idx;
        while (current_idx) {
            current_idx = (current_idx - 1) / 2;
            nodes.at(current_idx) = f(nodes.at(2 * current_idx + 1), nodes.at(2 * current_idx + 2));
        }
    }

    T query(int query_left, int query_right, int cur_idx, int cur_left, int cur_right) {
        if (cur_right <= query_left || query_right <= cur_left) return d1;
        if (query_left <= cur_left && cur_right <= query_right) return nodes.at(cur_idx);
        T value_from_left = query(query_left, query_right, 2 * cur_idx + 1, cur_left, (cur_left + cur_right) / 2);
        T value_from_right = query(query_left, query_right, 2 * cur_idx + 2, (cur_left + cur_right) / 2, cur_right);
        return f(value_from_left, value_from_right);
    }

    T query(int query_left, int query_right) {
        return query(query_left, query_right, 0, 0, n);
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> a_list(n, INT_MAX);
    SegmentTree<int, int> segtree(n,
        [](int a, int b){return min(a, b);},
        [](int a, int b){return b;},
        INT_MAX,
        a_list);

    for (int i = 0; i < q; i++) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 0) {
            segtree.update(x, y);
        }
        else {
            cout << segtree.query(x, y + 1) << "\n";
        }
    }
}



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

typedef long long ll;

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

    int N, M;

    cin >> N >> M;

    int count = 0;

    if(N >= 2) {
        count += N * (N - 1) / 2;
    }
    if(M >= 2) {
        count += M * (M - 1) / 2;
    }

    cout << count << endl;
}

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

using namespace std;

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

  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  cout << (d[n/2] - d[n/2-1]) << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//input
ll n,C;
ll d[40][40];
ll c[510][510];

ll iwakan[3][40];

int main(){
    cin >> n >> C;
    rep(i,C)rep(j,C){
        cin>>d[i][j];
    }
    rep(i,n)rep(j,n){
        cin>>c[i][j];
        c[i][j]--;
    }
    rep(k,C){
        rep(i,n){
            rep(j,n){
                iwakan[(i+j)%3][k]+=d[c[i][j]][k];
            }
        }
    }
    ll ans = INF;
    rep(i,C){
        rep(j,C){
            rep(k,C){
                if(i==j||j==k||k==i)continue;
                chmin(ans,iwakan[0][i]+iwakan[1][j]+iwakan[2][k]);
            }
        }
    }
    cout << ans << endl;


    return 0;
}



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

void main_()
{
    ll A, B;
    cin >> A >> B;

    ll AB_odd_count = (B - A) / 2 + ((A % 2 == 1 || B % 2 == 1) ? 1 : 0);
    ll ans = (AB_odd_count % 2 == 1) ? 1 : 0;
    for (ll div = 2; div <= B; div <<= 1) {
        bool A_odd = (((A / div) % 2) == 1) && (((A % div) % 2) == 1);
        bool B_odd = (((B / div) % 2) == 1) && (((B % div) % 2) == 0);

        if (A_odd ^ B_odd) {
            ans |= div;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, w; long long value[105] = {}, weight[105] = {};
long long dp[105][100005];
long long findSolution(int pos, long long Sum)
{
    if(pos < 0 || Sum < 0)
    {
        return 0;
    }
    if(dp[pos][Sum] != -1)
    {
        return dp[pos][Sum];
    }
    if(weight[pos] > Sum)
    {
        return findSolution(pos-1, Sum);
    }
    else
    {
        long long x = value[pos]+findSolution(pos-1, Sum-weight[pos]);
        long long y = findSolution(pos-1, Sum);
        return dp[pos][Sum] = max(x, y);
    }
}
int main()
{
    scanf("%d %d", &n, &w);
    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100000; j++)
        {
            dp[i][j] = -1;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        scanf("%d %d", &weight[i], &value[i]);
    }
    long long Max = findSolution(n, w);
    printf("%lld\n", Max);
    return 0;
}


Measured memory_bytes: 82748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)

vector<ll> combination(ll n,ll k){
	vector<ll> ans;
	ll x = (1LL<<k)-1;
	ll f = x<<(n-k);
	while(1){
		ans.push_back(x);
		if(x==f)return ans;
		x += x&-x;
		ll pcount = bitset<64>(x).count();
		x|=(1LL<<(k-pcount))-1;
	}
}

int main(){
	ll n,k;
	cin >> n >> k;
	for(ll x:combination(n,k)){
		cout << x << ":" ;
		FOR(i,0,n){
			if(x&(1LL<<i))cout<<" "<<i;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3448
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i]=sc.nextInt();
        }
        int k = sc.nextInt();
        int b = a[4]-a[0];
        if(b>k){
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }
    }
}


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

#define ll long long
ll n, m, a[200010], b[200010], c[200010],d[200010],ans,j;

int main() {
	cin >> n;

	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		m += a[i];
		b[i] = m;
		//		c[i] = m + 400000000000000;
		//		b[m + 400000000000000]++;
	}

	sort(b, b + (n+1));


	/*	for (ll i = 0; i<n; i++) {
			ans += b[c[i]] * (b[c[i]] - 1) / 2;
			b[c[i]] = 0;
		}
	*/
	for (ll i = 0; i < n; i++) {
		if (b[i] == b[i + 1]) {
			c[j]++;
		}
		else j++;
	}


	for (ll i = 0; i < n+1; i++) {
		ans += c[i] * (c[i] + 1) / 2;
	}

/*	for (int i = 0; i < n; i++) {
		cout << b[i]<<" ";
	}
	cout << endl;
:*/
	cout << ans;
	system("pause");
	return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> timing(n), order(n);
    for(int i = 0; i < n; i++)
        cin >> timing[i];
    for(int i = 0; i < n; i++)
        order[timing[i] - 1] = i + 1;  
    for(int i = 0; i < n; i++)
        cout << order[i] << "\n";
    return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>


const int year[4] = {1868, 1912, 1926, 1989};
const int month[4] = {9, 7, 12, 1};
const int day[4] = {8, 30, 25, 8};
const char gengou[5] = {'p', 'm', 't', 's', 'h'};

char gengouka (int inputyear, int inputmonth, int inputday)
{
    int i;
    char y;
    for (i = 0; i <= 3; ++i) {
        if (inputyear == year[i]) {
            if (inputmonth == month[i]) {
                if (inputday < day[i]) {
                    y = gengou[i];
                    break;
                } else if (inputday >= day[i]) {
                    y = gengou[i + 1];
                    break;
                } 
            } else if (inputmonth < month[i]) {
                y = gengou[i];
                break;
            } else if (inputmonth >= month[i]) {
                y = gengou[i + 1];
                break;
            }
            break;
        } else if (inputyear < year[i]) {
            y = gengou[i]; 
            break;
        } 
        if (inputyear > year[3]) {
            y = gengou[4];
            break;
        }
    }
    return y;
}

int main(void) 
{
    int inputyear, inputmonth, inputday, outputyear;
    while ((scanf("%d %d %d", &inputyear, &inputmonth, &inputday)) != EOF) {
        char y = gengouka(inputyear, inputmonth, inputday);
        if (y == 'p') {
            printf("pre-meiji\n");
        } else if (y == 'm') {
            outputyear = inputyear - year[0] + 1;
            printf("meiji %d %d %d\n", outputyear, inputmonth, inputday);
        } else if (y == 't') {
            outputyear = inputyear - year[1] + 1;
            printf("taisho %d %d %d\n", outputyear, inputmonth, inputday); 
        } else if (y == 's') {
            outputyear = inputyear - year[2] + 1;
            printf("showa %d %d %d\n", outputyear, inputmonth, inputday);
        } else {
            outputyear = inputyear - year[3] + 1;
            printf("heisei %d %d %d\n", outputyear, inputmonth, inputday);
        }
    } 
    return 0;
}

Measured memory_bytes: 1036
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
//#define int long long
//#define ll long long
//#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 214748364	//ない環境用
#define LL_HALFMAX 214748364	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

// フロー系のアルゴリズム
// 最大流
/*
Ford-Fulkerson法 O(F|E|)
F: 最大流量
E: 辺数
コンストラクタ引数でノード数nを受け取り初期化し、add_edge で辺と逆辺を追加していく
重みとして各辺の容量が入っていることを期待する
*/
class Ford_Fulkerson {
private:
	struct Edge {
		int src, dst;

		// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
		int rev;
		int cap;
		Edge(int s, int d, int c, int r) : src(s), dst(d), cap(c), rev(r) {}
	};
	vector<vector<Edge> > G;
	vector<bool> used;
public:
	Ford_Fulkerson(int n) :
		G(n),
		used(n, false)
	{}

	void add_edge(int s, int d, int cap) {
		G[s].push_back(Edge(s, d, cap, G[d].size()));
		G[d].push_back(Edge(d, s, 0, G[s].size() - 1));
	}

	int dfs(int v, int t, int f) {
		if (v == t) {
			return f;
		}
		used[v] = true;
		for (int i = 0; i < G[v].size();  i++) {
			Edge& e = G[v][i];
			if (!used[e.dst] && e.cap > 0) {
				// 流せる辺があったら流す
				int d = dfs(e.dst, t, min(f, e.cap));
				if (d > 0) {
					// 辺の残り容量を減らす
					e.cap -= d;
					// 逆辺の容量を増やす
					G[e.dst][e.rev].cap += d;
					return d;
				}
			}
		}
		// t にたどり着けなかったら0
		return 0;
	}
	int max_flow(int s, int t) {
		int flow = 0;

		while (1) {
			for (int i = 0; i < used.size(); i++) {
				used[i] = false;
			}
			int f = dfs(s, t, LL_HALFMAX);
			if (f == 0) {
				return flow;
			}
			flow += f;
		}
	}

};

signed main() {
	/*
	int N, K;
	cin >> N >> K;

	// ノード x: X座標xにビーム ノード y + N: Y座標yにビーム ノード 2*N: 始点 ノード 2*N+1: 終点
	Ford_Fulkerson ff(N * 2 + 2);

	rep(i, K) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		ff.add_edge(x, y + N, 1);
	}
	rep(i, K) {
		ff.add_edge(2 * N, i, 1);
		ff.add_edge(i + N, 2 * N + 1, 1);
	}

	cout << ff.max_flow(2 * N, 2 * N + 1) << "\n";
	*/

	int V, E;
	cin >> V >> E;

	Ford_Fulkerson ff(V);
	rep(i, E) {
		int u, v, c;
		cin >> u >> v >> c;
		ff.add_edge(u, v, c);
	}

	cout << ff.max_flow(0, V - 1) << "\n";
	return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> ans(a);
  for (int i=0;i<=(a-1);++i) {
    ans[i]=0;
  }

  int dist=0;
  for (int i=1;i<b;++i) {
    for (int j=i+1;j<=a;++j) {
      if (j<b) {
        dist=j-i;
      } else if (j<c) {
        dist=b-i+min((j-b),(c-j+1));
      } else {
        dist=j-c+1+b-i;
      }
      ans[dist]+=1;
    }
  } 
  for (int i=b;i<c;++i) {
    for (int j=(i+1);j<=a;++j) {
      if (j<c) {
        dist=min((j-i),(c-j+1+i-b));
      } else {
        dist=j-c+min((c-i),(i-b+1));
      }
      ans[dist]+=1;
    }
  } 
  for (int i=c;i<a;++i) {
    for (int j=(i+1);j<=a;++j) {
      dist=j-i;
      ans[dist]+=1;
    }
  }
  for (int i=1;i<=(a-1);++i) {
    cout<<ans[i]<<endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define st string
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
void solve(){
    st s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}
 
int main(){
    fastio
    solve();
    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static int path(Edge[] edges, Vertex[] vertices){
        int sum = 0;
        int[] in_degree = new int[vertices.length];
        boolean[] visited = new boolean[vertices.length];
        Arrays.fill(in_degree, 0);
        Arrays.fill(visited, false);
        for (Edge e : edges){
            in_degree[e.dst-1]++;
        }
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 0; i < vertices.length; i++) {
            if (!visited[i] && in_degree[i] == 0){
                queue.add(i);
            }
        }
        int[] path = new int[vertices.length];
        Arrays.fill(path, 0);
        while (!queue.isEmpty()){
            int v = queue.poll();
            visited[v] = true;
            for (Edge e: vertices[v].edges){
                in_degree[e.dst-1]--;
                if (path[e.src-1] + 1 > path[e.dst - 1]){
                    path[e.dst-1] = path[e.src-1] + 1;
                }
                if (in_degree[e.dst-1] == 0){
                    queue.add(e.dst-1);
                }
            }
        }
        for (int i = 0; i < vertices.length; i++) {
            if (path[i] > sum){
                sum = path[i];
            }
        }
        return sum;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        Edge[] edges = new Edge[M];
        Vertex[] vertices = new Vertex[N];
        for (int i = 0; i < N; i++) {
            vertices[i] = new Vertex();
            vertices[i].edges = new Vector<>();
        }

        for (int i = 0; i < M; i++) {
            st = new StringTokenizer(reader.readLine());
            edges[i] = new Edge();
            edges[i].src = Integer.parseInt(st.nextToken());
            edges[i].dst = Integer.parseInt(st.nextToken());
            vertices[edges[i].src-1].edges.add(edges[i]);
        }
        System.out.println(path(edges, vertices));
    }

    private static class Edge{
        int src;
        int dst;
    }

    private static class Vertex{
        Vector<Edge> edges;
    }
}


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

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

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

  for (int i = 1; i <= n; i++) cout << p[i] << endl;
}

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

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    bool Prime = true;
    for(int j = 2; j * j <= x; j++){
      if(x % j == 0){
        Prime = false;
        break;
      }
    }
    if(Prime) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3084
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    s = input()
    print(s[0:3])

main()


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

void answer1() {
  int N, K;
  cin >> N >> K;
  vector<int> bucket(200001, 0);
  int in;
  while (cin >> in) {
    bucket.at(in)++;
  }
  sort(bucket.begin(), bucket.end());

  int count = 0;
  for (int i = 0; i < bucket.size() - K; i++) {
    count += bucket.at(i);
  }
  cout << count << endl;
}

void answer2() {
  int bucket[200001] = {0};

}

int main() {
  answer1();
}


Measured memory_bytes: 1024
MOD=10**9+7
n,m=map(int,input().split())
A=[1 for i in range(n)]
if n!=1:
  A[1]=2
  for i in range(m):
    A[int(input())-1]=0
  
  if A[0]==0 and A[1]!=0:
    A[1]=1



  for i in range(2,n):
    if A[i]!=0:
      A[i]=(A[i-1]+A[i-2])
      A[i]%=MOD

    
  print(A[n-1])
  
else:print(1)

Measured memory_bytes: 7064
//AtCoder DP C

//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

ll n,a[sz],b[sz],c[sz],dp[sz][4];

ll vac(ll idx,ll flag)
{
	if(idx==n)
		return 0;

	if(dp[idx][flag]!=-1)
		return dp[idx][flag];

	if(flag==0)
	{
		return dp[idx][flag]=max(a[idx]+vac(idx+1,1),max(b[idx]+vac(idx+1,2),c[idx]+vac(idx+1,3)));
	}
	else if(flag==1)
	{
		return dp[idx][flag]=max(b[idx]+vac(idx+1,2),c[idx]+vac(idx+1,3));
	}
	else if(flag==2)
	{
		return dp[idx][flag]=max(a[idx]+vac(idx+1,1),c[idx]+vac(idx+1,3));
	}
	else
	{
		return dp[idx][flag]=max(a[idx]+vac(idx+1,1),b[idx]+vac(idx+1,2));
	}

}

int main()
{
	Ryuga;

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

	clock_t startTime=clock();

	cin>>n;
	memset(dp,-1,sizeof dp);
	rep(i,0,n)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<vac(0,0);

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 17008
def solve(string):
    a, b, c, x = map(int, string.split())
    ans = 0
    for i in range(a + 1):
        for j in range(b + 1):
            if 0 <= x - 500 * i - 100 * j <= 50 * c:
                ans += 1
    return str(ans)


if __name__ == '__main__':
    n = 4
    print(solve('\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e6 + 10, MAX = 30;
int n;
string s, t;
vector <int> indx[MAX];
int nxt[MAXN];
bitset <MAXN> b;

int32_t main () {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    
    cin >> n >> s >> t;
    
    for (int i = 0; i < n; ++i)
        indx[s[i] - 'a'].push_back(i);
    
    int point = n - 1;
    for (int i = n - 1; i >= 0; --i) {
        while (!indx[t[i] - 'a'].empty() && (indx[t[i] - 'a'].back() > point || indx[t[i] - 'a'].back() > i))
            indx[t[i] - 'a'].pop_back();
        if (indx[t[i] - 'a'].empty())
            return cout << -1, 0;
        int k = indx[t[i] - 'a'].back();
        point = k;
        if (!b[k])
            nxt[k] = i; 
        b[k] = true;
    }

    vector <pair <int, int>> vctr;
    for (int i = 0; i < n; ++i)
        if (b[i] && i != nxt[i])
            vctr.push_back({i, nxt[i]});
    // for (auto i : vctr)
    //     cout << i.first << ';' << i.second << ' ';
    int res = 0;
    int sz = vctr.size();
    point = sz - 1;
    for (int i = sz - 1; i >= 0; --i) {
        while (point > i && vctr[point].first - point + i >= vctr[i].second)
            --point;
        res = max(res, point - i + 1);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 40720