akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



int main()
{
    ll N,M,h;
    cin >> N >> M;

    vector<ll> H,ma;

    rep(i,N){
        cin >>h;
        H.push_back(h);
        ma.push_back(0);  
    } 

    ll A,B,ans=0;



    rep(i,M){
        cin >> A >> B;

        if(ma[A-1]<H[B-1]) ma[A-1]=H[B-1];
        if(ma[B-1]<H[A-1]) ma[B-1]=H[A-1];       
    }

    rep(i,N){
        if(H[i]>ma[i]) ans++;
    }

    cout << ans << endl; 

    return 0;

}

Measured memory_bytes: 5100
#include <stdio.h>
int getSn(long long int n);
int main(void) {
	int i, j;
	long long int x = 1;
	int k;
	long long int n = 1;
	int cnt = 0;
	scanf("%d", &k);
	puts("1");
	for (i=1; i < k; i++) {
		if ((i-cnt) % 9 == 0) {
			if (x + n > n * getSn(x+n)) {
				n *= 10;
				cnt = 0;
			} else {
				cnt++;
			}
		}
		x += n;
		printf("%lld\n", x);
	}
	return 0;
}

int getSn(long long int n) {
	int sn = 0;
	do {
		sn += n % 10;
		n /= 10;
	} while (n != 0);
	return sn;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin >> arr[i];
    }
    sort(arr,arr+n, greater<int>());
    ll tp=0;
    ll ans=0;
    ans+=arr[0];
    tp = n-2;
    int check=2;
    for(int i=1;i<n;i++){
        if(check>=n){
            break;
        }
    if(check+1==n){
            ans+=arr[i];
            break;
        }
        ans+=arr[i]*2;

        check+=2;

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


Measured memory_bytes: 5204
#include<stdio.h>

int max3(int a,int b,int c) {
	if (a<b) {
		if (b<c) return c;
		else return b;
	}
	else {
		if (a<c) return c;
		else return a;
	}
}

int main() {
	int a,b; scanf("%d%d",&a,&b);
	printf("%d",max3(a+b,a-b,a*b));
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
int dp[1 << 16], cost[1 << 16];
int a[17][17];
void solve(){
	int n;
	cin >> n;
	fr(i, 0, n - 1){
		fr(j, 0, n - 1){
			cin >> a[i][j];
		}
	}
	fr(mask, 1, (1 << n) - 1){
		fr(i, 0, n - 1){
			if(mask & (1 << i)){
				int ans = cost[(mask ^ (1 << i))];
				fr(j, i + 1, n - 1){
					if(mask & (1 << j)){
						ans += a[i][j];
					}
				}
				cost[mask] = ans;
				break;
			}
		}
	}
	dp[0] = 0;
	fr(mask, 1, (1 << n) - 1){
		int s = (mask - 1) & mask;
		dp[mask] = cost[mask];
		while(s > 0){
			dp[mask] = max(dp[mask], dp[s] + cost[(mask ^ s)]);
			s = (s - 1) & mask;
		}
	}
	cout << dp[(1 << n) - 1];
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int time_m[10001][1261]; // time[i][j] : i?????????????????????j????????°????????¶???

int main(){
	int N, M, r, q;
	while(true){
		cin >> N >> M;
		if(N == 0 || M == 0){
			break;
		}
		cin >> r;
		int t_, n_, m_, s_;
		for(int i = 0; i <= M; i++){
			for(int t = 540; t < 1261; t++){
				time_m[i][t] = 0;
			}
		}
		for(int loop = 0; loop < r; loop++){
			cin >> t_ >> n_ >> m_ >> s_;
			if(s_ == 1){
				time_m[m_][t_]++;
			}else{
				time_m[m_][t_]--;
			}
		}
		for(int i = 0; i <= M; i++){
			for(int t = 541; t < 1261; t++){
				time_m[i][t] += time_m[i][t - 1];
			}
		}
		cin >> q;
		int ts, te;
		for(int loop = 0; loop < q; loop++){
			cin >> ts >> te >> m_;
			int ans;
			ans = 0;
			for(int t = ts; t < te; t++){
				if(time_m[m_][t] > 0){
					ans++;
				}
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 50288
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>

int main() {
    bool st[30] = {false};
    int n;
    for (int i =0;i<28;++i) {
        scanf(" %d", &n);
        st[n-1] = true;
    }

    int r[2] = {0};
    int of = 0;
    for (int i=0; i < 30; ++i) {
        if (!st[i]) {
            r[of] = i;
            of++;
        }
    }

    if (r[1] < r[0]) {
        int t = r[0];
        r[0] = r[1];
        r[1] = t;
    }

    printf("%d\n%d\n", r[0] + 1, r[1] + 1);

    return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = list(int(i) for i in input().split())
color = []
for i in range(n):
    for j in range(8):
        if a[i]>=400*j and a[i]<400*(j+1):
            color.append(j)
            break
        elif a[i]>=3200:
            color.append(8)
            break

color_map = {}
for c in color:
    if not c in color_map.keys():
        color_map[c] = 1
    else:
        color_map[c] += 1

cmin = 0
cmax = 0
for k,v in color_map.items():
    if not k==8:
        cmin += 1
    else:
        cmax += v
cmax = cmin+cmax
if cmin==0:
    cmin = 1
print(cmin,cmax)

Measured memory_bytes: 3064
n=int(input())
x=list(map(int,input().split()))

middleIdx = n//2
s1 = sorted(x)[middleIdx-1]
s2 = sorted(x)[middleIdx]

for i in range(n):
    if x[i]<=s1:
        print(s2)
    elif x[i]>=s2:
        print(s1)

Measured memory_bytes: 25620
#include<stdio.h>
int main()

{
    int Arman_Dipu = 1;
    int H, A, i;
    int count=0;
    scanf("%d %d",&H,&A);
    if(A==0){return 0;}
    else if ( H % A == 0) 
    {
        count = (H / A);
    }
    else 
    { count = (H / A)+1;}
    
    printf("%d",count);
    return 0;
}

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

using namespace std;

int main(){

	int k, n;
	cin >> k >> n;

	int v[n], u[n];

	for(int i=0; i<n; i++) cin >> v[i];

	for(int i=1; i<n; i++) u[i-1] = v[i]-v[i-1];

	u[n-1] = k-v[n-1] + v[0];

	sort(u, u+n);

	int ans = 0;

	for(int i=0; i<n-1; i++) ans+=u[i];	

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N, K;
    cin >> N >> K;

    vector<int64_t> h(N);
    for (auto &hi: h) cin >> hi;

    vector<int64_t> dp(N, LLONG_MAX);
    dp[0] = 0;
    for (size_t i = 0; i < N; ++i) {
        for (size_t j = 1; j <= K; ++j) {
            if (i + j < N) {
                chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
            }
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


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

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

Measured memory_bytes: 256
package main

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

var INF int32 = math.MaxInt32
var INF64 int64 = math.MaxInt64

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineNum64s(bf *bufio.Reader) []int64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int64{}
	for _, field := range fields {
		num, _ := strconv.ParseInt(field, 10, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func dfs(n int, edges [][]int, visit []bool) (int, int) {
	if len(edges[n]) == 1 && visit[edges[n][0]] {
		return 1, 1
	}

	visit[n] = true

	m := 1000000007
	w := 1
	b := 1
	for _, nn := range edges[n] {
		if visit[nn] {
			continue
		}
		wi, bi := dfs(nn, edges, visit)
		w *= (wi+bi)
		b *= wi
		w %= m
		b %= m
	}

	return w, b
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	N := readLineNums(bf)[0]
	edges := make([][]int, N+1)
	for i:=0; i<N-1; i++ {
		xy := readLineNums(bf)
		if edges[xy[0]] == nil {
			edges[xy[0]] = make([]int, 0)
		}
		if edges[xy[1]] == nil {
			edges[xy[1]] = make([]int, 0)
		}
		edges[xy[0]] = append(edges[xy[0]], xy[1])
		edges[xy[1]] = append(edges[xy[1]], xy[0])
	}

	visit := make([]bool, N+1)
	w, b := dfs(1, edges, visit)
	fmt.Println((w+b)%1000000007)
}


Measured memory_bytes: 39424
S=input()
i=0
kot=[]
for a in S:
    kot.append(a)
tok=list(reversed(kot))

for a in range(len(kot)):
    if kot[a]==tok[a]:
        i=0
    else:
        print("No")
        i=1
        break
if i==0:
    for a in range(int((len(kot)-1)/2)):
        if kot[a]==tok[int((len(kot)-1)/2)-a-1]:
            i=0
        else:
            print("No")
            i=1
            break

if i==0:
        for a in range(int((len(kot)-1)/2)):
            if kot[int((len(kot)+3)/2)+a-1]==tok[-a-1]:
                i=0

            else:
                print("No")
                i=1
                break

if i==0:
    print("Yes")


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

int main(){
  int n;
  cin >> n;
  vector<int> an(n), bn(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  for(int i=0; i<n; ++i) cin >> bn[i];
  ll aplus2 = 0, bplus1 = 0;
  for(int i=0; i<n; ++i){
    if(an[i] > bn[i]) bplus1 += an[i] -bn[i];
    if(an[i] < bn[i]) aplus2 += (bn[i] -an[i]) /2;
  }
  if(bplus1 > aplus2) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007
int main(){
    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(i, n)cin >> t[i];
    rep(i, n)cin >> a[i];
    bool tmax[100010] = {false};
    bool amax[100010] = {false};
    tmax[0] = amax[n-1] = true;
    for(ll i = 1; i < n; ++i)if(t[i]!=t[i-1])tmax[i]=true;
    for(ll i = n-2; i >= 0; --i)if(a[i]!=a[i+1])amax[i]=true;
    ll ans = 1;
    rep(i, n){
        if(tmax[i] && t[i] > a[i])ans = 0;
        if(amax[i] && a[i] > t[i])ans = 0;
        if(!(tmax[i]|amax[i]))ans=(ans*min(t[i],a[i]))%MOD;
    }

    cout << ans << endl;
}

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

#define rep(i, n) for (size_t i = 0; i < (size_t)(n); ++i)

using namespace std;

int max_len(int k, const vector<int> &vec) {
  auto max = 0;
  auto n = vec.size();
  rep(i, n) {
    auto diff = i == 0 ? (k - vec[n - 1] + vec[i]) : (vec[i] - vec[i - 1]);
    if (max < diff) {
      max = diff;
    }
  }

  return max;
}

int main() {
  int k, n;
  cin >> k >> n;
  auto vec = vector<int>(n);
  for (auto &x : vec) {
    cin >> x;
  }

  cout << k - max_len(k, vec);
}


Measured memory_bytes: 1024
x = int(input())
#A = list(map(int, input().split()))
#l, r, d = map(int, input().split())

if x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
elif x <= 1999:
  print(1)

Measured memory_bytes: 9120
#include <stdio.h>

int main(){

	int	a, b;

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

	if (a == b){
		printf("a == b\n");
	}
	else if (a < b){
		printf("a < b\n");
	}
	else{
		printf("a > b\n");
	}

	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

LL lcd(LL a, LL b){
    LL c = a;
    LL d = b;
    while(d){
        c%=d;
        swap(c, d);
    }
    return a / c * b;
}

int main(){
    set<int> s;
    int N;
    cin >> N;
    REP(i, N){
        int d;
        cin >> d;
        if(s.count(d)){
            s.erase(d);
        }else{
            s.insert(d);
        }
    }
    cout << s.size() << endl;
    return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    int a, b;
    vector<int> number[N + 1];
    for (int i = 0; i < M; ++i) {
        cin >> a >> b;
        number[b].push_back(a);
    }
    bool ans = false;
    for (int i = 0; i < number[N].size(); ++i) {
        for (int j = 0; j < number[number[N][i]].size(); ++j) {
            if (number[number[N][i]][j] == 1) ans = true;
        }
    }
    if (ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF = 1<<30;

bool chmin(in &a,in b){
   if(a>b){
      a = b;
     return true;
   }
  else return false;
}

int main(){
   in n;
  cin>>n;
  vector<in> h(n);
  rep(i,n) cin>>h.at(i);
  
  vector<in> dp(n);
  rep(i,n) dp.at(i) = INF;
  
  dp.at(0) =0;
  dp.at(1) = abs(h.at(1)-h.at(0));
  
  for(int i = 2;i<n;i++){
      chmin(dp.at(i),dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    chmin(dp.at(i),dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
  }
  cout<<dp.at(n-1);
}


Measured memory_bytes: 1792
/* Dynamic Programming implementation of LCS problem */
#include<bits/stdc++.h> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X,string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
string res;// Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		res += X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 
reverse(res.begin(),res.end());
// Print the lcs 
cout << res; 
} 

/* Driver program to test above function */
int main() 
{ 
string X,Y;
  cin>>X>>Y;
int m = X.length(); 
int n = Y.length(); 
lcs(X, Y, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N;
LL d;
vector<pair<LL, pair<LL, LL>>> star;
multiset<LL> X, Y;
deque<pair<LL, pair<LL, LL>>> dq;
int main(){
	cin >> N >> d;
	for(int i=0; i<N; i++){
		LL x, y, b;
		cin >> x >> y >> b;
		star.PB({ b,{x,y} });
	}
	sort(star.begin(), star.end());
	LL ans = 0;
	for(int i=0; i<N; i++){
		while(dq.size() > 0 && dq.front().first < star[i].first-d){
			auto itr = X.find(dq.front().second.first);
			X.erase(itr);
			itr = Y.find(dq.front().second.second);
			Y.erase(itr);
			dq.pop_front();
		}
		X.insert(star[i].second.first);
		Y.insert(star[i].second.second);
		dq.push_back(star[i]);

		auto x = X.end();
		x--;
		auto y = Y.end();
		y--;
		//cout << *X.begin() << " " << *x << " " << *Y.begin() << " " << *y << endl;
		ans = max(ans, (*x-*X.begin()) * (*y-*Y.begin()));
	}
	cout << ans << endl;
}



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

int main(int argc, char *argv[]) {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];
  for(int i = 0; i < N; i++) {
    cin >> x[i];
  }
  for(int i = 0; i < M; i++) {
    cin >> y[i];
  }
  int x_max = x[0];
  for(int i = 0; i < N; i++) {
    x_max = max(x_max, x[i]);
  }
  int y_min = y[0];
  for(int i = 0; i < M; i++) {
    y_min = min(y_min, y[i]);
  }
  if(max(x_max, X) < min(y_min, Y)) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int x = 0, y = 0, t = 0;
	for(int i=1; i<=n; i++){
		int xx,yy,tt;
		scanf("%d%d%d",&tt,&xx,&yy);
		int dis = labs(xx-x) + labs(yy-y);
		if(dis > tt - t || dis%2 != (tt-t)%2){
			puts("No");
			return 0;
		}
		x = xx;
		y = yy;
		t = tt;
	}
	puts("Yes");
	return 0;
}


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

int dx[]{ 0,1,0,-1 }, dy[]{ 1,0,-1,0 };
char dir[] = "RDLU";
bool b[5][5][5][5];
int main() {
	rep(i, 9) {
		rep(j, i & 1 ? 5 : 4) {
			int d; scanf("%1d", &d);
			if (i & 1)b[i / 2][j][i / 2 + 1][j] = b[i / 2 + 1][j][i / 2][j] = d;
			else b[i / 2][j][i / 2][j + 1] = b[i / 2][j + 1][i / 2][j] = d;
		}
	}
	int id = 0, x = 0, y = 0;
	do {
		for (int i = 3;; i++) {
			int nx = x + dx[(id + i) % 4], ny = y + dy[(id + i) % 4];
			if (0 <= nx&&nx < 5 && 0 <= ny&&ny < 5 && b[x][y][nx][ny]) {
				x = nx; y = ny; (id += i) %= 4; printf("%c", dir[id]); break;
			}
		}
	} while (x != 0 || y != 0);
	printf("\n");
}

Measured memory_bytes: 3024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val inputs = Vector.fill(5)(sc.nextInt)

    val answerPre = (inputs.map(_ / 10 + 1).sum - inputs.count(_ % 10 == 0)) * 10
    val rest = if (inputs.forall(_ % 10 == 0)) 0 else inputs.filter(_ % 10 != 0).map(10 - _ % 10).max
    val answer = answerPre - rest
    println(answer)
  }
}


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

using namespace std;

typedef long long int ll;

int main(){
	int n;
	cin >> n;
	vector<vector<ll> > score(n,vector<ll>(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> score[i][j];
	vector<ll> dp(1 << n);
	dp[0] = 0;
	for(int mask = 1; mask < ( 1<< n); mask++){
		vector<int> rabbits; 
		for(int j = 0; j < n; j++){
			if(mask & (1 << j))
				rabbits.push_back(j);
		}
		int m =  rabbits.size();
		for(int i = 0; i < m-1; i++){
			for(int j = i+1; j < m; j++)
				dp[mask]+=score[rabbits[i]][rabbits[j]];
		}
	}	 
	for(int mask = 0; mask < (1<<n); mask++){
		
		for(int j = mask; j > 0; j = (j-1)&mask){
			dp[mask] = max(dp[mask],dp[j] + dp[j^mask]); 
		}
		
	}	
	cout << dp.back() << "\n";
	return 0;
}


Measured memory_bytes: 896
import Data.List (sort,sortBy, group)
import Control.Arrow ((&&&))

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  vs <- map read.words <$> getLine :: IO [Int]
  let odds = take 3 $ sortBy (flip compare) $ map (length&&&head) $ group $ sort $ map snd $ filter (odd.fst) $ zip [1..] vs
      evens = take 3 $ sortBy (flip compare) $ map (length&&&head) $ group $ sort $ map snd $ filter (even.fst) $ zip [1..] vs
      cs = [ lx+ly | (lx,x)<-odds, (ly,y)<-evens, x/=y ]
  if null cs
    then print (n`div`2)
    else print $ (+n) $ negate $ maximum cs


Measured memory_bytes: 42364
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):
#  print(sum(DD[i+1:i+2*k:2]))
#  print(DS[i+1+2*k]-DS[i+1])
#  ret[i]=T-2*sum(DD[i+1:i+2*k:2])
  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)

Measured memory_bytes: 24772
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c[a],d=0,e=1;
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	for(int i=0;i<a;i++){
		d+=c[i];
		if(d<=b){
		e++;
		}
	}
	cout<<e<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,x;
  cin>>a>>b>>x;
  
  long long int A;
  if(a!=0){
   A=(a-1)/x;
  }
  else{
     A=-1;
  }

  long long int B=b/x;
  
  long long int ans=B-A;
  

  cout<<ans<<endl;
  
 
}

   

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

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

void solve(void){
  ll x, n; cin >> x >> n;

  if (n == 0) {
    cout << x << endl;
    return;
  }
  vector<ll> v(n, 0);
  rep(n, i) cin >> v[i];

  vector<ll> vb;
  vector<ll> vc;
  for (ll i = 0; i <= 101; ++i) {
    bool flag = false;
    for (ll j = 0; j < n; ++j) {
      if (i == v[j]){
        flag = true;
        break;
      } 
    }
    if (flag == false) {
      vb.emplace_back(i);
      vc.emplace_back(abs(x - i));
    }
  }

  ll res = *(vb.end()-1);
  for (ll i = (ll)vb.size()-1; i-1 >= 0; --i) {
    if (vc[i-1] <= vc[i]) res = vb[i-1];
  }
  cout << res << endl;
}

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


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
	
long long n;
long long ans=0;
struct node{
	int num,p;
}a[100005];

bool cmp(node x,node y){
	return x.num<y.num;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
	cin>>a[i].num;
	a[i].p = i;	
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		if((abs(i-a[i].p))%2==1)ans++;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 1024
// Problem : C - Tax Increase
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
//create(tree,node,a,start,end)
//query(tree,node,start,end,l,r)
//update(tree,node,start,end,index,value)
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a,b;cin>>a>>b;
int ans=-1;
int i=1;
while(true)
{
	int x=i*8/100;
	int y=i*10/100;
	if(x==a and y==b)
	{
		ans=i;break;
	}
	else if(x>a or y>b)
	break;
	i++;
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
};

template<typename T1, typename T2>
istream& operator >> (istream& is, pair<T1, T2>& p){
  is >> p.first >> p.second;
  --p.first, --p.second;
  return is;
}
template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p){
  os << "{" << p.first << "," << p.second << "} ";
  return os;
}

int main() {
  LL N, M; cin >> N >> M;
  vector<pair<int, int>> es(M);
  for (int i = 0; i < M; ++i) cin >> es[i];

  UnionFindTree tree(N);
  LL inconvinience = N * (N - 1) / 2;
  vector<LL> ans;
  ans.reserve(N);
  for (auto it = es.rbegin(); it != es.rend(); ++it) {
    ans.push_back(inconvinience);
    int a = it->first, b = it->second;
    if (!tree.IsSameRoot(a, b)) {
      LL size_a = tree.Size(a), size_b = tree.Size(b);
      inconvinience -= size_a * size_b;
      tree.Unite(a, b);
    }
  }

  for (auto it = ans.rbegin(); it != ans.rend(); ++it) cout << *it << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
using namespace std;
 
int main (void) {
  int N, M;
  int a,b;
  int ans =0;
  cin >> N >> M;
  int A[N+1][N+1]={0};
  for (int i=1; i<=M;i++){
    cin >> a >> b;
    int x,y=0;
    x= int (A[a][b]);
    y= int (A[b][a]);
    A[a][b]=x+1;
    A[b][a]=y+1;
  }
  for (int j=1; j<=N; j++) {
    ans=0;    
    for (int k=1; k<=N; k++){
      if (A[j][k]){
        ans=ans+int(A[j][k]);
      }
    }
    cout << ans << endl;
    ans=0;
  }
}

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

namespace msolutions2020
{
    class SolverD
    {
        static void Main()
        {
            Solve();
        }

        public static void Solve()
        {
            var N = int.Parse(ReadLine());
            int[] A = ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            long money = 1000;
            long stock = 0;
            for(int day=0; day<N; day++)
            {
                if(day == N-1)
                {
                    money += stock * A[day];
                    break;
                }
                if(A[day] < A[day+1])
                {
                    long buyN = money / A[day];
                    stock += buyN;
                    money -= buyN * A[day];
                }else if(A[day] > A[day+1])
                {
                    money += stock * A[day];
                    stock = 0;
                }
                // WriteLine($"money={money}, stock={stock}");
            }
            WriteLine(money);
        }
    }
}


Measured memory_bytes: 28264
from math import gcd
 
K = int(input())
cnt = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        s = gcd(a, b)
        for c in range(1, K + 1):
            t = gcd(s, c)
            cnt += t
 
print(cnt)

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

int main(){
  int n,i;
  cin>>n;
  long long ans=0;
  map<string,int> mp;
  for(i=0;i<n;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    ans+=mp[s];
    mp[s]++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11136
"use strict";
const Main = (input) => {
	let xs = input.trim().split(' ');
    let nums =parseInt(xs[0]+xs[1]+xs[2],10);
    let ans ='';
    if(nums % 4 == 0){
    	ans = 'YES';
    }else if(nums % 4 != 0){
    	ans = 'NO';
    }  
    console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7624
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace  std;

struct StDtl
{
  int m_iLeft;

  StDtl(int a_iLeft) :
    m_iLeft(a_iLeft)
  { }

  ~StDtl() { }
};

struct StSum
{
  int m_iLeft;
  int m_iRight;
  int m_iArea;

  StSum(int a_iLeft, int a_iRight, int a_iArea) :
    m_iLeft(a_iLeft), m_iRight(a_iRight), m_iArea(a_iArea)
  { }

  ~StSum() { }
};

void fnCrossSectAreaSet(stack<StDtl> &a_rskStDtl, vector<StSum> &a_rvStSum, int &a_riTotalArea)
{
  string sCrossSect;
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
    if (sCrossSect[i] == '\\')
    {
      StDtl oDtl(i);
      a_rskStDtl.push(oDtl);
    }
    else if (sCrossSect[i] == '/')
    {
      if (a_rskStDtl.size() > 0)
      {
        int iLeft = a_rskStDtl.top().m_iLeft; a_rskStDtl.pop();
        int iSum = i - iLeft; 
        a_riTotalArea += iSum;

        while (a_rvStSum.size()  &&
               iLeft < a_rvStSum.back().m_iLeft  &&
               a_rvStSum.back().m_iRight < i       )
        {
          iSum += a_rvStSum.back().m_iArea;
          a_rvStSum.pop_back();
        }
        StSum oSum(iLeft, i, iSum);
        a_rvStSum.push_back(oSum);
      }
      else;
    }
  }
}

void  fnCrossSectAreaGet(const vector<StSum> &a_cnrvStSum, int a_iTotalArea)
{
  cout << a_iTotalArea << endl;
  cout << a_cnrvStSum.size();
  if (a_cnrvStSum.size() > 0)
  {
    cout << " ";
    for (auto itvStSum = begin(a_cnrvStSum); itvStSum != end(a_cnrvStSum); ++itvStSum)
    {
      if (itvStSum != begin(a_cnrvStSum)) cout << " ";
      cout << itvStSum->m_iArea;
    }
  }
  cout << endl;
}

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

  stack<StDtl> skStDtl;
  vector<StSum> vStSum;
  int iTotalArea = 0;

  fnCrossSectAreaSet(skStDtl, vStSum, iTotalArea);
  fnCrossSectAreaGet(vStSum, iTotalArea);

  return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

vector<vector<int>> poss1, poss2;

void choose(int pos, int k, int limit, string res, vector<vector<int>> &poss) {
    if (k == 0) {
        int z;
        vector<int> v;
        stringstream ss(res);
        while(ss >> z) v.push_back(z);
        poss.push_back(v);
        return;
    }
    if (pos == limit) return;
    choose(pos + 1, k - 1, limit, res + " " + to_string(pos), poss);
    choose(pos + 1, k, limit, res, poss);
}

int r, c, x;

bool check(vector<string> &grid, vector<int> cc, vector<int> rr) {
    int cnt = 0;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            if (binary_search(all(cc), j) || binary_search(all(rr), i))
                continue;
            if (grid[i][j] == '#') cnt++;
        }
    }
    return cnt == x;
}

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

    cin >> r >> c >> x;
    vector<string> v(r);
    for (int i = 0; i < r; ++i) cin >> v[i];

    for (int i = 0; i <= r; ++i) choose(0, i, r, "", poss1);
    for (int i = 0; i <= c; ++i) choose(0, i, c, "", poss2);

    

    int cnt = 0;
    for (int i = 0; i < poss1.size(); ++i) {
        for (int j = 0; j < poss2.size(); ++j) {
            if (check(v, poss2[j], poss1[i])) cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define uint unsigned int
void DEBUG() {
    cout << "]\n";
}
template<typename H, typename...T> void DEBUG(H h, T... t) {
    cout << h;
    if(sizeof...(t))
        cout << ", ";
    DEBUG(t...);
}
#define debug(...) cout << "[LINE: " << __LINE__ << "] -> [" << #__VA_ARGS__ << " = ", DEBUG(__VA_ARGS__)



void solve() {
    int n;
    cin >> n;
    if(n>=30)
        puts("Yes");
    else
        puts("No");
}

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

    solve();
    return 0;
}

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

using namespace std;

int main() {
    int N, X;
    int ans = 1;
    cin >> N >> X;

    vector<int> L(N), D(N+1);
    for (int i = 0; i < N; i++) {
        cin >> L[i] ;
    }

    D[0] = 0;

    for (int i = 1; i <= N; i++) {
        D[i] += D[i - 1] + L[i-1];
        if (D[i] <= X) {
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

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

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //auto dp=make_v<int>(4,h,w);
    //fill_v(dp,0);
    string s;
    cin >> s;
    print(stringcount(s, '1'));

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;
ll rec(ll n);

int main(void) {
    ll n;
    cin >> n;
    string s;
    
    if(n==0) cout << 0 << endl;
    while(abs(n)>0) {
        if(n&1) {
            s='1'+s;
            n--;
        }
        else {
            s='0'+s;
        }
        n/=-2;
    }
    
    cout << s << endl;
}

Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
const int Maxn=200000;
int n;
map<string,int> mp;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	string s;
	int maxn=0;
	for(int i=1;i<=n;i++){
		cin>>s;
		mp[s]++;
		maxn=max(maxn,mp[s]);
	}
	map<string,int>::iterator it;
	it=mp.begin();
	while(it!=mp.end()){
		if((it->second)==maxn){
			cout<<(it->first)<<endl;
		}
		it++;
	}
	return 0;
}


Measured memory_bytes: 23808
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
list = []
for k, v in hmap.items():
    if v == m:
        list.append(k)
print(*sorted(list), sep='\n')


Measured memory_bytes: 34256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int c[3][3];

int main()
{
	for(int i = 0;i<3;i++)
	{
		for(int j = 0;j<3;j++)
		{
			cin >> c[i][j];
		}
	}
	int a[3];
	for(a[0] = 0;a[0]<=100;a[0]++)
	{
		for(a[1] = 0;a[1]<=100;a[1]++)
		{
			for( a[2] = 0;a[2]<=100;a[2]++)
			{
				int b[3];
				b[0] = c[0][0] - a[0];
				b[1] = c[1][1] - a[1];
				b[2] = c[2][2] - a[2];
				if(b[0]<0||b[1]<0||b[2]<0)continue;
				bool cor= true;
				for(int i = 0;i<3;i++)
				{
					for(int j =0;j<3;j++)
					{
						if(c[i][j]!=a[i]+b[j])

						{
							cor = false;
						}
					}
				}
				//cout<<a[0];
				if(cor)
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] != 1:
  a[0] = 1
  ans += 1
b = [[]for i in range(n)]
for i in range(n):
  b[a[i]-1].append(i)
b[0].remove(0)
huka = 0
kyo = [float("inf")] * n
def dfs(x,y):
  kyo[x] = y
  for i in b[x]:
    dfs(i,y+1)
dfs(0,0)
def dfs2(x,y):
  if kyo[x] <=k-y:
    return
  if y == k-1 and x != 0:
    kyo[x] = 0
    global ans
    ans += 1
    return
  kyo[x] = 0
  dfs2(a[x]-1,y+1)
hukai = []
for i in range(n):
  hukai.append([kyo[i],i])
hukai.sort(key = lambda x:-x[0])
for j,i in hukai:
  if j <= k:
    continue
  dfs2(i,0)
print(ans)

Measured memory_bytes: 129964
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[210000];

int main(){
	int N;
	cin >> N;
	long long int S = 0;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		S += A[i];
	}
	long long int ans = S, S2 = 0;
	for(int i = 0; i < N; i++){
		S2 += A[i];
		ans = min(ans, abs(S2 - (S - S2)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int MX = 2e5;
int n, k;
int a[MX + 5];

int main(){
	k = re<int>(); n = re<int>();
	for (int i = 1; i <= n; i++) a[i] = re<int>();
	int mx = 0;
	a[n + 1] = a[1] + k;
	for (int i = 1; i <= n; i++)
		mx = max(mx, a[i+1] - a[i]);
	printf("%d\n", k - mx);
	return 0;
}


Measured memory_bytes: 1024
#define REP(i, a, b) for(int i = a; i < b; i++)

int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main(void){
    int h,w;
    scanf("%d%d",&h,&w);
    char s[h][w];
    REP(i, 0, h) {
        scanf("%s",s[i]);
    }
    REP(i, 0, h + 2) {
        REP(j, 0, w + 2) {
            if (i != 0 && j != 0 && i != h + 1 && j != w + 1) {
                printf("%c",s[i - 1][j - 1]);
            } else {
                printf("#");
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <map>
#include <array>

using namespace std;

int way[4] = {-1, +4, +1, -4};

inline int xy2pos(int x, int y){
  return y*4 + x;
}

inline int pos2x(int pos){
  return pos % 4;
}

inline int pos2y(int pos){
  return pos / 4;
}

map<array<int, 8>, int> m;

void Solve(){
  queue<pair<array<int, 8>, int> > q;
  array<int, 8> a;
  for(int i=0; i<8; i++)
	a.at(i) = i;
  q.push(make_pair(a, 0));
  
  while(q.size()){
  	pair<array<int, 8>, int> p = q.front();
  	q.pop();

  	if(m.find(p.first) != m.end()){
  	  continue;
  	}

  	m.insert(make_pair(p.first, p.second));

  	int pos_0;
  	for(int i=0; i<8; i++){
  	  pos_0 = (p.first[i] == 0) ? i : pos_0;
  	}
	
  	for(int i=0; i<4; i++){
  	  int npos = pos_0 + way[i];
  	  if(npos < 0 || npos >= 8 ||
  		 (pos_0 == 3 && npos == 4) || (pos_0 == 4 && npos == 3)){
  		continue;
  	  }
  	  swap(p.first[pos_0], p.first[npos]);
  	  q.push(make_pair(p.first, p.second + 1));
  	  swap(p.first[pos_0], p.first[npos]);	  
  	}
  }
}

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

  Solve();
  while(1){
	array<int, 8> a;
	cin >> a.at(0);
	if(cin.eof()){
	  return 0;
	}
	for(int i=1; i<8; i++){
	  cin >> a.at(i);
	}
	cout << m.at(a) << endl;
  }
}

Measured memory_bytes: 4720