akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, k, l int
	fmt.Scan(&n, &k, &l)

	roads := newUnionFind(n)
	var p, q int
	for i := 0; i < k; i++ {
		fmt.Scan(&p, &q)
		roads.unite(p-1, q-1)
	}
	rails := newUnionFind(n)
	var r, s int
	for i := 0; i < l; i++ {
		fmt.Scan(&r, &s)
		rails.unite(r-1, s-1)
	}

	m := make(map[[2]int]int)
	for i := 0; i < n; i++ {
		roads.par[i] = roads.root(i)
		rails.par[i] = rails.root(i)
		key := [2]int{roads.par[i], rails.par[i]}
		m[key]++
	}

	results := make([]string, n)
	for i := 0; i < n; i++ {
		key := [2]int{roads.par[i], rails.par[i]}
		results[i] = strconv.Itoa(m[key])
	}
	fmt.Println(strings.Join(results, " "))
}

// UnionFind .
type UnionFind struct {
	par  []int
	rank []int
}

func newUnionFind(n int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, n)
	u.rank = make([]int, n)
	for i := range u.par {
		u.par[i] = i
		u.rank[i] = 0
	}
	return u
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}
	if u.rank[x] < u.rank[y] {
		u.par[x] = y
	} else {
		u.par[y] = x
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}


Measured memory_bytes: 28288
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
#include<iomanip>

using namespace std;
typedef long long ll;

int main(void)
{
    ll MODNUM = 2019;

    ll L, R;
    cin >> L >> R;
    
    vector<ll> num;
    for(ll _num = L; _num <= R; _num++)
    {
        ll __num = _num % MODNUM;
        if(__num == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        num.push_back(__num);
    }

    if(num.back() * (num.back()-1) <= MODNUM)
    {
        cout << num.front() * (num.front()+1) << endl;
        return 0;
    }

    vector<ll> arr;
    for(int i = num.front(); i <= num.back(); i++)
    {
        for(int j = i + 1; j <= num.back(); j++)
        {
            arr.push_back(i*j%MODNUM);
        }
    }

    cout << *min_element(arr.begin(), arr.end()) << endl;
    return 0;
}

Measured memory_bytes: 16892
#include<cstdio>
#include<cmath>

int main(void){
  char a[10];
  int b;

  scanf("%d %s",&b,a);

  for(int i=0;a[i]!=0;i++)
    b = 10*b + a[i]-'0';

  if((double)sqrt(b) == (int)sqrt(b))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 128
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    H = [NI() for _ in range(N)]

    h = max(H) // B + 1
    l = 0
    while h > l+1:
        m = (h+l) // 2
        cnt = m
        for x in H:
            if x >= m * B:
                cnt -= math.ceil((x-m*B) / (A-B))
                if cnt < 0: break
        else:
            h = m
            continue
        l = m
    print(h)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46296
#include<iostream>
#include<vector>

std::vector<int> prime_factorize(int64_t n){
    std::vector<int> result;
    for(int64_t p=2;p*p<=n;++p){
        while(n%p==0){
            result.push_back(p);
            n/=p;
        }
    }
    if(n!=1)result.push_back(n);
    return result;
}

int main(){
    int n;
    std::cin>>n;
    auto pf = prime_factorize(n);
    std::cout<<n<<":";
    for(auto p:pf)std::cout<<" "<<p;
    std::cout<<std::endl;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		solve(s);
		s.close();
	}

	public static void solve(Scanner s) {
		int H = s.nextInt();
		int W = s.nextInt();
		int count = 0;

		for (int i = 0; i < H; i++) {
			String S = s.next();
			String[] SArray = S.split("");

			for (int j = 0; j < SArray.length; j++) {
				if (SArray[j].equals("#")) {
					count++;
				}
			}
		}

		if (count == H + W - 1) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}

Measured memory_bytes: 9812
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	ll W, H, x, y;
	cin >> W >> H >> x >> y;
	float ans = (float)W * (float)H * 0.5;
	ll pat = 0;
	if (W % 2 == 0 && H % 2 == 0) {
		if (x == W / 2 && y == H / 2) {
			pat = 1;
		}
	}
	cout << ans << " " << pat << endl;

	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

C_count = B // C - A // C
if A % C == 0:
    C_count += 1
D_count = B // D - A // D
if A % D == 0:
    D_count += 1
CD_count = B // lcm(C, D) - A // lcm(C, D)
if A % lcm(C, D) == 0:
    CD_count += 1
div_count = C_count + D_count - CD_count
ans = B - A + 1 - div_count
print(ans)

Measured memory_bytes: 5048
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int main()
{
	int n;
	int h;
	int w;
	cin >> n;
	cin >> h;
	cin >> w;
	int a = n - h;
	int b = n - w;
	cout << (a + 1) * (b + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;

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

    sort(a, a+N);

    cout << a[N-1] - a[0];

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def fact(n,mod):
    ret=1
    for i in range(2,n+1):
        ret=(ret*i)%mod
    return ret

def pCq(p,q,mod):
  pCq=1
  for i in range(q):
    pCq*=p-i
    pCq=pCq%mod
  den=fact(q,mod)
  inv=pow(den,mod-2,mod)
  pCq=(pCq*inv)%mod
  return pCq

X,Y=map(int,input().split())
MOD=10**9+7
ans=0
n,m=2*X-Y,2*Y-X
if n%3==0 and m%3==0:
  n//=3
  m//=3
  ans=pCq(m+n,max(m,n),MOD)
print(ans)

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

int main() {
  double a, b, H, M, C, c, t;
  cin >> a >> b >> H >> M;
  t = (11 * M / 2 - 30 * H) * 3.14159265358979 / 180;
  C = a * a + b * b - 2 * a * b * cos(abs(t));
  cout << fixed << setprecision(11) << sqrt(C) << endl;
}

Measured memory_bytes: 4188
import numpy as np

N,K=map(int,input().split())
L=[]
for i in range(K):
  d=int(input())
  A=np.array(list((map(int,input().split()))))
  A=np.unique(A)
  for a in A:
    if not(a in L):
      L.append(a)
print(N-len(L))
     

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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)


using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}


template <typename T>
T min(T a, T b, T c) {
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c) {
  return max(max(a, b), c);
}


template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:

  mytask() { }


  int solve() {

    ll n;
    cin >> n;

    map<string, ll> a;
    for (ll i = 0; i < n; i++) {
      string s;
      cin >> s;
      a[s]++;
    }

    ll max_count = 0;
    for (auto& kv : a) {
      max_count = max(kv.second, max_count);
    }


    for (auto& kv : a) {
      if (kv.second == max_count) {
        cout << kv.first << endl;
      }
    }

    return 0;
  }




};


int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  auto task = mytask();
  task.solve();


  cout << endl;

  return 0;
}


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

int main() {
    // input
    int n;
    cin >> n;
    int a[2][100];
    for(int i=0;i<n;i++){
        cin >> a[0][i];
    }
    for(int i=0;i<n;i++){
        cin >> a[1][i];
    }

    // calc
    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<i+1;j++){
            sum += a[0][j];
        }
        for(int j=i;j<n;j++){
            sum += a[1][j];
        }
        ans = max(ans, sum);
    }

    // output
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, A[51], B[51];
bool dp[51][51];

int f(ll S, int id) {
    MEM(dp, 0);
    dp[50][A[id]] = 1;
    for (int i = 50; i >= 1; --i)rep(j, 51)if (dp[i][j]) {
        if (S >> i & 1) {
            dp[i - 1][j%i] = 1;
        }
        dp[i - 1][j] = 1;
    }
    RT dp[0][B[id]];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> N;
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> B[i];

    ll ans = 0, bb = (1ll << 51) - 1;
    for (int k = 50; k >= 1; --k) {
        bb >>= 1;
        ll S = ans | bb;
        int ok = 1;
        rep(i, N) {
            ok &= f(S, i);
            if (!ok)break;
        }
        if (!ok) ans |= 1ll << k;
    }
    if (ans == 2251799813685246ll)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int n,a[100010],b[100010],c[100010],hb[100010],hc[100010];
long long int mb=0,mc=0,md=0,r=0;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)scanf("%d",&b[i]);
    for(int i=0;i<n;i++)scanf("%d",&c[i]);
    sort(a,a+n);sort(b,b+n);sort(c,c+n);
    
    for(int i=0;i<n;i++){
        while(mb<n){
            if(a[mb]<b[i])mb++;
            else break;
        }
        hb[i]=mb;
    }
    
    for(int i=0;i<n;i++){
        while(mc<n){
            if(b[mc]<c[i]){
                md+=hb[mc];
                mc++;
            }
            else break;
        }
        r+=md;
    }
    //for(int i=0;i<n;i++)printf("%d  ",hc[i]);
    printf("%lld\n",r);
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int n,m;
  cin>>n>>m;

  ll x[n],y[m];

  rep(i,n){
    cin>>x[i];
  }
  rep(i,m){
    cin>>y[i];
  }

  ll xsum=0;
  ll ysum=0;

  rep(i,n-1){
    xsum=(xsum+(x[i+1]-x[i])*(i+1)*(n-1-i))%MOD;
  }
  rep(i,m-1){
    ysum=(ysum+(y[i+1]-y[i])*(i+1)*(m-1-i))%MOD;
  }

  cout<< (xsum*ysum)%MOD <<"\n";


}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1792
l,r = map(int, input().split())


def solve(l,r):
    num = float("inf")
    count = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            if count >= 2019**2:
                print(num)
                return
            
            current = (i*j) % 2019
            if current == 0:
                print(current)
                return
            
            num = min(current,num)
            count += 1
    
    print(num)

solve(l,r)

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

#include <set>

using namespace std;

int main()
{
	string str;
	cin >> str;
	int n = stoi(str);
	multiset<int> vals;
	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		int x = stoi(str);

		auto p = vals.lower_bound(x);
		if (!vals.empty() && p != vals.cbegin())
		{
			--p;
			vals.erase(p);
		}
		vals.insert(x);
	}

	//for (const auto& x : vals)
	//{
	//	cout << x << endl;
	//}

	cout << vals.size() << endl;

	return 0;
}

Measured memory_bytes: 4992
package main

import (
	"fmt"
	"log"
	"strconv"
)

func main() {

	var S string

	_, err := fmt.Scan(&S)
	if err != nil {
		log.Fatal(err)
	}

	date1 := S[0:2]
	date2 := S[2:4]

	var result string

	if !isYear(date1) || !isYear(date2) {
		result = "NA"
	}

	if !isMonth(date1) && !isMonth(date2) {
		result = "NA"
	}

	if isYear(date1) && isMonth(date2) {
		result = "YYMM"
	}

	if isMonth(date1) && isYear(date2) {
		result = "MMYY"
	}

	if isMonth(date1) && isMonth(date2) {
		result = "AMBIGUOUS"
	}

	fmt.Println(result)
}

func isYear(s string)(b bool){
	b = false
	//i, _ := strconv.Atoi(s)
	//if i > 0{
		b = true
	//}
	return b
}

func isMonth(s string)(b bool){

	b = false
	i, _ := strconv.Atoi(s)
	if i > 0{
		if i < 13 {
			b = true
		}
	}
	return b
}

Measured memory_bytes: 512
n = int(input())
ans = 0
for i in range(1, int(n ** 0.5) + 1):
    k = n // i
    ans += i * k * (k + 1) // 2
    if i != k:
        l = n // (i + 1)
        ans += i * (i + 1) * (k + l + 1) * (k - l) // 4
print(ans)

Measured memory_bytes: 9400
<?php
//https://atcoder.jp/contests/arc061/tasks/arc061_a

fscanf(STDIN,"%s",$num);

$count = strlen($num)-1;

$sum = 0;
for($i=0;$i<=pow(2,$count)-1;$i++){
    $newsum = [];
    $get = "";
    for($j=0;$j<=$count;$j++){
        $get = $get . $num[$j];
        if($i & pow(2,$j)){
            $newsum[] = (float)$get;
            $get = "";
        }
    }
    $newsum[] = (float)$get;
    $sum += array_sum($newsum);
}

echo $sum.PHP_EOL;


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

using namespace std;


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

    long sum = 0;

    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sa[i]);
		}
		br.close();

		int[][] cnt = new int[62][2];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < cnt.length; j++) {
				cnt[j][(int) ((a[i] >> j) & 1)]++;
			}
		}

		int mod = 1000000007;
		long ans = 0;
		for (int j = 0; j < cnt.length; j++) {
			long val = 1L << j;
			val %= mod;
			val *= cnt[j][0];
			val %= mod;
			val *= cnt[j][1];
			val %= mod;
			ans += val;
			ans %= mod;
		}
		System.out.println(ans);
	}
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {


    string S;
    cin >> S;
    char t, s, temp;
    int count = 0;
    for (int i = 0; i < 4; ++i) {
        temp = S[i];

        if (i == 0) {
            t = S[i];
            continue;
        }
        if (temp == t) {
            count++;
            continue;
        }

        if (s == S[i]) {
            count++;
        } else {
            s = S[i];
        }

    }
    string ans = "No";
    if (count == 2) {
        ans = "Yes";
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    string s; cin >> s;
    s[3] = '8';

    cout << s << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int find(int a[],int n)
{
	int dp[n];
	dp[1]=abs(a[1]-a[0]);
	dp[0]=0;
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	return dp[n-1];
}

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	cout<<find(a,n);
}

Measured memory_bytes: 1024
while 1:
    f = []; s = [];
    m = input()
    if m==0: break
    comp = lambda x, y: cmp(x[1],y[1]) if x[0]==y[0] else cmp(x[0], y[0])
    for i in xrange(m):
        f.append(map(int, raw_input().split()))
    f.sort(cmp = comp)
    n = input()
    for i in xrange(n):
        s.append(map(int, raw_input().split()))
    s.sort(cmp = comp)

    for i in xrange(n):
        x0 = s[i][0] - f[0][0]
        y0 = s[i][1] - f[0][1]
        c = 1
        for j in xrange(i+1,n):
            if f[c][0]+x0==s[j][0] and f[c][1]+y0==s[j][1]:
                c+=1
            elif f[c][0]+x0<s[j][0] or (f[c][0]+x0==s[j][0] and f[c][1]+y0<s[j][1]):
                break
            if c==m : break;
        if c==m: break
    print "%d %d"%(x0, y0)

Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
  int n,i,a[200010],amax=0,amax2=0;
  map<int,int> m;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a[i];
    m[a[i]]++;
    if (amax<a[i]){
      amax2=amax;
      amax=a[i];
    }else if (amax2<a[i]){
      amax2=a[i];
    }
  }
  for (i=0;i<n;i++){
    if (a[i]==amax){
      if (m[a[i]]>1) cout << a[i] << endl;
      else cout << amax2 << endl;
    }else{
      cout << amax << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7936
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    int Y;
    cin >> Y;

    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; i + j <= N; j++)
        {
            int y = i * 10000 + j * 5000 + (N - (i + j)) * 1000;
            if (y == Y)
            {
                cout << i << " " << j << " " << N - (i + j) << endl;
                return;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

  unsigned int a[n];
  
  long long a1 = 0 , a2 =0, a4 = 0; 
  rep(i,0,n){

    cin >> a[i];
    if(a[i] %4  == 0 ){
      a4++;
    }else if(a[i] %2 == 0 ){
      a2++;
    }else{
      a1++;
    }
  }
  
  if(a4 - a1 < -1){
    No;

    //P("a");
  }else{
    if(a2 % 2 == 0){
      Yes;
      //P("b");
    }
    else{
      if(a4 - a1 >= 0){
        Yes;
        //P("c");
      }
      else{
        No;
        //P("d");
      }
    }
  }


  ret 0;

}

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

m_a = max(A)+1
B = [0]*(m_a)

for i in A:
  B[i]+=1
  if B[i] == 1:
    for j in range(i*2, m_a, i):
      B[j]+=100
print(B.count(1))

Measured memory_bytes: 40556
#include<cstdio>
#include<algorithm>
#define N_ 101000
using namespace std;
long long D[N_];
int a, b, n, W;
int main() {
	int i, j;
	scanf("%d%d", &n,&W);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &a, &b);
		for (j = W - a; j >= 0; j--) {
			D[j + a] = max(D[j + a], D[j] + b);
		}
	}
	long long r = 0;
	for (i = 0; i <= W; i++)r = max(r, D[i]);
	printf("%lld\n", r);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int A, B;

int main() {
	cin >> A >> B;
	if (A <= 9 && B <= 9) {
		cout << A*B << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

//#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
//typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n, m;
vector<int> graph[550000];
int color[550000];
int BITPARTITE = 1;
vector<int> bp, p;
int SZ = 0;

int dfs(int v, int fl)
{
    color[v] = fl;
    SZ++;
    for (auto u : graph[v])
    {
        if (color[u] == 0) dfs(u, 3 - fl);
        if (color[u] == fl) BITPARTITE = 0;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int v, u;
        cin >> v >> u;
        v--, u--;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    ll ans = 0;
    ll cnt = n - 1;
    for (int i = 0; i < n; i++)
    {
        if (graph[i].size() == 0)
        {
            ans += 2 * cnt + 1;
            cnt--;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (color[i] == 0 && graph[i].size() != 0)
        {
            BITPARTITE = 1;
            SZ = 0;
            dfs(i, 1);
            if (BITPARTITE) bp.push_back(SZ);
            else p.push_back(SZ);
        }
    }
    cout << ans + 2LL * bp.size() * bp.size() + p.size() * p.size() + 2LL * bp.size() * p.size();
}


Measured memory_bytes: 20608
#include<iostream>
#include<cstring>
#include<climits>
#include<cmath>
#include<algorithm>

using namespace std;

#define lli long long int
int main()
{
    int n,a[200005],hash[200005],i;
    cin>>n;
    for(i-0;i<=n;i++)
    {
        hash[i]=0;
    }
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=2;i<=n;i++)
    {
        hash[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<hash[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5172
S = input()
T = input()
s = len(S)
t = len(T)
ans = "UNRESTORABLE"
for i in range(s-t+1):
  for j in range(t):
    T[j],S[i+j]
    if(T[j] == S[i+j] or S[i+j] == '?'):
      continue
    else:
      break
  else:
    ans = S[:i] + T + S[i+t:]
    ans = ans.replace('?', 'a')
print(ans)

Measured memory_bytes: 3064
<?php
list($s) = strs();
$t[] = '';
for ($i = $j = 0; $i < strlen($s); ++$i) {
    if ($i < strlen($s) - 1 && $s[$i] === 'B' && $s[$i + 1] === 'C') {
        if (isset($t[$j])) $t[$j] .= 'D';
        else $t[$j] = 'D';
        ++$i;
    } elseif ($s[$i] === 'B' || $s[$i] === 'C') {
        if (isset($t[$j])) ++$j;
    } else {
        if (isset($t[$j])) $t[$j] .= $s[$i];
        else $t[$j] = $s[$i];
    }
}
$cnt = 0;
foreach ($t as $v) {
    for ($i = 0, $j = strlen($v) - 1; $i < strlen($v); ++$i) {
        if ($v[$i] === 'A') {
            $cnt += $j - $i;
            --$j;
        }
    }
}
echo $cnt;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 19548
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    vector<int> mp(102, 0);
    int x, n;
    cin >> x >> n;
    for(int i = 0; i < n; i++) {
        int y;
        cin >> y;
        mp[y]++;
    }
    mp[0] = 0;
    mp[101] = 0;
    int ans_ind = 0;
    int ans = INT_MAX;
    for(int i = 0; i <= 101; i++) {
        if(mp[i] == 0) {
            if(ans > abs(i - x)) {
                ans_ind = i;
                ans = abs(i - x);
            }
        }
    }
    cout << ans_ind << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int A = Integer.parseInt(scan.next()); 
        int B = Integer.parseInt(scan.next()); 
        scan.close();
        int sum = A + B;
        int minus = A - B;
        int multi = A * B;

        if (sum > minus) {
            if (sum > multi) {
                System.out.println(sum);
            } else {
                System.out.println(multi);
            }
        } else {
            if (minus > multi) {
                System.out.println(minus);
            } else {
                System.out.println(multi);
            }
        }
    }
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (LL i=st;i<=ed;++i)
#define drp(i,st,ed) for (LL i=st;i>=ed;--i)

typedef long long LL;

int main(void) {
	LL a,b; scanf("%lld%lld",&a,&b);
	if (a==b) return 0&puts("1");
	drp(i,60,0) if (((a>>i)&1)!=((b>>i)&1)) {
		LL r=1LL<<i,k=0;
		a&=(r*2LL-1); b&=(r*2LL-1);
		drp(j,i-1,0) if ((b>>j)&1) {
			k=1LL<<j;
			break;
		}
		if (!k) k=1;
		else k=k*2LL;
		LL ans;
		if (r+a<=r+k) ans=r*2LL-a;
		else ans=r+k-a+r*2LL-r-a;
		printf("%lld\n", ans);
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll n, m;
    cin >> n >> m;
    auto res = n * (n-1) / 2;
    res += m * (m -1 ) /2;
    cout << res << endl;
}


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

int main(){
	char ch, ch2, ch3;
	int num;
	int counter[26] = {0};
	
	while(cin >> ch){
		ch2 = tolower(ch);
		num = ch2 - 'a';
		
		counter[num]++;
	}
	
	for(int i = 0; i < 26; i++){
		ch3 = 'a' + i;
		cout << ch3 << " : " << counter[i] << endl;
	}
		
    return 0;
}

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

using namespace std;

int const NMAX = 100;
int const KMAX = 100000;
int n, k;
int a[1 + NMAX];
int dp[1 + KMAX];

int main() {
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for(int i = 1; i <= k; i++) {
    dp[i] = false;
  }
  for(int i = 1; i <= k; i++) {
    for(int j = 1; j <= n; j++) {
      if(i - a[j] < 0) {
        break;
      }
      if(dp[i - a[j]] == false) {
        dp[i] = true;
        break;
      }
    }
  }
  if(dp[k] == true) {
    cout << "First";
  } else {
    cout << "Second";
  }
}


Measured memory_bytes: 640
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ld long double
const int inf = 9e18L;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        int n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        vector<tuple<int, int>> op = {
                {2, a},
                {3, b},
                {5, c}
        };

        map<int, int> dp;
        dp[0] = 0;
        dp[1] = d;
        function<int(int)> dfs = [&](int x) -> int {
            if (dp.find(x) != dp.end())return dp[x];
            int ans = inf;
            if ((ld) d * (ld) x < ans) ans = d * x;
            for (auto &i:op) {
                int num, cost;
                tie(num, cost) = i;
                ans = min(ans, dfs(x / num) + cost + d * (x % num));
                if (x % num)ans = min(ans, dfs(x / num + 1) + cost + d * (num - x % num));
            }
            return dp[x] = ans;
        };

        cout << dfs(n) << endl;
    }
}

Measured memory_bytes: 4484
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong(); long Y = sc.nextLong();
		long n = 0;
		while(X<=Y) {
			n++;
			X *= 2;
		}
		System.out.println(n);
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 22228
n = int(input())
if n == 1:
    print(0)
    exit()

from collections import Counter
def factorize(n):    
    d = Counter()
    if n < 2:
        return d
    
    while n%2 == 0:
        n //= 2
        d[2] += 1

    m = 3
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 2
    if n > 1:
        d[n] += 1
    return d
 
fac = factorize(n)
ans = 0
for v in fac.values():
    n = 1
    while v >= n:
        v -= n
        ans += 1
        n += 1
print(ans)


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD = 1000000007;

void solve(long long N, long long K, std::vector<long long> A){
    ll sum=0, cnt=0, rev_cnt=0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = i+1; j < N; j++)
        {
            if (A[i] > A[j]) {
                cnt++;
            } else if (A[j] > A[i]) {
                rev_cnt++;
            }
        }
    }
    ll sum_l, sum_r;
    sum_l = (K*(K+1)/2);
    sum_l = sum_l % MOD;
    sum_r = (K*(K-1)/2);
    sum_r = sum_r % MOD;
    sum = cnt*sum_l + rev_cnt*sum_r;
    std::cout << sum % MOD << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    x = list(map(int, input().split()))

    #output
    for i in range(5):
        if x[i] == 0:
            print(i+1)
            break

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
package main

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

// MOD :
var MOD = 1000000007

// Fac :
var Fac [300001]int

// IFac :
var IFac [300001]int

func mpow(x, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % MOD
		}
		x = x * x % MOD
		n = n >> 1
	}
	return ans
}

func comb(a, b int) int {
	if (a == 0) && (b == 0) {
		return 1
	}
	if (a < b) || (a < 0) {
		return 0
	}
	tmp := IFac[a-b] * IFac[b] % MOD
	return tmp * Fac[a] % MOD
}

func initPow() {
	Fac[0] = 1
	IFac[0] = 1
	for i := 0; i < 300000; i++ {
		Fac[i+1] = Fac[i] * (i + 1) % MOD            // n!(mod M)
		IFac[i+1] = IFac[i] * mpow(i+1, MOD-2) % MOD // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	initPow()
	sc.Split(bufio.ScanWords)

	H := getInt()
	W := getInt()
	A := getInt()
	B := getInt()

	H0 := H - A
	W0 := W
	W1 := W - B
	H1 := A

	out(H0, W0, H1, W1)

	idx := 0
	sum := 0
	for i := B + 1; i <= W; i++ {
		out(H0+i-2, "C", H0-1)
		out(W1+H1-idx-2, "C", H1-1)
		x := comb(H0+i-2, H0-1)
		y := comb(W1+H1-idx-2, H1-1)
		sum = (sum + (x * y % MOD)) % MOD
		idx++
	}
	fmt.Println(sum)
}


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

#define MOD 1000000007
typedef unsigned long long ull;

int N = 0;

int main() {
  cin >> N;
  vector<int> A(N);

  int t;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  vector<int> Orig(N);
  sort(A.begin(), A.end());
  Orig = A;
  
  auto p = unique(A.begin(), A.end());
  A.erase(p, A.end());

  if (A == Orig) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}


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

int main()
{
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 9; i <= n; i+=2) {
		int count = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0)count++;
		}
		if (count == 8)ans++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 3708
#include <stdio.h>

int main() {
    
    long int h, t = 0, n, temp;
    
  	scanf("%ld%ld", &h, &n);
  	
  	
  	for(long int i=0; i<n; i++) {
  	    scanf("%ld", &temp);
  	    t += temp;
  	}
  	
  	if(t<h) {
  	    printf("No");
  	} else {
  	    printf("Yes");
  	}
  
  return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque

n, *a = map(int, sys.stdin.read().split())

def main():
    b = deque()
    for i in range(n):
        if (i & 1): b.appendleft(a[i])
        else: b.append(a[i])
    if (n & 1): b.reverse()
    print(*b, sep=' ')

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 25948
s=int(input())
lis=[s]
loop=True
while loop:
    last=lis[-1]
    if last%2==0:
        val=int(last/2)
        if val in lis:
            loop=False
    else:
        val=int(3*last+1)
        if val in lis:
            loop=False
    lis.append(val)
print(len(lis))

Measured memory_bytes: 3060
N, M = map( int, input().split())
P = list( map( int, input().split()))
par = [ i for i in range(N)]

def find(x):
    p = par[x]
    if p == x:
        return x
    a = find(p)
    par[x] = a
    return a

for i in range(M):
    x, y = map( int, input().split())
    x, y = x-1, y-1
    bx, by = find(x), find(y)
    par[y] = bx
    par[by] = bx

ans = 0
for i in range(N):
    if find(i) == find(P[i]-1):
        ans += 1
print(ans)

Measured memory_bytes: 13812
#include <iostream>
#include <regex>
#include <string>
#include <stdio.h>
using namespace std;

int main(void) {
    string S;
    int S_int;
    cin >> S;
    
    S = regex_replace(S, regex("/"), "");
    S_int = atoi(S.c_str());
    if (S_int <= 20190430) cout << "Heisei";
    else cout << "TBD";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	ll h, w;
	cin >> h >> w;
	ll ans = min(h, w);
	if (w % 3 == 0 || h % 3 == 0) {
		puts("0");
		return 0;
	}
	rep(i, 1ll, h) {
		ll M = max(max(w * i, w / 2 * (h - i)), (w+1) / 2 * (h - i));
		ll m = min(min(w * i, w / 2 * (h - i)), (w + 1) / 2 * (h - i));
		ans = min(ans, M - m);
	}
	rep(i, 1ll, w) {
		ll M = max(max(h * i, h / 2 * (w - i)), (h + 1) / 2 * (w - i));
		ll m = min(min(h * i, h / 2 * (w - i)), (h + 1) / 2 * (w - i));
		ans = min(ans, M - m);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3736
// Tima the best
#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long                   
#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;                    
const ll maxn=2e5+123,inf=1e18,mod=1e9+7;
int n,ans=1e9;
int get(int n){
	int res=0;
	while(n)
		res+=n%10,n/=10;
	return res;
}
int main(){
	#ifdef LOCAL
		freopen ("test.in", "r", stdin);
    #endif                                     
	cin>>n;
	for(int i=1;i<n;i++)
		ans=min(ans,get(i)+get(n-i));
	cout<<ans;
}


Measured memory_bytes: 764
#たぶん普通の配列ではメモリ不足なのでハッシュを使う
n = gets.to_i
num = gets.strip.split.map(&:to_i)

#ここから新規
rec = Hash.new()
for i in 0..n-1
  if rec.key?(num[i])
    rec[num[i]] += 1
  else
    rec[num[i]] = 1
  end
end
#これでハッシュによる数字のカウント成功

a = rec.to_a
#これで配列にして返した[数字、個数]

sum = 0
for i in 0..a.size-1
  if a[i][0] <= a[i][1]
    sum += a[i][1]-a[i][0]
  else
    sum += a[i][1]
  end
end
puts sum

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

typedef long long ll;

int mod = 1e9 + 7;
ll p = 5e5 + 100;

int main() {	
	vector<ll> com(p + 1);
	vector<ll> inv(p + 1);
	vector<ll> mul(p + 1);
	com[0] = 1;
	for (ll i = 1; i <= p; ++i) {
		com[i] = (com[i - 1] * i) % mod;
	} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll> sum_prefix(n + 2);
	vector<ll> sum_suffix(n + 2);
	for (ll i = 1; i <= n; ++i) {
		sum_prefix[i] = (i + sum_prefix[i - 1]) % mod;
	}
	for (ll i = n; i >= 0; --i) {
		sum_suffix[i] = (i + sum_suffix[i + 1]) % mod;
	}
	//sum_suffix[0] = sum_suffix[1];
	//sum_suffix[n] = sum_prefix[n + 1];
	//sum_suffix[0] = sum_suffix[1];
	//sum_suffix[0] = sum_suffix[1];
	//for (int i = 0; i <= n; ++i) {
		//cout << sum_prefix[i] <<  " " << sum_suffix[i] << "  ";
	//}
	//cout << endl;
	for (int i = k; i <= n + 1; ++i) {
		ll pp = (sum_suffix[n - i + 1]  + mod - sum_prefix[i - 1]) + 1;
		//cout << pp << endl;
		ans = (ans + pp) % mod;
	}
	cout << ans;
}
//1  6 









Measured memory_bytes: 17932