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


long long yokaPow(long long base,long long exp)
{
    if(exp==0)return 1;
    if(exp==1)return base;
    long long inner = yokaPow(base,exp/2);
    if(exp%2)
    {
        return inner*inner*base;
    }
    else
        return inner*inner;
}

void primeFactors(long long n,vector<long long>&uniqueprimes,map<long long,int>& primenum)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        if(!primenum[2])uniqueprimes.push_back(2);
        primenum[2]++;
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            if(!primenum[i])uniqueprimes.push_back(i);
            primenum[i]++;
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        {
            if(!primenum[n])uniqueprimes.push_back(n);
            primenum[n]++;
        }
}

int main() {
    long long a, b;
    cin>>a>>b;
    vector <long long> uniqueprimes;
    map<long long,int>primenum;
    vector <long long> uniqueprimesa;
    map<long long,int>primenuma;
    vector <long long> uniqueprimesb;
    map<long long,int>primenumb;
    primeFactors(a,uniqueprimesa,primenuma);
    primeFactors(b,uniqueprimesb,primenumb);
    for(int i=0;i<uniqueprimesa.size();i++)
    {
        if(primenumb[uniqueprimesa[i]])
        {
            uniqueprimes.push_back(uniqueprimesa[i]);
        }
    }
    uniqueprimes.push_back(1);

    cout<<uniqueprimes.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
a,b,c,d=map(int,input().split())
lcm_cd=(c*d)//math.gcd(c,d)
c_times=b//c-(a-1)//c
d_times=b//d-(a-1)//d
cd_times=b//lcm_cd-(a-1)//lcm_cd
print(b-a+1-c_times-d_times+cd_times)


Measured memory_bytes: 9164
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  ll M = max({A, B, C});
  if ((3 * M) % 2 == (A + B + C) % 2) {
    cout << ((3 * M - (A + B + C)) / 2) << endl;
  } else {
    cout << ((3 * (M + 1) - (A + B + C)) / 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3548
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N, A, B = rl()
if (B-A)%2 == 0:
    answer = (B-A)//2
else:
    answer = min(A-1-(-(B-1-(A-1)))//2, N-B-(-(N-(A+(N-B)))//2))

print(answer)


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

int gcd(int x, int y) {
    if (x == 0) {
        return y;
    } else if (y == 0) {
        return x;
    }
    if (x >= y) {
        return gcd(y, x%y);
    } else {
        return gcd(x, y%x);
    }
}

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

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
from collections import deque

def main():
    h, w = map(int, input().split())
    tizu = [input().strip() for _ in range(h)]
    directions = [[-1, 0], [1, 0], [0, -1], [0, 1]]
    used = [[False for _ in range(w)] for _ in range(h)]
    
    ans = 0
    for i in range(h):
        for j in range(w):
            if used[i][j]:
                continue
            used[i][j] = True
            queue = deque()
            queue.append([i, j])
            queue.append(tizu[i][j])
            b_cnt = 0
            w_cnt = 0
            while queue:
                pos = queue.popleft()
                bw = queue.popleft()
                if bw == "#":
                    b_cnt += 1
                else:
                    w_cnt += 1
                for dy, dx in directions:
                    ny = dy + pos[0]
                    nx = dx + pos[1]
                    if ny == -1 or ny == h or nx == -1 or nx == w:
                        continue
                    if used[ny][nx]:
                        continue
                    bw2 = tizu[ny][nx]
                    if bw == bw2:
                        continue
                    used[ny][nx] = True
                    queue.append([ny, nx])
                    queue.append(bw2)
            ans += b_cnt * w_cnt
    print(ans)

main()

Measured memory_bytes: 78524
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    long len=strlen(str);

    long nump=0;
    long i;
    for(i=0; i<len; i++) {
        if(str[i]=='p') nump++;
    }

    long nump0 = len/2;    

    printf("%ld\n", nump0-nump);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N), R(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    rep(i,N) R[i] = i + 1;
    int count_p, count_q;
    int k = 1;
    do {
        bool check_p, check_q;
        check_p = true; check_q = true;
        rep(i,N) {
            check_p = check_p && P[i] == R[i];
            check_q = check_q && Q[i] == R[i];
        }
        if (check_p) count_p = k;
        if (check_q) count_q = k;
        k++;
    } while (next_permutation(R.begin(), R.end()));

    cout << abs(count_p - count_q) << endl;

    return 0;
}

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

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> pi, qi, ri, si;
    for (int i = 0; i < A; i++){
        int p; cin >> p;
        pi.push_back(-p);
    }
    for (int i = 0; i < B; i++){
        int q; cin >> q;
        qi.push_back(-q);
    }
    for (int i = 0; i < C; i++){
        int r; cin >> r;
        ri.push_back(-r);
    }
    sort(pi.begin(), pi.end());
    sort(qi.begin(), qi.end());
    sort(ri.begin(), ri.end());
    for (int i = 0; i < X; i++)
        si.push_back(pi[i]);
    for (int i = 0; i < Y; i++)
        si.push_back(qi[i]);
    for (int i = 0; i < C; i++)
        si.push_back(ri[i]);
    sort(si.begin(), si.end());
    long long ans = 0;
    for (int i = 0; i < X+Y; i++)
        ans += si[i];
    cout << -ans << endl;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  vi p(n),q(n);
  rep(i, n) std::cin >> p[i];
  rep(i, n) std::cin >> q[i];
  int pval = 0, qval = 0;
  rep(i, n) pval = pval * 10 + p[i];
  rep(i, n) qval = qval * 10 + q[i];
  vi pervec = p, svec;
  sort(rng(pervec));
  do {
    int val = 0;
    rep(i, n) val = val * 10 + pervec[i];
    svec.pb(val);
  } while ( next_permutation(rng(pervec)) );
  sort(rng(svec));
  auto pit = lower_bound(rng(svec), pval);
  auto qit = lower_bound(rng(svec), qval);
  std::cout << abs(pit - qit) << "\n";
}


Measured memory_bytes: 640
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int A, B;
	sci(A), sci(B);
	bool valid[4];
	RESET(valid);
	valid[A] = valid[B] = 1;
	for (int i = 1; i <= 3; ++i) {
		if (!valid[i]) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#define INFTY 10000000000
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int h[110000];
  long long dp[110000];
  for(int i=0;i<n;i++){
    cin>>h[i];
    dp[i]=INFTY;
  }
  dp[0]=0;
  for(int i=0;i<n-1;i++){
    for(int j=1;j<=k;j++){
      if(i+j<=n-1)
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1408
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 998244353;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, cnt[N], dp[N], ans;

int binpow(int x, int deg) {
    if (!deg) return 1;
    if (deg & 1) return binpow(x, deg ^ 1) * 1ll * x % base;
    int res = binpow(x, deg >> 1);
    return res * 1ll * res % base;
}

int inv(int x) {
    return binpow(x, base - 2);
}

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

    #ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    cin >> n;
    int mx = 0;
    forn(i, 1, n) {
        int x;
        cin >> x;
        cnt[x]++;
        mx = max(mx, x);
    }

    for1(i, mx, 1) {
        int sum = 0, prs = 0;
        int sd = 0;
        for (int j = i; j <= mx; j += i) {
            prs = (prs + cnt[j] * 1ll * (sum * 1ll * j % base)) % base;
            prs = (prs + (j * 1ll * j % base) * (cnt[j] * 1ll * (cnt[j] - 1) / 2 % base)) % base;
            sum = (sum + j * 1ll * cnt[j]) % base;
            sd = (sd + dp[j]) % base;
        }
        dp[i] = (prs - sd + base) % base;
        ans = (ans + dp[i] * 1ll * inv(i) % base) % base;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 10496
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
	int N, K; cin >> N >> K;
	double ans = 0;

	for(int i = 1; i <= N; ++i){
		double tmp = 1.0/N;
		int now = i, m = 0;
		while(now<K){
			now*=2;
			tmp/=2;
		}
		// tmp = 1.0 / pow(2, m) / (double)N;

		ans += tmp;
	}

	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
  
    int count = 0;
    
    if(S.length() != 4){
        cout << "No" << endl; 
    }else{
        
        for (auto n : S) {
            
            for (auto m : S) {
                if(n == m){
                    count ++;
                }
            }
            
        }
        
        if(count == 8){
            cout << "Yes" << endl; 
        }else{
            cout << "No" << endl; 
        }
        
        
    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;
const ll mod = 1e9 + 7;

ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }

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

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

std::tuple<ll, ll, ll> extgcd(ll a, ll b) {
	ll x, y;
	ll g = extgcd(a, b, x, y);
	return std::make_tuple(x, y, g);
}

int main(void)
{
	ll k;
	cin >> k;
	ll sum = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				sum += gcd(gcd(a, b), c);
			}
		}
	}
	cout << sum << endl;
	return 0;
}


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

int main()
{
	int a,b;
	cin >> a >> b;
	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a > b)
	{
		cout << "a > b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import math

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]

hist= []
visited_pos = [-1] * n

#初期情報
#print(ab)
ts = {}
for el in ab:
  wk = ts.get(el[0]) 
  if wk is None:
    sss  = set()
    ts[el[0]] = sss
  ts[el[0]].add(el[1])
  wk = ts.get(el[1]) 
  if wk is None:
    sss  = set()
    ts[el[1]] = sss
  ts[el[1]].add(el[0])
#print(ts)


#幅優先探索
def tsk(pos):
  wk = ts.get(pos)
  if ts.get(pos) is None:
    return
  else:
    #print(pos,wk)
    for e in wk:
      if visited_pos[e-1] < 0:
        visited_pos[e-1] = pos # idx 値　0-
        hist.append(e) # 実値　1-

idx = 0
hist.append(1) #実値　1-
while True:
  if idx >= len(hist):
    break
  else:
    tsk(hist[idx])
    idx += 1
#print(hist)
#print(visited_pos)
ans = 'Yes'
for i in range(n):
  if visited_pos[i] == -1:
    ans = 'No'
    break

print(ans)
if ans == 'Yes':
  for i in range(1,n):
    print(visited_pos[i])


Measured memory_bytes: 154200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int a[3];

int solve(){
  if(a[0]==a[1]&&a[1]==a[2]) return 1;
  else return 0;
}

int main(){
  rep(i,3) cin>>a[i];
  int cnt=0;
  while(!solve()){
    sort(a,a+3);
    if(a[2]-a[0]>1) a[0]+=2;
    else{
      if(a[0]==a[1]){
        cnt++;
      }else{
        cnt+=2;
      }
      break;
    }
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
    int n,m,k;
    std::cin >> n>>m>>k;
    std::vector<int> ans(n,0);
    UnionFind tree(n);
    rep(i,m){
        int a,b;
        std::cin >> a>>b;
        a--;b--;
        tree.merge(a,b);
        ans[a]++;
        ans[b]++;
    }
    rep(i,n){
        ans[i]=tree.size(i)-ans[i]-1;
    }
    rep(i,k){
        int a,b;
        std::cin >> a>>b;
        a--;b--;
        if(tree.issame(a,b)){
            ans[a]--;
            ans[b]--;
        }
    }
    rep(i,n){
        std::cout << ans[i] << std::endl;
    }
}

Measured memory_bytes: 2816
#include <stdlib.h> 
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std; 

int main()
{
   string s;

   cin>>s;

   if(s.substr(2,1) == s.substr(3,1)) 
   {
       if(s.substr(4,1) == s.substr(5,1)) cout<<"Yes";
       else cout<<"No";
   }
   else cout<<"No";

    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int score = 0 ;
    int total = 0 ;
    for ( int i = 0 ; i < 5 ; i++ )
    {
        cin >> score ;
        if (score < 40) score = 40 ;
        total += score ;
    }
    cout << total / 5 << endl ;
    return 0 ;
}

Measured memory_bytes: 3096
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, K = inpl()
H = inpl()
H.sort()
H.reverse()
for i in range(K):
    if len(H) == i:
        break
    H[i] = 0
print(sum(H))

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 31328
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7 ; 

int main() 
{ 
    int n ; 
    cin >> n ; 
    long long mn = 2e18 , mn2 = 2e18 , mn3 = 2e18 , mn4 = 2e18 ,
    mx = -2e18 , mx2 = -2e18 , mx3 = -2e18 , mx4 = -2e18; 
    long long ans = 0 ,x,y; 

    for(int i = 0 ; i < n ; ++i) {
        cin >> x >> y ; 
        mx = max(mx, x+y) ; 
        mn = min(mn, x+y) ; 
        mx2 = max(mx2, x-y) ; 
        mn2 = min(mn2, x-y) ; 
        mx3 = max(mx3, -x-y) ;
        mn3 = min(mn3, -x-y) ; 
        mx4 = max(mx4, -x+y) ; 
        mn4 = min(mn4 , -x+y) ; 
    }
    ans = max(ans , mx-mn ) ; 
    ans = max(ans, mx2-mn2) ; 
    ans = max(ans, mx3-mn3) ; 
    ans = max(ans, mx4-mn4) ; 
    cout << ans ; 
    

    return 0; 
} 


Measured memory_bytes: 3616
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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

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

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    vector<ll> ans, last;
    rep(i,1,10)ans.emplace_back(i);
    last = ans;
    while(ans.size() < k){
        vector<ll> temp;
        for(auto &t : last){
            ll num = t % 10;
            temp.emplace_back(t * 10 + num);
            ans.emplace_back(t * 10 + num);
            if(num != 0){
                temp.emplace_back(t * 10 + num - 1);
                ans.emplace_back(t * 10 + num - 1);
            }
            if(num != 9){
                temp.emplace_back(t * 10 + num + 1);
                ans.emplace_back(t * 10 + num + 1);
            }
        }
        last = temp;
    }
    sort(all(ans));
    cout << ans[k-1] << "\n";
}

Measured memory_bytes: 8104
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[1]+[0]*(len(T))for i in range(len(S)+1)]
dp[0] = [1]*(len(T)+1)
dp_sum = [[1]+[0]*(len(T))for i in range(len(S)+1)]
dp_sum[0] = [1]*(len(T)+1)
for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp_sum[i][j]
        dp_sum[i+1][j+1] = (dp[i+1][j+1]+dp_sum[i+1][j]+\
            dp_sum[i][j+1]-dp_sum[i][j])%(10**9+7)
print(dp_sum[-1][-1])

Measured memory_bytes: 112860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

using Graph = vector<vector<int>>;

int main(){
    int n,u,v;
    cin >> n >> u >> v;
    Graph G(n+1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> q;
    vector<int> d(n+1,-INF);
    q.push(u);
    d[u] = 0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto t : G[p]){
            if(d[t]!=-INF) continue;
            d[t] = d[p] + 1;
            //cout << "dt=" << d[t] << endl; 
            q.push(t);
        }
    }
    while(!q.empty()){
        q.pop();
    }

    q.push(v);
    vector<int> e(n+1,-INF);
    e[v] = 0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto t : G[p]){
            if(e[t]!=-INF) continue;
            e[t] = e[p] + 1;
            //cout << "et=" << e[t] << endl;
            q.push(t);
        }
    }
    int ans = -INF;
    rep(i,n+1){
        if(d[i]<e[i] && ans<e[i]) ans = e[i];
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <map>
using namespace std;

int N, A, B;
int main() {
  while (cin >> N >> A >> B) {
	if (abs(A-B) % 2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;
  }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int m,d,ans = 0;
		String str;
		String[] s;
		str = bf.readLine();
		s = str.split(" ");
		m = Integer.parseInt(s[0]);
		d = Integer.parseInt(s[1]);
		if(d >= 22) {
			int d1 = d/10;
			int d2 = d%10;
			for(int i = 2;i <= d1;++i) {
				if(i != d1) {
					for(int j = 2;j <= 9;++j) {
						if(i*j <= m){
							ans++;
						}
					}
				} else {
					for(int j = 2;j <= d2;++j) {
						if(i*j <= m) {
							ans++;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    
    ll r = 0, g = 0, b = 0;
    rep(i, N){
        r +=  S[i] == 'R';
        g +=  S[i] == 'G';
        b +=  S[i] == 'B';
    }
    ll ans = r * g * b;
    rep(i, N){    
        reps(j, 1, N){
            if (i + 2 * j < N){
                char a = S[i];
                char b = S[i + j];
                char c = S[i + 2 * j];
                if (a != b && b != c && c != a){
                    ans--;
                }
            }
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main() {
  int N = 0,max = 0,a = 0;

  long long int ans = 0;

  scanf("%d",&N);
  for(int i=0;i<N;i++){
     scanf("%d",&a);
     if(i != 0){
       if(max > a){
         ans += max - a;
       }else{
         max = a;
       }
     }else{
       max = a;
     }
  }
  printf("%lld\n",ans);

  return 0;
}


Measured memory_bytes: 1712
INF = 998244353

n = gets.to_i
d = gets.chomp.split.map(&:to_i)
d0 = d[0]
d.sort!

hs = Hash.new(0)
d.each do |x|
  hs[x] += 1
end

res = 1
d[-1].times do |i|
  if hs[i] == 0
    res = 0
    break
  end

  hs[i + 1].times do |_|
    res *= hs[i]
    res %= INF
  end
end
puts (d0 == 0 && d[1] != 0)? res : "0"

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

int main(){
    ll n,k[8]={1,2,3,4,5,6,7,8},p[8],q[8],a,b,check=0,cnt=1;
    cin>>n;
    rep(i,n){
        cin>>p[i];
    }
    rep(i,n){
        cin>>q[i];
    }
    do {
        check=0;
        rep(i,n){
            if(k[i]!=p[i]) check=1;
        }
        if(check==0){a=cnt;}
        check=0;
        rep(i,n){
            if(k[i]!=q[i]) check=1;
        }
        if(check==0){b=cnt;}
        cnt++;
    } while(next_permutation(k,k+n));
    cout<<abs(a-b);
}

Measured memory_bytes: 3476
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,u,v;
    cin >> N >> u >> v;
    u--; v--;
    rep(i,0,N-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
        priority_queue<lpair, vector<lpair> ,greater<lpair> > pq;
    
    // priority_queue<lpair, vector<lpair> ,compare > pq;
    ll dist[100010] = {}, dist2[100010] = {};
    rep(i,0,N) dist[i] = INF;
    dist[u] = 0;
    pq.push({0,u});
    while(!pq.empty()){
        lpair l1 = pq.top();
        pq.pop();
        if(dist[l1.second] < l1.first) continue;
        for(auto &e: tree[l1.second]){
            if(dist[e] > dist[l1.second] + 1){
                dist[e] = dist[l1.second] + 1;
                pq.push(make_pair(dist[e], e));
            }
        }
    }
    
    rep(i,0,N) dist2[i] = INF;
    dist2[v] = 0;
    pq.push({0,v});
    while(!pq.empty()){
        lpair l1 = pq.top();
        pq.pop();
        if(dist2[l1.second] < l1.first) continue;
        for(auto &e: tree[l1.second]){
            if(dist2[e] > dist2[l1.second] + 1){
                dist2[e] = dist2[l1.second] + 1;
                pq.push(make_pair(dist2[e], e));
            }
        }
    }
    ll ans = 0;
    rep(i,0,N){
        if(tree[i].size() == 1 && dist[i] < dist2[i]){
            ans = max(ans, dist2[tree[i][0]]);
        }
    }
    print(ans);
}

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

int ord[] = { 0, 1, 3, 2 };

string dir = "ENWS";
string rdir = "WSEN";

int roll[4][6] = {
	{ 4, 1, 0, 3, 5, 2 },
	{ 3, 0, 2, 5, 4, 1 }, 
	{ 2, 1, 5, 3, 0, 4 },
	{ 1, 5, 2, 0, 4, 3 }
};

bool check(const vector<int>& dice) {
	if (dice[0] < 0) return false;
	int v1 = dice[0] + dice[5], v2 = dice[1] + dice[3], v3 = dice[2] + dice[4];
	if (v1 >= v2 + v3 + 1) return false;
	if (v2 > v1 + v3 + 1) return false;
	if (v3 > v1 + v2 + 1) return false;
	return true;
}

vector<int> get_roll(const vector<int>& dice, int d) {
	vector<int> res(6);
	for (int i = 0; i < 6; i++) res[roll[d][i]] = dice[i];
	return res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	vector<int> t(6);
	while (true) {
		for (int i = 0; i < 6; i++) {
			cin >> t[i];
		}
		if (accumulate(t.begin(), t.end(), 0) == 0) break;
		int p, q;
		cin >> p >> q; --p;
		sort(t.begin(), t.end());
		string res = "Z";
		do {
			if (!check(t)) continue;
			auto dice = t;
			string s;
			while (*max_element(dice.begin(), dice.end()) > 0) {
				for (int i = 0; i < 4; i++) {
					char c = dir[ord[i]];
					dice = get_roll(dice, ord[i]);
					dice[0]--;
					if (check(dice)) {
						s.push_back(c);
						break;
					}
					dice[0]++;
					dice = get_roll(dice, (ord[i] + 2) % 4);
				}
				if (s > res) break;
			}
			res = min(res, s);
		} while (next_permutation(t.begin(), t.end()));
		if (res == "Z") {
			cout << "impossible" << endl;
		}
		else {
			cout << res.substr(p, q - p) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

#define MAXN 1000

ll pow5[MAXN];


int main(){
  ll x, i;
  ll a, *ap, b;
  
  scanf("%lld ", &x);

  for (i = 0; i < MAXN; i++)
  {
      pow5[i] = i*i*i*i*i;
  }

  for (i = -MAXN; i < MAXN; i++)
  {
      b = i*i*i*i*i;
    b = x+b;
      ap = bsearch(&b, pow5, MAXN, sizeof(pow5[0]), upll);
      if(ap != NULL){
          a = (ll)(ap - pow5);
          break;
      }
  }
  

  printf("%lld %lld", a, i);

  return 0;
}

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

int main() {
  long a,b,c;
  string str;
  cin >> a >> b >> c;
  
  if (c-a-b < 0){
    str = "No";
  }
  
  else if (c-a-b >= 0){
    if (a*a + b*b + c*c -2*a*b -2*b*c -2*c*a > 0){
      str = "Yes";
    }
    
    if (a*a + b*b + c*c -2*a*b -2*b*c -2*c*a <= 0){
      str = "No";
    }
  }
  
  cout << str << endl;
  
} 
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,sum_A,sum_B;
    cin >> N;
    vector<int> card(N);
    for (int i=0;i<N;i++) {
        int a;
        cin >> a;
        card.at(i)=a;
    }
    for (int i=0;i<N;i++) {
        sort(card.begin(),card.end());
        reverse(card.begin(),card.end());
        if (i%2==0) sum_A+=card.at(i);
        else sum_B+=card.at(i);
    }
    cout << sum_A-sum_B << endl;


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     int n;
     cin>>n;
     int A[n];
     for(int i=0;i<n;++i)
     {
       cin>>A[i];
	 }
	  int ans=0,ct=0;
	  for(int i=0;i<n-1;++i)
	  {
	  	if(A[i]>=A[i+1])
	  	{
	  	  ct++;
			ans=max(ans,ct);	
		}
		else
		ct=0;
	  }
	  cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int a, b;
    char op;

    while (true)
    {
        cin >> a >> op >> b;
        if (op == '?')
        {
            break;
        }
        else if (op == '+')
        {
            cout << a + b << endl;
        }
        else if (op == '-')
        {
            cout << a - b << endl;
        }
        else if (op == '*')
        {
            cout << a * b << endl;
        }
        else
        {
            cout << a / b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    static ref H: Mutex<Vec<i32>> = Mutex::default();
    static ref W: Mutex<Vec<i32>> = Mutex::default();
}

//abc163-D
// #[fastout]

const MOD: usize = 1000000000 + 7;

fn main() {
    input![n: usize, k: usize];

    let mut ans = 0;
    // let mut mods = vec![0; n+1];
    // for i in 0..(n+1) + 1{
    //     mods[i] =
    // }

    for kk in k..(n + 1) + 1 {
        let min = (kk - 1) * kk / 2;
        let max = kk * (2 * n - kk + 1) / 2;
        // eprintln!("{}, {}, {}", kk, min, max);
        let num = max - min + 1;
        ans += num;
        ans %= MOD;
    }
    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 2152
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int tmp[] = convertStringToArrayInt(input);
		int N = tmp[0];
		int C = tmp[2];
		int counter = 0;

		input = sc.nextLine();
		int b[] = convertStringToArrayInt(input);

		for (int i = 0; i < N; i++) {
			input = sc.nextLine();
			int arr[] = convertStringToArrayInt(input);
			int source = 0;
			for (int j = 0; j < arr.length; j++) {
				source = source + (b[j] * arr[j]);
			}
			if (source + C > 0) {
				counter++;
			}
		}
		System.out.println(counter);
		sc.close();
	}
	
	private static int[] convertStringToArrayInt(String input) {
		return Arrays.stream(input.split(" ")).filter(s -> !s.isEmpty()).mapToInt(Integer::parseInt).toArray();
	}
}

Measured memory_bytes: 29140
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int x,y,r,W,H;
        W=sc.nextInt();
        H=sc.nextInt();
        x=sc.nextInt();
        y=sc.nextInt();
        r=sc.nextInt();
        if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26332
#include <stdio.h>

int main()
{
    int n, checker = 0;
    char string[101] = {0};
    scanf("%d %s", &n, string);

    for (int i = 0; i < n/2; i++)
    {
        if (string[i] != string[i+(n/2)])
        {
            checker = 1;
            break;
        }
    }
    
    if (checker == 0 && n % 2 == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);

	int N; cin >> N;
	vector<ll> A(N), B(N);
	map<ll, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (mp.find(A[i]) == mp.end()) { mp.insert({ A[i],1 }); }
		else { mp[A[i]]++; }
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		if (mp.find(B[i]) == mp.end()) { mp.insert({ B[i],1 }); }
		else { mp[B[i]]++; }
	}

	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second > N) { cout << "No" << endl; return 0; }
	}

	vector<int> imos_diff(N, 0);
	{
		int c0 = 0, d0 = 0;
		while (c0 < N && d0 < N) {
			if (A[c0] < B[d0]) {
				while (c0 < N - 1 && (A[c0] == A[c0 + 1])) { c0++; } c0++;
			}
			else if (A[c0] > B[d0]) {
				while (d0 < N - 1 && (B[d0] == B[d0 + 1])) { d0++; } d0++;
			}
			else {
				int c1 = c0, d1 = d0;
				while (c1 < N - 1 && (A[c0] == A[c1 + 1])) { c1++; } c1++;
				while (d1 < N - 1 && (B[d0] == B[d1 + 1])) { d1++; } d1++;
				// [c0, c1) and [d0, d1)

				// c0 - d1 + 1 <= offset < c1 - d0 → No]

				int u = c0 - d1 + 1;
				int v = c1 - d0;

				while (u < 0) { u += N, v += N; }
				while (u >= N) { u -= N, v -= N; }

				if (v > N) {
					imos_diff[0]++;
					imos_diff[v - N]--;
					imos_diff[u]++;
				}
				else {
					imos_diff[u]++;
					imos_diff[v]--;
				}
				c0 = c1;
				d0 = d1;
			}
		}
	}
	for (int i = 1; i < N; i++) {
		imos_diff[i] += imos_diff[i - 1];
	}

	int k = -1;
	for (int i = 0; i < N; i++) {
		if (imos_diff[i] == 0) { k = i; break; }
	}
	if (k == -1) { cout << "No" << endl; return 0; }
	
	cout << "Yes" << endl;
	for (int i = 0; i < N; i++) {
		cout << B[(i + N - k) % N] << " ";
	}

	return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  ll ima=a[0];
  ll ans=0;
  for(int i=1;i<n;++i){
    if(a[i]<ima){
      ans+=ima-a[i];
    }else{
      ima=a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

void dfs(vector<int>& perm, int state, int pre, ll sum, ll& ans,
         vector<vector<ll>>& adj) {
    if (state == (1 << perm.size())-1) {
        ans = min(ans, sum);
        return;
    }
    for(int i = 0; i < perm.size(); i++) {
        if (((state >> i) & 1) == 0) {
            state |= (1 << i);
            dfs(perm, state, perm[i], sum+adj[pre][perm[i]], ans, adj);
            state ^= (1 << i);
        }
    }
}

int main() {
    int n, m, r;
    int a, b, c;
    cin >> n >> m >> r;
    vector<vector<ll>> adj(n+1, vector<ll>(n+1, 1e7));
    vector<int> perm(r, 0);
    for(int& val: perm)
        cin >> val;
    for(int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        adj[a][b] = adj[b][a] = min(adj[a][b], ll(c));
    }
    for(int i = 1; i <= n; i++)
        adj[i][i] = 0;
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if (adj[i][k] + adj[k][j] < adj[i][j])
                    adj[i][j] = adj[i][k] + adj[k][j];
            }
        }
    }

    ll ans = INT_MAX;
    int state = 0;
    for(int i = 0; i < perm.size(); i++) {
        state |= (1 << i);
        dfs(perm, state, perm[i], 0LL, ans, adj);
        state ^= (1 << i);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/



int main(){
  int n = 1000000;
  vector<bool> p(n, true);
  p[0] = false;
  p[1] = false;

  REP(i, 2, n){
    if(p[i]){
      for(int j = i * 2; j < n; j += i){
        p[j] = false;
      }
    }
  }
  
  int N;

  VI v(n, 0);
  REP(i, 1, n){
    if(p[i]){
      v[i] = v[i-1] + 1;
    } else {
      v[i] = v[i-1];
    }
  }
  while(cin >> N){
    cout << v[N] << endl;
  }

  return 0;
}

Measured memory_bytes: 6608
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn kaibun(s: Vec<char>) -> bool {
    let mut r = s.clone();
    r.reverse();
    r == s
}

fn main() {
    input! {
        s: chars,
    }
    let mut s2 = s.clone();
    s2.resize(s.len() / 2, ' ');
    let mut s3 = vec![];
    for i in (s.len() / 2 + 1)..s.len() {
        s3.push(s[i]);
    }

    if kaibun(s) && kaibun(s2) && kaibun(s3) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
s = list(input())
count1 = 0
s_copy = s.copy()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count1 += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
print(count1)

Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    long long d;
    scanf("%d%lld",&n,&d);
    d*=d;
    for(int i=1;i<=n;i++)
    {
        long long x,y;
        scanf("%lld%lld",&x,&y);
        ans+=x*x+y*y<=d;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3732