akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <csetjmp>
#include <cmath>
#include <utility>
#include <stack>
#include <queue>
#include <list>

#define SQ(X) \
  ( (X) * (X) )
#define N 1000

using namespace std;

typedef pair<double,int> arw;

typedef struct Building
{
  int x;
  int y;
  int mark;
  int p;
  double j;
  list<arw> neighbor;

  Building (
    )
  {
    x = -1;
    y = -1;

    return ;
  }
} Building;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  list<arw>::iterator it;
  int i, j;

  for ( ; ; )
  {
    Building d[ N + 1 ];
    jmp_buf cont;
    int n;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;

    /* ビル情報入力 */
    for ( i = 0; i < n; ++i )
    {
      int b, x, y;

      scanf ( "%d%d%d", &b, &x, &y );
      d[ b ].x = x;
      d[ b ].y = y;
    }

    /* 隣接点データを構築 */
    for ( i = 1; i <= N; ++i )
    {
      if ( d[ i ].x == -1 ) continue ;

      for ( j = i + 1; j <= N; ++j )
      {
        int r2;

        if ( d[ j ].x == -1 ) continue ;

        r2 = SQ( d[ j ].x - d[ i ].x ) + SQ( d[ j ].y - d[ i ].y );
        if ( r2 <= SQ( 50 ) )
        {
          d[ i ].neighbor.push_back ( make_pair ( sqrt ( r2 ), j ) );
          d[ j ].neighbor.push_back ( make_pair ( sqrt ( r2 ), i ) );
        }
      }
    }

    scanf ( "%d", &n );
    while ( n-- )
    {
      priority_queue<arw, vector<arw>, greater<arw> > lis;
      int src, dst;

      scanf ( "%d%d", &src, &dst );

      /* 初期化 */
      for ( i = 0; i <= N; ++i )
      {
        d[ i ].mark = 0;
        d[ i ].p = 0;
        d[ i ].j = 1e8;
      }

      /* 総距離優先探索 */
      lis.push ( make_pair( 0., dst ) );
      if ( setjmp ( cont ) == 0 )
      {
        while ( !lis.empty ( ) )
        {
          const arw c = lis.top ( );
          lis.pop ( );

          if ( d[ c.second ].mark )
            continue ;

          if ( c.second == src )
          {
            for ( i = src; i != 0; i = d[ i ].p )
            {
              if ( i != src )
                putchar ( ' ' );
              printf ( "%d", i );
            }
            puts ( "" );

            longjmp ( cont, 1 );
          }

          for ( it = d[ c.second ].neighbor.begin ( ); it != d[ c.second ].neighbor.end ( ); ++it )
          {
            const double jt = c.first + it->first;

            if ( d[ it->second ].mark )
              continue ;

            if ( jt < d[ it->second ].j )
            {
              d[ it->second ].p = c.second;
              d[ it->second ].j = jt;
              lis.push ( make_pair ( jt, it->second ) );
            }
          }

          d[ c.second ].mark = 1;
        }
        puts ( "NA" );
      }
    }
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 1104
import java.util.Scanner;

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

        if (n % 500 <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21972
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> 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)*}
    };
}
 
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, 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 main() {
/*106
    fn judge(n:i32)->i32{
        let mut ans=0;
        for i in 1..n+1{
            if n%i==0{
                ans+=1;
            }
        }
        ans
    }
    input!{n:i32}
    let mut ans=0;
    for i in 1..n+1{
        if judge(i)==8  && i%2==1{ans+=1;}
    }
    println!("{}", ans);
*/
/*105
*/
    input!{n:i32}
    let mut ans=false;
    for i in 0..n/4+1{
        for j in 0..n/7+1{
            if 4*i+7*j==n{
                ans=true;
                break
            }
        }
    }
    if ans{println!("Yes");}else{println!("No");}



}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  set<int> se;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    se.emplace(x);
  }
  if(se.size()==n){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 9600
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]
 
# 10^(N-1)から10^Nの数を順に調べる
# N=1の場合のみ、0から10であることに注意
if N == 1:
  a, b = 0, 10
elif N >= 2:
  a, b = 10**(N-1), 10**N

ans = -1
for i in range(a, b):
  tmp = str(i)
  flag = True
  for j in range(M):
    if tmp[arr[j][0]-1] != str(arr[j][1]):
      flag = False
  if flag:
    ans = i
    break

print(ans)

# Memo: 0からNの中でM個の条件全てを満たす整数を求めるときは、以下のようにする
'''
a = -1
for i in range(N):
  flag = True
  for j in range(M):
    if 条件を満たさない: flag = False
  if flag:
    a = i
    break
'''

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

int main(){
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  intl N;
  cin >>N;
  map<intl,intl> A;
  int a;
  intl Asum = 0;
  Rep(i,N){
    cin >>a;
    Asum += a;
    if(A.count(a) ){
      A.at(a) ++;
    }
    else{ A.insert(make_pair(a,1));}
  }
  
  intl Q;
  cin >>Q;
  
  intl b,c;
  Rep(i,Q){
    cin >>b>>c;
    int num;
    if(A.count(b)){
      num = A.at(b);
      if(A.count(c)){
        A.at(c) += num;
        Asum += num * (c - b); 
        A.erase(b);
      }else{
        A[c] = 0;
        A[c] += num;
        Asum += num * (c - b);
        A.erase(b);
      }
    }
    
    cout << Asum <<'\n';
  }
}

Measured memory_bytes: 7588
n = int(input())
v_inputs =[int(i) for i in input().split()]

while v_inputs:
    if len(v_inputs)==1:
        print(v_inputs[0])
        break
    v_inputs = sorted(v_inputs)
    x=v_inputs.pop(0)
    y=v_inputs.pop(0)
    v_inputs.append((x+y)/2)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

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

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

    ll cnt=0;
    for(int i=K;i<H.size();++i)
    {
        cnt+=H[i];
    }

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

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		int count=0;
		int anse=0;
		for(int i=Math.min(a,b);i>0;i--){
			if(a%i==0&&b%i==0){
				count++;
				if(count==k){
					System.out.println(i);
					return;
				}
			}
		}
		
	}
}


Measured memory_bytes: 35652
n,m = map(int, input().split())
h=list(map(int, input().split()))
good=[True]*n
for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    good[b-1]=False
  if h[b-1] > h[a-1]:
    good[a-1]=False
  if h[a-1] == h[b-1]:
    good[b-1]=False
    good[a-1]=False
ans=0
for i in good:
  if i:
    ans+=1
print(ans)

Measured memory_bytes: 20020
#B
s=input()
t=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="L":
            t=10
            break
    else:
        if s[i]=="R":
            t=10
            break
if t==0:
    print("Yes")
else:
    print("No")

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

int main() {
  int k; cin >> k;
  long long int out = 0;
  for(int i = 1; i <= k; i++) out += i;
  for(int i = 1; i < k; i++){
    for(int j = i + 1; j <= k; j++){
      int ti = i, tj = j;
      while(tj % ti != 0){
        int tmp = tj;
        tj = ti;
        ti = tmp % ti;
      }
      out += 6 * ti;
    }
  }
  for(int i = 1; i < k - 1; i++){
    for(int j = i + 1; j < k; j++){
      for(int l = j + 1; l <= k; l++){
        int ti = i, tj = j, tl = l;
        while(tl % tj != 0){
          int tmp = tl;
          tl = tj;
          tj = tmp % tj;
        }
        if(tj < ti){
          int tmp = ti;
          ti = tj;
          tj = tmp;
        }
        while(tj % ti != 0){
          int tmp = tj;
          tj = ti;
          ti = tmp % ti;
        }
        out += 6 * ti;
      }
    }
  }
  cout << out;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n], b[n];
    for (int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a, a+n);
    sort(b, b+n, greater<int>());
    if (n % 2) {
        cout << b[n/2] - a[n/2] + 1 << '\n';
    } else {
        cout << (b[n/2] + b[(n-1)/2]) - (a[n/2] + a[(n-1)/2]) + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 6728
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll x, y;
  cin >> x >> y;
  
  if (abs(x-y) < 2)
    cout << "Brown" << endl;
  else
    cout << "Alice" << endl;

  return 0;
}


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

int main() {
	int n = 5;
	int i = 1;
	while (n--) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i;
			return 0;
		}
		++i;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
const int _max = 100010;
typedef long long ll;


int main()
{
    char n;
    cin>>n;
    if(n>='A'&&n<='Z'){
        cout<<'A';
    }else{
        cout<<'a';
    }
    return 0;
}

Measured memory_bytes: 3628
import sys
from string import ascii_lowercase as alphabets
from collections import Counter

def main():
    inf=100
    alphd={x:0 for x in alphabets}
    ansd={x:inf for x in alphabets}
    n=int(input())
    s=[input() for _ in range(n)]
    for st in s:
        for x in st:
            alphd[x]+=1
        for a in alphabets:
            ansd[a]=min(ansd[a],alphd[a])
            alphd[a]=0
    print(''.join([a*ansd[a] for a in alphabets if ansd[a]<inf]))
    

def main2():
    inf=100
    n=int(input())
    s=[Counter(input()) for _ in range(n)]
    ansd={x:inf for x in alphabets}
    for c in s:
        for x in alphabets:
            ansd[x]=min(ansd[x],c[x])
    print(''.join([a*ansd[a] for a in alphabets if ansd[a]<inf]))

if __name__=='__main__':
    main2()


Measured memory_bytes: 9956
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n;
bool b[25][25];
int dp[22][1<<21];
signed main() {
	cin>>n;
	rep(i,n)rep(j,n)cin>>b[i][j];
	dp[0][0]=1;
	rep(i,n){
		rep(j,1<<n){
			dp[i][j]%=mod;
			if(__builtin_popcount(j)!=i)continue;
			rep(k,n){
				if(!(j>>k&1)&&b[i][k]){
					dp[i+1][j|(1<<k)]+=dp[i][j];
				}
			}
		}
	}
	cout<<dp[n][(1<<n)-1]%mod<<endl;
}


Measured memory_bytes: 346368
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



ll fun(ll n) {
    ll val = n * (n-1);
        return val / 2;
}


void test_case() {

    ll n;
    cin>>n;

    vecl arr(n+1,LONG_MAX);
    fo(i,1,n) {
        cin>>arr[i];
    }

    unordered_map<ll,ll> mp;
    for(int i=1; i<=n; i++) {
        mp[arr[i]]++;
    }

    ll ans = 0;

    for(auto it : mp) {
        if(it.second > 1) {
            ans += fun(it.second);
        }
    }

    // cout<<ans<<endl;


    for(int i=1; i<=n; i++) {

        ll val = mp[arr[i]];
        ll temp = ans;

        if ( val > 1) {
            temp = temp - fun(val) + fun(val - 1);
        }

        cout<<temp<<endl;



    }




  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 11832
from collections import defaultdict


N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
al = []
for a in A:
    al += a

d = defaultdict(int)

for v in al:
    d[v] += 1

for i in range(N):
    print(d[i+1])


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

import static java.lang.Integer.parseInt;

/**
 * Country Road
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int t = parseInt(br.readLine());
		for (int i = 0; i < t; i++) {
			line = br.readLine();
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int k = parseInt(line.substring(line.indexOf(' ') + 1));

			if (n <= k) {
				br.readLine();
				System.out.println(0);
				continue;
			}

			//
			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line);

			int[] d = new int[n - 1];
			int ans = 0;

			int prev = parseInt(st.nextToken());

			for (int j = 0; j < n - 1; j++) {
				int next = parseInt(st.nextToken());
				d[j] = next - prev;
				prev = next;
				ans += d[j];
			}

			Arrays.sort(d);

			for (int j = 0, l = d.length - 1; j < k - 1 && l > 0; j++, l--) {
				ans -= d[l];
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 63384
import sys
import bisect
input=sys.stdin.readline
a,b,q=map(int,input().split())
s=[ int(input()) for _ in range(a)]
t=[ int(input()) for _ in range(b)]
#print(s,end=" s\n")
#print(t,end=" t\n")
for _ in range(q):
  x=int(input())
  sr=bisect.bisect_left(s,x)
  sr=sr-1 if sr==len(s) else sr
  sl=sr-1 if sr>0 else sr 
  tr=bisect.bisect_left(t,x)
  tr=tr-1 if tr==len(t) else tr
  tl=tr-1 if tr>0 else tr
 # print(sl,sr,tl,tr)
  def f(i,j):
    #print( abs(x-s[i]),abs(x-t[j]))
    return min(abs(x-s[i]),abs(x-t[j]))+abs(t[j]-s[i])
#  print(x)
#  print(f(sl,tl),f(sl,tr),f(sr,tl),f(sr,tr))
  ans=min(f(sl,tl),f(sl,tr),f(sr,tl),f(sr,tr))
  print(ans)



  




Measured memory_bytes: 12200
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    unsigned long long r,c, ans;
    cin >> r >> c;
    if(r>1&&c>1){
    	ans =(r*c);
   		if(ans&1) cout << (ans/2)+1;
   		else cout << (ans/2);
    } else {
    	cout << 1;
    }
    
   	cout << "\n";

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
sumgrid = [[0] * w for i in range(h)]   # 個数を集計していく表

for i in range(h):
    # 1行読み込んで1か0の配列に変換
    line = list(map(int, input().replace('#', '1 ').replace('.', '0 ').split()))

    for j in range(w):
        # 現在の位置を含む3マス幅分の爆弾の数
        bom_cnt = line[j-1] if 0 < j else 0
        bom_cnt += line[j]
        bom_cnt += line[j+1] if j < (w - 1) else 0

        # カレント行に足し込む
        if line[j] == 0:
            sumgrid[i][j] += bom_cnt
        else:
            sumgrid[i][j] = '#' # 爆弾マス

        # 上の行の集計に足し込む
        if 0 < i and sumgrid[i-1][j] != '#':
            sumgrid[i-1][j] += bom_cnt

        # 下の行の集計に足し込む
        if i + 1 < h:
            sumgrid[i+1][j] += bom_cnt

for i in range(h):
    print(''.join([str(n) for n in sumgrid[i]]))


Measured memory_bytes: 3064
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static int n;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int size=1;
		dfs(new StringBuilder("a"),1,1);
	}
	static void dfs(StringBuilder sb,int count,int var){
		if(count==n){
			System.out.println(sb);
			return;
		}
		for(int i=0; i<=var; i++){
			dfs(new StringBuilder(sb).append((char)((int)'a'+i)),count+1,Math.max(i+1,var));
		}
	}
}


Measured memory_bytes: 45024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
  	int val = n%10;
  	if(val == 3){
      cout<<"bon";
    }
  	else if(val==0 || val==1 ||val==6 ||val==8){
    	cout<<"pon";
    }
  	else{
  		cout<<"hon";
  	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef long double llu;

const lld MAX = 555555;
vector<lld> G[MAX];
map<lld, lld> mp;
lld finalAns[MAX];

void dfs(lld u, lld val, lld par = -1)
{
    finalAns[u] = val;
    for(lld i = 0; i < G[u].size(); i++) {
        lld to = G[u][i];
        if(to != par) {
            dfs(to, finalAns[u] + mp[to], u);
        }
    }
    return;
}

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        lld n, q;
        cin >> n >> q;

        for(lld i = 0; i < n - 1; i++) {
            lld u, v;
            cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }

        for(lld i = 0; i < q; i++) {
            lld id, val;
            cin >> id >> val;
            mp[id] += val;
        }
        lld val = 0;
        if(mp.find(1) != mp.end()) {
            val = mp[1];
        }
        dfs(1, val);
        for(lld i = 1; i <= n; i++) {
            cout << finalAns[i] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 54784
from itertools import combinations
from collections import defaultdict
import sys
input = sys.stdin.readline

N = int(input())
S = [input().rstrip() for _ in range(N)]
cnt = defaultdict(int)
for s in S:
    if s[0] in 'MARCH':
        cnt[s[0]] += 1
ans = 0
for comb in combinations('MARCH', 3):
    ans += cnt[comb[0]] * cnt[comb[1]] * cnt[comb[2]]
print(ans)

Measured memory_bytes: 48860
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    vector<ll> B(m), C(m);
    rep(i, m) cin >> B[i] >> C[i];
    
    typedef pair<ll, ll> P;
    
    priority_queue<P, vector<P>, greater<P>> que;
    rep(i, n) que.push(P(A[i], 1));

    rep(i, m) {
        ll cnt = 0;
        ll b = B[i];
        while (true) {
            if (que.empty()) break;

            P q = que.top();
            if (q.first >= C[i]) {
                break;
            }
            else {
                que.pop();
                cnt += q.second;
                if (b < cnt) {
                    P q2 = P(q.first, cnt - b);
                    que.push(q2);
                    cnt = b;
                }
                if (b == cnt) {
                    break;
                };
            }
        }
        que.push(P(C[i], cnt));
    }

    ll res = 0;
    while (que.empty() == false) {
        res += que.top().first * que.top().second;
        que.pop();
    }
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 7712
#include <bits/stdc++.h>
    
#define int long long

#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;

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

int32_t main(){
    int n;
    cin >> n;
    vector<int> v;
    set<int> s;
    REP(i, n){
        int a;
        cin >> a;
        if(s.find(a)!=s.end()){
            v.pb(a);
            s.erase(a);
        }
        else s.insert(a);
    }
    SORT(v);
    
    if(v.size()<2){
        cout << 0 << endl;
    }
    else{
        cout << v[v.size()-1]*v[v.size()-2] << endl;
    }
    
}

Measured memory_bytes: 4992
def main():
    N,K = map(int,input().split())

    A,AB = set(),{}
    for i in range(N):
        a,b = map(int,input().split())
        if a not in A:
            A.add(a)
            AB[a] = b
        else:
            AB[a] += b

    A = list(A)
    A.sort()

    for i in range(len(A)):
        K -= AB[A[i]]
        if K <= 0:
            ans = A[i]
            break

    print(ans)

if __name__ == "__main__":
    main()


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

#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";
#define L_MAX 1e16


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

/*
#ifndef ONLINE_JUDGE
freopen("inpute.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
*/

int t=1, x = 0;
//cin>>t;
while(t--)
{ 
  int n, k;cin>>n>>k;
  int i=0, j = k;
  lli ar[n];for(lli &x:ar) cin>>x;
  while(j<n)
  {
    if(ar[j]>ar[i]) cout<<"Yes\n";
    else cout<<"No\n";
    j++;i++;
  }

} 


return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200)
	{
		cout << s << endl;
	}
	else
	{
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

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

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b) ; }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}

void read(vt<int> &a) {
    rep(i,0,a.size()) 
        cin >> a[i] ; 
}
void read(vt<ld> &a) {
    rep(i,0,a.size()) 
    cin >> a[i] ; 
}

bool prime(ll t) {
    for(ll i  =2 ; i*i <= t ; ++i) {
        if(t%i==0) 
            return 0 ; 
    }
    return 1 ; 
}
bool cmp(pii &a , pii &b) {
    if(a.ss == b.ss) 
        return a.ff > b.ff ; 
    return a.ss < b.ss ; 
}

// ==========Start Here==============



int main() 
{ 
    int n ;
    cin >> n ; 
    vt<ll> a(n); 
    rep(i,0,n) cin >> a[i] ;  
    ll sum= 0;
    vt<ll> sums(n) ;  
    rep(i,0,n){
        sum += a[i] ; 
        sum %= mod; 
        sums[i] = sum ; 
      //  cout << sums[i] << " " ; 
    }

    ll ans = 0 ; 
    rep(i,1,n) {
        ans += (sums[i-1]*a[i])%mod ;
        ans %= mod ;
    }
    cout << ans ; 


    return 0; 
} 

Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

template<class T, class ResultType = long long> vector<ResultType> binary_representation(T x, int const LeastDigit = 0) {if(x == 0) return {0};vector<ResultType> ret;while(x > 0) {ret.push_back(x % 2);x /= 2;}while((int)ret.size() < LeastDigit) {ret.push_back(0);}reverse(all(ret));return ret;}
template<class T> ostream& operator << (ostream& ost, vector<T> && v) { for(auto && e: v) ost << e; return ost; }
template<class T> ostream& operator << (ostream& ost, vector<T> const& v) { ost << "["; rep(i, v.size()) { if(i) ost << ", "; ost << v[i]; } ost << "]"; return ost; }

int main() {

  string pstr;
  rep(i, 10) pstr += '0' + i;
  rep(i, 26) pstr += 'A' + i;
  rep(i, 26) pstr += 'a' + i;

  int N; cin >> N;

  ll s = 0;
  rep(i, N) {
    ll p; string m; cin >> p >> m;
    ll x = 0;
    ll u = 1;
    reverse(all(m));
    rep(i, m.size()) {
      x += pstr.find(m[i]) * u;
      u *= p;
    }

    auto vx = binary_representation(x);

    int cnt = 0;
    rep(i, vx.size()) {
      if(vx[i] == 0 && cnt > 0) {
        s ^= cnt;
        cnt = 0;
      } else {
        if(vx[i] == 1) {
          cnt ++;
        }
      }
    }
    if(cnt) s ^= cnt;
  }

  cout << (s ? "win" : "lose") << endl;
  
  return 0;
}

Measured memory_bytes: 3192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> 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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize
    }
    if n % 2 == 1 {
        for i in (1..=m).rev() {
            println!("{} {}", i, n + 1 - i);
        }
        return;
    }
    let mut c = 0;
    for i in 1..n / 2 {
        if c == m || i >= n / 2 - i {
            break;
        }
        println!("{} {}", i, n / 2 - i);
        c += 1;
    }
    for i in n / 2..n {
        if c == m || i >= n - 1 - (i - n / 2) {
            break;
        }
        println!("{} {}", i, n - 1 - (i - n / 2));
        c += 1;
    }
}


Measured memory_bytes: 2156
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;


int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int d = h2 * 60 + m2 - (h1 * 60 + m1) - k;
  kek(d);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int n,m;

int main()
{
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
 
int main(){

  int k;

  while(cin>>k, k){
    int c, sum=0;
    
    for(int i=0;i<k*(k-1)/2;i++){
      cin>>c;
      sum+=c;
    }
    
    cout<<sum/(k-1)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    long long a[100005];
    long long sum[100005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
        sort(a+1,a+1+n);
        sum[1]=a[1];
    for(int i=2;i<=n;i++)
        sum[i]=a[i]+sum[i-1];
    int ans=1;
    for(int i=n-1;i>=1;i--)
    {
        if(sum[i]*2>=a[i+1])
            ans++;
        else
            break;
    }
        printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main() {
  // N is the length of integer array
  // 2 <= N <= 100
  int N;
  int A[100] = {0};
  std::cin >> N;

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

  int max = A[0], min = A[0];
  for (int i = 0; i < N; ++i) {
    if (A[i] > max) max = A[i];
    if (A[i] < min) min = A[i];
  }

  std::cout << max - min << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int64_t n; cin>>n;

    int64_t ans=0;
    FOR(i, 1, n){
        int64_t s=n/i;
        ans+=i*s*(s+1)/2;
    }

    cout<<ans<<endl;

}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};


signed main(){
    int T;
    cin >> T;
    rep(ti,0,T) {
        int N;
        cin >> N;
        vector<ll> K(N), L(N), R(N);
        rep(i,0,N) cin >> K[i] >> L[i] >> R[i];
        vector<pair<ll, ll>> LR(N);
        rep(i,0,N) LR[i] = {abs(L[i] - R[i]), i};
        sort(all(LR), greater<>());
        ll answer = 0;
        set<int> unusedL, unusedR;
        rep(i,1,N+1) {
            unusedL.insert(i);
            unusedR.insert(i);
        }
        rep(i,0,N) {
            int j = LR[i].second;
            if (L[j] - R[j] >= 0) {
                auto itr = unusedL.upper_bound(K[j]);
                if (unusedL.begin() == itr) {
                    answer += R[j];
                } else {
                    itr--;
                    unusedL.erase(itr);
                    answer += L[j];
                }
            } else {
                auto itr = unusedR.lower_bound(K[j]+1);
                if (itr == unusedR.end()) {
                    answer += L[j];
                } else {
                    unusedR.erase(itr);
                    answer += R[j];
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 29888
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(long i=0;i<(n);i++)
#define For1(i,n) for(long i=1;i<(n);i++)
#define mod 1000000007
int main(){
    string S;
    cin>>S;
    if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(2)){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(S.at(0)==S.at(2)&&S.at(1)==S.at(3)&&S.at(0)!=S.at(3)){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(S.at(0)==S.at(3)&&S.at(1)==S.at(2)&&S.at(0)!=S.at(1)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <map>
#include <string>
#include <iostream>
#include<vector>
#include <set>
#include<math.h>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	int a[3];
	
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a+3);
		if ((a[2]*a[2]) == (a[1] * a[1]) + (a[0] * a[0]))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> houses;
    rep (i, 0, N) {
        int in; cin >> in;
        houses.push_back(in);
    }
    sort(houses.begin(), houses.end());
    cout << houses[houses.size()-1] - houses[0] << endl;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n, u, v;
	cin >> n >> u >> v;
	u--;
	v--;
	vector<vector<int> > graph(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	vector<int> stepFromV(n, -1);
	queue<int> qu;
	qu.push(v);
	stepFromV[v] = 0;
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (stepFromV[next] >= 0) continue;
			stepFromV[next] = stepFromV[now] + 1;
			qu.push(next);
		}
	}
	int ans = 0;
	vector<int> stepFromU(n, -1);
	stepFromU[u] = 0;
	qu.push(u);
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		// cout << now << " " << stepFromU[now] << endl;
		if (graph[now].size() == 1) {
			ans = max(ans, stepFromV[now] - 1);
		}
		for (int i = 0; i < graph[now].size(); i++) {
			int next = graph[now][i];
			if (next == v || stepFromU[next] >= 0 ||
			    stepFromV[next] == stepFromU[now] ||
			    stepFromV[next] == stepFromU[now] + 1)
				continue;
			stepFromU[next] = stepFromU[now] + 1;
			qu.push(next);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6656
n = int(input())
blue = []
for i in range(n):
  blue.append(input())
  
m = int(input())
red = []
for i in range(m):
  red.append(input())
  
s = set(blue)

maxnum = 0
for item in s:
  cnt = blue.count(item) - red.count(item)
  if cnt > maxnum:
    maxnum = cnt

print(maxnum)

  
 

Measured memory_bytes: 3060
import sys

cards_exist = []
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0: continue
    cards_exist.append(line.rstrip('\n'))

for suit in ('S', 'H', 'C', 'D'):
    for num in range(1, 14):
        card = '%s %d' % (suit, num) 
        if card in cards_exist: continue
        print card

Measured memory_bytes: 4208
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);

		int cost = 0;
		for (int i = 0; i < 3; i++) {
			if (i != 0) {
				cost += a[i] - a[i - 1];
			}
		}

		System.out.println(cost);

	}

}


Measured memory_bytes: 23380
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 54304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}
void solve(){
    int ar[3][3];
    for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    cin>>ar[i][j];
    int a,n;
    cin>>n;
    for(int k=0;k<n;k++)
    {
        cin>>a;
        for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      if(ar[i][j]==a)
      ar[i][j]=-1;
    }
    for(int i=0;i<3;i++)
    {
        if(ar[i][0]==-1&&ar[i][1]==-1&&ar[i][2]==-1)
        {
            cout<<"Yes";
            return;
        }
        if(ar[0][i]==-1&&ar[1][i]==-1&&ar[2][i]==-1)
        {
            cout<<"Yes";
            return;
        }
        
    }
    if((ar[0][0]==-1&&ar[1][1]==-1&&ar[2][2]==-1)||(ar[0][2]==-1&&ar[1][1]==-1&&ar[2][0]==-1))
    {
        cout<<"Yes"<<endl;
        return;
    }
    cout<<"No";
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if (Math.abs(N-M) >= 2) {
            System.out.println(0);
            return;
        }
        long count = 1;
        if (N != M) {
            for (int i = N; i > 0; i--) {
                count *= i;
                count %= 1000000007;
            }
            for (int i = M; i > 0; i--) {
                count *= i;
                count %= 1000000007;
            }
        } else {
            for (int i = N; i > 0; i--) {
                count *= i;
                count %= 1000000007;
            }
            for (int i = M; i > 0; i--) {
                count *= i;
                count %= 1000000007;
            }
            count = (count*2)%1000000007;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35496
#include <stdio.h>

int main(){
  char a[120][120];
  int i,j,h,w;
  int tate[120]={};
  int yoco[120]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++) scanf("%s",a[i]);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j] == '#'){
        yoco[i] = 1;
        tate[j] = 1;
      }
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(yoco[i]==1 && tate[j]==1) printf("%c",a[i][j]);
    }
    if(yoco[i] == 1) putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 128