akhauriyash/Code-Regression huggingface dataset:
class ModCombination:
    """
    nCk (mod m)を扱うクラス
    """

    def __init__(self, mod, n_max):
        """
        イニシャライザ
        予め 1~nの階乗と階乗の逆元を計算しておく
        :param mod: 法
        :param n_max: nの最大値(100,000で約1秒)
        """
        self.mod = mod
        self.n_max = n_max
        self.facts = [1, 1]
        self.inverses = [None, 1]
        self.fact_inverses = [1, 1]

        for i in range(2, self.n_max + 1):
            self.facts.append(self.facts[i - 1] * i % self.mod)
            # self.inverses.append(mod_inverse(i, self.mod))
            self.inverses.append(
                self.mod - self.inverses[self.mod % i] *
                (self.mod // i) % self.mod
            )
            self.fact_inverses.append(
                self.fact_inverses[i - 1] * self.inverses[i] % self.mod
            )

    def mod_combination(self, n, k):
        """
        nCk (mod m)を計算する
        :param n: n
        :param k: k
        :return: nCk (mod m)
        """
        if k > n:
            raise ValueError
        elif k == n:
            return 1
        elif k == 0:
            return 1

        denominator = self.fact_inverses[k] * self.fact_inverses[n - k] % self.mod
        return self.facts[n] * denominator % self.mod


X, Y = map(int, input().split(' '))
MOD = 10 ** 9 + 7
N_MAX = max(X, Y)

ans = 0
comb = ModCombination(mod=MOD, n_max=N_MAX)
for a in range(N_MAX + 1):
    if a > X or 2 * a > Y:
        break
    dx = X - a
    dy = Y - (2 * a)
    if dx != 2 * dy:
        continue
    b = dy

    ans += comb.mod_combination(a + b, a)
    ans %= MOD

print(ans)


Measured memory_bytes: 127620
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.begin()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  string s; cin >> s;

  int cnt[1000] = {};
  rep(i, 4) {
    cnt[s[i]] += 1;
  }

  bool isYes = true;
  rep(i, 4) {
    if( cnt[s[i]] != 2 ) {
      isYes = false;
      break;
    }
  }

  if( isYes ) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int N, K, H[100000], min, i, j;

int f;
char c;
int nextInt();
int med3(int x, int y, int z);
void quickSort(int a[], int left, int right);
void sort(int a[], int size);

int main(){
	N = nextInt();
	K = nextInt();
	for(i=0; i<N; i++){
		H[i] = nextInt();
	}
	sort(H, N);
	min = H[N-1] - H[1];
	for(i=K; i<=N; i++){
		j = H[i-1] - H[i-K];
		if(j<min){min=j;}
	}
	printf("%d\n", min);
}

int nextInt(){
	f=0;
	c = getchar();
	while((c<'0')||('9'<c)){
		c=getchar();
	}
	while((c>='0')&&(c<='9')){
		f=f*10+(c-'0');
		c=getchar();
	}
	return f;
}

int med3(int x, int y, int z){
	if(x < y){
		if (y < z){return y;}else if(z < x){return x;}else{return z;}
	} else {
		if (z < y){return y;}else if(x < z){return x;}else{return z;}
	}
}

void quickSort(int a[], int left, int right){
	if(left >= right){return;}
	int pivot = med3(a[left], a[left+(right-left)/2], a[right]);
	int l=left, r=right;
	while(1){
		while (a[l] < pivot){l++;}
		while (pivot < a[r]){r--;}
		if(l>=r){break;}
		int t=a[l]; a[l]=a[r]; a[r]=t;
		l++; r--;
	}
	quickSort(a, left, l-1);
	quickSort(a, r+1, right);
}

void sort(int a[], int size){
	quickSort(a, 0, size-1);
}


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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;
constexpr LL Mod = 998244353;

LL n, m, k, ans, fac[MAXN];

inline void Init() {
    fac[0] = 1;
    for (LL i = 1; i < MAXN; i++) fac[i] = fac[i - 1] * i % Mod;
}

inline LL qpow(LL a, LL b) {  // a^b
    LL res = 1;
    while (b) {
        if (b & 1) res = res * a % Mod;
        a = a * a % Mod;
        b >>= 1;
    }
    return res;
}

inline LL C(LL N, LL M) {
    if (M > N || M < 0) return 0;
    return fac[N] * qpow(fac[M], Mod - 2) % Mod * qpow(fac[N - M], Mod - 2) % Mod;
}
// At most K adjacent pairs can be same. So at least n-1-k pairs have to be
// different. Let we need to make p pairs different. So it can be done in
// C(n-1,p)*M*(M-1)^p. Do this for all p from n-1-k to n-1.

//n - k 个数 相邻的数两两不同
int main() {
    // freopen("test.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    Init();
    for (LL i = n - 1 - k; i <= n - 1; i++)
        ans = (ans + C(n - 1, i) * m % Mod * qpow(m - 1, i) % Mod) % Mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define M 1000005
#define FI first
#define SE second
#define MP std::make_pair
#define PB push_back
#define mod 1000000007
#define base 233
#define INF 1000000000
typedef long long ll;
ll n, X[M], Y[M], ans, pos1 = 1, pos2 = 1, pos3 = 1, pos4 = 1;
ll read() {
	ll ans = 0; char c = getchar(); bool flag = 1;
	while (c < '0' || c > '9') flag &= (c != '-'), c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return flag ? ans : -ans;
}
void Write(ll x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
	return;
}
ll max(ll x, ll y) {return x > y ? x : y;}
ll abs(ll x) {return x < 0 ? -x : x;}
ll power(ll x, ll y, ll ans = 1) {
	for (; y; y >>= 1, x = x * x % mod)
		if (y & 1) ans = ans * x % mod;
	return ans;
}
ll dist(ll x, ll y) {return abs(X[x] - X[y]) + abs(Y[x] - Y[y]);}
int main() {
	n = read();
	for (ll i = 1; i <= n; i++) X[i] = read(), Y[i] = read();
	for (ll i = 2; i <= n; i++) {
		if (X[i] + Y[i] < X[pos1] + Y[pos1]) pos1 = i;
		if (-X[i] + Y[i] < -X[pos2] + Y[pos2]) pos2 = i;
		if (X[i] - Y[i] < X[pos3] - Y[pos3]) pos3 = i;
		if (-X[i] - Y[i] < X[pos4] - Y[pos4]) pos4 = i;
	}
	for (ll i = 1; i <= n; i++)
		ans = max(ans, max(max(dist(i, pos1), dist(i, pos2)), max(dist(i, pos3), dist(i, pos4))));
	return Write(ans), 0;
}


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

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  
  int p1=0,p2=0,p3=0; //各区画ごとの該当配点問題の個数
  rep(i,n){
    int tmp = 0; cin >> tmp;
    if(tmp<=a) p1++;
    else if(a<tmp && tmp<=b) p2++;
    else p3++;
  }
  cout << min(p1,min(p2,p3)) << endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b, c;
		
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		if (		a < b
				&&	b < c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int A, B; 
  cin >> A >> B;
  int ans = -1;
  for(int i = 1; i <= 2000; i++){
  	if((int)(i*0.08) == A && (int)(i*0.1) == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt
I_list=[]
prime_list=[]
while True:
    try:
        I_list.append(int(input()))
    except:
        break
I_max=max(I_list)
search_set={x for x in range(2,I_max+1)}
 
 
p=-1
while p<=sqrt(I_max):
    p=min(search_set)
    prime_list.append(p)
    search_set={x for x in search_set if x%p !=0 }
 
search_list=sorted(list(search_set))
prime_list+=search_list
 
#print(prime_list)
 
 
for i in I_list:
    lower_set={j for j in prime_list if j<=i } 
#   print(lower_set)
    print(len(lower_set))

Measured memory_bytes: 103596
N = int(input())
Alst = list(map(int, input().split()))
Blst = [0]*(N+1)
num = 0
for i in Alst:
    num = num + Blst[i]
    Blst[i] += 1

for i in Alst:
    k = Blst[i] -1
    print(num - k)

Measured memory_bytes: 100696
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 200000;

int main() {
	int w,h,x,y,r;
	cin >> w >>h>> x>> y>> r;
	if ((x + r <= w) && (x - r >= 0) && (y + r <= h) && (y - r >= 0))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3080
Module Program
  Sub Main
    Dim s = Gets()
    Dim a=s(0)
    Dim ans=0
    ans+=If(a(0)="+"c,1,-1)
    ans+=If(a(1)="+"c,1,-1)
    ans+=If(a(2)="+"c,1,-1)
    ans+=If(a(3)="+"c,1,-1)
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22608
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n):
    for j in range(n):
        if i+j+j>=n:
            break
        s1=s[i]
        s2=s[i+j]
        s3=s[i+j*2]
        if s1!=s2 and s2!=s3 and s1!=s3:
            ans-=1
print(ans)

Measured memory_bytes: 9212
#include <cstdio>
using namespace std;
int main() {
    int N; scanf("%d", &N);
    int a[N+1], cnt[N+1]; int sum = 0;
    for(int i = 1; i <= N; i++) {
        scanf("%d", &a[i]);
        cnt[i] = 0;
    }
    for(int p = 1; p != 2; sum++) {
        if(cnt[p] > 0) {
            sum = -1;
            break;
        }
        cnt[p]++;
        p = a[p];
    }
    printf("%d", sum);
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(string S) {
	set <char> st;
	for(auto itr = S.begin(); itr != S.end(); itr++) {
		st.insert(*itr);
	}
	if(st.size() == S.size()) printf("yes");
	else printf("no");
}

int main() {
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,k;cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    int diff =INF ;
    rep(i,n-k+1) {
        diff = min(diff,h[i+k-1]-h[i]);
    }
    cout << diff << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

string s, t, ans;

void reconstruct(int i, int j, vv<vll>& dp) {
	if (i <= 0 || j <= 0)
		return;
	if (s[i] == t[j]) {
		ans.push_back(s[i]);
		reconstruct(i - 1, j - 1,dp);
	} else {
		if (dp[i - 1][j] > dp[i][j - 1])
			reconstruct(i - 1, j, dp);
		else
			reconstruct(i, j - 1, dp);
	}
}

int main() {
	fastio;
	cin >> s >> t;
	ll n, m;
	n = s.size(), m = t.size();
	s = '@' + s;
	t = '#' + t;
	/* s[i] == t[j]
		dp[i][j] = 1+dp[i-1][j-1];
		else
		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	*/

	// dp[i][j] is the length of maxsubsequence of strings
	// s(0...i) and t[0..j]

	vv<vll> dp(n + 1, vll(m + 1, 0));

	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (s[i] == t[j])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	// for(ll i=0; i<n; i++){
	// 	for(ll j=0; j<m; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	// cout<<dp[0][0];
	reconstruct(n,m,dp);
	// ll i = n, j = m;
/* 	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j - 1] + 1) {
			ans.push_back(s[i]);
			i--;
			j--;
		} else if (dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}
 */	
	// LG(ans)
	// if (ans.size() < dp[n - 1][m - 1]) {
	// 	if (i == 0) {
	// 		ans.push_back(s[0]);
	// 	} else if (j == 0)
	// 		ans.push_back(t[0]);
	// }
	reverse(all(ans));
	cout << ans << endl;
}

Measured memory_bytes: 73628
#include <iostream>
#include <algorithm>
#define N 110
using namespace std;


int main(){
  int data[N][N];
  int size[N];

  while(1){
    int m;
    cin >> m;
    if(m==0) break;
    for(int i=0;i<=m;i++){
      size[i]=0;
    }
    for(int i=1;i<=m;i++){
      data[i][size[i]]=i;
      size[i]++;
    }
    while(1){
      /*for(int i=0;i<=m;i++){
	cout << size[i] <<  ' ';
	}
      cout << endl;
      */
      int a, b;
      cin >> a >> b;
      if(a==0 && b==0) break;

      if(a==b) continue;
      
      int tmp1[2], tmp2[2];
      for(int i=0;i<=m;i++){
	for(int j=0;j<size[i];j++){
	  if(data[i][j]==a){
	    tmp1[0]=i;
	    tmp1[1]=j;
	  }
	  if(data[i][j]==b){
	    tmp2[0]=i;
	    tmp2[1]=j;
	  }
	}
      }
      if(b==0){
	if(tmp1[1]==0) continue;
	else{
	  int tmpsize=size[tmp1[0]]-tmp1[1];
	  for(int i=tmp1[1];i<size[tmp1[0]];i++){
	    int tmp;
	    tmp=data[tmp1[0]][i];
	    data[tmp][size[tmp]]=tmp;
	    size[tmp]++;
	  }
	  for(int i=0;i<tmpsize;i++){
	    size[tmp1[0]]--;
	  }
	}
      }
      else if(tmp1[0]==tmp2[0]){
	if(tmp1[1]>tmp2[1]) continue;
	else{
	  int count=0;
	  for(int i=tmp1[1]+1;i<size[tmp1[0]];i++){
	    int tmp;
	    tmp=data[tmp1[0]][i];
	    data[tmp][size[tmp]]=tmp;
	    size[tmp]++;
	    count++;
	  }
	  size[tmp1[0]]-=count;
	  data[b][size[b]]=a;
	  size[b]++;
	  size[tmp1[0]]--;
	}
      }
      else{
	int count=1;
	data[tmp2[0]][size[tmp2[0]]]=data[tmp1[0]][tmp1[1]];
	size[tmp2[0]]++;
	for(int i=tmp1[1]+1;i<size[tmp1[0]];i++){
	  int tmp=data[tmp1[0]][i];
	  data[tmp][size[tmp]]=tmp;
	  size[tmp]++;
	  count++;
	}
	for(int i=0;i<count;i++){
	  size[tmp1[0]]--;
	}
      }
    }


    sort(size, size+m+1);

    for(int i=0;i<=m;i++){
      if(size[i]==0) continue;
      cout << size[i] << endl;
    }
    cout << "end" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
score = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
N = int(input())
for _ in range(N):
    result = input()
    if result == 'AC':
        score[result] += 1
    elif result == 'WA':
        score[result] += 1
    elif result == 'TLE':
        score[result] += 1
    elif result == 'RE':
        score[result] += 1
for i in score.keys():
    print(i, 'x', score[i])



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(p[i]!=i+1){
      cnt++;
    }
  }
  if(cnt>2) cout << "NO" << endl;
  else cout << "YES" << endl;
}
      


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

int main(){
char c;
cin >> c;
if(c == 'a' || c == 'i' || c == 'u' || c  == 'e' || c == 'o'){
cout << "vowel" << endl;
    }
 else{
cout << "consonant" << endl;
 }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int num[3];
    num[0]=n/100;
    num[1]=(n-num[0]*100)/10;
    num[2]=n%10;
   if(n>num[0]*111) cout<<(num[0]+1)*111;
   else cout<<num[0]*111;
   return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<P> p(N);
	rep(i,N){
		ll tmp; cin>>tmp;
		p[i]=mp(tmp,i);
	}
	sort(p.bg,p.ed);
	ll l=p[N/2-1].a,r=p[N/2].a;
	vector<ll> ans(N,l);
	for(int i=0;i<=N/2-1;i++){
		ll tp=p[i].b;
		ans[tp]=r;
	}
	rep(i,N) cout<<ans[i]<<endl;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a;
  cin>>a;
  string s;
  cin>>s;
  
  long long int b=0;
  int p=(s[0]-'0');
  int q=(s[2]-'0');
  int r=(s[3]-'0');
  b=b+((p*100)+(10*q)+(1*r));
  b=(b*a);
  cout<<(b/100)<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;





int main(){

    int A[4][4];

    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            cin>>A[i][j];
        }
    }

    int N; cin>>N;

    for(int k=1;k<=N;k++){
        int b; cin>>b;


    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            if(A[i][j]==b) A[i][j] = 0;
        }
    }

    }

    int ans = 0;

    if(A[1][1] == A[2][2] and A[2][2]==A[3][3]) ans = 1;
    if(A[1][3] == A[2][2] and A[2][2] == A[3][1]) ans =1;

    for(int i=1; i<=3;i++){
        if(A[i][1] == A[i][2] and A[i][2] == A[i][3]) ans = 1;
    }


    for(int i=1 ;i<=3;i++){
        if(A[1][i] == A[2][i] and A[2][i] == A[3][i]) ans = 1;
    }


if(ans == 1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const string ans[]={"First","Second"};
vector<int> A;
long long D[2][3000][3000];

long long solve(int t, int l, int r)
{
	if(l>r) return 0;
	if(D[t][l][r]!=0x7f7f7f7f7f7f7f7fLL) return D[t][l][r];
	if(t) {
		D[t][l][r]=max(solve(!t,l+1,r)+A[l],solve(!t,l,r-1)+A[r]);
	}
	else {
		D[t][l][r]=min(solve(!t,l+1,r)-A[l],solve(!t,l,r-1)-A[r]);
	}
	return D[t][l][r];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	cin>>N;
	A.resize(N);
	for(int i=0;i<N;i++) {
		cin>>A[i];
	}
	memset(D,0x7f,sizeof(D));
	cout<<solve(1,0,N-1)<<'\n';
	return 0;
}

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

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    if(n!=m) {
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<n; i++){
        int ok = 1;
        for(int j=0; ok && j<m; j++){
            if (t[j]!=s[(i+j)%n])
                ok = 0;
        }
        if (ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  string s;
  cin >> s;
  if(s[0] == s[1]) cout << "Bad\n";
  else if(s[2] == s[1]) cout << "Bad\n";
  else if(s[2] == s[3]) cout << "Bad\n";
  else cout << "Good\n";
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  cin>>s;
  int j = 700;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == 'o'){
      j += 100;
    }
  }
  cout<<j<<endl;
}

Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int main()
{
  long int n,d;
  cin>>n>>d;
  long int a,b,res=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a>>b;
    if((a*a + b*b)<=d*d)
      res++;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 3548
#include<cstdio>
#include<cstdio>
#include<cstring> 
using namespace std;
int main()
{
	char a[10001];
	scanf("%s",a+1);
	if(a[1]=='Y'&&a[2]=='A'&&a[3]=='K'&&a[4]=='I')
	printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include <stdio.h>
 
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if(i==1 || i==h || j==1 || j==w)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}



Measured memory_bytes: 2040
a=[]
for i in range(3):
    a.append(list(map(int, input().split())))

n=int(input())

b=[]
for i in range(n):
    b.append(int(input()))

for bingo in b:
    for gyou in range(3):
        for retu in range(3):
            if a[gyou][retu]==bingo:
                a[gyou][retu]=True

if a[0][0]==True and a[0][1]==True and a[0][2]==True:
    print("Yes")
    exit()
elif a[1][0]==True and a[1][1]==True and a[1][2]==True:
    print("Yes")
    exit()
elif a[2][0]==True and a[2][1]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][0]==True and a[1][0]==True and a[2][0]==True:
    print("Yes")
    exit()
elif a[0][1]==True and a[1][1]==True and a[2][1]==True:
    print("Yes")
    exit()
elif a[0][2]==True and a[1][2]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][0]==True and a[1][1]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][2]==True and a[1][1]==True and a[2][0]==True:
    print("Yes")
    exit()

print("No")

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline int sz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool cmax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool cmin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int n, l;
    cin >> n >> l;
    vi v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];
    vi dp(l + 1);
    repp(i, l) {
        dp[i] = dp[i - 1];
        rep(j, n) {
            if (i >= w[j])
                cmax(dp[i], dp[i - w[j]] + v[j]);
        }
    }
    prt(dp[l]);

    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cstdlib>
using namespace std;

int main(){
	string S;
	string str;
	vector<string> result;
	cin >> S;
	istringstream iss(S);
	int count=0;
	getline(iss,str,'/');
	int num1 = atoi(str.c_str());
	getline(iss,str,'/');
	int num2 = atoi(str.c_str());
	getline(iss,str,'/');
	int num3 = atoi(str.c_str());
	if(num1 > 2019){
		count++;
	}else if((num1 == 2019 && num2 > 4) || (num1 == 2019 && num2 == 4 && num3>30)){
		count++;
	}

	if(count == 0){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
}


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

int main() {
    int N;
    int D, X;
    int A[100];

    cin >> N;
    cin >> D >> X;

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

    int Choco_num = 0;

    for (int i = 0; i < N; i++) {
        int j = 1;
        while (j <= D) {
            Choco_num++;
            j += A[i];
        }
    }

    cout << Choco_num  + X<< endl;
}


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

namespace ACBC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 3 || x == 5 || x == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadKey();

            }
    }
}


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

int main(){
	int n,x,t;
	cin>>n>>x>>t;
	int tmp=n/x;
	if(n%x==0){
		cout<<tmp*t<<endl;
	}
	else{
		cout << (tmp+1)*t << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import sys
import math

INF = 10**9+7

def k(i):
    if(i == 1):
        return 1
    else:
        return(i * k(i-1))

def comb(n, r):
    if(n == r or r == 1):
        return 1
    else:
        return k(n) / (k(n-r) * k(r))

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

a = ns()
b = ns()


an = len(a)
bn = len(b)


if(an > bn):
    print("GREATER")
    exit()
elif(an < bn):
    print("LESS")
    exit()

for i in range(an):
    if(a[i] > b[i]):
        print("GREATER")
        exit()
    elif(b[i] > a[i]):
        print("LESS")
        exit()

print("EQUAL")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n;
  cin>>n;
  vi a(n),b(n),c(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n-1){
    cin>>c[i];
  }

  int ans=0,p=100000;
  rep(i,n){
    ans+=b[a[i]];
    if(p==a[i]-1) ans+=c[a[i]-1];
    p=a[i];
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

//Bの方は+n
int bb[2][2010];
//bb[0][i]=Wiのある位置
int a[4010];
//a[i]=位置iにある数
int tt[4010][2010];
//tt[i][j]=B1～Bjの内、Wiより上にあるものの個数

ll dp[4010][2010];
//dp[i][j]=iまで見てWがjまで揃ってる最短手数
int main(){
	int n;
	scanf("%d\n",&n);
	rep(i,0,2*n){
		char c;int t;
		scanf("%c%d\n",&c,&t);
		a[i]=(c=='B')*n+t;
		bb[c=='B'][t]=i;
	}
	rep(i,1,n+1)rep(j,1,n+1)if(bb[0][i]>bb[1][j])tt[i][j]=1;
	rep(i,1,n+1)rep(j,1,n+1)if(bb[1][i]>bb[0][j])tt[n+i][j]=1;
	rep(i,1,n+n+1){
		rep(j,1,n+1){
			tt[i][j]+=tt[i][j-1];
//			printf("%lld ",tt[i][j]);
		}
//		puts("");
	}
	
	
	rep(i,0,n+n+1)rep(j,0,n+1)dp[i][j]=INF;
	dp[0][0]=0;
	
	rep(i,1,n+n+1)rep(j,max(i-n,0),n+1){
		if(j==0){
			//BiをW1より上へ
			dp[i][j]=dp[i-1][j]+tt[n+i][n];
		}else{
			//WjがB(i-j+1)以降を追い抜くか、
			//B(i-j)がW(j+1)以降を追い抜く
			dp[i][j]=min(dp[i-1][j-1]+tt[j    ][n]-tt[j    ][i-j],
						 dp[i-1][j  ]+tt[i-j+n][n]-tt[i-j+n][j]);
		}
	}
/*	rep(i,0,7){
		rep(j,0,4)printf("%lld ",dp[i][j]);
		puts("");
	}
	printf("%lld\n",dp[n+n][n]);
*/
	ll cnt=0;
	rep(kkk,0,2*n)rep(i,0,2*n-1)if(a[i]>a[i+1]){
		if(!((a[i]>n)^(a[i+1]>n)))cnt++;
		int t=a[i];a[i]=a[i+1];a[i+1]=t;
	}
	printf("%lld\n",dp[n+n][n]+cnt);
	
	return 0;
}

Measured memory_bytes: 94464
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main(){
  int A,B,K,g;
  cin>>A>>B>>K;
  g=gcd(A,B);
  vector<int> X(15);
  int j=0;
  	for(int i=1;i<=g;i++){
      if(g%i==0){
        X.at(j)=g/i;
        j++;
      }
     
    }
  cout<<X.at(K-1);
}


Measured memory_bytes: 384
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> tree(N);
    for(int i = 0; i < N; i++){
        cin >> tree[i];
    }
    sort(tree.begin(),tree.end());
    ll mini = INF;
    for(int i = 0; i <= N - K ; i++){
        mini = min(mini,tree[i+K-1]-tree[i]);
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {

  var inp = input.split('\n');
  var X = parseInt(inp[0]);
  var A = parseInt(inp[1]);
  var B = parseInt(inp[2]);

  var tmp = parseInt((X - A) / B);
  var ans = X - A - tmp * B;

  console.log('%d', ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H*W+1, vector<int>(2));
    for (int i = 0; i < H; i++){
	for (int j = 0; j < W; j++){
	    int a;
	    cin >> a;
	    A[a][0] = i+1;
	    A[a][1] = j+1;
	}
    }
    int Q;
    cin >> Q;
    vector<vector<int>> q(Q, vector<int>(2));
    for (int i = 0; i < Q; i++){
	int l, r;
	cin >> l >> r;
	q[i][0] = l;
	q[i][1] = r;
    }

    vector<int> d(H*W+1, 0);
    for (int i = 1; i <= H*W; i++){
	if (i <= D) continue;

	int p = i-D;
	d[i] = d[p]+(abs(A[i][0]-A[p][0])+abs(A[i][1]-A[p][1]));
    }

    for (int i = 0; i < Q; i++){
	int l = q[i][0], r = q[i][1];
	cout << d[r]-d[l] << endl;
    }

    return 0;
}


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

int main(){
    int N,M;
    cin >> N >> M;
    int a[M*2];
    for(int i=0;i<M*2; ++i) cin >> a[i];
    int tmp[N+1] = {0};
    for(int i=0;i<M*2;++i) {
        tmp[a[i]]++;
    }
    for(int i=1;i<=N;++i) {
        cout << tmp[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    int[] X = new int[N];
    int[] Y = new int[N];
    
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      Y[i] = X[i];
    }

    sc.close(); 

    Arrays.sort(X);

    int b = X[N/2];
    int s = X[N/2-1];

    for (int i = 0; i < N; i++) {
      if (Y[i] <= s) {
        System.out.println(b);
      } else {
        System.out.println(s);
      }
    }
  
  }

}

Measured memory_bytes: 93616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a;i>b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=1e5+10;
#define MAX 2*1e9;
#define fi first
#define se second
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	string s;
	ll i;
	bool b=1;
	string t;
	cin>>s>>t;
	rep(i,s.length())
	{
		if(s[i]!=t[i])
			{b=0;break;}
	}
	if(b)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;




	
	return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
from itertools import product
from collections import Counter, defaultdict
from string import ascii_uppercase as ABC
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

S = input()
ans = 0
for i in range(len(S)//2):
    if S[i] != S[-i-1]:
        ans += 1
print(ans)


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

int f(int n){
  int res = 0;
  int fn = 0;
  for(int x = 1; x<150; x++){
    for(int y = 1; y<150; y++){
      for(int z = 1; z<150; z++){
        fn = x*x + y*y + z*z + x*y + y*z + z*x;
        if(fn == n) res++;
        if(fn > n){
          fn = 0;
          break;
        }
      }
      if(fn > n) break;
    }
    if(fn > n) break;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  for(int i = 1; i<=n; i++){
    cout << f(i) << endl;
  }
}

Measured memory_bytes: 3616
import copy
a = [list(map(int, input().split())) for _ in range(5)]
b = copy.deepcopy(a) #二次元配列だと単純なコピーでは参照が残る。
a2 = []
diff = 0
total = 0

for i in range(5):
    b[i][0] = (0 - (-b[i][0]//10)*10)
    a2.append(b[i][0])

total = sum(a2)

for i in range(5):
    diff1 = b[i][0] - a[i][0]
    diff = max(diff, diff1)

ans = total - diff
print(ans)

Measured memory_bytes: 3444
from collections import Counter


n = int(input())
v = list(map(int, input().split()))

v_odd = []
v_even = []
for index in range(len(v)):
    i = index + 1
    if i % 2 == 0:
        v_even.append(v[index])
    else:
        v_odd.append(v[index])
# print(v_odd)
# print(v_even)
# print(Counter(v_odd).most_common())
# print(Counter(v_even).most_common())

if Counter(v_odd).most_common()[0][0] != Counter(v_even).most_common()[0][0]:
    number_of_rewrites = len(v_odd) - Counter(v_odd).most_common()[0][1]
    number_of_rewrites += len(v_even) - Counter(v_even).most_common()[0][1]
else:
    odd_1st = Counter(v_odd).most_common()[0][1]
    even_1st = Counter(v_even).most_common()[0][1]
    odd_2nd = Counter(v_odd).most_common()[1][1] if len(Counter(v_odd).most_common()) >= 2 else 0
    even_2nd = Counter(v_even).most_common()[1][1] if len(Counter(v_even).most_common()) >= 2 else 0

    number_of_rewrites = min(
        len(v_odd) - odd_1st + len(v_even) - even_2nd,
        len(v_odd) - odd_2nd + len(v_even) - even_1st,
    )

print(number_of_rewrites)


Measured memory_bytes: 17788
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n!=0){
		int cnt=0;
		for(int i=1;i<=1000;i++){
			int sum=0;
			if(n==sum)cnt++;
			for(int j=i;j<=1000;j++){
				sum+=j;
				if(n==sum){cnt++;}

			}
		}
		cout<<cnt-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*  ex4_3
    L40S38  */
#include<stdio.h>
int snow(int west, int east);
int main(void){
    int west,east;
    scanf("%d %d",&west,&east);
    //a:西側の塔の雪に埋もれていない部分の高さ　
    //b:東側の塔の雪に埋もれていない部分の高さ
    printf("%d",snow(west,east));
}

int snow(int west, int east){
    int d=east-west;
    int height=d*(d+1)/2;
    //height:東側の塔の本当の高さ
    return(height-east);
}


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

"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline


def dijkstra(s, G):
    pq = []
    d = [float('inf')] * len(G)
    d[s] = 0
    heappush(pq, (0, s))

    while pq:
        c, v = heappop(pq)
        if d[v] < c:
            continue
        for t, c in G[v].items():          #  ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
            if d[t] > d[v] + c: #  ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
                d[t] = d[v] + c
                heappush(pq, (d[t], t)) #  python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
    return d


def main(args):
    while True:
        n, k = map(int, input().split())
        if n == 0 and k == 0:
            break

        G = [{} for _ in range(n+1)]
        costs = [[float('inf')]*(n+1) for _ in range(n+1)]

        for _ in range(k):
            data = [int(x) for x in input().split()]
            if data[0] == 0:
                f, t = data[1], data[2]
                costs[f] = dijkstra(f, G)
                if costs[f][t] == float('inf'):
                    print(-1)
                else:
                    print(costs[f][t])
            else:
                f, t, c = data[1], data[2], data[3]
                if t in G[f]:
                    G[f][t] = min(G[f][t], c)
                else:
                    G[f][t] = c
                if f in G[t]:
                    G[t][f] = min(G[t][f], c)
                else:
                    G[t][f] = c


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

Measured memory_bytes: 8664
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll k, a, b; cin >> k >> a >> b;
    reprr(i, a, b + 1) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

#define INF 1000000000000


int main(){
  ll n=0;
  string s="00";
  cin>>n>>s;
  ll ans=0;
  ll hiku=0;

  vector<int>r,g,b(0);
  rep(i,n){
    if(s[i]=='R'){r.push_back(i);}
    if(s[i]=='G'){g.push_back(i);}
    if(s[i]=='B'){b.push_back(i);}
  }
  ll rsize=0,gsize=0,bsize=0;
  rsize=r.size();
  gsize=g.size();
  bsize=b.size();
  rep(i,rsize){
    rep(j,gsize){
      if(r[i]-g[j]>0){
        if(r[i]+(r[i]-g[j])<=n-1){if (s[r[i]+(r[i]-g[j])]=='B'){hiku++;}}
        if(g[j]-(r[i]-g[j])>=0){if (s[g[j]-(r[i]-g[j])]=='B'){hiku++;}}
      }
      else{
        if(r[i]-(g[j]-r[i])>=0){if (s[r[i]-(g[j]-r[i])]=='B'){hiku++;}}
        if(g[j]+(g[j]-r[i])<=n-1){if (s[g[j]+(g[j]-r[i])]=='B'){hiku++;}}
      }
      if((r[i]+g[j])%2==0){if (s[(r[i]+g[j])/2]=='B'){hiku++;}}
      }
    }
  ans=rsize*gsize*bsize-hiku;
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def nCr(n, r):
    a, b = 1, 1
    for i in range(r):
        a = a * (n - i) % MOD
        b = b * (i + 1) % MOD
    
    return a * pow(b, MOD - 2, MOD) % MOD

def Main():
    n, a, b = read_ints()
    num = pow(2, n, MOD) - 1

    print((num - nCr(n, a) - nCr(n, b)) % MOD)   

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9248
N, K = map(int,input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

sunu = [0 for i in range(N+1)]
ans = N


for a in A:
    for j in a:
        if sunu[j] == 0:
            ans -= 1
            sunu[j] += 1

print(ans)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e3+10,mod=1e9+7;
int f[maxn],num[maxn],tmp;
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int main(){
	int n=read(),m=read();
	for(int i=1;(ll)i*i<=n;++i) if(n%i==0){
		num[++tmp]=i;
		if(i*i!=n) num[++tmp]=n/i;
	}
	sort(num+1,num+tmp+1);
	int ans=0;
	REP(i,1,tmp){
		f[i]=(f[i]+ksm(m,(num[i]+1)/2))%mod;
		REP(j,i+1,tmp) if(num[j]%num[i]==0) f[j]=(f[j]+mod-f[i])%mod;
		ans=(ans+(ll)f[i]*num[i]%mod*((num[i]&1)?1:((mod+1)/2)))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    string N;
    cin>>N;
    bool ok=false;
    if(N[0]==N[1] && N[1]==N[2]) ok=true;
     if(N[2]==N[3] && N[1]==N[2]) ok=true;
    cout<<(ok ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;

int main() {
    ll S;
    cin >> S;
    static pii point[3];

    int sq = ceil(sqrt(S));
    point[1].first = point[2].second = sq;
    int dif = (ll)sq * sq - S;
    point[1].second = (dif != 0);
    point[2].first = (ll)sq * sq - S;

    for(int i = 0; i < 3; ++i)
        printf("%d %d ", point[i].first, point[i].second);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String[] input = br.readLine().split(" ");
       int n = Integer.parseInt(input[0]);
       long k = Long.parseLong(input[1]);
       long[] cnt = new long[100000+1];
       for(int i = 0;i < n;i++){
       	input = br.readLine().split(" ");
       	cnt[Integer.parseInt(input[0])] += Integer.parseInt(input[1]);
       }
       for(int i = 1;i <= 100000;i++){
       	if(k <= cnt[i]){
       		System.out.println(i);
       		break;
       	}
       	k -= cnt[i];
       }
   }
       

}

Measured memory_bytes: 49692