akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  std::vector<int> P(N);
  for (int i = 0; i < N; ++i)
    std::cin >> S[i] >> P[i];

  // Main
  std::vector<int> idx(N);
  std::iota(idx.begin(), idx.end(), 0);
  std::stable_sort(idx.begin(), idx.end(),
                   [&](int k, int l) { return P[k] > P[l]; });
  std::stable_sort(idx.begin(), idx.end(),
                   [&](int k, int l) { return S[k] < S[l]; });

  // Output
  for (int i = 0; i < N; ++i)
    std::cout << idx[i] + 1 << std::endl;

  return 0;
}


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

int N;
int ans[1111];
int main(){
  for(int i=1;i<=1000;i++){
    int sum = i;
    for(int j=i+1;j<=1000;j++){
      sum += j;
      if( sum > 1000 ) break;
      ans[sum]++;
    }
  }
  while( cin >>N && N ){
    cout << ans[N] << endl;
  }
}

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

int N, A[200];

int main()
{
	int dmin = 100;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		int A;
		scanf("%d", &A);
		int d = 0;
		while (A % 2 == 0) {
			A /= 2;
			++d;
		}
		dmin = min(dmin, d);
	}
	printf("%d\n", dmin);
	return 0;
}


Measured memory_bytes: 1724
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,readline().split())
LR = np.array(read().split(),np.int32)

L = LR[::2]; R = LR[1::2]

x = R.min() - L.max() + 1
if x < 0: x = 0
print(x)

Measured memory_bytes: 23212
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int r;
    cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// 各点到当前工厂的距&#31163;
int d[1024][1024];
const int direction[4][2] = {
    { -1, 0 },
    { 1, 0 },
    { 0, -1 },
    { 0, 1 },
};
 
int factory[16][2];
typedef pair<int, int> P;
 
 
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const int & sx 起点x
// Parameter: const int & sy 起点y
// Parameter: const int & gx &#32456;点x
// Parameter: const int & gy &#32456;点y
//************************************
int bfs(const int sx, const int sy, const int&gx, const int gy)
{
    //memset(d, -1, sizeof(d));
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            d[j][i] = -1;
        }
    }
    queue<P> que;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    while (que.size())
    {
        const P p = que.front(); que.pop();
        // 如果是&#32456;点就&#32467;束
        if (p.first == gx && p.second == gy)
        {
            break;
        }
 
        // 四方向漫游
        for (int i = 0; i < 4; ++i)
        {
            int nx = p.first + direction[i][0];
            int ny = p.second + direction[i][1];
            // 是否可以移&#21160;，并且&#35813;点没有&#35775;&#38382;&#36807;
            if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
            {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
 
    return d[gx][gy];
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
    cin >> h >> w >> n;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin >> map[j][i];
        }
    }
 
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (map[j][i] == 'S')
            {
                factory[0][0] = j;
                factory[0][1] = i;
                map[j][i] = '.';
            }
            else if (isdigit(map[j][i]))
            {
                int index = map[j][i] - '0';
                factory[index][0] = j;
                factory[index][1] = i;
            }
        }
    }
 
    int step = 0;
    for (int i = 0; i < n; ++i)
    {
        // 按&#39034;序吃遍中&#21326;
        step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
    }
     
    cout << step << endl;
 
    return 0;
}

Measured memory_bytes: 6316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n);
}


Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());
  int m,nmin,nmax;
  while(1){
    cin >> m>>nmin>>nmax;
    if(m==0 && nmin==0 && nmax==0){
      return 0;
    }
    int pi,pib,sa,ans;
    int samax=0;
    for(int i=0;i<m;i++){
      if(i>0)pib=pi;
      cin >> pi;
      if(i==0)pib=pi;
      if(nmin<=i && i <=nmax){
	sa=pib-pi;
	if(sa>=samax){
	  samax=sa;
	  ans=i;
	}
      }
      //   if(i>nmax)break;
    }
    cout << ans <<endl;
  }
}

Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main(void)
{
    int N, i, j, judge=0;

    cin >> N;

    for(i=1; i<=9; i++){
        for(j=1; j<=9; j++){
            if(i * j == N){
                judge = 1;
            }
        }
    }

    if(judge == 1){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;
void B_135()
{
  int N;
  cin >> N;

  int count = 0;
  for (int i = 1; i <= N; ++i)
  {
    int p;
    cin >> p;

    if (i != p) ++count;
    if (count > 2)
    {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}
int main()
{
  //C_131();
  //B_139();
  //B_138();
  //B_137();
  //B_136();
  B_135();
}


Measured memory_bytes: 256
pub fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let ab: Vec<i32> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    if ab[0] < ab[1] {
        for _ in 0..ab[1] {
            print!("{}", ab[0]);
        }
    } else {
        for _ in 0..ab[0] {
            print!("{}", ab[1]);
        }
    }
    println!("");
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	cin >> n;
	int arr[n][26] = {0};
	/*REP(i, 0, n){
		REP(j, 0, 26) arr[i][j] = 0;
	}*/
	string tmp;
	REP(i, 0, n){
		cin >> tmp;
		for(char c: tmp) ++arr[i][c-'a'];
	}
	string ans = "";
	REP(i, 0, 26){
		int m = INT_MAX;
		REP(j, 0, n) m = min(m, arr[j][i]);
		REP(j, 0, m) ans += (i+'a');
	}
	cout << ans;

}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, Y;
    cin >> N >> X >> Y;
    for (ll k = 1; k < N; ++k) {
        ll s = 0;
        for (ll i = 1; i <= N; ++i) {

            if (abs(X - i) >= k) {
                if (i + k <= N)
                    s++;
                continue;
            }

            if (i + k <= N) {
                //! i+kまでの距離
                ll l = abs(X - i) + 1 + abs(i + k - Y);
                if (l >= k)
                    s++;
            }

            ll a = Y - (k - abs(X - i) - 1);
            ll b = Y + (k - abs(X - i) - 1);
            if (a == b) {
                if (a > i && a - i > k)
                    s++;
            }
            else {
                if (a > 0 && a > i && a - i > k)
                    s++;
                if (b <= N && b > i && b - i > k)
                    s++;
            }

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

Measured memory_bytes: 256
import sys
import heapq
N,M=map(int,input().split())
alist=list(map(int,input().split()))

cblist=[]
for i in range(M):
  B,C=map(int,input().split())
  cblist.append((C,B))
cblist.sort(reverse=True)

hq=[]
for a in alist:
  heapq.heappush(hq,a)
  
for C,B in cblist:
  for i in range(B):
    if C<=hq[0]:
      print(sum(hq))
      sys.exit(0)
    else:
      heapq.heapreplace(hq,C)
else:
  print(sum(hq))

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

#define IS_EVEN(a) ( ((a)&0x01) == 0 )

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

    int a[200];
    int min_cnt=0x0fffffff;
    for(int i = 0 ; i < n ; i++) {
        int tmp_cnt=0;
        cin >> a[i];
        while(1) {
            if( IS_EVEN(a[i]) ) {
                tmp_cnt++;
                a[i] = a[i] >> 1;
            } else {
                break;
            }
        }
        if( tmp_cnt < min_cnt ) {
            min_cnt = tmp_cnt;
        }
    }
    cout << min_cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i; 
    char s[4];
    // 文字列の入力
    
  scanf("%s", s);
  
  if((s[0]=='A')&&(s[1]=='A')&&(s[2]=='A'))
    printf("No");
    
    
  else if((s[0]=='B')&&(s[1]=='B')&&(s[2]=='B'))
    printf("No");

  else 
    printf("Yes");
    
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

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

    int n;
    cin >> n;

    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        int c = n / i;
        ans += (ll) i * c * (c + 1) / 2;
    }

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

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


	int main() {
		int n, k;
		cin >> n >> k;
		vector<int>a;
		
		while (n>0) {
			a.push_back(n%k);
			n /= k;
		}
		
		cout << a.size() << endl;
	}



Measured memory_bytes: 256
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;

int main(){
    string s;
    cin>>s;
    int n = (int)s.size();
    cout<<s[0]<<n-2<<s[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll M = 1000000007;
ll bigm(ll m, ll n)
{
    ll r = 1;
    for(int i=0; i<n; i++)
    {
       r = r*m%M;
    }
    return r;
}
int main(){

    ll n; cin >> n;
    ll ans = bigm(10,n)-bigm(9,n)-bigm(9,n)+bigm(8,n);
    ans%=M;
    ans = (ans+M)%M;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3620
function permutation(n,k){
    var ret=[[]];
    var next;
    for(var i=0;i<k;i++){
        next=[];
        ret.forEach(e=>{
            for(var k=1;k<=n;k++){
                if(!e.includes(k)){
                    next.push(e.concat([k]));
                }
            }
        });
        ret=next.concat([]);
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const A=input[0].split(' ')[0];
  const B=input[0].split(' ')[1];
  console.log(B+A);

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29524
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

	if ("Sunny" == weather)
	{
		cout << "Cloudy" << endl;
	}
	else if ("Cloudy" == weather)
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,k,arr[100000];
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>arr[i];
  int ans=(n-1)/(k-1);
  if((n-1)%(k-1)!=0)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrt((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}


int main(void) {
	Rapid_pleaseAC_fast;
    long double a,b,c,ad=1.0, bd=1.0, cd=1.0,x,y,z,unknown=1.0e-14;
	cin >> a>>b>>c;
	ad += a - 1.0;
	bd += b - 1.0;
	cd += c - 1.0;
	x = mysqrtl(ad);
	y = mysqrtl(bd);
	z = mysqrtl(cd);
	if (x+y+unknown<z)cout << "Yes" << endl;
	else cout << "No" << endl;
	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

vector< bool > get_prime(int n){
  vector< bool > prime( n + 1, true);
 
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
 
  for(int i = 2; i * i <= n; i++){
    if(prime[i]){
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }
 
  return prime;
}

int main(){
  int n, x;
  while(cin >> n >> x, n){
    vector< int > food(n);
    for(int i = 0; i < n; i++){
      cin >> food[i];
    }
    vector< bool > dp(x + 1, false);
    dp[0] = true;
    for(int i = 0; i <= x; i++){
      if(dp[i]){
        for(int j = 0; j < n; j++){
          if(i + food[j] > x) continue;
          dp[i + food[j]] = true;
        }
      }
    }
    vector< bool > prime = get_prime(x);
    int ret = -1;
    for(int i = x; i >= 0; i--){
      if(prime[i] && dp[i]){
        ret = i;
        break;
      }
    }
    if(~ret) cout << ret << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1436
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = 924844033;

void add(int & a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mult(int a, int b) {
  return (ll) a * b % mod;
}

const int maxn = 2200;
int dp[maxn][maxn][4];
int dp2[maxn][maxn];
int fact[maxn];

void precalc() {
  fact[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fact[i] = mult(fact[i - 1], i);
  }
  dp[0][0][3] = 1;
  for (int i = 1; i < maxn; i++) {
    for (int j = 0; j <= i; j++) {
      for (int mask = 0; mask < 4; mask++) {
        int nmask = !(mask / 2);
        nmask += ((int) !(mask & 1)) << 1;
        int cnt = __builtin_popcount(mask);
        if (j - cnt < 0) {
          continue;
        }
        for (int k = 0; k < 4; k++) {
          if ((k & nmask) == k) {
            add(dp[i][j][mask], dp[i - 1][j - cnt][k]);
          }
        }
      }
    }
  }
  for (int i = 0; i < maxn; i++) {
    for (int j = 0; j < maxn; j++) {
      for (int k = 0; k < 4; k++) {
        add(dp2[i][j], dp[i][j][k]);
      }
    }
  }
}

int n, k;

bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  return true;
}

void solve() {
  vector<int> ans(1, 1);
  for (int i = 0; i < k; i++) {
    int cnt = (n - 1 - i) / k + 1;
    vector<int> nans(sz(ans) + cnt);
    for (int j = 0; j < sz(ans); j++) {
      for (int k = 0; k <= cnt; k++) {
        add(nans[j + k], mult(ans[j], dp2[cnt][k]));
      }
    }
    swap(nans, ans);
  }
  int res = 0;
  for (int i = 0; i < sz(ans); i++) {
    if (i & 1) {
      add(res, mod - mult(ans[i], fact[n - i]));
    } else {
      add(res, mult(ans[i], fact[n - i]));
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  if(k == 1) cout << 0 << endl;
  else cout << n - k << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()

    sum_count = s.count('R') * s.count('G') * s.count('B')

    r_list = set()
    g_list = set()
    b_list = set()

    for i in range(n):
        if s[i] == 'R':
            r_list.add(i)
        elif s[i] == 'G':
            g_list.add(i)
        elif s[i] == 'B':
            b_list.add(i)

    for r in r_list:
        for g in g_list:
            L = g - r
            if g + L in b_list:
                sum_count -= 1
            if r - L in b_list:
                sum_count -= 1
            if L % 2 == 0 and L//2 + r in b_list:
                sum_count -= 1

    print(sum_count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9476
import sys
input = sys.stdin.readline

n = int(input())
h = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r):
        l += self.n
        r += self.n
        s = self.one
        t = self.one
        while l < r:
            if l & 1:
                s = self.func(s, self.b[l - 1])
                l += 1
            if r & 1:
                r -= 1
                t = self.func(self.b[r - 1], t)
            l >>= 1
            r >>= 1
        return self.func(s, t)


seg = SegmentTree([0]*(n+1))

for i in range(n):
    j = seg.get_segment(0, h[i] + 1)
    seg.update_func(h[i], j + a[i])
print(seg.get_segment(0, n+1))


Measured memory_bytes: 119668
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  p=1e9+7; 



 int main() {
        ff;
        ll n;
        cin>>n;
        ll z=n%10;
        
        if(z==4 || z==5|| z==7 ||z==2 ||z==9){
            cout<<"hon"<<endl;
        }else if(z==0 || z==1 || z==6 ||z==8){
            cout<<"pon"<<endl;
        }else{
            cout<<"bon"<<endl;
        }
        
            
            
            
        
           
       
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int ans=0;
    char s[99];
    
    cin >> n;
    cin >> s;
    
    for(int i=0; i<=n-3; i++){
        
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            
            ans += 1;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    ll x, y;
    cin >> x >> y;

    ll count = 0;
    if (abs(x) > abs(y)) {
        if (x > 0) {
            count++;
            x = -x;
        }
    } else {
        if (x < 0) {
            count++;
            x = -x;
        }
    }

    ll diff = abs(abs(x) - abs(y));
    count += diff;
    x += diff;
    if (x != y) {
        count++;
        x = -x;
    }
    assert(x == y);
    cout << count << endl;
}




Measured memory_bytes: 256
fn solve(nstr: &str, k: usize) -> usize {
    if k == 0 {
        return 1;
    }

    let n = nstr.len();
    if n < k {
        return 0;
    }

    let top: usize = nstr[0..1].parse().unwrap();

    if top == 0 {
        solve(&nstr[1..], k)
    } else {
        let mut s = "".to_string();
        for _ in 0..(n - 1) {
            s.push_str("9");
        }

        solve(&s, k) + solve(&nstr[1..], k - 1) + (top - 1) * solve(&s, k - 1)
    }
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let nstr = read_line!();
    let k = parse_line!(usize);

    println!("{}", solve(&nstr, k));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long res = 0;
	vector<long long> a(n + 1, 0), b(n, 0);
	for(int i = 0; i < n + 1; ++i)cin>>a[i];
	for(int i = 0; i < n; ++i)cin>>b[i];
	for(int i = 0; i < n; i++){
		if(a[i] - b[i] >= 0){
			a[i] -= b[i];
			res += b[i];
			b[i] = 0;
		}
		else{
			b[i] -= a[i];
			res += a[i];
			a[i] = 0;			
		}
		if(b[i] > 0){
			if(a[i + 1] - b[i] >= 0){
				a[i + 1] -= b[i];
				res += b[i];
				b[i] = 0;
			}
			else{
				b[i] -= a[i + 1];
				res += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    s.erase(unique(s.begin(), s.end()), s.end());
    if (s.size() != len)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {

	int n;
	cin >> n;
	vector<int> l(n);
	int sum=0;
	rep(i, n) {
		cin >> l[i];
		sum += l[i];
	}
	rep(i, n) {
		if (l[i] >= sum - l[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}





Measured memory_bytes: 256
using System;
class Program {
    static void Main() {

        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);

        int divisorCount = 0;

        for(int i = a; i <= b; i++) {
            if (c % i == 0) divisorCount++;
        }

        Console.WriteLine(divisorCount);
    }
}

Measured memory_bytes: 9220
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = 1000001
table = list(range(N+1))
for i in range(2, N+1):
    # 各素数から、自分の倍数になる数に、オイラーのファイ関数を掛け込んでいく
    if table[i] == i:
        for j in range(i, N+1, i):
            table[j] *= 1 - 1/i

# 0/0の分を入れる
table[0] = 1
ans = list(accumulate(table))
for i in range(INT()):
    a = INT()
    print(int(ans[a]))



Measured memory_bytes: 73904
/*
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second 
#define ll long long 
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<29
const int mod=1e9+7;
const int MAX=1e6+5;
ll a[MAX]; 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll k,n,sum=0;
	cin>>k>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll Max=-1;
	for(int i=1;i<n;i++)
	{
		sum+=a[i]-a[i-1];
		Max=max(Max,a[i]-a[i-1]);
	}
	sum+=k-a[n-1]+a[0];
	Max=max(Max,k-a[n-1]+a[0]);
	cout<<sum-Max;	
}*/

/*
#include<bits/stdc++.h>
using namespace std;
const int MAX=2005;
const int mod=1e9+7;
#define ll long long 
#define endl '\n'
#define _for(i,j,k) for(int i=j;i<k;i++)
int gcd(int a, int b){return a % b ? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}
ll qpow(int a,int b,int mod){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a*=a;b>>=1; }}
int a[MAX];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int p=min(abs(i-j),abs(i-x)+abs(j-y)+1);
			a[p]++;
		 }
	} 
	for(int i=1;i<=n-1;i++)
	cout<<a[i]<<'\n';
}
 */
 
 
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+5;
const int mod=1e9+7;
#define ll long long 
#define endl '\n'
#define _for(i,j,k) for(int i=j;i<k;i++)
int gcd(int a, int b){return a % b ? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}
ll qpow(int a,int b,int mod){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a*=a;b>>=1; }}
 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<int>p(a),q(b),r(c);
	for(int i=0;i<a;i++)
	cin>>p[i];
	for(int i=0;i<b;i++)
	cin>>q[i];
	for(int i=0;i<c;i++)
	cin>>r[i];	
	sort(p.begin(),p.end());
	sort(q.begin(),q.end());
	sort(r.begin(),r.end());
	vector<int>v;
	for(int i=a-x;i<a;i++)
	v.push_back(p[i]);
	for(int i=b-y;i<b;i++)
	v.push_back(q[i]);
	for(int i=0;i<c;i++)
	v.push_back(r[i]);
	ll sum=0;
	sort(v.begin(),v.end());
	for(int i=v.size()-x-y;i<=v.size()-1;i++)
	sum+=v[i];
	cout<<sum;
} 

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

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

    if(b >= c || a >= b)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes"<< endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int n, d, x, a[110];

int main() {
	cin >> n >> d >> x;
	rep (i, n) cin >> a[i];
	int ans = x;
	d--;
	rep (i, n) {
		ans += d / a[i] + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
int water, bill;
scanf("%d",&water);
while(water!=-1) {
bill=1150;
if(water-10>0)
bill+=(water-10)*125;
if(water-20>0)
bill+=(water-20)*15;
if(water-30>0)
bill+=(water-30)*20;
printf("%d\n",4280-bill);
scanf("%d",&water);
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a[5];
int32_t main(){
CODE_START;
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if(a[0]==a[1]&&a[0]!=a[2]){
    cout<<"Yes"<<endl;
}else if(a[1]==a[2]&&a[2]!=a[0]){
cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define vi vector<int>
#define all(x) (x).begin(),(x).end()

#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define mod 1000000007

int pref[101][100005];
int dp[101][100005];
 main()
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vi a(n);
	rep(i,0,n) cin>>a[i];

	rep(i,0,n)
	{
		rep(j,0,k+1)
		{
			if(i==0)
			{
				if(j<=a[i] ) dp[i][j] = 1;
				else dp[i][j] = 0;
			}
			else
			{
				int id1 = j;
				int id2 = j-a[i]-1;
				dp[i][j] = pref[i-1][id1]%mod;
				if(id2>=0) dp[i][j] -= pref[i-1][id2],dp[i][j] = (dp[i][j]%mod+mod)%mod;
			}
			if(j==0)
			{
				pref[i][j] = dp[i][j]%mod;
			}
			else pref[i][j] = pref[i][j-1]%mod+dp[i][j]%mod,pref[i][j]%=mod;


		}
	}
	cout<<dp[n-1][k]<<endl;




}

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

int main(){
  int N, p[10000], max=0, max_index=0, sum=0;
  cin >> N;
  for (int i=0; i < N; i++) {
    cin >> p[i];
    if (max < p[i]) {
      max = p[i];
      max_index = i;
    }
  }
  for (int i=0; i < N; i++) {
    if (i == max_index) {
      sum += p[i] / 2;
    } else {
      sum += p[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a, b, c, d;
    while(cin>>a>>b>>c>>d){
        ll ans = LONG_LONG_MIN;
        for(auto x: {a,b}){
            for(auto y: {c,d})
                max_self(ans, x*y);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

int main(){
  int h,w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)return 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if((i%2 == 0) ^ (j%2 == 1))
          putchar('#');
        else
          putchar('.');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}



Measured memory_bytes: 2580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int main(int argc, char const *argv[])
{
    int X, A;
    cin >> X >> A;
    if (X < A)
    {
        cout << 0;
    } else {
        cout << 10;
    }


    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    times = []
    ans = 0
    for _ in range(5):
        time = int(input())
        if time % 10 == 0:
            ans += time
        else:
            times.append(time)
    if len(times)==0:
        print(ans)
        return 0

    times.sort(key=lambda x: x%10,reverse=True)
    ans += times[-1]
    times = times[:-1]
    if len(times)==0:
        print(ans)
        return 0

    for time in times:
        ans += 10*(time//10+1)
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
    ll N; cin >> N;
 
    vector<ll>A(N);
    for (ll i = 0; i < N; i++)
    cin >> A[i];
 
    sort(A.begin(), A.end(), greater<ll>());

    priority_queue<ll> Q;
    Q.push(A.at(0));
    
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        ans += Q.top();
        Q.pop();
        Q.push(A[i]);
        Q.push(A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int fa[100005];
int n,m,ans=0;
vector<int>isl[100005];
int findx(int v)
{
    int j=v,a;
    while(fa[v]!=v)
    {
       v=fa[v];
    }
    while(fa[j]!=j)
    {
        a=j;
        j=fa[j];
        fa[a]=v;
    } 
    return v;
}
bool check(int p)
{
	int f=findx(p-1);
	for(int i=isl[p].size()-1;i>=0;i--)
	    {
	    	int u=isl[p][i];
	    	if(findx(u)==f)
	    	   return false;
	    }
	fa[p]=f;    
	return true;    
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	    fa[i]=i;
	for(int i=1;i<=m;i++)
	    {
	    	int a,b;
	    	scanf("%d%d",&a,&b);
	    	if(a>b)
	    	   isl[a].push_back(b);
	    	else
			   isl[b].push_back(a);   
	    }
	for(int i=1;i<=n-1;i++)
	    {
	    	if(!check(i+1))
	    	   ans++; 
	    } 
	printf("%d",ans);	   
	return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string t;
  bool ok=true; 
  cin >> n >> y;
  for(int i=0; i<=n;i++){
    for(int j=0; j<=n ;j++){
        int k = n-i-j;
        if(i*10000 + j*5000 + k*1000 == y && i+j+k==n && k>=0){
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 3560
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,k,N,H,W,ans=0;
  string s;
  cin>>N;++N;
  rep1(i,N)rep1(j,N)rep1(k,N){
    ans+=gcd(gcd(i,j),k);
  }
  print(ans);
  return 0;
}

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

pro = 1

if 0 in a:
    pro = 0
else:
    for i in a:
        if pro > 10 ** 18:
            pro = -1
            break
        else:
            pro = pro * i

if pro > 10 ** 18:
    print(-1)
else:
    print(pro)

Measured memory_bytes: 21592
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define int ll

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e6 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		
		vector<int> arr(n);
		FOR(i,0,n) cin >> arr[i];
		
		sort(arr.begin(),arr.end(),greater<int>());
		
		priority_queue<pair<int,int> > pq;
		vector<int> f(n,0);
		f[0] = 2;
		
		int ans = arr[0];
		pq.push({arr[1],1});
		
		for(int i = 2; i < n; ++i){
			pair<int,int> val = pq.top();
			pq.pop();
			
			ans += val.first;
			f[val.second]++;
			if(f[val.second] == 1) pq.push(val);
			pq.push({arr[i],i});
		}
		
		cout << ans << "\n";
	}	
	return 0;
}


Measured memory_bytes: 10548
import numpy as np

n = int(input())
h = np.array(list(map(int, input().split() )))

ans = 0
for i in range(100 + 1):
	#100まで
	for j in range(n+1):
		ishigher = h > i
		if(j==0):
			if ishigher[j] == True:
				ans += 1
		elif j==n:
			if ishigher[j-1] == True:
				ans += 1
		elif (ishigher[j] != ishigher[j-1]):
			ans += 1

# False→TrueとTrue→Falseを数えているから、2で割ったものが答え
print (ans//2) # 整数除算



Measured memory_bytes: 12424