akhauriyash/Code-Regression huggingface dataset:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, k = wi()

t = n % k
if t > k / 2:
    print(k - t)
else:
    print(t)

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

int main(){
  int N, A, B; scanf("%d%d%d", &N, &A, &B);

  if(A + B - 1 > N || N > 1LL * A * B){ puts("-1"); return 0; }

  for(int l = 0, g = N - A, a = 1; a <= A; a++){
    int t = g > B - 1 ? B - 1 : g;
    for(int i = l + t + 1; i > l; i--) printf("%d ", i);
    l += t + 1; g -= t;
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 2048
{-# LANGUAGE BangPatterns #-}
module Main where

import Data.Bool
import Data.Functor
import Data.List

main :: IO ()
main = do
  { [n] <- getInts
  ; xs  <- getInts
  ; case bubbleSort xs of
      (c,ys) -> do
        { putInts ys
        ; putInts [c]
        }
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

bubbleSort :: Ord a => [a] -> (Int,[a])
bubbleSort = step (0,[])
  where
    step cxs    [] = cxs
    step (c,xs) ys = case bubble ys of
      ((z,d),zs) -> step (c+d,z:xs) zs

bubble :: Ord a => [a] -> ((a,Int),[a])
bubble (x:xs) = mapAccumL swap (x,0) xs

swap :: Ord a => (a,Int) -> a -> ((a,Int),a)
swap (x,!c) y = bool ((y,c),x) ((x,succ c),y) (x > y)

Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(x,a)for(auto &x: a)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll>pii;
typedef vector<ll>vi;
typedef map<ll,ll>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int main()
{
	//fopen();
	fastio;
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	int i=0,j=0;
	int c=0;
	while(j<n)
	{
		if(c%2)
			{cout<<s2[j];j++;}
		else{cout<<s1[i];i++;}
		c++;
	}
	//cout<<m<<" "<<e;
	
	
}
	


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 4e3 + 3;
const LL mod = 924844033; 
LL dp[N][N][2];
LL f[N];
bool check[N];
int n,k,cnt;
LL fac[N];
inline void up(LL &x){
	if(x >= mod) x -= mod;	
}
int main(){
	cin >> n >> k;
	for(int i = 1;i <= k;++i){
		for(int m = 1;m <= 2;++m){
			for(int j = i;j <= n;j += k){
				cnt++;
				if(j != i) check[cnt] = 1;	
			}
		}
	}
	dp[0][0][0] = 1;
	for(int i = 0;i < n * 2;++i)
		for(int j = 0;j <= n;++j){
			dp[i + 1][j][0] = dp[i][j][0] + dp[i][j][1];
			up(dp[i + 1][j][0]);
			if(check[i + 1]) dp[i + 1][j + 1][1] = dp[i][j][0];
		}
	fac[0] = 1;
	for(int i = 1;i <= n;++i)
		fac[i] = (fac[i - 1] * i) % mod;
	for(int i = 0;i <= n;++i)
		f[i] = (dp[2 * n][i][0] + dp[2 * n][i][1]) % mod;
	//for(int i = 0;i <= n;++i) printf("%lld ",fac[i]);puts("");
	LL ans = 0;	
	for(int i = 0;i <= n;++i){
		if(i & 1) ans = (ans - (f[i] * fac[n - i]) % mod + mod) % mod;
		else ans = (ans + f[i] * fac[n - i] % mod) % mod;
	}
	printf("%lld\n",ans);
	return 0;	
}

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

const int inf = 1e9;

int main()
{
    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    vector<int> dp(n, inf);

    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[n - 1] << endl;
    
    return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
    fastio;cin.tie(0);cout.tie(0);
    int n ; string s ; 
    cin >> n >> s ;
    if(n&1) cout << "No";
    else
    {
        if(s.substr(0 , n/2) == s.substr(n/2)) cout << "Yes";
            else cout << "No";
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a;
  cin >> a;

  cout << a + a * a + a * a * a << endl;
  return 0;
}



Measured memory_bytes: 3540
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct SegmentTree {
	int n;
	vector<int>d, lazy;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
		lazy.assign(2 * n, 0);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			d[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k] += lazy[k] / 2;
				lazy[2 * k + 1] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}
	void add(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] += (r - l)*x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k, l, (l + r) / 2);
			add(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = d[2 * k] + d[2 * k + 1];
		}
	}
	int sumget(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l&&r <= b)return d[k];
		else return sumget(a, b, 2 * k, l, (l + r) / 2) + sumget(a, b, 2 * k + 1, (l + r) / 2, r);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	rep(i, 0, q) {
		int  com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.sumget(s - 1, t) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.add(s - 1, t, x);
		}
	}
	return 0;
}

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

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

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

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

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

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

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout<< lcs; 
} 

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


Measured memory_bytes: 38792
from decimal import *
import math

getcontext().prec = 28

a, b, c = map(int, input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)

if a + b < c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5588
N, K = map(int, input().split())
mod = 10**9 + 7

ans = 0
for num in range(K, N+2):
    res1 = int((2*N-num+1) * num / 2) % mod
    res2 = int((num-1) * num / 2) % mod
    ans += res1 - res2 + 1
    # print(num, res1, res2)

print(ans % mod)


Measured memory_bytes: 64864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * d, max(a * c, max(b * d, b * c))) << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (X - Z) / (Y + Z) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
[abc119] C - Synthetic Kadomatsu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 8;
const int K = 3;
const int INF = 1e7;

int N;
int A[K];
int l[MAX_N];

ll solve() {
    int ans = INF;
    for (int pat = 0; pat < (1 << (2 * N)); pat++) {
        int cnt[K + 1];
        int s[K + 1];
        memset(cnt, 0, sizeof(cnt));
        memset(s, 0, sizeof(s));
        for (int i = 0; i < N; i++) {
            int n = (pat >> (i * 2)) & 0b11;
            cnt[n]++;
            s[n] += l[i];
        }

        int t = 0;
        for (int i = 0; i < K; i++) {
            t += (cnt[i] == 0) ? INF : (abs(s[i] - A[i]) + (cnt[i] - 1) * 10);
        }
        ans = min(ans, t);
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < K; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    cout << solve() << endl;

    return 0;
}


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

#define endl "\n"

int main ()
{
	
	
    #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	vector <int> nums(n);
	for (int i=0; i<n; i++) cin >> nums[i];
	sort(nums.begin(), nums.end());

	vector <int> dp(nums.back() + 2, 0);
	for (int i=0; i<n; i++){
		for (int j=nums[i]; j<=nums.back(); j+=nums[i]){
			dp[j]++;
		}
	}
	int ans = 0;
	for (int i=0; i<=n; i++){
		if (dp[nums[i]] == 1) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using ll = long long;
#define mod 998244353


int main() 
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n-1;i++)
    {
    	ans+=(n-1)/i;
    }
    cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18;                    //1*10^18
const double PI = 3.141592653589793238; //18桁
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  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;
  }
}

// 二項係数計算
long long 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;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  string t;
  cin >> t;
  for (i = 0; i < t.length(); i++)
  {
    if (t[i] == '?')
    {
      t[i] = 'D';
    }
    cout << t[i];
  }
  // cout << t << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 150004;

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

	int n;
	cin >> n;
	vector<int> a(2*n, 0);
	for(int &x:a){
		cin >> x;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i=0; i<2*n; i+=2){
		ans += a[i];
	}
	cout << ans;
	return 0;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;

  int result = 0;
  if(A >= B && A >= C){
    result = A*10 + B + C;
  }else if(B >= A && B >= C){
    result = A + B*10 + C;
  }else{
    result = A + B + C*10;
  }

  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n;
long long p = 998244353;
long long e = 1000000005;
long long x[200000];
long long d[200000];
long long h[200000];
long long m[200000];
long long dp[200001];
long long t[500];
long long y, l, r, lr;
long long rmq(long long ll, long long rr) {
	long long f = 0;
	long long i;
	i = ll;
	while (i % 400 && i <= rr) {
		if (f < m[i])f = m[i];
		i++;
	}
	i = rr;
	while ((i + 1) % 400 && i >= ll) {
		if (f < m[i])f = m[i];
		i--;
	}
	i = (ll + 399) / 400;
	while (i * 400 + 399 <= rr) {
		if (f < t[i])f = t[i];
		i++;
	}
	return f;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, d + i);
		x[i] += e;
		h[i] = x[i] * e + d[i];
	}
	std::sort(h, h + n);
	for (int i = 0; i < n; i++) {
		d[i] = h[i] % e;
		x[i] = h[i] / e - e;
	}
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		y = x[i] + d[i];
		l = i; r = n;
		while (r - l > 1) {
			lr = (l + r) / 2;
			if (x[lr] >= y)r = lr;
			else l = lr;
		}
		r = rmq(i, l);
		if (r == 0)r = i;
		m[i] = r;
		if (t[i / 400] < r)t[i / 400] = r;
		dp[i] = dp[i + 1] + dp[r + 1];
		dp[i] %= p;
	}
	printf("%lld\n", dp[0]);
}

Measured memory_bytes: 7936
'use strict';
const main = arg => {
  const input = arg.trim().split(' ');
  const S = parseInt(input[0], 10);
  const W = parseInt(input[1], 10);

  if (S > W) {
    console.log('safe');
  }else {
    console.log('unsafe')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29616
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){
    std::vector<int> t(5);
    for(int i = 0; i < 5; ++i){
        std::cin >> t.at(i);
    }

    std::vector<int> ten(5);
    for(int i = 0; i < 5; ++i){
        ten.at(i) = ((t.at(i) + 9) / 10) * 10; 
    }

    std::vector<int> diff(5);
    for(int i = 0; i < 5; ++i){
        diff.at(i) = ten.at(i) - t.at(i); 
    }

    int maxDiffIndex = std::distance(diff.begin(), max_element(diff.begin(), diff.end()));

    int ans = 0;
    for(int i = 0; i < 5; ++i){
        if(maxDiffIndex == i){
           ans += t.at(i);
        }else{
           ans += ten.at(i);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    multiset<pair<int,int>> yet;
    rep(i,n)yet.insert({a[i],b[i]});
    ll ans = 0;
    priority_queue<int> pq;
    REP(i,1,m+1){
        auto itr = yet.begin();
        while(itr!=yet.end()&&itr->first<=i){
            pq.push(itr->second);
            itr = yet.erase(itr);
        }
        if(pq.size()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6396
#include<iostream>

using namespace std;
bool is_p(int n){
    for(int i=2;i*i<=n;i++)
        if(n%i==0) return 0;
    return 1;
}
int main(){
    int n,m,cont=0;
    cin>>n;
    while(n--){
        cin>>m;
        if(is_p(m))
            cont++;
    }
    cout<<cont<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int main(){
	int b[10];
	int i, j;
	while(scanf("%1d", &b[0]) != EOF){
		for(i = 1; i < 10; i++){
			scanf("%1d", &b[i]);
		}
	for(j = 9; j >= 1; j--){
		for(i = 0; i < j; i++){
			b[i] += b[i + 1];
			if(b[i] >= 10) b[i] -= 10;
		}
	}
	printf("%d\n", b[0]);
	}
	return 0;
}

Measured memory_bytes: 596
N = int(input())
Value = [[0 for i in range(N)] for j in range(2)]
Value = input().split()
Cost = input().split()
v = []
c = []
ac = 0
av = 0
best = []
wra = []
for i in range(N):
    v.append(int(Value[i]))
    c.append(int(Cost[i]))
    pass

for i in range(N):
    if c[i] < v[i]:
        best.append(v[i])
        wra.append(c[i])
print(sum(best) - sum(wra))

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        String main = sc.next();
       StringBuilder sb = new StringBuilder();
        int q = sc.nextInt();
        boolean flag = true;
        List<String> front = new ArrayList<>();
        List<String> back = new ArrayList<>();
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            if(x==1) {
                flag = !flag;
            }
            else if (x==2){
                int z = sc.nextInt();
                String s = sc.next();
                if(!flag){
                    if(z==1) z = 2;
                    else z = 1;
                }
                if(z==1){
                 //   out.println(s+" "+"front");
                   front.add(s);
                }else{
               //     out.println(s+" "+"bac");
                    back.add(s);
                }
            }
        }
        for(int i=front.size()-1; i>=0; i--){
            sb.append(front.get(i));
        }
        sb.append(main);
        for (String s : back) sb.append(s);
        if(!flag) sb.reverse();
        out.println(sb);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair {
   int x,y;
   Pair(int x, int y){
       this.x = x;this.y = y;
   }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 55480
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    int N;
    long i,j,k;
    long sum=0;
    cin>>N;

    for(i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

while True:
    N = int(input())
    if N == 0:
        break
    p = [int(i) for i in input().split()]
    cnt = 0

    while True:
        flag = True
        s = [0 for i in range(101)]
        for i in range(N):
            s[p[i]] += 1
        for i in range(N):
            if p[i] != s[p[i]]:
                flag = False
                p[i] = s[p[i]]
        if flag:
            break
        cnt += 1
    print(cnt)
    for i in range(N-1):
        print(p[i], end = " ")
    print(p[N-1])



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  int A, B; cin >> A >> B;

  int minEight = ceil(A * 25 / 2.0);
  int maxEight = ceil((A+1) * 25 / 2.0)-1;
  int minTen = B * 10;
  int maxTen = ((B+1) * 10) - 1;

  int answer = -1;
  if(minEight <= minTen && minTen <= maxEight) answer = minTen;
  if(minTen <= minEight && minEight <= maxTen) answer = minEight;
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
using ll = long long;
int main() {
  ll ans = 0;
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 &&i % 5 != 0) {
      ans += i;
    }
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 3648
n, W_LIMIT = gets.to_s.split.map{|t| t.to_i }
wv = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }

V_MAX = (10 ** 3) * n

dp = Array.new(V_MAX+1){ (10**9) * n + 1 }
dp[0] = 0

v_sum = 0
wv.each do |(w_i, v_i)|
  v_sum = V_MAX < v_sum + v_i ? V_MAX : v_sum + v_i
  v_sum.downto(v_i) do |v|
    w_n = dp[v-v_i] + w_i
    dp[v] = w_n if dp[v] > w_n
  end
end

v_sum.downto(0) do |v|
  if dp[v] <= W_LIMIT
    puts v
    exit
  end
end

Measured memory_bytes: 2556
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();
        long[] input = new long[N];

        for (int i=0; i<N; i++) {
            input[i] = nextLong();
            if(input[i]==0) {
                System.out.println(0);
                return;
            }
        }

        long ans =input[0];

        for (int i=1; i<N; i++) {
            // If you directly perform multiplication on 64-bit integers, it causes overflow
            // if((Math.log10(ans) + Math.log10(input[i]) >= 18) && ans * input[i] != 1e18){
            //if(ans> 1e18/ input[i]){ 
            // > not working, need use <=, because 1e18/ input[i] will lose 0.000001
            if((ans > (long)(1e18)/ input[i])){ 
                System.out.println(-1);
                return;
            }
            ans = ans * input[i];
        }

        System.out.println(ans);
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}


Measured memory_bytes: 48916
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(j=2; j<=n; j++){
    key = A[j];
    i = j-1;
    while(i>0 && A[i] > key){
      A[i+1] = A[i];
      i = i-1;
      A[i+1] = key;
    }
    trace(A,n);
  }

  return 0;
}

Measured memory_bytes: 608
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxn 100005
#define maxm 1000006
#define maxc 1000000007
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
const int mod = maxc;
int Pow(int a,int b)
{
    int res = 1;
    for (;b;b >>= 1,a = 1ll*a*a%mod)
    {
        if (b & 1)
        {
            res = 1ll*res*a%mod;
        }
    }
    return res;
}
int k,n,ans,gt[maxm << 1],a[maxm << 1],b[maxm << 1],nd[maxm  << 1];
string s;
int main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    cin >> k >> s;
    n = s.size();
    gt[0] = a[0] = b[0] = 1;
    FOR(i,1,n + k)
    {
        gt[i] = 1ll*gt[i-1]*i % mod;
        a[i] = 1ll*a[i-1]*25%mod;
        b[i] = 1ll*b[i-1]*26%mod;
    }
    nd[n+k] = Pow(gt[n+k],mod-2);
    FORD(i,n+k-1,0)
    {
        nd[i] = 1ll*nd[i+1]*(i+1)%mod;
    }
    FOR(i,n,n+k)
    {
        //ans += C[n-1][i-1]*25^(i-(n-1))*26^(n+k-i);
        long long temp = 1ll*a[i-n]*b[n+k-i] % mod;
        temp = temp * gt[i-1] % mod;
        temp = temp * nd[n-1] % mod;
        temp = temp * nd[i-n] % mod;
        ans = (ans + temp) % mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 35660
s = input()
d = {}
for c in "abcdefghijklmnopqrstuvwxyz":
    d[c] = 0

for c in s:
    d[c] += 1

result = None
for k, v in sorted(d.items(), key=lambda x: x[0]):
    if v == 0:
        result = k

        break

print(result if result else "None")


Measured memory_bytes: 3188
N = int(input())
S = input()

num2alpha = lambda c: chr(c+64) if c <= 26 else chr(c+38)
alpha2num = lambda c: ord(c) - ord('A') + 1

SNUM = map(alpha2num, S)
print(''.join(list(map(lambda a: num2alpha(a + N), SNUM))))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var ans = "A" + GetStrArray()[1][0].ToString() + "C";

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

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

int main() {
  int k,x;
  cin>>k>>x;
  if(k*500>=x) cout<< "Yes" <<endl;
  else cout << "No"<<endl;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;


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

	int a, b;
	cin >> a >> b;

	if (b % a == 0)
	{
		cout << a + b << endl;
	}
	else
	{
		cout << b - a << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e9+7;

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

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x/11)*2;
  if(x%11 <= 6 && x%11 >= 1) ans += 1;
  else if(x%11 >= 7) ans += 2;
  cout << ans << "\n";
  return 0;
}   

Measured memory_bytes: 256
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type base_size;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : base_size(0), c() {}
	explicit segment_tree(const size_type size)
		: base_size(getsize(size)),
		c(base_size + size, value_structure::identity()) {}

	bool empty() const { return size() == 0; }
	size_type size() const { return c.size() - base_size; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + base_size];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += base_size, last += base_size; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < base_size)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - base_size + 1;
	}

	void update(size_type index, const value_type &value) {
		assert(index < size());
		index += base_size;
		c[index] = value;
		while (index >>= 1)
			recalc(index);
	}
};

#include <algorithm>
#include <limits>
template <class T> class min_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return ::std::min(x, y);
	}
	static value_type identity() {
		return 2147483647;
	}
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	segment_tree<min_monoid<int>, vec_alias> seg(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;

		if (c)
			::std::cout << seg.fold(x, y + 1) << ::std::endl;
		else
			seg.update(x, y);
	}

	return 0;
}



Measured memory_bytes: 3544
n = int(input())
a = list(map(int, input().split()))

for i in range(len(a)):
    if a[i] == 0:
        print(0)
        exit()

ans = a[0]
for i in range(1, len(a)):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

Measured memory_bytes: 21792
#include <stdio.h>
#include <stdlib.h>
int compare(int* a,int* b){
    return *b-*a;
}
int main(){
    int w[10],k[10],i;
    for (i=0; i<10; i++) {
        scanf("%d",&w[i]);
    }
    for (i=0; i<10; i++) {
        scanf("%d",&k[i]);
    }
    qsort(w, 10, sizeof(int), (int(*)(const void*,const void*))compare);
    qsort(k, 10, sizeof(int), (int(*)(const void*,const void*))compare);
    printf("%d %d\n",w[0]+w[1]+w[2],k[0]+k[1]+k[2]);
    return 0;
}

Measured memory_bytes: 600
#include  <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int ans = 0;
	for (; ans < 2500; ans++) {
		if (ans / 10 == b && int(ans * 0.08) == a)  break;
	}

	if (ans == 2500)  cout << -1 << endl;
	else  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    int n, x, y;
    cin >> n >> x >> y;
    Vl ans(n);
    Rep(i, 1, n-1){
        Rep(j, i+1, n){
            ans[min(j-i, abs(i-x)+abs(j-y)+1)]++;
        }
    }
    rep(i, 1, n){
        cout << ans[i] << "\n";
    }
}


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

    solve();
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
typedef long long ll;


int main(){

    string s;
    cin >> s;

    ll cnt = 0;
    for(ll i = 0; i < s.size()-1; i++){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt << endl;

}

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

using namespace std;

const int N=2e3+10;

int n,a[N];
int f[N][N][2];

int DP(int last,int cur,int player){
    if (cur==n) return abs(a[n]-a[last]);
    int &ans=f[last][cur][player];
    if (ans!=-1) return ans;

    if (player==0) ans=max(DP(cur,cur+1,1),DP(last,cur+1,0));
    else ans=min(DP(cur,cur+1,0),DP(last,cur+1,1));

//    cout<<last<<" "<<cur<<" "<<player<<" "<<ans<<'\n';
    return ans;
}
int main(){
    cin>>n>>a[n+1]>>a[0];
    for(int i=1;i<=n;i++) cin>>a[i];
    memset(f,-1,sizeof(f));
    cout<<DP(0,1,0);
}


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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

int nc2(int n) {
	return 1ll*(n *(n - 1)) / 2;
}

signed main() {
	int n; cin >> n;
	vector<int> v(n); cin >> v;
	int ways = 0;
	map<int ,int > mm;
	for(int i : v) mm[i]++;
	for(auto i : mm) {
		ways += nc2(i.second);
	}
	for(int i: v) {
		if(mm[i] == 1) {
			w << ways << e;
			continue;
		}
		int can = nc2(mm[i]);
		int ll = ways;
		ll += nc2(mm[i] - 1);
		ll -= can;
		w << ll << e;
	}
}


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

int main()
{
    int n,k;
    string s;
    cin >> n >> s >> k;
    char key=s[k-1];
    for(int i=0;i<n;i++)
    {
        if(s[i]!=key) s[i]='*';
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int N, C; cin >> N >> C;
    vector<int> s(N), t(N), c(N);
    REP(i, N) cin >> s[i] >> t[i] >> c[i];
    vector<tuple<int, int, bool>> ops;
    REP(i, N) {
        ops.push_back(make_tuple(s[i]*2-1, c[i], true));
        ops.push_back(make_tuple(t[i]*2, c[i], false));
    }
    sort(ops.begin(), ops.end());
    vector<int> channels(C+1);
    int channels_used = 0;
    int channels_used_max = 0;
    for(const auto& op : ops) {
        int t, c;
        bool start;
        tie(t, c, start) = op;
        if (start) {
            if (channels[c] == 0) {
                channels_used++;
            }
            channels[c]++;
        } else {
            channels[c]--;
            if (channels[c] == 0) channels_used--;
        }
        channels_used_max = max(channels_used_max, channels_used);
    }
    cout << channels_used_max << endl;
    return 0;
}

Measured memory_bytes: 6004
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] a = new int[s.nextInt()];
        for (int i = 0; i < a.length; ++i) {
            a[i] = s.nextInt() - 1;
        }
        int count = 0;
        for( int i  = 0; i < a.length; ++i) {
            int j = a[i];
            if (i < j && a[i] == j && i == a[j]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 32416
import math
a = int(input())
l = []
for i in range(1,int(math.sqrt(a))+1):
    if a % i == 0:
        l.append(i)
k = l[-1]
k2 = a//k
if k < k2:
    print(len(str(k2)))
else:
    print(len(str(k)))

Measured memory_bytes: 3060
mod = 1000000007
n,k = map(int, input().split())
d = [0]*(k+1)
for i in range(1,k+1):
  d[i] = pow(k//i, n, mod)
for i in range(k,0,-1):
  for j in range(2*i, k+1, i):
    d[i] -= d[j]
    d[i] %= mod
ans = 0
for i in range(1,k+1):
  ans += d[i]*i
  ans %= mod
print(ans)

Measured memory_bytes: 69596
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

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


int main(){

  int x,y;
  scanf("%d %d",&x,&y);

  for(int i = 0; i <= x; ++i){
    if(i*2+(x-i)*4 == y){
        printf("Yes");
        return 0;
    }
  }
  printf("No");

  return 0;
}


Measured memory_bytes: 1736