akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();	//?????????????????°?????????
		String[] mark = {"S","H","C","D"};	//?????????????????????S H C D
		String markTmp;
		int num;		//??????????????°???1~13
		boolean[][] trump = new boolean[4][13];
		
		for (int i = 0; i < n; i++) {
				markTmp=sc.next();
				num=sc.nextInt();
				
				//?????£??????????????????????????§??????
				if(markTmp.equals("S")){
					trump[0][num-1]=true;
				}
				else if (markTmp.equals("H")) {
					trump[1][num-1]=true;
				}
				else if (markTmp.equals("C")) {
					trump[2][num-1]=true;
				}
				else if (markTmp.equals("D")) {
					trump[3][num-1]=true;
				}
		}
		
		//?????£??????????????????????????????
		for (int i = 0; i < trump.length; i++) {
			for (int j = 0; j < trump[i].length; j++) {
				if(trump[i][j] == false){
					System.out.println(mark[i]+" "+(j+1));
				}
			}
			
		}
	}
}

Measured memory_bytes: 18072
import Control.Monad
import Data.List
import Text.Printf

indexToMove :: [Int] -> (Int, Int)
indexToMove (b:f:r:v:_) = (((b-1) * 30 + (f-1) * 10 + r), v)

houseMove :: [(Int, Int)] -> [Int] -> [Int]
houseMove [] res = res
houseMove (x:xs) h = let (f, s) = splitAt (fst x) h
                         v = (snd x) + (last f)
                     in houseMove xs ((init f) ++ v:s)

showHouse :: Int -> [Int] -> IO ()
showHouse _ [] = return ()
showHouse n (x:xs) | n `mod` 30 == 0 && n < 120
                                     = do
                                        printf "%2d\n" x
                                        putStrLn . take 20 . repeat $ '#'
                                        showHouse (n+1) xs
                   | n `mod` 10 == 0 = do
                                        printf " %d\n" x
                                        showHouse (n+1) xs
                   | otherwise       = do
                                        printf " %d" x
                                        showHouse (n+1) xs

main = do
    n <- getLine
    ls <- replicateM (read n) getLine
    let move = map (map (read) . words) ls
        moves = map indexToMove move
        houseInit = take 120 . repeat $ 0
        resolve = houseMove moves houseInit
    showHouse 1 resolve

Measured memory_bytes: 5576
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

signed main()
{
   faster;
///   #ifndef ONLINE_JUDGE
  //   freopen("ip.txt", "r", stdin);
 //    freopen("op.txt", "w", stdout);
  // #endif
    // int t;cin>>t;
     //while(t--)
     {
          int n,i,j;
          cin>>n;
          double p[n+1];
          for (int i=1;i<=n;i++)  cin>>p[i];
          double dp[n+1][n+1];
          dp[1][1]=p[1];
          dp[1][0]=1-p[1];
          for ( i=2;i<=n;i++)
          { dp[i][0]=dp[i-1][0]*(1-p[i]);
              dp[i][i]=dp[i-1][i-1]*p[i];
               for (j=1;j<i;j++)
                    dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
          }
          double sum=0;
          for (int j=n/2+1;j<=n;j++)
               sum+=dp[n][j];
         cout.precision(20);
          cout<<sum;
     }
}

Measured memory_bytes: 70272
import collections

if __name__ == "__main__":
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    S_collect = collections.Counter(S)
    S_tp = []
    for word in S_collect.most_common():
        S_tp.append(word)
    S_tp_sort = []
    for i in S_tp:
        if i[1] == S_tp[0][1]:
            S_tp_sort.append(i[0])
        else:
            break
    S_tp_sort = sorted(S_tp_sort)
    for s in S_tp_sort:
        print(s)

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

int main(){
  int N;
  cin>>N;
  int j=0,k=0,p=0,o=0;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    if(A>j){
      k=j;
      o=p;
      j=A;
      p=i;
    }else if(A>k){
      k=A;
      o=i;
    }
  }
  for(int i=0;i<N;i++){
    if(i==p)
      cout<<k<<endl;
    else
      cout<<j<<endl;
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
6
1 1 1 2 2 3
1 1 1 2 2 3
総数に対して半数をうわまわってなければいいか
1 1 1 2 2
2 2 3 3 2
1は2個までOK
2は3個までOK

queueにいれる
4 5 5 6
4 5 5 6

5 4 6 5
5 6 4 5
M[5]=2 [4]=1 [6]=1
queue {5, 4, 6}

[1]={0,2}
[2]={3,5}
[3]={6,8}

[1]={0,2} 2 - 0 + 1 = 3
[3]={3,5} 8 - 3 + 1 = 6
[4]={6,8} 0 - 6 + 1 = -5 = 0
1 1 1 2 2 2 3 3 3 
1 1 1 3 3 3 4 4 4 1 1 1 3 3 3 4 4 4
|3    |6    |0
max = 6
4ずらし

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin >> N;
  vector<pair<ll, ll>> A(200010, {-1, -1}), B(200010, {-1, -1});
  vector<ll> a(200010), b(200010);
  vector<ll> ka(N, 0), kb(N * 2, 0);
  ll a1 = 0;
  rep(i, N){
    ll a2;
    cin >> a2;
    a[a2]++;
    ka[i] = a2;
    if (a1 != a2){
      A[a1].second = i - 1;
      A[a2].first = i;
      a1 = a2;
    }
    if (i == N-1)
      A[a2].second = i;
  }

  ll b1 = 0;
  rep(i, N){
    ll b2;
    cin >> b2;
    b[b2]++;
    kb[i] = b2;
    if (b1 != b2){
      B[b1].second = i - 1;
      B[b2].first = i;
      b1 = b2;
    }
    if (i == N-1)
      B[b2].second = i;
  }
  rep(i, N)
    kb[i + N] = kb[i];
  rep(i, 200001){
    if (a[i] + b[i] > N){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  ll slide = 0;
  for (ll i = 1; i <= 200000; i++){
    if (A[i].first == -1 || B[i].first == -1)
      continue;
//cout << "i:"<< i << " a1:"<<A[i].first<<" a2:"<<A[i].second<<" b1:"<<B[i].first<<" b2:"<<B[i].second<<endl;    
    ll tmp = A[i].second - B[i].first + 1;
    chmax(slide, tmp);
  }
//cout << "slide:"<< slide << endl;  
  slide = N - slide;
  for(ll i = slide; i < N + slide; i++){
    cout << kb[i];
  if (i == N + slide - 1)
      cout << endl;
  else
      cout << " ";
  }
}


Measured memory_bytes: 17196
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  int N; string s;

  cin >> N;
  cin >> s;

  int r=0;
  for(int i=0;i<N;++i){
    if(s[i]=='R') r++;
  }
  int b=N-r;
  if(r>b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
# from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_4
import sys
n=int(input())
blocks=[]
for line in sys.stdin.readlines():
    w,s,v=map(int,line.split())
    blocks.append((w+s,w,s,v))
blocks.sort()

dp=[-1]*20001
dp[0]=0
for _,w,s,v in blocks:
    for i in range(s,-1,-1):
        if dp[i]==-1:
            continue
        dp[i+w]=max(dp[i+w],dp[i]+v)
print(max(dp))


Measured memory_bytes: 42348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main()
{
	// 142_B
	int N;
	int K;
	cin >> N >> K;
//	int h[N] = {};

	int ans = 0;
	int h;
	REP(idx, N) {
		cin >> h;
		if (h >= K) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
import sys

n,m = list(map(int, input().split()))
a = np.asarray([])
r = np.asarray([])
for _ in range(n):
    a = np.append(a,(list(map(int, input().split()))[1:]))
for i in range(m):
    r = np.append(r,np.size(a[a==i+1]))
#print(r)
print(np.size(r[r==n]))


Measured memory_bytes: 12488
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
const ll INF = 1LL<<62;
ll f1(ll a, ll b) {
	if (gcd(2*a, b) != 1) return INF;
	__int128 n = (__int128)(b - 1) * inv_mod(2*a, b) % b;
	if (n == 0) n = b;
	__int128 r = n * a * 2;
	if (r >= INF) return INF;
	return r;
}
ll f2(ll a, ll b) {
	if (gcd(2*a, b) != 1) return INF;
	__int128 n = (__int128)inv_mod(2*a, b);
	if (n == 0) n = b;
	__int128 r = n * a * 2 - 1;
	if (r >= INF) return INF;
	return r;
}
int main() {
	ll N;
	cin >> N;
	ll r = INF;
	for (ll a = 1; a*a <= N; ++ a) if (N % a == 0) {
		ll b = N / a;
		r = min(r, f1(a, b));
		r = min(r, f1(b, a));
		r = min(r, f2(a, b));
		r = min(r, f2(b, a));
	}
	cout << r << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> blacks;
  int cnt=0;
  
  for (int i=0; i<s.length(); i++) {
    if(s[i]=='#') cnt++;
    blacks.push_back(cnt);
  }
  
  int ans=3000000;
  int tmp;
  tmp = (int)(s.length()-1) - (-1) - (blacks[s.length()-1] - 0);
  if(tmp<ans) ans = tmp;
  
  for (int j=0; j< s.length(); j++) {
    tmp = (int)(s.length()-1) - j - (blacks[s.length()-1] - blacks[j]) + blacks[j]; // 変更する白の数 + 黒の数
    if(tmp<ans) ans = tmp;
  }

  tmp = blacks[s.length()-1];
  if(tmp<ans) ans = tmp;
  
  cout << ans << endl;
}

Measured memory_bytes: 1532
test = ""
#test = \
"""
13 7 2
"""
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
    
    
a,b,c = map(int, input2().split())
if a+b+c<22:
    print("win")
else:
    print("bust")

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)

int n,A[50];

bool dp[30][2018]; //dp[i][j]でi番目まで使ってjを作れるかのbool値を返す

int main(){
    cin>>n;
    REP(i,1,n+1) cin>>A[i];
    REP(i,0,n+1) dp[i][0]=true; //i番目まで使って0は作れるのでtrue
    REP(i,0,n+1){
        REP(j,0,2001){
            if(j+A[i]<=2000&&dp[i][j]){
                dp[i+1][j+A[i+1]]=dp[i+1][j]=true; //i番目まで使ってjが作れるならi+1番目まで使ってj+A[i+1]とjが作れる
            }
            else if(dp[i][j]) dp[i+1][j]=true; //j+A[i]>2000のときは考えない
        }
    }
    int q,m;
    cin>>q;
    REP(i,0,q){
        cin>>m;
        if(dp[n][m]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
std::vector<int> vec;

int main() {
    cin >> n >> m;
    vec.assign(n, 0);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;
        vec[a]++;
        vec[b]++;
    }
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    ll A[N+1]; REP(i, N+1) cin >> A[i];
    ll B[N]; REP(i, N) cin >> B[i];

    ll cnt = 0;
    ll num = 1'000'000'000;
    REP(i, N) {
        num = min(A[i], B[i]);
        A[i] -= num;
        B[i] -= num;
        if (A[i]<0) A[i] = 0;
        if (B[i]<0) B[i] = 0;
        cnt += num;
        if (B[i]>0) {
            num = min(A[i+1], B[i]);
            A[i+1] -= num;
            B[i] -= num;
            if (A[i]<0) A[i] = 0;
            if (B[i]<0) B[i] = 0;
            cnt += num;
        }
    }
    cout << cnt << '\n';

    return 0;
}



Measured memory_bytes: 1792
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Map.Strict as M

main = sub <$> get >>= put

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines <$> C.getContents

sub ([n,k,_]:es) = sol n (splitAt k es)

put = putStrLn . unwords . fmap show

sol n (es0,es1) = runST $ do
  uf0 <- newUnionFind n
  forM es0 (unionUF uf0) 
  uf1 <- newUnionFind n
  forM es1 (unionUF uf1)
  rt0 <- forM [1..n] (rootUF uf0)
  rt1 <- forM [1..n] (rootUF uf1)
  let ps = zip rt0 rt1
  let mp = M.fromList . fmap (liftM2 (,) head length) . group $ sort ps
  return $ (mp M.!) <$> ps

-- | Union-Find
data UnionFind s = UnionFind {ids:: STUArray s Int Int, szs:: STUArray s Int Int}

newUnionFind :: Int -> ST s (UnionFind s)
newUnionFind n = liftM2 UnionFind (newListArray (1,n) [1..n]) (newArray (1,n) 1)

rootUF :: UnionFind s -> Int -> ST s Int
rootUF uf i = do
  ix <- readArray (ids uf) i
  if ix == i
    then return i
    else do
      writeArray (ids uf) i =<< readArray (ids uf) ix
      rootUF uf ix

unionUF :: UnionFind s -> [Int] -> ST s ()
unionUF uf [p,q] = do
  i <- rootUF uf p
  j <- rootUF uf q
  szi <- readArray (szs uf) i
  szj <- readArray (szs uf) j
  if szi < szj
    then do
      writeArray (ids uf) i j
      writeArray (szs uf) j (szi+szj)
      writeArray (szs uf) i 0
    else do
      writeArray (ids uf) j i
      writeArray (szs uf) i (szj+szi)
      writeArray (szs uf) j 0

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

int main(){
    int n,t;
    cin >> n >> t;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<int> vec;
    int tmp=a[0];
    for(int i=1;i<n;i++){
        if(tmp<a[i]){
            vec.push_back(a[i]-tmp);
        }else{
            tmp=a[i];
        }
    }
    sort(vec.begin(),vec.end(),greater<int>());
    int ans=1;
    for(int i=0;i<vec.size()-1;i++){
        //cout << vec[i] << endl;
        if(vec[i]!=vec[0]) break;
        if(vec[i]==vec[i+1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1276
#ABC 109 B
n = int(input())
first = input()
words = {first}
flag = False
for i in range(n-1):
    second = input()
    if first[-1] == second[0] and second not in words:
        words.add(second)
        first = second
    else:
        print("No")
        flag = True
        break
        
if not flag:
    print("Yes")

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

int main() {
	int a, b, c;
    cin>>a>>b>>c;  
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5))
	{
		cout << "YES" << endl;
	}
	else { cout << "NO" << endl; }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int w[100];
using namespace std;
int main(){
	int n,t,res=10001,s1=0,s2=0;
	cin>>n;
	for (int i=0;i<n;i++) cin>>w[i];
	for (int t=1;t<n;t++){
		s1=0;
		s2=0;
		for (int i=0;i<n;i++) 
			if (i<=t) s1+=w[i];
			else s2+=w[i];
		res=min(res,abs(s1-s2));
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,m,i,j,ans=0,tmp;
	string s[123],t[123];
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> s[i];
	}
	cin >> m;
	for(j=0; j<m; ++j){
		cin >> t[j];
	}
	for(i=0; i<n; ++i){
		tmp = 0;
		for(j=0; j<n; ++j){
			if(s[i] == s[j]){
				++tmp;
			}
		}
		for(j=0; j<m; ++j){
			if(s[i] == t[j]){
				--tmp;
			}
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll N,W;
ll w[110],v[110];
ll w1;
ll ans = -1001001001;
vector<ll> rui[10];
int main(){
  cin >> N >> W;
  rep(i,N){
    cin >> w[i] >> v[i];
    if(i==0) w1 = w[i];
    rui[w[i] - w1].push_back(v[i]);
  }
  rep(i,4){
    sort(rui[i].begin(),rui[i].end(),greater<ll>() );
  }
  rep(i,4){
    if(rui[i].size() > 0){
      rep(j,rui[i].size()-1){
        rui[i][j+1] += rui[i][j];
      }
    }
    vector<ll>::iterator it = rui[i].begin();
    rui[i].insert(it,0);
  }
  ll il = rui[0].size();
  ll jl = rui[1].size();
  ll kl = rui[2].size();
  ll pl = rui[3].size();
  for(ll i=0;i<il;i++){
    for(ll j=0;j<jl;j++){
      for(ll k=0;k<kl;k++){
        for(ll p=0;p<pl;p++){
          if(i*w1 + j*(w1+1) + k*(w1+2) + p*(w1+3) > W) continue;
          ans = max(ans,rui[0][i]+rui[1][j]+rui[2][k]+rui[3][p]);
        }
      }
    }
  }
  cout <<ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>

double sqrt(double number, const int& SIGNIFICANT_DIGITS);

int main(){
	double x1, x2, y1, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	printf("%0.5f\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2), 10));
	return 0;
}

double sqrt(double number, const int& SIGNIFICANT_DIGITS){
	double result = 0;
	double digitsOffset = 1;

	for (int i = 0; i < SIGNIFICANT_DIGITS + 1; i++){
		while (number >= (result + digitsOffset) * (result + digitsOffset)){
			result += digitsOffset;
		}
		digitsOffset /= 10;
	}
	return result;
}


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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const int mod = 998244353;
const int mxN = 200*1000+5;
int fact[mxN], finv[mxN];

int add(int a, int b) {
	a += b;
	while(a >= mod) {
		a -= mod;
	}
	return a;
}

void add_self(int& a, int b) {
	a = add(a, b);
}

int mul(int a, int b) {
	return 1LL * a * b % mod;
}

int mpow(int a, int n) {
	if(n == 0) {
		return 1;
	}
	int x = mpow(a, n/2);
	x = mul(x, x);
	if(n&1) {
		x = mul(x, a);
	}
	return x;
}

int binomial(int n, int k) {
	return mul(fact[n], mul(finv[n-k], finv[k]));
}

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

	int n, m, k;
	cin >> n >> m >> k;
	fact[0] = finv[0] = 1;
	for(int i = 1; i < n; i++) {
		fact[i] = mul(i, fact[i-1]);
		finv[i] = mpow(fact[i], mod-2);
	}
	int ans = 0;
	forn(i, k+1) {
		add_self(ans, mul(mul(m, binomial(n-1, i)), mpow(m-1, n-i-1)));
	}
	cout << ans << endl;
}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie

Measured memory_bytes: 5204
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    int H, A;

    cin >> H >> A;

    if(H % A == 0){
        cout << H/A << endl;
    }

    else{
        cout << H/A+1 << endl;
    }

    return 0;
}

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

namespace Plastic_Board
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans1 = 0;
            int ans2 = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] temp = input.Split(',');
                int a = int.Parse(temp[0]);
                int b = int.Parse(temp[1]);
                int c = int.Parse(temp[2]);
                if (a * a + b * b == c * c) ans1++;
                else if (a == b) ans2++;
            }
            Console.WriteLine(ans1);
            Console.WriteLine(ans2);
        }
    }
}



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

int main()
{
    int N, M, X;
    std::cin >> N >> M >> X;

    std::vector<int> A(N);
    for (int i = 0; i < M; i++) {
        int a;
        std::cin >> a;
        A[a] = 1;
    }

    int l = 0;
    int r = 0;
    for (int i = 1; i < N; i++) {
        if (i < X) {
            l += A[i];
        }
        else if (i > X) {
            r += A[i];
        }
    }

    std::cout << std::min(l, r) << std::endl;

    return 0;
}

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

int main(){
  int N,K,x,count;
  cin >> N >> K;
  
  for(int i=0; i < N; i++){
    cin >> x;
    
    if (x <= K-x) // (x-0 <= K-x) -> A moves.
      count += 2*x;
    else
      count += 2*(K-x);     
  }
  
  cout << count <<endl;
  
}

Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

sumA = sum(A)
for i in range(n-1,-1,-1):
    y = B[i]
    if(B[i] <= A[i+1]):
        A[i+1] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i+1]
        A[i+1] = 0
    
    if(B[i] == 0):
        continue
    if(B[i] <= A[i]):
        A[i] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i]
        A[i] = 0
subSumA = sum(A)

print(sumA - subSumA)

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

using namespace std;

#define endl "\n"

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);

   long long int n;
   cin>>n;
   long long int a[n],i;
   for(i=0;i<n;++i)
      cin>>a[i];
      
    long long int mx=a[0],ans=0;  
   
   for(i=1;i<n;++i)
   {
       if(mx<a[i])
          mx=a[i];
          
       else
          ans+=mx-a[i];
   }
   
   cout<<ans;
    
   

     return 0;
}

Measured memory_bytes: 5212
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <iomanip>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, vector<double> v) {
  sort(ALL(v));
  auto ans = accumulate(ALL(v), v[0],
                        [](double acc, double x) { return (acc + x) / 2.; });
  cout << fixed << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  vector<double> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  solve(N, move(v));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long w[1000010],h[3000010];
int main(){
    int x,y,z,k,t,i,j;
    long long a[1010],b[1010],c[1010];
    cin >> x >> y >> z >> k;
    for(i=0;i<x;i++){
        cin >> a[i];
    }
    for(i=0;i<y;i++){
        cin >> b[i];
    }
    for(i=0;i<z;i++){
        cin >> c[i];
    }
    t=0;
    for(i=0;i<x;i++){
        for(j=0;j<y;j++){
            w[t++]=a[i]+b[j];
        }
    }
    sort(w,w+t);
    i=t-1;
    t=0;
    for(int b=0;b<k;b++,i--){
        for(j=0;j<z;j++){
            h[t++]=w[i]+c[j];
        }
    }
    sort(h,h+t);
    i=t-1;
    for(j=0;j<k;j++,i--)
        cout << h[i] << endl;
    return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
int N;

void dfs(string s) {
  // v から行ける各頂点 next_v について
  if(SZ(s)==N){
    cout << s << endl;
    return;
  }
  char c='a';
  rep(i,SZ(s)) chmax(c,s[i]);
  for (int i=0;i<=c-'a'+1;i++) {
    string S="";
    char c2='a'+i;
    S=s+c2;
    dfs(S); // 再帰的に探索
  }
}

signed _main(){
  cin >> N;
  dfs("a");
  return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353

MAX_N = 2 * 10**5 + 10

fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD

fac_inv = [1] + [0] * MAX_N
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

ans = 0
n, m, k = map(int, input().split())

for i in range(k + 1):
    orig = n - i
    cnt = m * pow(m - 1, orig - 1, MOD)
    cnt = cnt * mod_nCr(n-1, i)
    ans += cnt
    ans %= MOD
print(ans)

Measured memory_bytes: 76940
#include <stdio.h>

int main(void)
{
	int N;
	int D;
	
	scanf("%d %d",&D, &N);
	
	
	if(D == 1){
			if(N == 100){
				N++;
			}
		printf("%d\n", N * 100);
	}
	
	else if(D == 2){
			if(N == 100){
				N++;
			}
		printf("%d\n", N * 100 * 100);
	}
	
	else if(D == 0){
			if(N == 100){
				N++;
			}
		printf("%d\n", N);
	}
	
	return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  map<string, ll> s;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    s[a]++;
  }
  ll maxi = -1e9;
  for (auto i = s.begin(); i != s.end(); i++) {
    if (i->second > maxi) maxi = i->second;
  }
  for (auto i = s.begin(); i != s.end(); i++) {
    if (i->second == maxi) {
      cout << i->first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int N=3e5+5;
const ll MOD=1e9+7;

char s[N]; int n;
ll f[N][3][3],ans;

inline void inc(ll &a,ll b){
	(a+=b)>=MOD?a-=MOD:a;
}

inline void trans(int &a,int &b,int c){
	if(!c){
		++b; if(b>=3) b-=2;
	}
	else{
		if(b) --b;
		else ++a,a=min(a,2);
	}
}

int main(){
	//freopen("test.in","r",stdin);

	scanf("%s",s+1); n=strlen(s+1);
	f[0][0][0]=1ll;
	lor(k,1,n){
		if(s[k]!='0'){
			lor(i,0,2) lor(j,0,2){
				int a=i,b=j; trans(a,b,1);
				inc(f[k][a][b],f[k-1][i][j]);
			}
		}
		if(s[k]!='1'){
			lor(i,0,2) lor(j,0,2){
				int a=i,b=j; trans(a,b,0);
				inc(f[k][a][b],f[k-1][i][j]);
			}			
		}
	}
	lor(i,0,2) lor(j,0,i) inc(ans,f[n][i][j]);
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 21632
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int arr[] = new int[3];
        int temp;
        for(int i=0;i<3;i++) arr[i] = sc.nextInt();
        for(int i=2;i>0;i--){
            for(int j=0;j<i;j++){
                if(arr[j]>arr[j+1]){
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        
        System.out.println(arr[0]+" "+arr[1]+" "+arr[2]);
    }
}


Measured memory_bytes: 26312
#include<iostream>

using namespace std;

int main(){
  int i,n,m,l,r,l_max,r_min;
  cin>>n>>m;
  l_max=1;
  r_min=n;
  for(i=0;i<m;i++){
    cin>>l>>r;
    if(r<r_min) r_min=r;
    if(l_max<l) l_max=l;
  }

  if(r_min<l_max) cout<<0<<endl;
  else cout<<r_min-l_max+1<<endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if sum(A)<sum(B):
    print(-1)
    exit()

D=[]
X=0
count=0
for i in range(N):
    a=A[i]
    b=B[i]
    if a>b:
        D.append(a-b)
    elif b>a:
        X+=b-a
        count+=1

D=sorted(D, reverse=True)
for d in D:
    if X==0:
        break
    Y=min(d,X)
    X-=Y
    count+=1
    
print(count)

Measured memory_bytes: 18356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    set<int> color_set;
    vector<int> a(N);
    int super = 0;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        if(a[i]/400 >= 8) {
            super++;
        }
        else {
            color_set.insert(a[i]/400);
        }
    }
    int n = color_set.size();

    cout << max(1, n) << " " << n+super << endl;

}

Measured memory_bytes: 3512
import sys
sys.setrecursionlimit(1000000)

def DFS(start):
    global graph
    global zahyou

    start_num=zahyou[start]

    for w,d in graph[start]:
        if(zahyou[w]==None):
            zahyou[w]=start_num + d
            if( not DFS(w)):
                return False
        else:
            if(start_num + d != zahyou[w]):
                return False
    
    return True
            


n,m=map(int,input().split())
graph=[[] for _ in range(n)]

zahyou=[None]*n
for i in range(m):
    l,r,d=map(int,input().split())
    graph[l-1].append((r-1,d))
    graph[r-1].append((l-1,-1*d))

flag=True
for i in range(n):
    if(zahyou[i]==None):
        zahyou[i]=0
        flag&=DFS(i)
        if( not flag):
            break

if(flag):
    print("Yes")
else:
    print("No")

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

#define FILED (-1)

enum TILE_TYPE{
  TILE_NONE = 0,
  TILE_UP,
  TILE_DOWN,
  TILE_RIGHT,
  TILE_LEFT,

  TILE_TYPE_NUM
};
static const char tile_type[TILE_TYPE_NUM] {
  '.',
  '^',
  'v',
  '>',
  '<'
};
int get_tile_type(char data) {
  for (int i = 0; i < TILE_TYPE_NUM; i++)
    if (data == tile_type[i])
      return i;
  return FILED;
}

struct Tile {
public:
  Tile(int _type) : type(_type), entered(false) {}
  
  void  SetType(int _type) { type = _type; }
  int   GetType(void)      { return type; }
  bool  StepOn(void) {
    bool has_entered = entered;
    entered = true;

    return has_entered;
  }
private:
  int   type;
  bool  entered;
};

struct Pos {
public:
  Pos(int _x, int _y) : x(_x), y(_y) {}
  bool operator ==(const Pos _pos) { 
    return this->x == _pos.x && this->y == _pos.y; 
  }

  int x;
  int y;
};

class TileSet {
public:
  TileSet() { arr.reserve(MAX_ARRAY_SIZE); }
  void Resize(const int h,const int w)
  {
    // ????´???°????¨??????????TILE_NONE??§?????????
    arr.resize(h);
    for (int i = 0; i < h; i++) {
      arr[i].resize(w, TILE_NONE);
    }
  }
  void Set(const int x, const int y, const int data)
  {
    assert(data != FILED);

    arr[x][y].SetType(data);
  }
  Pos Move(Pos pos)
  {
    switch (arr[pos.x][pos.y].GetType())
    {
    case TILE_NONE:
      return pos;
    case TILE_UP:
      return Pos(pos.x, pos.y - 1);
    case TILE_DOWN:
      return Pos(pos.x, pos.y + 1);
    case TILE_LEFT:
      return Pos(pos.x - 1, pos.y);
    case TILE_RIGHT:
      return Pos(pos.x + 1, pos.y);
    default:
      // ?????????????????£??????????????????
      return pos;
    }
  }

  // ????????????????¨????
  Pos EnterRoom(void)
  {
    Pos pos(0,0);

    while (1)
    {
      Pos now_pos = pos;
      pos = Move(pos);
      //cout << pos.x << " " << pos.y << endl;
      // ??????????????¢????????´?????????????????????
      if (now_pos == pos) return pos;
      // ????????????????????´??????????????????
      if (arr[pos.x][pos.y].StepOn()) return Pos(FILED,FILED);
    }
  }
private:
  static const int MAX_ARRAY_SIZE = 100 * 100;

  vector< vector<Tile> > arr;
  int now_tile_x;
  int now_tile_y;
};

int main() {
  // ???????????????????????\???
  int H, W;
  while(1){
    cin >> H >> W;
    // 0 0 ?????\??????????????¨??????
    if (!(H+W))  break;

    TileSet tile_set;
    tile_set.Resize(W, H);
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        char tile_data;
        cin >> tile_data;
        tile_set.Set(x, y, get_tile_type(tile_data));
      }
    }

    // ??????
    Pos pos = tile_set.EnterRoom();

    // ????????¨??????????????£?????????
    if (pos.x == FILED)
      cout << "LOOP" << endl;
    // ?§???????????????????
    else
      cout << pos.x << " " << pos.y << endl;
  }
}

Measured memory_bytes: 1292
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int questions = sc.nextInt();
		int firstBorder = sc.nextInt();
		int secondBorder = sc.nextInt();
		int firstQuestions = 0;
		int secondQuestions = 0;
		int thirdQuestions = 0;
		for(int i = 0; i < questions; i++) {
			int point = sc.nextInt();
			if (point <= firstBorder) {
				firstQuestions++;
			} else if (point <= secondBorder) {
				secondQuestions++;
			} else {
				thirdQuestions++;
			}
		}
		int min = Math.min(Math.min(firstQuestions, secondQuestions), thirdQuestions);
		System.out.println(min);
	}
}

Measured memory_bytes: 23124
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline

N = int(input())
if N > 100:
    n = int(np.sqrt(N)) + 5
else:
    n = N
n_np = np.zeros(105**3)
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            idx = i**2 + j**2 + k **2 + i*j + i*k + j*k
            n_np[idx-1] += 1
for i in range(N):
    print(int(n_np[i]))







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

typedef long long ll;
typedef pair<int, int> P;
const int INF = (int)1e9 + 1;

bool isprime[100001];
int cnt[100001];

void eratos() {
	isprime[0] = false;
	isprime[1] = false;

	for (int i = 2; i * i <= 100000; i++) {
		if (isprime[i]) {
			for (int j = i * i; j <= 100000; j += i) {
				isprime[j] = false;
			}
		}
	}
}

int main(void) {
	int Q, l, r;
	cin >> Q;

	for (int i = 0; i < 100001; i++) {
		isprime[i] = true;
		cnt[i] = 0;
	}

	eratos();

	for (int i = 3; i <= 100000; i += 2) {
		if (isprime[i] && isprime[(i + 1) / 2]) {
			cnt[i]++;
		}
	}

	for (int i = 1; i <= 100000; i++) {
		cnt[i] += cnt[i - 1];
	}

	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
n = int(input())
t,a = map(int,input().split())
for i in range(n-1):
    ti,ai = map(int,input().split())
    if t*ai == a*ti:
        continue
    else:
            b = max(-(-t//ti),-(-a//ai))
            t = ti*b
            a = ai*b
print(t+a)

Measured memory_bytes: 40304
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    if (W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2 == y) {
        cout << 0.5 * W * H << ' ' << 1 << endl;
    } else {
        cout << 0.5 * W * H << ' ' << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std; 
int main()
{  
    long int i,n; 
    cin>>n; 
    long int a[n+2]; 
    for(i=0; i<n; i++)
    cin>>a[i]; 
    long int x[n+2], y[n+2];  
     x[0]=a[0]; 
    for(i=1; i<n; i++)
     {  
          x[i]= __gcd(x[i-1],a[i]);

     } 

     y[n-1] = a[n-1]; 

     for(i=n-2; i>=0; i--)
     {  
         y[i] = __gcd(y[i+1],a[i]);
     }
      
     long int Max=0; 
     Max = y[1]; 
     Max = max(Max,x[n-2]);   
     //cout<<"max from Here is "<<Max;
     for(i=1; i<n-1; i++)
     Max = max(Max, __gcd(x[i-1],y[i+1])  ); 
     cout<<Max;





    return(0);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

int main(void) {
	char S[200001];
	int len, cnt[200000], t;
	long long ans;
	scanf("%s", S);

	len = strlen(S);

	t = 0;
	for (int i = len - 1; i >= 0; i--) {
		if (S[i] == 'W') {
			t++;
		}
		cnt[i] = t;
	}
	ans = 0;
	for (int i = 0; i < len; i++) {
		if (S[i] == 'B') {
			ans = ans + cnt[i];
		}
	}
	printf("%lld\n", ans);
}


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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s[s.Length-1] == 's')
            {
                s += "es";
            }
            else
                s += "s";
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 25900
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>

using namespace std;

class UnionFind
{
	vector<int> par;
	vector<int> rk;
public:
	UnionFind(int n)
	{
		par.resize(n);
		rk.resize(n);
		for (int i = 0; i < n; ++i)
		{
			par[i] = i;
			rk[i] = 0;
		}
	}
	int find(int x)
	{
		if (par[x] == x)
		{
			return(x);
		}
		return(par[x] = find(par[x]));
	}
	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
		{
			return;
		}
		if (rk[x] < rk[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (rk[x] == rk[y])
			{
				++x;
			}
		}
	}
	bool same(int x, int y)
	{
		return(find(x) == find(y));
	}
};

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	UnionFind uf(N + 1);
	vector< vector<int> > bunny(K);
	for (int i = 0; i < K; ++i)
	{
		int m;
		cin >> m;
		for (int j = 0; j < m; ++j)
		{
			int b;
			cin >> b;
			bunny[i].push_back(b);
		}
	}
	for (int i = 0; i < K; ++i)
	{
		for (int j = 1; j < bunny[i].size(); ++j)
		{
			uf.unite(bunny[i][0], bunny[i][j]);
		}
	}
	set<int> NGBunny;
	int R;
	cin >> R;
	for (int i = 0; i < R; ++i)
	{
		int p, q;
		cin >> p >> q;
		if (uf.same(p, q))
		{
			NGBunny.insert(p);
			NGBunny.insert(q);
		}	
	}
	cout << NGBunny.size() << endl;
}

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

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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int count = 0;
    for(int i = 0; i < (N-1)/2; i++){
        if(S.at(i) == S.at((N+3)/2-1+i)){
            count++;
        }
    }
    if(count == (N-1)/2){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    for {
      i <- 0 to a
      c500 = 500*i
      if c500 <= x
      j <- 0 to b
      rem = x - c500 - 100*j
      if rem >= 0 && rem % 50 == 0 && rem / 50 <= c
    } yield true
  }.size

  println(ans)
}

Measured memory_bytes: 26940
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
    string b;
    cin >> b;

    if (b == "A") {
        cout << "T" << endl;
    } else if (b == "T") {
        cout << "A" << endl;
    } else if (b == "C") {
        cout << "G" << endl;
    } else if (b == "G") {
        cout << "C" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define maxelem(v) max_element(all(v))
#define minelem(v) min_element(all(v))
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;


ll dp[55][5555]={0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n, a;
  cin >> n >> a;
  vi y(n);
  rep(i,n){
    int x;
    cin >> x;
    y[i] = x - a;
  }
  sort(all(y));
  int mini = abs(y[0]);
  int maxi = abs(y[y.size()-1]);
  rep(i,n){
    if(i == 0){
      dp[0][n*mini+y[0]] = 1;
      continue;
    }
    dp[i][n*mini+y[i]]++;
    rep(j,n*(maxi+mini+1)){
      if(dp[i-1][j] != 0 || j==n*mini ){
        dp[i][j] += dp[i-1][j];
        dp[i][j+y[i]] += dp[i-1][j];
      }
    }
  }
  #ifdef debug
  rep(j,n*(maxi+mini+1)){
    if(j == n*mini) cout << "*" << " ";
    else cout << "  ";
  }
  cout << endl;
  rep(i,n){
    rep(j,n*(maxi+mini+1)){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  #endif
  cout << dp[n-1][n*mini] << endl;
	return 0;
}


Measured memory_bytes: 896
N = gets.to_i 
A = gets.split.map(&:to_i)
F = A.inject(Array.new(N, 0)){|a, x| a[x] += 1; a}

def calc(n)
  ans = 1
  (1..n).each do |x|
    ans = (ans * 2) % 1_000_000_007
  end
  ans 
end

if N.odd?
  flag = true 
  2.step(N - 1, 2) do |x|
    flag = false if F[x] != 2 
  end
  if F[0] == 1 and flag 
    puts calc(N / 2)
  else
    puts 0 
  end
else
  flag = true
  1.step(N - 1, 2) do |x|
    flag = false if F[x] != 2 
  end
  if flag
    puts calc(N / 2)
  else
    puts 0 
  end 
end

Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint n, k;
  cin >> n >> k;
  vector< bool > d(10, false);
  for (lint i=0; i<k; ++i) {
    lint di;
    cin >> di;
    d[di] = true;
  }
  /*
  lint piv = 1;
  while (n >= piv) {
    //cerr << n/piv%10 << endl;
    if (d[n/piv%10]) n += piv;
    else piv *= 10;
  }
  cout << n << endl;
  */
  while (true) {
    string n_str = to_string(n);
    bool flg = true;
    for (auto c : n_str) {
      lint c_idx = c-'0';
      if (d[c_idx]) flg = false;
    }
    if (flg) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
TInt SelectionSort(TList& List)
{
    typedef TList::iterator TIt;
    TInt Count = 0;
    for(TIt It = List.begin(); It != List.end(); ++It){
        TIt Min = std::min_element(It, List.end());
        if(It != Min){
            std::swap(*It, *Min);
            ++Count;
        }
    }
    return Count;
}

void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
int main()
{
    TList List = Input();
    TInt Count = SelectionSort(List);
    Output(List);
    std::cout << Count << std::endl;
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

unordered_map<ll,ll>modcnt;

void solve()
{
       ll n,m;
       cin>>n>>m;
       ll a[n];
       ll sum=0, ans=0;
       modcnt[0]=1;
       for(ll i=0; i<n; i++) cin>>a[i];
       for(ll i=0; i<n; i++)
       {
              sum += a[i];
              ll k = sum % m;
              ans += modcnt[k];
              modcnt[k]++;
       }
       cout<<ans;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 4492
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  ll c, k;
  cin >> n >> c >> k;
  vector<ll> T(n);
  rep(i,n) cin >> T[i];
  sort(all(T));
  ll idx = 0, ans = 0;
  while (idx < n) {
    ll dan = T[idx] + k + 1;
    ll nidx = lower_bound(all(T), dan) - T.begin();
    ans++;
    if (nidx - idx > c) {
      idx = idx + c;
    }
    else idx = nidx;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   int r;
   cin >> r;
   if(r < 1200){
       cout << "ABC" << endl;
   }else if(1200 <= r && r < 2800){
       cout << "ARC" << endl;
   }else{
       cout << "AGC" << endl;
   }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = 0;
		int i = 1;
		while(true) {
			x = scan.nextInt();
			if(x == 0) break;
			System.out.println("Case " + i + ": " + x);
			i++;
		}
	}

}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            var aArray = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            var scarfs = new long[n];
            long totalXor = 0;

            foreach(var a in aArray)
            {
                totalXor ^= a;
            }

            for(var i = 0; i < n; i++)
            {
                scarfs[i] = aArray[i] ^ totalXor;
            }

            for(var i = 0; i < n; i++)
            {
                Write(scarfs[i]);
                if(i < n - 1)
                {
                    Write(" ");
                }
            }
            WriteLine();
        }
    }
}


Measured memory_bytes: 45004
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,ans=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a;
        if(i%2==1 && a%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3564