akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<usize> = sc.vec(n);
    let mut ans = 0;
    let mut c = 1;
    for i in 0..n {
        if xs[i] == c {
            c += 1;
        } else {
            ans += 1;
        }
    }
    put!(if ans < n { ans as i64 } else { -1 });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    int A, B;

    cin >> A >> B;

    int ans = max(0, A - B * 2);

    cout << ans << endl;

    return 0;
}

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

int main(int argc, char const* argv[])
{
	int n;
	std::cin >> n;
	std::vector<int> v(n);
	for (int i = 0; i < n; i++) {
		std::cin >> v.at(i);
	}

	std::reverse(std::begin(v), std::end(v));
	for (int i = 0; i < n-1; i++) {
		std::cout << v.at(i) << " ";
	}
	std::cout << v.at(n-1) << std::endl;

	/*
	for (int i = n-1; i > 0; i--) {
		std::cout << v.at(i) << " ";
	}
	std::cout << v.at(0);
	*/

	return 0;
} 


Measured memory_bytes: 3092
object Main extends App {
  for(line <- io.Source.stdin.getLines()) {
    val numAry = line.split(' ').map { _.toInt }
    val S = numAry(0) * numAry(1)
    val L = numAry(0)*2 + numAry(1)*2
    println(S + " " + L)
  }
}


Measured memory_bytes: 43944
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N, ans;
  cin >> N;
  bool C[1001] = {0};
  C[1] = true;
  for(int i=2; i<32; i++){
    for(int j=2; pow(i, j)<=1000; j++){
      C[(int) pow(i, j)]=true;
    }
  }
  for(int i=N; i>=1; i--){
    if(C[i]) {
      ans =i; break;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	int x;
	std::cin >> x;
	if (x < 1200)
	{
		std::cout << "ABC";
	}
	else
	{
		std::cout << "ARC";
	}


	return 0;
}
	

		
	

Measured memory_bytes: 256
integer :: n,i,ans=0
integer,allocatable :: v(:),c(:)

read*,n
allocate( v(n),c(n) )
read*,v
read*,c

do i = 1,n
  if( v(i)>=c(i) )then
    ans = ans + v(i) - c(i)
  end if
end do
print*,ans
end


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, m;
  cin >> n >> m;
  ll sum = 0;
  REP(i, 0, m){
      int x;
      cin >> x;
      sum += x;
  }
  if(n >= sum)
    cout << n - sum << endl;
  else
    cout << -1 << endl;


  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

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

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll out = 0;
    for (ll i = 10; i <= n; i *= 5) out += n / i;

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int  K,N, minDist;
    cin >> K >> N;
    vector<int> haus(N);
    for(int i=0; i<N; i++){
        cin >> haus.at(i);
    }

    minDist = (K -haus.at(N-1) + haus.at(0));
    for (int i = 0; i < N - 1; i++) {
        minDist = max(minDist, haus.at(i+1) - haus.at(i));
    }

    cout << K-minDist << endl;
}

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

int main(void) {
    std::string s;
    std::cin >> s;
    std::vector<int>  alp_times(26,0);

    if (s.size() <= 0 || s.size() > 100) {
        std::cout << "No" << std::endl; 
            return 0;
    }

    for (int i = 0; i < s.size(); i++) {
        if(((int)s[i] >= 97 && (int)s[i] <= 122)) {
            alp_times[(int)s[i] - 97]++; 
        } else {
            std::cout << "No" << std::endl; 
            return 0;
        }
    }
    for (int i = 0; i < alp_times.size(); i++) {
        if (alp_times[i] % 2 == 1) {
            std::cout << "No" << std::endl; 
            return 0;
        }
    }
    std::cout << "Yes" << std::endl; 

    return 0;
}


Measured memory_bytes: 256
local read = io.read

local N = read("*n", "*l")
local card_point_s = {}
for i = 1, N do
	local str = read("*l")
	if card_point_s[str] then
		card_point_s[str] = card_point_s[str] + 1
	else
		card_point_s[str] = 1
	end
end

local M = read("*n", "*l")
for i = 1, M do
	local str = read("*l")
	if card_point_s[str] then
		card_point_s[str] = card_point_s[str] - 1
	else
		card_point_s[str] = -1
	end
end


local max_point = 0
for key, value in pairs(card_point_s) do
	if value >= max_point then
		max_point = value
	end
end

print(max_point)


Measured memory_bytes: 2744
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, t; cin >> n >> t;
  vector<pair<int, int> > ab(n);
  REP(i, n) cin >> ab[i].first >> ab[i].second;
  sort(ALL(ab));
  vector<vector<int> > dp(n + 1, vector<int>(t + 1, 0));
  dp[0][0] = 0;
  REP(i, n) {
    REP(j, t) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      dp[i + 1][min(j + ab[i].first, t)] = max(dp[i + 1][min(j + ab[i].first, t)], dp[i][j] + ab[i].second);
    }
    dp[i + 1][t] = max(dp[i + 1][t], dp[i][t]);
  }
  int ans = 0;
  REP(j, t + 1) ans = max(ans, dp[n][j]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n,cnt,mx,mn;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&cnt);
        A[cnt]=i;
    }
    for(int i=1;i<=n;++i)
        printf("%d%c",A[i]," \n"[i==n]);
    return 0;
}


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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int A,B;
  cin>>A>>B;

  if(A == 1) A=14;
  if(B == 1) B=14;

  if(A > B) cout<<"Alice"<<endl;
  else if(A < B) cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;

  return 0;
}


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


int main() {
  int n, h, pre;
  cin >> n >> pre;
  int cnt=0, ans=0;
  rep(i,n-1){
    cin >> h;
    if(pre >= h) cnt++;
    else{
      if(ans < cnt) ans = cnt;
      cnt = 0;
    }
    pre = h;
  }
  if(cnt > ans) ans = cnt;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


N = int(readline())

A = list(map(int,readline().split()))

if A.count(0) :
    print(0)
else:
    res = 1
    for i in range(N):
        res*=A[i]
        if res > 10**18:
            print(-1)
            exit()

    print(res)



Measured memory_bytes: 20176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	r, _ := strconv.Atoi(Scanner())
	s, _ := strconv.Atoi(Scanner())
	p, _ := strconv.Atoi(Scanner())
	t := Scanner()
	ans := 0
	for i := 0; i < k; i++ {
		f := false
		ans += point(string(t[i]), r, s, p)
		for j := i + k; j < n; j += k {
			if t[j-k] == t[j] && !f {
				f = true
			} else {
				ans += point(string(t[j]), r, s, p)
				f = false
			}
		}
	}
	fmt.Println(ans)
}
func point(x string, r int, s int, p int) int {
	if x == "r" {
		return p
	} else if x == "s" {
		return r
	} else {
		return s
	}
}


Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[1] and s[1] == s[2]){
        cout << "Yes" << "\n";
    }else if(s[1] == s[2] and s[2] == s[3]){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m,f,b;
    cin>>m>>f>>b;
    if(m>b){
        cout<<"0"<<endl;
    }
    else if((m+f)>=b){
        cout<<b-m<<endl;
    }
    else if((m+f)<b){
        cout<<"NA"<<endl;
    }
    }


Measured memory_bytes: 3104
from collections import Counter

n = int(input())
xc = Counter()
for _ in range(n):
    xc[input()] += 1

mx = xc.most_common(1)[0][1]
ans = []
for k, v in xc.items():
    if v == mx:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")


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

const int INF = 1001001001;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, q) {
        int num;
        cin >> num;
        a[num - 1]++;
    }

    rep(i, n) {
        if (k - (q - a[i]) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
using System;
class Program{
    static void Main(string[] args){
        string[] str = Console.ReadLine().Split(' ');
        int h = int.Parse(str[0].ToString());
        int w = int.Parse(str[1].ToString());
        string[] c = new string[h];
        for(int i=0;i<h;i++){
            c[i] = Console.ReadLine();
        }
        for(int i=0;i<h;i++){
            Console.WriteLine(c[i]);
            Console.WriteLine(c[i]);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll d;cin >> d;
    vl c(26);rep(i,26)cin >> c[i];
    vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
    vl last(26,-1);
    ll res=0;
    rep(i,d){
        ll t;cin >> t;t--;
        res+=s[i][t];
        last[t]=i;
        ll p=0;
        rep(j,26){ 
            p+=c[j]*(i-last[j]);
        }
        res-=p;
        cout << res <<endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>

using namespace std;

using TUP = tuple<string, int, int>;

int main() {
	int n, p;
	string s;
	cin >> n;

	vector<TUP> stores(n);
	for (int i = 0; i < n; i++) {
		cin >> s >> p;
		stores[i] = make_tuple(s, p, i + 1);
	}

	sort(stores.begin(), stores.end(),
		[](TUP &a, TUP &b) {
			if (get<0>(a) == get<0>(b)) {
				return get<1>(a) > get<1>(b);
			} else {
				return get<0>(a) < get<0>(b);
			}
		});

	for (auto t: stores) {
		cout << get<2>(t) << endl;
		// cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(L.begin(), L.end());

  int sum = 0;
  rep(i, n - 1) sum += L[i];

  if (L[n - 1] < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int inp[100005][3];
int dp[100005][3];
int main() {
	int N; scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", inp[i] + j);
		}

		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) if (j != k) {
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + inp[i][k]);
			}
		}
	}
	printf("%d", *max_element(dp[N], dp[N] + 3));

}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string S;
    int i;
    int cnt;
    int flag;
    while (cin >> S) {
        flag = 0;
        if (S[0] == 'A') {
            S[0] = 'a';
            cnt = 0;
            for (i = 2; i <= S.size()-2; i++) {
                if (S[i] == 'C') {
                    cnt++;
                    S[i] = 'c';
                }
            }
            if(cnt == 1) {
                flag = 1;
                for (i = 0; i < S.size(); i++) {
                    if(isupper(S[i])) {
                        flag = 0;
                        break;
                    }
                }
            }
        }
        if (flag)
        {
            cout << "AC" << endl;
        }
        else
        {
            cout << "WA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	string s; cin >> s;
	if(s[a]!='-'){
		cout << "No" << endl;
		return 0;
	}else{
		for(int i=0;i<a;i++){
			if(s[i]=='-'){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=1;i<=b;i++){
			if(s[a+i]=='-'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	words := make(map[string]int)
	var W string
	var p byte
	for i := 0; i < N; i++ {
		fmt.Scan(&W)
		words[W]++
		if words[W] > 1 || (p != 0 && p != W[0]) {
			fmt.Println("No")
			return
		}
		p = W[len(W)-1]
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;

int x ; 
bool prime(int n)
{
	for(int i = 2 ;  i <= sqrt(n) ; i++ )
	{
		if(n % i == 0) return false ; 
	}
	return true ; 
}

int main()
{
	migmig ;
	cin>>x ; 
	for(int i = x ; i <= 1e9 ; i ++ )
	{
		if(prime(i)) 
		{
			cout<<i<<endl ; 
			return 0 ; 
		}
	}
}
//////
////////
///////////




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

const int N = 100;
const int V = 1000;
ll dp[N*V+1];

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

	int n, mw;
	cin >> n >> mw;
	int mv = n * V;
	for (int i = 1; i <= mv; ++i) dp[i] = mw + 1;

	for (int i = 0; i < n; ++i) {
		int w, v;
		cin >> w >> v;
		for (int j = mv - v; j >= 0; --j) {
			dp[j + v] = min(dp[j + v], dp[j] + w);
		}
	}
	for (int i = mv; i >= 0; --i) {
		if (dp[i] <= mw) {
			cout << i << '\n';
			break;
		}
	}
}


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

int main() {

    int K , A , B;

    cin >> K >> A >> B;

    string ans = "NG" ;

    for(int i = 0; i < B-A+1 ; i++){

        if( (A + i) % K == 0 ) {

            ans = "OK" ;

            break;
        }

    }

    if(ans=="OK") cout << ans <<endl;

    else cout << ans << endl;


}

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

int main() {
  int a = 0;
  bool b = 0, c = 0;
  string s, t = "keyence";
  cin >> s;
  if(s == t) b = 1;
  else{
    rep(i, s.size()){
      if(!c && s[i] == t[a]){
        ++a;
      }
      else if(!c) c = 1;
      else if(c && i > s.size()-8+a){
        if(s[i] == t[a]) ++a;
        else break;
      }
      if(i == s.size()-1) b = 1;
    }
  }
  if(b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main()
{
  int n, f(0), s(0);
  cin >> n;
  vector<int> a(n);
  for (auto idx(0); idx < n; ++idx) {
    cin >> a[idx];
    if (a[idx] >= f) {
      s = f;
      f = a[idx];
    } else if (a[idx] >= s) {
      s = a[idx];
    }
  }
  for (auto idx(0); idx < n; ++idx) {
    if (a[idx] != f) cout << f << "\n";
    else cout << s << "\n";
  }
  cout << endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,ans=0,p;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<0;
		return 0;
	}
	while(1){
		if(a%2==b%2&&b%2==c%2){
			p=min(a,min(b,c));
			if(a==p){
				a+=2;
			}
			else if(b==p){
				b+=2;
			}
			else{
				c+=2;
			}
			ans++;
		}
		else if(a%2!=b%2&&a%2!=c%2){
			b++;
			c++;
			ans++;
		}
		else if(b%2!=a%2&&b%2!=c%2){
			a++;
			c++;
			ans++;
		}
		else if(c%2!=a%2&&c%2!=b%2){
			a++;
			b++;
			ans++;
		}
		if(a==b&&b==c){
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        long n;
        long m;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = long.Parse(words[0]);
            m = long.Parse(words[1]);
        }

        long[] prices = new long[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (long i = 0; i < n; i++)
            {
                prices[i] = long.Parse(words[i]);
            }
        }

        Array.Sort(prices);
        Array.Reverse(prices);

        while (m > 0)
        {
            prices[0] = prices[0] / 2;
            m--;
            if (m == 0)
            {
                break;
            }
            for (int i = 1; i < n; i++)
            {
                if (prices[0] > prices[i])
                {
                    Array.Sort(prices);
                    Array.Reverse(prices);
                    break;
                }
                prices[i] /= 2;
                m--;
                if (m == 0)
                {
                    break;
                }
            }
        }

        long answer = prices.Sum();

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 27740
def rec(n, arr)
  div = (2..(n**0.5).to_i).find { |i| n % i == 0 }
  return arr << n if div.nil?

  rec(n / div, arr << div)
end

gets
as = gets.split.map(&:to_i)

gcd = as.inject(:gcd)
as.map! { |a| a / gcd }

divisor = rec(as[0], []).sort.uniq
ans_without_a0 = as[1..-1].inject(:gcd)

deletes = []
divisor.each do |i|
  tmp = as.select { |a| a % i != 0 }
  deletes << tmp[0] if tmp.size == 1
end

ans = 1
deletes.each do |d|
  as_tmp = as.dup
  as_tmp.delete(d)
  ans = [as_tmp.inject(:gcd), ans].max
end
puts [ans, ans_without_a0].max * gcd


Measured memory_bytes: 11396
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d);
 } 

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int n,x,t; 
	scanf("%d%d%d",&n,&x,&t);
	if(n%x==0){
		printf("%d",n/x*t);
		return 0;
	}
	else{
		printf("%d",n/x*t+t);
		return 0;
	}
}

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

#define int long long

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

int N, M;
string A[50], B[50];

signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    for (int i = 0; i <= N - M; i++) {
        for (int j = 0; j <= N - M; j++) {
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (A[i + k][j + l] != B[k][l]) {
                        goto check;
                    }
                }
            }
            cout << "Yes" << endl;
            return 0;
check:
            ;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2809.cc: Graduation Ceremony
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2000;
const int MAX_K = 2000;
const int MINF = 1 << 31;

const char cs[] = "RULD";
const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, 1, 0, -1 };

const int qxs[] = { 1, -1, -1, 1 }, qys[] = { 1, 1, -1, -1 };
const int rxs[] = { 1, -1, 1, -1 }, rys[] = { 1, 1, -1, -1 };
const int bnums[] = { 0, 1, 1, 2 };


/* typedef */

/* global variables */

int cdis[256], dp[2][MAX_K + 1][4];
char s[MAX_N + 4];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  for (int di = 0; di < 4; di++) cdis[cs[di]] = di;

  int k;
  scanf("%s%d", s, &k);

  int maxd = MINF;
  for (int q = 0; q < 4; q++) {
    const int &qx = qxs[q], &qy = qys[q];

    int cur = 0, nxt = 1;
    for (int j = 0; j <= k; j++)
      fill(dp[cur][j], dp[cur][j] + 4, MINF);
    fill(dp[cur][0], dp[cur][0] + 4, 0);

    for (int i = 0; s[i]; i++) {
      for (int j = 0; j <= k; j++)
	fill(dp[nxt][j], dp[nxt][j] + 4, MINF);

      int &di = cdis[s[i]];
      int dx = dxs[di] * qx, dy = dys[di] * qy;

      for (int j = 0; j <= k; j++)
	for (int r = 0; r < 4; r++)
	  if (dp[cur][j][r] > MINF)
	    for (int r1 = 0; r1 < 4; r1++) {
	      const int &b = bnums[r1];
	      if (j + b <= k) {
		const int r2 = r ^ r1;
		setmax(dp[nxt][j + b][r2],
		       dp[cur][j][r] + dx * rxs[r2] + dy * rys[r2]);
	      }
	    }
      cur ^= 1, nxt ^= 1;
    }

    for (int j = 0; j <= k; j++)
      for (int r = 0; r < 4; r++)
	setmax(maxd, dp[cur][j][r]);
  }

  printf("%d\n", maxd);
  return 0;
}



Measured memory_bytes: 3288
N = int(input())
cnt = {}

for _ in range(N):
    s = ''.join(sorted(input(), key=str.lower))
    if s in cnt:
        cnt[s] += 1
    else:
        cnt[s] = 1

res = 0
for val in cnt.values():
    res += val * (val - 1) // 2

print(res)

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

int main() {
 
  int n;
  cin >> n;
  vector<char> s(n);
  vector<pair<int,int>> num(n);
  int w = 0;
  for(int i = 0; i < n; i++) {
    cin >> s.at(i);
    if(s.at(i) == 'W')
      num.at(i).first = w + 1;
    else
      num.at(i).first = w;
    w = num.at(i).first;
    //cout << i << ':' << num.at(i) << endl;
  }
  
  int e = 0;
  for(int i = n-1; i > -1; i--) {
    if(s.at(i) == 'E') {
      num.at(i).second = e + 1;
    }
    else
      num.at(i).second = e;
    e = num.at(i).second;
  }
  
  int mini = n;
  for(int i = 0; i < n; i++) {
    if(mini > num.at(i).first + num.at(i).second)
      mini = num.at(i).first + num.at(i).second;
  }
  
  cout << mini-1 << endl;
  
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
  int H, W, h, w;
  
  cin >> H >> W >> h >> w;
  cout << H*W-(H*w+h*(W-w)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,q,rem,r,sum=0;
    scanf("%d",&x);
    if(x>=5&&x<500)
    {
        r=x/5;
        sum=sum+(r*5);
    }
    else if(x>=500)
    {
        rem=x%500;
        q=x/500;
        if(rem>=5)
        {
            r=rem/5;
        }
        sum=sum+(q*1000)+(r*5);
    }
    printf("%d",sum);
}

Measured memory_bytes: 128
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (n, m) = readIntList()
    val a = readIntList()
    val sumA = a.sum()
    if ((a.count { it.toDouble() >= sumA.toDouble()/(4*m)}) >= m) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 37444
n = int(input())

A = [int(x) for x in input().split()] #yoko

A.sort(reverse=True)
#print(A)
#A1 = A[1:n-1]
ans = A[0]

count = 1
guuki = 0
i = 1

while count < n-1:
    ans += A[i]

    guuki += 1
    count += 1
    if guuki != 1:
        guuki = 0
        i += 1




print(ans)


Measured memory_bytes: 31540
package main

import "fmt"

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	n := len(s)

	costs := make([]int, n)
	for i := range s {
		costs[i] = (26 - int(s[i]-'a')) % 26
	}

	ans := make([]byte, 0, n)
	for i := 0; i < n-1; i++ {
		if costs[i] <= k {
			ans = append(ans, 'a')
			k -= costs[i]
		} else {
			ans = append(ans, s[i])
		}
	}
	ans = append(ans, byte((int(s[n-1]-'a')+k)%26+'a'))
	fmt.Println(string(ans))
}


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

using namespace std;

string s;
string t;

int main(){
  cin >> s;
  cin.ignore();
  cin >> t;
  cin.ignore();

  string tmp = s;
  for(char i = 'a'; i <= 'z'; i++){
    if(t == s + i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    vector<pair<int, int>> from, to;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int x; cin >> x;
            a[i][j] += x;
            if (a[i][j] & 1) {
                if (j < W - 1) {
                    a[i][j + 1]++;
                    from.push_back(make_pair(i + 1, j + 1));
                    to.push_back(make_pair(i + 1, j + 2));
                } else if (i < H - 1) {
                    a[i + 1][j]++;
                    from.push_back(make_pair(i + 1, j + 1));
                    to.push_back(make_pair(i + 2, j + 1));
                }
            }
        }
    }
    long long N = from.size();
    cout << N << endl;
    for (int i = 0; i < N; i++) {
        cout << from[i].first << " " << from[i].second << " " << to[i].first << " " << to[i].second << endl;
    }
}

Measured memory_bytes: 5228
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll po(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    ll k, n, z = 0, f[2000006] = {1}, g[2000006] = {};
    g[2000000] = 407182070;
    for (int i = 1; i <= 2000000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    string s;
    cin >> k >> s;
    n = s.length();
    //H(i+1,n-1)=C(i+1+n-1-1,n-1)
    for (int i = 0; i <= k; i++) z = (z + f[i + n - 1] * g[n - 1] % mod * g[i] % mod * po(25, i) % mod * po(26, k - i)) % mod;
    cout << z;
}


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

ll N, A[3][100005], dp[3][100005];

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

	cin >> N;
	for (ll i = 0; i < 3; i++) {
		for (ll j = 0; j < N; j++) {
			cin >> A[i][j];
		}
		sort(A[i], A[i]+N);
	}

	ll ans = 0;
	for (ll i = 0; i < 3; i++) {
		ll cur = 0, idx = 0;
		for (ll j = 0; j < N; j++) {
			if (i == 0) dp[i][j] = 1;
			else {
				while (idx < N && A[i-1][idx] < A[i][j]) {
					cur += dp[i-1][idx];
					idx++;
				}
				dp[i][j] = cur;
			}
			if (i == 2) {
				ans += dp[i][j];
			}
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 4992
import numpy as np
N, M = map(int, input().split())
s = np.array([[int(v) for v in input().split()] for _ in range(N)])
c = np.array([[int(v) for v in input().split()] for _ in range(M)])

for i in range(N):
    print(np.argmin(np.sum(np.abs(s[i] - c), axis=1)) + 1)

Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
using namespace std;

int main(){
	int a, b;
	int n;
	while(cin >> a >> b >> n){
		if(cin.eof()) break;
		int div = a%b*10;
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum += div/b;
			div = div%b*10;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    vector<int> A = {A1, A2, A3};
    sort(all(A));
    cout << A[2] - A[0] << endl;
}


Measured memory_bytes: 3624
// clang++ -std=c++14 -stdlib=libc++ -O2 ./*.cpp

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A - C) * (B - C) < 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    int n,m; cin>>n>>m;
    vector<int> vec(n);
    rep(i,m){
        int a,b; cin>>a>>b;
        vec.at(a-1)++; vec.at(b-1)++;
    }
    rep(i,n){
        if(vec.at(i)%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    set<int> a;
    int mv = 0, mn = 0;
    double target, diff = INT_MAX;
    
    rep(i, n) {
        int tmp;
        cin >> tmp;
        mv = max(mv, tmp);
        a.insert(tmp);
    }
    
    a.erase(mv);
    target = mv / 2.0;
    
    for (int x : a) {
        double tmp = abs(target - x);
        
        if (tmp < diff) {
            diff = tmp;
            mn = x;
        }
    }
    
    cout << mv << " " << mn << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<stdlib.h>
#include<stdio.h>
#define d_flag 0
typedef struct{
  int u;
  int v;
} edge;

edge   G[100000];
int comp[100001];
int height[100001];
int count;
int n,m;

int find(int i){
  if(comp[i]==i)return i;
  int v=find(comp[i]);
  comp[i]=v;
  return v;
}  

void print_graph(){
  int i;
  for(i=1;i<=n;i++){
    printf("%2d",comp[i]);
  }
  printf(":comp,count=%d\n",count);
  for(i=1;i<=n;i++){
    printf("%2d",height[i]);
  }
  printf(":height\n");
}

int main(){
  int i,z;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d%d%d",&G[i].u,&G[i].v,&z);
  }
  for(i=1;i<=n;i++){
    comp[i]=i;
    height[i]=1;
  }
  count=n;

  int u,v,max;
  for(i=0;i<m;i++){
    u=find(G[i].u);
    v=find(G[i].v);
    
    if(u==v)continue;
    max=height[u]<height[v]?v:u;
    comp[u+v-max]=max;
    height[max]++;
    count--;
    if(d_flag){
      printf("(%d(%d), %d(%d))\n",G[i].u,u,G[i].v,v);
      print_graph();
    }
  }
  printf("%d",count);
}


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

int main(){
	int n; cin >> n;
	rep(i, n) {
		int a[3]{};
		int cnt = 0, out = 0;
		while (1) {
			string s; cin >> s;
			if (s == "HIT") {
				if (a[2]) { a[2] = 0; cnt++; }
				for (int i = 2; i >= 1; i--)if (a[i - 1]) { a[i] = 1; a[i - 1] = 0; }
				a[0] = 1;
			}
			if (s == "HOMERUN") { cnt++; rep(i, 3)if (a[i]) { a[i] = 0; cnt++; } }
			if (s == "OUT") { if (out == 2) { cout << cnt << endl; break; } out++; }
		}
	}
	return 0;
}

Measured memory_bytes: 3232
#include <fstream>
#include <map>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, a;
map<int,int> cts;

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    lli ans = 0;
    F0R(i,N) {
        cin >> a;
        if (cts.count(i-a)) ans += cts[i-a];
        cts[i+a]++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 12948
N = int(input())
A = list(map(int, input().split()))

s = sum(A)

for i in range(1, N):
    A[i] += A[i - 1]

ans = 10 ** 20

for i in range(N):
    ans = min(ans, abs(s - 2 * A[i]))

print(ans)


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

using namespace std;
typedef long long ll;

int main(){
  ll N, K, tmp;
  cin >> N >> K;
  vector<ll> H;
  for (ll i=0; i<N; i++){
    cin >> tmp;
    H.push_back(tmp);
  }
  ll ans = 0;
  sort(H.begin(), H.end());
  for (ll i=H.size() - 1; i>=0; i--){
    if (K > 0){
      K--;
    }
    else{
      ans += H[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    char alpha[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

    vector<string> ans;

    ans.push_back("a");

    if (N == 1){
        cout << ans[0] << endl;
        return 0;
    }

    for (int i = 1; i < N; i++){
        vector<string> temp;
        for (int j = 0; j < int(ans.size()); j++){
            int cnt = 0;
            for (int k = 0; k < 10; k++){
                if (ans[j].find(alpha[k]) != -1) {
                    cnt++;
                }
            }
            for (int k = 0; k < cnt+1; k++){
                temp.push_back(ans[j] + alpha[k]);
            }
        }
        ans = temp;
    }
    
    for (int i = 0; i < int(ans.size()); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 9116
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    string ans="NO";
    
    for(int i=1;i<=9999;i++){
        if((a*i)%b==c) ans="YES";
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
Aij = []
c = 0
for i in range(3):
    Aij += list(map(int, input().split()))
    
N = int(input())
for i in range(N):
    b = int(input())
    if b in Aij:
        Aij[Aij.index(b)] = 0

for i in range(3):
    if Aij[3*i] == Aij[3*i+1] and Aij[3*i] == Aij[3*i+2]:
        c = -1
        break

    if Aij[i] == Aij[i+3] and Aij[i] == Aij[i+6]:
        c = -1
        break

if c == Aij[4]:
    if Aij[0] == Aij[4] and Aij[4] == Aij[8]:
        c = -1
    elif Aij[2] == Aij[4] and Aij[4] == Aij[6]:
        c = -1
    else:
        pass

print(['No', 'Yes'][c])

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main() {
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	vector<VI> grid(n+1);
	vector<int> mn(n+1,n+1);
	rep(i,0,m){
		scanf("%d%d",&a,&b);
		mn[a] = min(mn[a],b);
		grid[a].pb(b);
	}
	int board=n+1,ans=0;
	for(int i=n-1;i;i--){
		if(mn[i]<board){
			board = i+1;
			ans++;
		}
	}
	printf("%d",ans);
  	return 0;
}






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

using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e7 + 10;

long long di[N];
ll n, ans;

void sieve() {
  vector<ll> pr, cnt(N + 1), pcnt(N + 1);
  vector<bool> comp(N + 1);
  di[1] = 1;
  for(int i = 2; i <= N; i++) {
    if(!comp[i]) {
      pr.push_back(i);
      di[i] = 2;
      cnt[i] = 1;
      pcnt[i] = i;
    }
    // cerr << i << ' ';
    // cerr << (int)pr.size();
    for(int j = 0; j < (int)pr.size(); j++) {
      if(1LL * pr[j] * i > N)
        break;
      comp[i * pr[j]] = true;
      // cerr << i << ' ';
      if(i % pr[j] != 0) {
        cnt[i * pr[j]] = 1;
        pcnt[i * pr[j]] = pr[j];
        di[i * pr[j]] = di[i] * 2;
      } else {
        ll temp;
        cnt[i * pr[j]] = cnt[i] + 1;
        pcnt[i * pr[j]] = pcnt[i] * pr[j];
        temp = cnt[i * pr[j]];
        di[i * pr[j]] = di[i / pcnt[i]] * (temp + 1);
        break;
      }
    }
  }
}

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

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

  sieve();
  cin >> n;
  for(int i = 1; i <= n; i++) {
    ans += 1LL * i * di[i];
  }
  cout << ans << '\n';
  return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    vector<int> sM(N);
    vector<int> uM(N);
    sM[0]=A[0];
    repd(i,1,N) sM[i]=(sM[i-1]<A[i])? A[i] : sM[i-1];
    uM[N-1]=A[N-1];
    rrepd(i,N-2,0) uM[i]=(uM[i+1]<A[i])? A[i] : uM[i+1];

    cout << uM[1] <<endl;
    repd(i,1,N-1){
        cout << max(sM[i-1], uM[i+1])<<endl;
    }
    cout << sM[N-2] << endl;

    return (0);
}

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

int main()
{
    int N, K;
    int h[100005];

    std::cin >> N >> K;
    for(int i=0; i<N; i++){ std::cin >> h[i]; }

    std::sort(h, h+N);

    int cant = 0;
    for(int i=0; i<N; i++){
        // std::cout << h[i];
        if(h[i]>=K) break;
        cant++; 
    }

    std::cout << N-cant << std::endl;

    return 0;
}

Measured memory_bytes: 640