akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 55;

vint graph[MAX_N];

int N, X, D;
vint m, p, l;

vint subw, subv;

void dfs(int u) {
  subv[u] = 1;
  subw[u] += m[u];
  for(int v : graph[u]) {
    dfs(v);
    subv[u] += subv[v];
    subw[u] += subw[v];
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> X >> D;
  resz(m, N);
  resz(p, N);
  resz(l, N, D);
  l[0] = 1000000000;
  cin >> m[0];
  reps(i, 1, N) {
    cin >> m[i] >> p[i];
    --p[i];
    graph[p[i]].push_back(i);
  }
  resz(subw, N);
  resz(subv, N);
  dfs(0);

  vector<tuple<double, int, int, int> > vec;
  rep(i, N) {
    if(l[i] > 50) {
      vec.emplace_back((double)subv[i]/subw[i], subv[i], subw[i], l[i]-50);
      l[i] = 50;
    }
  }
  sort(all(vec));
  reverse(all(vec));


  vint dp(50*50*50+1, LLONG_MAX/2);
  dp[0] = 0;
  rep(i, N) {
    int lim = l[i];
    for(int k = 0; lim > 0; ++k) {
      int num = min(lim, 1LL<<k);
      for(int j = 50*50*50-subv[i]*num; j >= 0; --j) {
	if(dp[j] == LLONG_MAX/2) continue;
	chmin(dp[j+subv[i]*num], dp[j]+subw[i]*num);
      }
      lim -= num;
    }
  }
  /*
  rep(i, 50*50+1) {
    if(dp[i] < LLONG_MAX/2) cout << i << " " << dp[i] << endl;
  }
  */
  int ans = 0;
  rep(i, 50*50*50+1) {
    int tmp = i;
    int x = X-dp[i];
    if(x < 0) continue;
    rep(j, vec.size()) {
      double e;
      int a, b, c;
      tie(e, a, b, c) = vec[j];
      if(x >= b) {
	int num = min(c, x/b);
	tmp += num*a;
	x -= num*b;
      }
    }
    if(tmp > ans) ans = tmp;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,ptr=0,res=0;
    cin >> n;
    int A[n+10];

    rep(i,n){
        cin >> A[i];
    }

    sort(A,A+n);

    while(ptr<n){
        int cc=A[ptr], f=0;
        while(ptr<n && A[ptr] == cc){
            f++;ptr++;
        }
        res += f%2;
    }

    cout << res << endl;
}

Measured memory_bytes: 640
m,d=map(int,input().split())
cnt=0
for i in range(1,m+1):
    for j in range(1,d+1):
        d_10=j//10
        d_1=j%10
        if (d_1>=2)&(d_10>=2):
            if i==d_10*d_1:
                cnt+=1
print(cnt)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long double a, long double b, long double x)
{
    long double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans =  M_PI / 2 - atan(2 * x / (a * b * b));
    }

    cout << fixed << setprecision(10) << ans * 180.0 / M_PI << endl;
}

int main()
{
    long double a;
    long double b;
    long double x;
    cin >> a >> b >> x;
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

ll extgcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

ll invmod(ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}

ll nCk(ll n, ll k, ll mod) {
  ll ans = 1;
  for (ll i = n, j = 1; j <= k; i--, j++) ans = (((ans * i) % mod) * invmod(j, mod)) % mod;
  return ans;
}

ll n, m;
vector<ll> primeC;
ll mod = 1000000007;

int main() {
  scanf("%lld%lld", &n, &m);
  ll i = 2;
  while (m != 1) {
    ll c = 0;
    while (m % i == 0) {
      c++;
      m /= i;
    }
    if (c > 0) primeC.push_back(c);
    i++;
  }
  ll ans = 1;
  for (ll i = 0; i < primeC.size(); i++) {
    ans = (ans * nCk(primeC[i] + n - 1, primeC[i], mod)) % mod;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
priority_queue<int> q;
int n,m,a,b;
vector<int> jo[100100];
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		jo[a].push_back(b);
	}
	int res=0;
	for(int i=1;i<=m;i++){
		for(int j:jo[i])
			q.push(j);
		if(q.size()){
			res+=q.top();
			q.pop();
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	while (N) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}
	cout << "No" << endl;
}


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


 int main (void) {
   map<string,int>memo;
 int n;
 cin >> n;
 for (int i = 0; i < n; i++) {
 string s;
 cin >> s;

 memo[s] += 1;
 }


 int maxv = 0;
 for (const auto& x : memo) {
 int v = x.second;
 if (v > maxv) maxv = v;
 }
 for (auto it = memo.begin(); it != memo.end(); it++) {
 if (it->second == maxv) {
 cout << it->first << endl;
 }
 }
 }


Measured memory_bytes: 25216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<long long>b[8];
	vector<long long>x;
	vector<long long>y;
	vector<long long>z;
	int n, m;
	long long xx, yy, zz;
	long long s, ans;
	s = 0;
	ans = 0;
	scanf("%d %d", &n, &m);
	f(i, n){
		scanf("%lld %lld %lld", &xx,&yy,&zz);
		x.push_back(xx);
		y.push_back(yy);
		z.push_back(zz);
	}
	yy = -1000000000000000000;
	f(kk, 8){
		f(i, n){
			xx = 0;
			if (kk % 2 > 0)xx += x[i];
			else xx -= x[i];
			if (kk % 4 > 1)xx += y[i];
			else xx -= y[i];
			if (kk > 3)xx += z[i];
			else xx -= z[i];
			b[kk].push_back(xx);
		}
		sort(b[kk].begin(), b[kk].end(),greater<long long>());
		zz = 0;
		f(i,m){
			zz += b[kk][i];
		}
		if (yy < zz)yy = zz;
	}
	printf("%lld\n", yy);

	return 0;
}

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> A(n);
        for(int i = 0; i < n; i++) cin >> A[i];
        sort(A.begin(), A.end());
        int ans = INF;
        for(int i = 0; i < n - 1; i++)
        {
            ans = min(ans, abs(A[i] - A[i + 1]));
        }
        cout << ans << endl;
    }
    return 0;
}




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

int main(){
  int n;
  std::cin >> n;
  if (n == 0)
    return -1;

  long price, min_price;
  long max_diff = 1 - 10e+9;
  std::cin >> min_price;
  while(std::cin >> price){
    max_diff = std::max(max_diff, price - min_price);
    min_price = std::min(min_price, price);
  }

  std::cout << max_diff << std::endl;
}

Measured memory_bytes: 3116
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut strs = vec![];
    for i in 0..n {
        strs.push(read::<String>());
    }
    strs.sort();
    for string in strs {
        print!("{}", string);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,n) for (int i = a; i < n; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
double PI=acos(-1.0);
using namespace std;
int mod = 1000000007;
int inf=INT_MAX;
int minf = INT_MIN;

int main()
{
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3600
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(-(-N//2))


Measured memory_bytes: 6100
n = int(input())
ch = ['a','b','c','d','e','f','g','h','i','j']
def l (num,s):
    global n
    global ch
    if num == n:
        return s
    new = []
    for i in s:
        x = len(set(i)) +1
        for j in range(x):
            p = i + ch[j]
            new.append(p)
    return num+1,new
dt = (1,['a'])
for k in range(n):
    dt = l(dt[0],dt[1])
for z in dt:
    print(z)

Measured memory_bytes: 12984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    ll n,cnt = 1,ans = 0;
    cin >> n;
    vector<ll> dp(n + 1);
    dp[0] = 0;
    nfor(i, 1, n + 1){
        cin >> dp[i];
        dp[i] += dp[i - 1];
    }
    sort(dp.begin(), dp.end());
    rep(i, n){
        if (dp[i] == dp[i + 1]) {
            cnt++;
        }else{
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    ans += cnt * (cnt - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }


const int maxN = 100 + 1, maxK = 3 + 1;

int dp[2][maxN][maxK];

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    str s;
    int k;
    cin >> s >> k;
    int n = sz(s);
    dp[1][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int val = 0; val < 10; val++) {
            for (int j = 0; j <= k; j++) {
                int ok = (val > 0);
                if (j - ok < 0) {
                    continue;
                }
                if (val > s[i - 1] - '0') {
                    dp[0][i][j] += dp[0][i - 1][j - ok];
                }
                if (val == s[i - 1] - '0') {
                    dp[0][i][j] += dp[0][i - 1][j - ok];
                    dp[1][i][j] += dp[1][i - 1][j - ok];
                }
                if (val < s[i - 1] - '0') {
                    dp[0][i][j] += dp[0][i - 1][j - ok] + dp[1][i - 1][j - ok];
                }
            }
        }
    }
//    for (int x = 0; x < 2; x++) {
//        for (int i = 0; i <= n; i++) {
//            for (int j = 0; j <= k; j++) {
//                cout << dp[x][i][j] << ' ';
//            }
//            cout << endl;
//        }
//        cout << endl;
//    }

    cout << dp[0][n][k] + dp[1][n][k];

    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int A,B,K;
signed main() {
  cin>>A>>B>>K;
  bool a=true;
  for(int i=0;i<K;i++){
    if(a){A/=2;B+=A;}
    else{B/=2;A+=B;}
    a=!a;
  }
  cout<<A<<" "<<B<<endl;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var count = Math.Min(s.Count(x => x == '0'), s.Count(x => x == '1'));
            Console.WriteLine(2 * count);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
typedef long long LL;
const int MAXN = 1e5+1;
LL A[MAXN], C[MAXN], S[MAXN];
int find(int L, int R, LL x)
{
	int mid;
	while (L < R)
	{
		mid = (L+R)>>1;
		if(A[mid] >= x)
			R = mid;
		else
			L = mid+1;
	}
	return L;
}
int main()
{
	int N, Q, i, pos, Len = 0;
	LL x;
	scanf("%d%d", &N, &Q);
	A[Len++] = N;
	for(i=0; i<Q; ++i)
	{
		scanf("%lld", &x);
		while (Len && A[Len-1]>=x) --Len;
		A[Len++] = x;
	}
	C[Len-1] = 1;
	for(i=Len-1; i>=0; --i)
	{
		x = A[i];
		while (x > A[0])
		{
			pos = find(0, Len, x)-1;
			C[pos] += C[i] * (x / A[pos]);
			x %= A[pos];
		}
		S[x] += C[i];
	}
	for(i=N-1; i>0; --i)
		S[i] += S[i+1];
	for(i=1; i<=N; ++i)
		printf("%lld\n", S[i]);
}

Measured memory_bytes: 3968
<?php
fscanf(STDIN, "%d", $n);
$x = 0;
$m = 101;
while ($n--) {
	fscanf(STDIN, "%d", $s);
	$x += $s;
	if ($s % 10 && $s < $m) $m = $s;
}
echo $x % 10 ? $x : ($m <= 100 ? $x - $m : 0);

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

int func(pair<int, int> i1, pair<int, int> i2){
    return abs(i1.first - i2.first) + abs(i1.second - i2.second);    
}
int main(){
    int H, W, D;
    cin >> H >> W >> D;

    std::vector<pair<int, int>> loc(H * W);
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            int a;
            cin >> a;
            loc[a-1] = pair<int, int>(i, j);
        }
    }

    std::vector<std::vector<int>> mem(D);
    for(int i = 0;i < D;i++){
        int j = i + D;
        int sum = 0;
        mem[i].push_back(0);
        while(j < H * W){
            sum += func(loc[j - D], loc[j]);
            mem[i].push_back(sum);
            j += D;
        }
        // for(int m : mem[i]){
        //     cout << m << ", ";
        // }
        // cout << endl;
    }

    int Q;
    cin >> Q;
    for(int i = 0;i < Q;i++){
        int L, R;
        cin >> L >> R;
        int d = (L - 1) % D;
        // L = (L - 1) / D;
        // R = (R - 1) / D;
        cout << mem[d][(R - 1) / D] - mem[d][(L - 1) / D] << endl;
    }




}


Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
int main(){
    int x, y;
    while(std::cin >> x >> y && (x != 0 || y != 0)){
        if(x > y){ std::swap(x, y); }
        std::cout << x << " " << y << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2968
import math
import itertools
#n = int(input())
#n, d = list(input().split())
#n, l = list(map(int, input().split()))
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    if A[i]%2==0:
        if not(A[i]%3==0 or A[i]%5==0):
            print("DENIED")
            exit()

print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <numeric>
#include <map>
#include <cstring>
using namespace std;

int main(){
    long long N, Q;
    long long A[200000];
    long long B[200000];
    long long P[200000];
    long long X[200000];
    long long S[200001];
    memset(S, 0, sizeof(S));
    cin>>N;
    cin>>Q;
    for(long long i=0;i<N-1;i++){
        cin>>A[i];
        cin>>B[i];
    }
    for(long long i=0;i<Q;i++){
        cin>>P[i];
        cin>>X[i];
    }
    // printf("N=%d, Q=%d\n", N, Q);
    // for (int i = 0; i < N-1; ++i) {
    //     printf("A=%d, B=%d\n", A[i], B[i]);
    // }
    // for (int i = 0; i < Q; ++i) {
    //     printf("P=%d, X=%d\n", P[i], X[i]);
    // }

    std::map<long long, std::vector<long long>> C;

    for(long long i=0;i<N-1;i++){
        auto a = A[i];
        auto b = B[i];
        if (a > b) {
            auto c = b;
            b = a;
            a = c;
        }
        if (C.count(a) == 0) {
            std::vector<long long> r;
            C[a] = r;
        }
        C[a].push_back(b);
    }
    for(long long i=0;i<Q;i++){
        auto p = P[i];
        auto x = X[i];
        S[p - 1] += x;
    }
    // for (long long i = 0; i < N; ++i) {
    //     std::cout << S[i] << endl;
    // }

    for (long long i = 1; i < N; ++i) {
        if (C.count(i) == 0) {
            continue;
        }
        auto r = C[i];
        auto s = S[i - 1];
        // printf("i=%d, s=%d, ", i, s);
        for (auto j: r) {
            // printf("j=%d", j);
            S[j - 1] += s;
        }
        // printf("\n");
    }

    for (long long i = 0; i < N; ++i) {
        std::cout << S[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 32128
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int n;

int main(){
	ri(n);
	ll ans = 1LL * n * (n-1) / 2LL;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def solve():
    x, y, z, n = [int(input()) for _ in range(4)]
    ans = 0
    for i in range(x+1):
        for j in range(y+1):
            for k in range(z+1):
                if 500 * i + 100 * j + 50 * k == n:
                    ans += 1
    return ans

print(solve())


Measured memory_bytes: 2940
n = int(input())
s = [int(input()) for i in range(n)]

S = sum(s)

if S%10 != 0:
  print(S)
  
else:
  re = float('inf')
  for i in range(n):
    if s[i]%10 != 0:
      re = min(re,s[i])
      
  if re != float('inf'):
    print(S-re)
  else:
    print(0)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >> N;
  int T;
  cin >>T;
  vector<int>c(N);
  vector<int>t(N);
  rep(i,N) {
    cin >>c.at(i)>>t.at(i);
  }
  int count=0;
  rep(i,N) {
    if(t.at(i)>T) {
      count++;
    }
  }
  if(count==N) {
cout <<"TLE"<< endl;
  }
  
  
  else {
    vector<pair<int ,int>> P(N);
    rep(i,N) {
      if(t.at(i)<=T) {
      P.at(i).first=c.at(i);
      P.at(i).second=t.at(i);
      }
    }
    sort(all(P));
    rep(i,N) {
      if (P.at(i).first !=0) {
        cout <<P.at(i).first<< endl;
        break;
      }
      
    
    
  }
}
    
}   
      
 

Measured memory_bytes: 256
n = int(input())
ss = []
for i in range(n):
    s = list(input())
    s.sort()
    ss.append(s)
ans = []
ans = ss[0]
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
print(''.join(ans))


Measured memory_bytes: 3064
N, K = map(int, input().split())
V = list(map(int, input().split()))
dp = [[-10 ** 10 for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        if i+j <= N and i+j <= K:
            nokori = K - i - j
            now = []
            now.extend(V[:i])
            if j != 0:
                now.extend(V[-j:])
            now.sort()
            nowmax = sum(now)
            #print(nokori)
            #print(now)
            for k in range(min(nokori, len(now))):
                nnn = now.pop(0)
                if nnn < 0:
                    nowmax -= nnn
                else:
                    break
            dp[i][j] = nowmax
#print(dp)
ans = -10 ** 10
for i in range(N+1):
    ans = max(ans, max(dp[i]))
print(ans)




Measured memory_bytes: 3188
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

#define ll long long
#define INF ((int)1e9+1)

using namespace std;

signed main(){
    /* 入力の受け取り(Aは逆順) */
    int n;
    cin >> n;
    int* a = new int[n];
    for (int i = 1;i <= n;++i)
        cin >> a[n - i];
    /* 逆順AのLISを考える */
    int dp[n];
	fill(dp, dp + n, INF);
	for (int i = 0; i < n; ++i) {
		*lower_bound(dp, dp + n, a[i] + 1) = a[i];
	}
    cout << lower_bound(dp, dp + n, INF) - dp << endl;
    /* メモリの開放、プログラムの終了 */
    delete[] a;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>


int main(){

int menit;
int angkaangka[5];
for(int i=0;i<5; i++){
    scanf("%d", &angkaangka[i]);
}
//for(int i=0;i<5; i++){
//   printf("%d ", angkaangka[i]);
//}
int jam=angkaangka[2]-angkaangka[0];
//printf("total jam: %d\n", jam);
if(angkaangka[3]>angkaangka[1]){
    menit=angkaangka[3]-angkaangka[1];
}
else if(angkaangka[1]>angkaangka[3]){
    menit=60-(angkaangka[1]-angkaangka[3]);
    jam--;
}
else{
    menit=0;
}
//printf("total menit=%d\n", menit);
//printf("total k= %d\n", angkaangka[4]);
printf("%d\n", jam*60+menit-angkaangka[4]);





    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
using namespace std;
static const int MAX_IDX = 2e5;
static const int INF = 1e9 + 5;

int L[MAX_IDX/2 + 1];
int R[MAX_IDX/2 + 1];

void merge(int *A, int left, int mid, int right) {
  int len_left = mid - left;
  int len_right = right - mid;

  for (int i = 0; i < len_left; i++) {
    L[i] = A[left + i];
  }

  for (int i = 0; i < len_right; i++) {
    R[i] = A[mid + i];
  }

  L[len_left] = INF;
  R[len_right] = INF;
  int i = 0;
  int j = 0;

  for (int k = left; k < right; k++) {
    if (L[i] > R[j]) {
      A[k] = R[j++];

    } else {
      A[k] = L[i++];
    }
  }
}

void mergeSort(int *A, int left, int right) {
  //recursion version
  if (left + 1 < right) {

    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int n;
  cin >> n;
  int A[n];
  int B[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  mergeSort(A, 0, n);

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (B[i] != A[i]) {
      cnt++;
    }
  }

  if ((cnt == 0) || (cnt == 2)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

//クラス名をMainに
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		int i,j;
		int min = 0;
		int num = 0;
		
		for(i = 0; i < N; i++){
			 a[i] = sc.nextInt();
			 b[i] = sc.nextInt();
		}
		for(i = 0; i < M; i++){
			 c[i] = sc.nextInt();
			 d[i] = sc.nextInt();
		}
		//Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
		for(i = 0; i < N; i++){
			min = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			num = 0;
			for(j = 0; j < M; j++){
				if(min > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])){
					min = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
					num = j;
				}
			}
			System.out.println(num + 1);
		}
		
	}
}


Measured memory_bytes: 23764
func gcd(x: Int, _ y: Int) -> Int {
    if y == 0 {
        return x
    } else {
        return gcd(y, x%y)
    }
}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!} + [input[1]]).sort()
let d = (1...input[0]).map{x[$0] - x[$0-1]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)

Measured memory_bytes: 6844
sum[3<<17],cnt[3<<17];
N,i,acc,t,k,x;
char f[10];
main()
{
	for(;;)
	{
		k=getchar_unlocked();
		if(k<'0'||k>'9')break;
		N=N*10+k-'0';
	}
	for(i=0;i<N;i++)
	{
		x=0;
		for(;;)
		{
			k=getchar_unlocked();
			if(k<'0'||k>'9')break;
			x=x*10+k-'0';
		}
		++sum[cnt[x]++];
	}
	i=0;
	for(t=N;t;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)
	{
		if(!cnt[i])
		{
			putchar_unlocked('0');
		}
		else
		{
			if(cnt[i-1]!=cnt[i])
			{
				k=0;
				t=cnt[i];
				while(t)
				{
					f[k++]=t%10;
					t/=10;
				}
				acc=k;
			}
			else k=acc;
			while(k--)putchar_unlocked(f[k]+'0');
		}
		putchar_unlocked('\n');
	}
}

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

using namespace std;

int main() {
    
    ios_base::sync_with_stdio(false); 
 
    cin.tie(NULL);
 
    cin.tie(NULL);
  	int n;
  	cin>>n;
  	int q=(n/1000);
  	if(n%1000){q++;}
  	q=q*1000-n;
  	cout<<q<<"\n";
  return 0;
}

Measured memory_bytes: 3612
import * as fs from 'fs'
const reader = (s: string) =>
  s
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input: string) {
  const [N, ...d] = reader(input)
  let answer = 0
  for (let i = 0; i < N - 1; i++) {
    for (let j = i + 1; j < N; j++) {
      answer += d[i] * d[j]
    }
  }

  console.log(answer)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int count = 0;
        for(int i = 0;i<s.length();i++){
            if(s.charAt(i) != t.charAt(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 42344
N,K = map(int,input().split())
a = list(map(int,input().split()))

def f(N,K,a):
    a.sort()
    if a[0] >= K:
        print(0)
        exit()

    a = [a[i] for i in range(N) if a[i]<K]
    N = len(a)
    ans = N
    dp = [False]*K
    dp[0] = True
    Smax = 0
    for i,a_ in reversed(list(enumerate(a))):
        if Smax + a_ >= K:
            ans = i
        updated = True
        for j in range(min(Smax,K-a_-1),-1,-1):
            if dp[j]:
                dp[j+a_]=True
                if updated:
                    Smax = max(Smax,j+a_)
                    updated = False
    return ans

print(f(N,K,a))

Measured memory_bytes: 3828
import numpy as np
 

A = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
  b = int(input())
  A = np.where(A == b, 0, A)
  
x = np.all(A[[0, 1, 2], [0, 1, 2]] == 0)
y = np.all(A[[0, 1, 2], [2, 1, 0]] == 0)
z = np.any(np.sum(A, axis=0) == 0)
w = np.any(np.sum(A, axis=1) == 0)
 
print(['Yes', 'No'][not x and not y and not z and not w])

Measured memory_bytes: 12488
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long K){
  if (2*K > N + 1) {
    std::cout << -1 << std::endl;
    return;
  }
  long long M = K + 3*N -1;
  long long a, b, c;
  c = M;
  b = M - N;
  for (int i = 0; i < (N+1)/2; i++) {
    a = K + (N+1)/2 - i -1;
    std::cout << a << " " << b << " " << c << std::endl;
    c -= 2;
    b -= 1;
  }
  c = M - 1;
  for (int i = 0; i < N/2; i++) {
    a = K + (N+1)/2 + N/2 - i-1;
    std::cout << a << " " << b << " " << c << std::endl;
    c -= 2;
    b -= 1;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>





using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());
const int MOD = 1000000007;
const int INF = INT_MAX;
const double PI = 3.14159265358979323846;



int main(int argc, char const *argv[])
{
    int x, a, b;
    cin >> x >> a >> b;

    x -= a;
    x %= b;
    


    cout << x << endl;






    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    ll x; cin >> x;
    int up = 5000,down = -5000;
    for(int a = 0;a<up+1;a++){
        for(int b = down;b<up+1;b++){
            if(pow(a,5) - pow(b,5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4228
#include<cstdio>
#define MIN(a,b) ((a)<(b)?(a):(b))
signed main()
{
	long long a,b,c;
	return scanf("%lld%lld%lld",&a,&b,&c),printf("%lld\n",a&1&&b&1&&c&1?MIN(MIN(a*b,a*c),b*c):0),0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	int a;
	a=2*d+1;
	if(n%a==0)
	{
		cout<<n/a;
    }
	else
		cout<<n/a+1;	
}


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

using namespace std;

#define int int64_t

int get(int x) {
    cout << x << endl;
    string s;
    cin >> s;
    if(s == "Vacant") {
        exit(0);
    } else {
        return s == "Male";
    }
}

signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    
    int l = 0, r = n - 1;
    int A = get(l);
    int B = get(r);
    while(true) {
        int m = (l + r) / 2;
        int C = get(m);
        int t = m - l + 1;
        if((A == C) != (t % 2 == 0)) {
            l = m;
            A = C;
        } else {
            r = m;
            B = C;
        }
    }
    
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

  int e,x,y,z;

  for(;;){
    cin >> e;
    if(!e)break;
    int xm = e+1;
    int ym = (int)sqrt(e)+1;
    int zm = (int)cbrt(e)+1;

    int f,g2,g3,m=3*e;
    for(int i=zm;0<=i;--i){
      for(int j=0;j<=ym;++j){
	if(i*i*i+j*j<=e){
	  int k=e-i*i*i-j*j;
	  f=i+j+k;
	  if(f<m)m=f;
	}
      }
    }
    
    cout << m << endl;
  }
  
}

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

void solve()
{
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(bit, 1 << n - 1)
    {
        string t;
        rep(i, n - 1)
        {
            t += s[i];
            if ((bit >> i) & 1)
            {
                t += "+";
            }
        }
        t += s[n - 1];
        t += "+";
        ll sum = 0;
        rep(i, t.size())
        {
            if (t[i] == '+')
            {
                ans += sum;
                sum = 0;
            }
            else
            {
                sum *= 10;
                sum += t[i] - '0';
            }
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3632
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        double a =sc.nextInt();

        double two=Math.sqrt(a);
        double three=Math.cbrt(a);
        double four=Math.pow(a,0.25);
        double five=Math.pow(a,0.2);

        double unti[];
        unti=new double[4];
        unti[0]=Math.floor(two);
        unti[1]=Math.floor(three);
        unti[2]=Math.floor(four);
        unti[3]=Math.floor(five);
        double max=0;
        for(int i=0;i<4;i++){
             double jo=Math.pow(unti[i],i+2);
            max=Math.max(max,jo);
        }
        int ans=(int)max;
        System.out.println(ans);


        
    }
}

Measured memory_bytes: 23252
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  two = 0
  four = 0
  for i in a:
    if i %4 == 0:
      four += 1
    elif i%2 == 0:
      two += 1
  four += two//2
  if n <= four*2+1:
    print("Yes")
  else:
    print("No")
solve()

Measured memory_bytes: 14636
#include<iostream>
using namespace std;
int main()
{ int x;
	cin>>x;
	int a,v=0;
	for(int i=1;i<=x;i++)
	{
		cin>>a;
		if(a!=i)
		 v++;
		
		
	}
	if(v==0||v==2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;	
    
    
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

const int mod = 1'000'000'007;

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

int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cur = 1;
  int ans = 0;
  for (int i = 1; i <= n + 1; ++i) {
    cur = add(cur, (n + 1) - i);
    cur = sub(cur, i - 1);
    if (i >= m) {
      ans = add(ans, cur);
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	bool ok = (s.size() % 2 == 0);
	for (int i = 0; i < s.size(); ++i) {
		if (i % 2 == 1 && s[i] != 'i') { ok = false; }
		if (i % 2 == 0 && s[i] != 'h') { ok = false; }
	}
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )

int main()

{  
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    while(n>0)
    {
        n/=k;
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	counter := 0
	for i := 0; i < N-2; i++ {
		char := S[i : i+1]
		if char == "A" {
			if S[i+1:i+2] == "B" && S[i+2:i+3] == "C" {
				counter++
			}
		}
	}

	fmt.Println(counter)
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2100000
using ll = long long;

//二項係数を求める。

ll fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  ll ans = 0;
  ll X,Y; cin>>X>>Y;
  for(ll w = 0; w*2 <= X; w++){
    ll h = X - 2*w;
    if(w+h*2==Y){
      ans += COM(w+h,w);
      ans %= MOD;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n; i>0; i--)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int type = 26;

int main() {
	int D;
	cin >> D;
	// 不開催により低下する満足度
	int dec = 0;
	vector<int64_t> c(type);
	vector<vector<int64_t>> l(type, vector<int64_t>(1, -1));
	rep(i, type) {
		cin >> c.at(i);
		dec += c.at(i);
	}
	// 開催により増加する満足度
	vector<vector<int64_t>> s(D, vector<int64_t>(type));
	rep(i, D) {
		rep(j, type) {
			cin >> s.at(i).at(j);
		}
	}

	// 仮の日程
	vector<int64_t> t(D);
	// rep(i, D) {
	// 	cin >> t.at(i);
	// 	t.at(i)--;
	// }

	// 日程変更クエリ
	// int M;
	// cin >> M;
	// vector<pint> dq(M);
	// rep(i, M) {
	// 	cin >> dq.at(i).first >> dq.at(i).second;
	// 	dq.at(i).first--;
	// 	dq.at(i).second--;
	// }

	// 初期解の満足度計算
	int64_t a=0, b=0, x, y, z;
	rep(i, D) {
		// i日目に開催するtype
		x = 0;
		y = 0;
		rep(j, type) {
			if(chmax(y, s.at(i).at(j))) {
				x = j;
			}
		}
		t.at(i) = x;
		// 開催による増加
		a += s.at(i).at(x);
		// 不開催による減少
		b += (dec - c.at(x)*(i-l.at(x).at(l.at(x).size()-1)));
		l.at(x).push_back(i);
		a -= b;
		// 暫定満足度
		// cout << a << endl;
	}
	rep(i, type) {
		l.at(i).push_back(D);
	}

	// 変更処理
	// rep(i, M) {
	// 	x = dq.at(i).first;
	// 	y = t.at(x);
	// 	z = dq.at(i).second;
	// 	t.at(x) = z;
	// 	// 開催による増加差分
	// 	a -= s.at(x).at(y);
	// 	a += s.at(x).at(z);
	// 	// 不開催による減少差分 減少
	// 	int f = 0;
	// 	rep1(j, l.at(y).size()) {
	// 		if (l.at(y).at(j-1) == x) {
	// 			l.at(y).at(j-1) = l.at(y).at(j);
	// 			l.at(y).at(j) = x;
	// 		} else {
	// 			f = j;
	// 		}
	// 	}
	// 	l.at(y).pop_back();
	// 	a -= (l.at(y).at(f) - x) * (x - l.at(y).at(f-1)) * c.at(y);
	// 	// 不開催による減少差分 増加
	// 	f = 0;
	// 	l.at(z).push_back(x);
	// 	rrep(j, l.at(z).size()-1) {
	// 		if (l.at(z).at(j-1) > x) {
	// 			l.at(z).at(j) = l.at(z).at(j-1);
	// 			l.at(z).at(j-1) = x;
	// 		} else {
	// 			f = j;
	// 			break;
	// 		}
	// 	}
	// 	a += (l.at(z).at(f+1) - x) * (x - l.at(z).at(f-1)) * c.at(z);
	// 	// 暫定満足度
	// 	cout << a << endl;
	// }

	// 解
	rep(i, D) {
		cout << t.at(i)+1 << '\n';
	}
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
const int mod= 1e9+7;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " is " << x << endl;
int main()
{
    int n,x;
    cin>>n;

    bool bo=1;
    for (int i=0; i<n; ++i)
    {
        cin>>x;
        if (x%2==0)
        {
            if (x%3!=0 && x%5!=0)
                bo=0;
        }
    }
    bo?cout<<"APPROVED":cout<<"DENIED";



}


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

bool bo[200010],fl;
int n,k,p[200010],ans,nxt[200010];
set<int> s;

int main()
{
	scanf("%d%d",&n,&k),s.clear(),ans=0,fl=0;
	for (int i=1 ;i<=n; i++) scanf("%d",&p[i]);
	for (int i=1; i<=k; i++) s.insert(p[i]);
	for (int i=1 ;i<n; i++) nxt[i]=(p[i]<p[i+1]);
	nxt[n]=n;
	for (int i=n-1; i; i--) if (nxt[i]) nxt[i]=nxt[i+1]; else nxt[i]=i;
	for (int i=1; i<=n-k+1; i++) bo[i]=(nxt[i]>=i+k-1);
	for (int i=k+1; i<=n; i++)
	{
		bool bo1=0,bo2=0;
		if ((*s.begin())==p[i-k]) bo1=1;
		s.erase(p[i-k]),s.insert(p[i]);
		if ((*s.rbegin())==p[i]) bo2=1;
		if (bo1&&bo2) ans++; else
		if (bo[i-k]) {if (!fl) fl=1; else ans++;}
	}
	if (bo[n-k+1]) {if (!fl) fl=1; else ans++;}
	printf("%d\n",n-k+1-ans);
	return 0;
}

Measured memory_bytes: 11136
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  if A[i] == B[i] and B[i] == C[i]:
    pass
  elif A[i] == B[i]:
    ans += 1
  elif B[i] == C[i]:
    ans += 1
  elif C[i] == A[i]:
    ans += 1
  else:
    ans += 2
    
print(ans)

Measured memory_bytes: 3064
use std::io::stdin;

fn main(){
    let points = getvec();
    let (sx, sy, tx, ty) = (points[0], points[1], points[2], points[3]);
    print!("{}", repeat_char(b'R',(tx-sx) as usize));
    print!("{}", repeat_char(b'U',(ty-sy) as usize));
    print!("{}", repeat_char(b'L',(tx-sx) as usize));
    print!("{}", repeat_char(b'D',(ty-sy+1) as usize));
    print!("{}", repeat_char(b'R',(tx-sx+1) as usize));
    print!("{}", repeat_char(b'U',(ty-sy+1) as usize));
    print!("L");
    print!("U");
    print!("{}", repeat_char(b'L',(tx-sx+1) as usize));
    print!("{}", repeat_char(b'D',(ty-sy+1) as usize));
    println!("R");
}

fn repeat_char(c :u8, n :usize) -> String{
    let s = String::from_utf8(vec![c;n]);
    match s{
        Ok(x) => x,
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int dp[100005][3],a,b,c;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c;
	}
	printf("%d",max(max(dp[n][0],dp[n][1]),dp[n][2]));
}

Measured memory_bytes: 1408
#include<stdio.h>
int count = 0;
void Traverse(int A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(i > 0)
		printf(" ");
		printf("%d", A[i]);
	}
		
	putchar('\n');
}
void SelectionSort(int A[], int N)
{
	
	for(int i = 0; i < N-1; i++)
	{
		int min = i;
		for(int j = i+1 ; j < N; j++)
		{
			if(A[j] < A[min])
				min = j;
		}
		if(min != i)
		{
			int tmp = A[min];
			A[min] = A[i];
			A[i] = tmp;
			count++;
		}
	
	}
 } 
int main()
{
	int N, A[100];
	scanf("%d", &N);
	for(int i = 0; i < N; i++)
		scanf("%d", &A[i]);
	SelectionSort(A, N); 
	Traverse(A, N);
	printf("%d\n", count);
}



Measured memory_bytes: 2736