akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, M;
	ll sum = 0;
	cin >> N >> M;
	priority_queue<ll> data;
	FOR(i, 0, N){
		ll c;
		cin >> c;
		data.push(c);
	}
	while(M--){
		ll c = data.top();
		data.pop();
		data.push(c >> 1);
	}

	while(data.size()!=0){
		sum += data.top();
		data.pop();
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 4288
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int a[n],r1=0,max,sec,i;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(a[r1]<a[i]){
      r1=i;
    }
  }
  max=a[r1];
  a[r1]=0;
  int r2=0;
  for(i=0;i<n;i++){
    if(a[r2]<a[i]){
      r2=i;
    }
  }
  sec=a[r2];
  for(i=0;i<n;i++){
    if(i==r1){
      printf("%d\n", sec);
    }else{
      printf("%d\n", max);
    }
  }
  return 0;
}

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

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

    int count = 0;
    for (long long int a=1; a<=n; a = a + 2){
        vector<long long int> div;
        for (long long int i=1; i*i<=a; i++){
            if (a % i == 0){
                div.push_back(i);

                long long int j = a / i;// counterpart
                if (j != i) div.push_back(j);
            }
        }
        if(div.size() == 8) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            int n = NextInt;
            var s = Enumerable.Range(0, n).Select(_ => string.Join("", Line.OrderBy(x => x))).ToArray();
            var dictionary = new Dictionary<string, long>();

            foreach (var item in s)
            {
                if (dictionary.ContainsKey(item))
                {
                    dictionary[item] = dictionary[item] + 1;
                }
                else
                {
                    dictionary[item] = 1;
                }
            }

            System.Console.WriteLine(dictionary.Values.Select(x => x * (x - 1) / 2).Sum());
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 33040
import numpy as np
K, N = map(int, input().split())
x_list = list(map(int, input().split()))

sub_x_list = x_list.copy()[1:]
sub_x_list.append(K + x_list[0])

for i in range(N):
    sub_x_list[i] -= x_list[i]
    
max_i = max(sub_x_list)
print(K - max_i)

Measured memory_bytes: 34176
t[999];n,m,a,*p,i;c(int*x){a=*1[&x]-*x;}main(b){for(;i=scanf("%d",&n)*n;puts(t>p?"OK":"NG")){for(p=t;i--;*p++=-m)scanf("%d%d%d",&m,&a,&b),*p++=a,*p++=m,*p++=b;for(qsort(t,2*n,m=8,c);t-p--&&m<159|p[-1]==p[1];)m+=*p--;}}

Measured memory_bytes: 0
n = gets.to_i
a = gets.split.map(&:to_i).sort
b = a[n-1]
t = 1.0 * b / 2
d = 1000000000.0
j = 0

(n-1).times do |i|
  if d > (a[i] - t).abs
    d = (a[i] - t).abs
    j = a[i]
  end
end

puts [b, j].join(' ')


Measured memory_bytes: 10112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
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 long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	string s,t;
	cin >> s >> t;

	int cnt = 0;
	if (s[0] == t[0]) {
		cnt++;
	}
	if (s[1] == t[1]) {
		cnt++;
	}
	if (s[2] == t[2]) {
		cnt++;
	}


	cout << cnt  << endl;

	return 0;
}

Measured memory_bytes: 256
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const x = r.nn()

    return x.indexOf(0) + 1
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 29624
import sys

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 = 10 ** 19
MOD = 10 ** 9 + 7

h1, m1, h2, m2, K = MAP()

hm1 = h1*60 + m1
hm2 = h2*60 + m2
diff = hm2 - hm1
ans = diff - K
print(ans)


Measured memory_bytes: 9256
#include<iostream>

using namespace std;
int data[1001];
int main(){
	data[0]=0;
	for(int i=1;i<1001;i++)data[i]=data[i-1]+i;
	
	int n;
	while(cin>>n &&n){
		int now=1;
		int ans=0;
		for(int i=1;i<1001;){
			int tmp=data[now]-data[i-1];
			if(tmp<n)now++;
			else if(tmp>n)i++;
			else {
				ans++;
				i++;
			}
		}
		cout<<ans-1<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
	int i;
	int t[10];
	for(i=0; i<10; i++){
		scanf("%d", &t[i]);
	}
	int a = 0, b = 0, c = 0;
	for(i=0; i<10; i++){
		if(a < t[i]){
			c = b;
			b = a;
			a = t[i];
		}
		else if(b < t[i]){
			c = b;
			b = t[i];
		}
		else if(c < t[i])
			c = t[i];
	}
	printf("%d\n%d\n%d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;
int main() 
{
	ll n,m,h[N],ma[N];
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		ma[i]=0;
	}
	ll a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
		ma[b]=max(ma[b],h[a]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=h[i]>ma[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5220
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
  ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    string S;
    cin >> S;
    rep(i,S.length()){
        if (i%2==0){
            if (S[i] == 'R' || S[i]=='U' || S[i]=='D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if (S[i] == 'L' || S[i]=='U' || S[i]=='D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
    int n; cin >> n;
    string str; cin >> str;
  
    int x = 0;
    int ans = 0;
    for(int i = 0; i < n; i++) {
      if(str.at(i) == 'I') {
        x++;
      } else {
        x--;
      }
      if(ans < x) ans = x;
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3536
n,m=map(int,input().split())
sum_n=[0]*m
sum=0
for i in range(n):
    lst=list(map(int,input().split()))
    sum_m=0
    for j in range(m):
        print(lst[j], end=" ")
        sum_m+=lst[j]
        sum_n[j]+=lst[j]
    print(sum_m)
    sum+=sum_m
for i in range(m):
    print(sum_n[i], end=" ")
print(sum)


Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n;
	vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
	}
	sort(v.begin(), v.end());
	for (int h = 0; h < n; h++) {
		for (int i = h + 1; i < n; i++) {
			ll sum = 0;
			if (v[h] + v[i] <= v[n - 1]) {
				sum = lower_bound(v.begin(), v.end(), v[h] + v[i]) - v.begin();
			}
			else { sum = n; }
			ans += sum - i - 1;
		}
	}
	cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1 << endl;
	}
	else {
		cout << n / 2 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin>>S;
    if(S=="SUN"){
    cout<<7<<endl;
        
    }
    else if(S=="MON"){
        cout<<6<<endl;
    }
    else if(S=="TUE"){
        cout<<5<<endl;
    }
    else if(S=="WED"){
        cout<<4<<endl;
    }
    else if(S=="THU"){
        cout<<3<<endl;
    }
    else if(S=="FRI"){
        cout<<2<<endl;
    }
    else if(S=="SAT"){
        cout<<1<<endl;
    }
    return 0;
}


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

int main()
{
  int n,d,r;
  cin>>n>>d;
  if(n>=10)
  {
    r=d;
  }
  else
  {
    r=d+(100*(10-n));
  }
  cout<<r<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

string func(string str){
	stringstream ss;
	
	for(int i = 0; i < str.length();){
	
		int cnt = 0;
		char t = str[i];
		while(str[i] == t){
			++cnt;
			++i;
			
			if(i == str.length())break;
		}
		ss << cnt << t;
	}
	
	return ss.str();
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string str;
	
	while(cin >> n, n){
		cin >> str;
		
		REP(i, n){
			str = func(str);
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000ll)

//global


int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	ll a,b,c;
	cin >> a >> b >> c;
	cout << min({a*b,b*c,a*c,OOL*(a%2!=0 && b%2!=0 && c%2!=0)});
	return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
m=math.ceil(pow(2*n+1/4,0.5)-1/2)
s=m*(m+1)//2
for i in range(1,m+1):
  if i!=s-n:
    print(i)
  

Measured memory_bytes: 75252
# include <iostream>
using namespace std;
 
int main(void) {
 
  int counter[26];
  for (int i=0; i<26; i++) {
    counter[i]=0;
  }
 
  char ch;
  while(cin>>ch){
    int num = tolower(ch) - 'a';
   counter[num]++;
  }
 
  for (int i=0; i<26; i++){
    ch = i + 'a';
    cout << ch << " : " << counter[i] << endl;
  }
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
int h[1000005];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n>>h[1];
    int low=h[1]-1;
    bool f=true;
    for(int i=2;i<=n;i++)
    {
        cin>>h[i];
        if(h[i]>low)
        {
            low=h[i]-1;
        }
        else if(h[i]==low)
        {
            low=h[i];
        }
        else
        {
            f=false;
        }

    }
    if(f)
        cout<<"Yes";
    else
        cout << "No";
	return 0;
}



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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<x<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

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

int i, j, k;
priority_queue<pair<int,int>> q;
int main()
{
	ll n,k;
	cin >> n >> k;
	ll count = 0;
	rep(i,n) {
		int x, y;
		cin >> x >> y;
		q.push(make_pair(-x,y));
	}
	while(!q.empty()) {
		pii v = q.top();
		q.pop();
		count += v.second;
		if (count >= k) {
			print(-v.first);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1400
// coded by- mrNOBODY_

#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cin.sync();
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c == '+')
    {
        cout<<a+b;
    }
    if( c== '-' )
    {
        cout<<a-b;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;

int main(){
	
	int i,j,k;
	scanf("%d%d",&i,&j);
	printf("%d",(i-1)*(j-1)); 

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int n,k;

int findTrackMax(int stackWeight[]){
	int max = 0;
	for(int i = 0; i < k; i++){
		if(max < stackWeight[i]){
			max = stackWeight[i];
		}
	}
	return max;
}

bool pileW(int w[],int p){

	int trial[k];
	for(int i = 0; i < k; i++){
		trial[i] = 0;
	}
	int index_w = 0;
	int index_track = 0;
	int tmp = 0;

	if(k == 1){
		for(int i = 0; i < n; i++){
			trial[0] += w[i];
		}
		return (trial[0] <= p);
	}

	while(true){
		if(tmp + w[index_w] <= p){
			tmp += w[index_w++];
		}else{
			trial[index_track++] += tmp;
			tmp = 0;
		}

		if(index_track == k-1){
			for(int i = index_w; i < n; i++){
				trial[index_track] += w[i];
			}
			return (trial[index_track] <= p);
		}else if(index_w == n-1){
			return (w[index_w] <= p);
		}
	}
}

int main(){

	scanf("%d %d",&n,&k);

	int w[n];
	int guessPMax[k];

	for(int i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}

	for(int i = 0; i < k; i++){
		guessPMax[i] = 0;
	}

	int p_trial_number;
	if(n >= k){
		if(n%2 == 0 && k%2 == 0){
			p_trial_number = n/k;
		}else{
			p_trial_number = n/k + 1;
		}
	}else{
		p_trial_number = 1;
	}

	int k_trial = 0,n_trial = 0;
	while(true){

		for(int i = 0; (i < p_trial_number && n_trial < n-1);i++){
			guessPMax[k_trial] += w[n_trial++];
		}
		k_trial++;
		if(k_trial == k-1){
			for(int i = n_trial;i < n;i++){
				guessPMax[k_trial] += w[i];
			}
			break;
		}else if(n_trial == n-1){
			guessPMax[k-1] += w[n_trial];
			break;
		}
	}

	int right = findTrackMax(guessPMax);

	int left = n/k;

	if(left == right){
		//Do nothing
	}else if(right - left == 1){
		if(pileW(w,left)){
			right = left;
		}
	}else{
		int m;
		while(right - left > 1){
			if((left + right)%2 == 1){
				m = (left + right+1)/2;
			}else{
				m = (left + right)/2;
			}
			if(pileW(w,m)){
				right = m;
			}else{
				left = m;
			}
		}
	}
	printf("%d\n",right);
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);

  cout << (s.size() == 2 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/



signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin >> n;
        vector<string> v;
        map<string,int> m;
        rep(i,0,n){
            string s;
            cin >> s;
            v.pb(s);
            m[s]++;
        }
        cout << "AC x " << m["AC"] << endl;
        cout << "WA x " << m["WA"] << endl;
        cout << "TLE x " << m["TLE"] << endl;
        cout << "RE x " << m["RE"] << endl;
    }
}

Measured memory_bytes: 7500
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<string> vs;
    typedef vector<ll> vl;
    typedef vector<vector<int> > vvi;
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define in insert
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    const int INF = 1e9 + 5;
    int main(){
        int n;
        cin >> n;
        map<int, bool> m;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            if(m[x] == false){
                m[x] = true;
            }
            else{
                m[x] = false;
            }
        }
        map<int, bool> :: iterator it;
        ll ans = 0;
        for(it = m.begin(); it != m.end(); it++){
            if(it->second == true) ans++;
        }
        cout << ans;
    }

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans=3;
    for(int i=0;i<N;i++){
      char s;
      cin >> s;
      if(s=='Y'){ans++;break;}
    }
    if(ans==3)cout << "Three";
    else cout << "Four";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
double root(double a1, double b1, double a2, double b2, double a3, double b3) {double S=a1*b2+a2*b3+a3*b1-b1*a2-b2*a3-b3*a1;if (S<0) return -S; else return S;}
int main() {
    double x1,x2,x3,xp,y1,y2,y3,yp;while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF) {
    double s=root(x1,y1,x2,y2,x3,y3),s1=root(x1,y1,x2,y2,xp,yp),s2=root(x1,y1,xp,yp,x3,y3),s3=root(xp,yp,x2,y2,x3,y3);
    if (s==s1+s2+s3) puts("YES"); else puts("NO");} return 0;}

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

int check(int N, int P[1001], int X[1001], int current) {
	vector<int> child;
	for (int i = 1; i <= N; i++) {
		if (P[i] == current) { child.push_back(i); }
	}
	if (child.empty()) { return 0; }

	bool possible[5001];
	int sum = 0;
	for (int i = 0; i < 5001; i++)
		possible[i] = false;
	possible[0] = true;
	for (int i = 0; i < child.size(); i++) {
		int c = check(N, P, X, child[i]);
		if (c == -1) return -1;

		sum += c + X[child[i]];
		bool next[5001];
		for (int j = 0; j <= 5000; j++)
			next[j] = false;
		for (int j = 0; j <= 5000; j++) {
			if (possible[j]) {
				if (j + c <= 5000) next[j + c] = true;
				if (j + X[child[i]] <= 5000) next[j + X[child[i]]] = true;
			}
		}
		for (int j = 0; j <= 5000; j++)
			possible[j] = next[j];
	}
	for (int i = X[current]; i >= 0; i--) {
		if (possible[i]) return sum - i;
	}
	return -1;
}

int main() {
	int N;
	int P[1001];
	int X[1001];
	cin >> N;
	for (int i = 2; i <= N; i++)
		cin >> P[i];
	for (int i = 1; i <= N; i++)
		cin >> X[i];

	cout << (check(N, P, X, 1) != -1 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 4480
s = str(input())
n = int(input())

for i in range(n):
    x = list(map(str,input().split()))
    x[1],x[2] = (int(x[1]),int(x[2]))
    if x[0] == 'print':
        print(s[x[1]:(x[2]+1)])
    if x[0] == 'reverse':
        s = s[:x[1]] + s[x[1]:(x[2]+1)][::-1] + s[x[2]+1:]
    if x[0] == 'replace':
        s = s[:x[1]] + x[3] + s[x[2]+1:]


Measured memory_bytes: 5616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        while(0 != h--){
            String str = sc.nextLine();
            System.out.println(str);
            System.out.println(str);
        }
    }
}

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

int main() {
  int N,x;
  cin >> N;
  
  x=0;
   for (int i=0; i<N ;i++){
     string Si;
     cin >> Si;
     
     if (Si=="Y") {
       x++;
     }
   }
  if (x==0){
    cout << "Three" <<endl;
  }
  else {
    cout << "Four" <<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

ll calc(ll a,ll b,ll p){//a^(b) mod p   
	if(b==0)return 1;
	ll y = calc(a,b/2,p);y=(y*y)%p;
	if(b & 1) y = (y * a) % p;
	return y;
}


int main(){
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N),X(N,0);
	FOR(i,0,N)cin >> A[i];
	ll ans = 0;
	FOR(i,0,N){
		ll x = 0;
		FOR(j,i+1,N){
			x += (A[i]>A[j]);
		}
		ans += x*K;
		ans %= MOD;
	}
	FOR(i,0,N){
		FOR(j,0,N){
			if(A[i]>A[j]){
				X[i]++;
			}
		}
	}
	FOR(i,0,N){
		ans += X[i]*(K-1)%MOD*K%MOD*calc(2,MOD-2,MOD)%MOD;
		ans  %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << (A[0]<1000 ? "ABC" : "ABD") << endl;
}

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

int main(void){
  int h, w;
  
  while(1){
    cin >> h >> w;

    if(h == 0 && w == 0) break;
    
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	if((i + j) % 2 == 0){
	  cout << "#";

	} else {
	  cout << ".";

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

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S, K;
cin >> S >> K;
S += K;
int P;
P = stoi(S);
bool check = 0;
for(int i = 1; i < 1000; i++){
if(i*i == P) check = 1;

}

if(check == 1) cout << "Yes" << endl;
else cout << "No" << endl;


}

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

int main(){
  int a[9];
  for(int i=0; i<9; i++){
    cin >> a[i];
  }
  int n;
  cin >> n;
  int b[n];
  bitset<9> u;
  for(int j=0; j<n; j++){
    cin >> b[j];
    for(int p=0; p<9; p++){
      if(a[p]==b[j]){
        u.set(p,1);
      }
    }
  }
if (u[0] & u[4] & u[8] |
    u[2] & u[4] & u[6] |
    u[0] & u[1] & u[2] |
    u[3] & u[4] & u[5] |
    u[6] & u[7] & u[8] |
    u[0] & u[3] & u[6] |
    u[1] & u[4] & u[7] |
    u[2] & u[5] & u[8]
   )
  {
  cout << "Yes" <<endl;
}
else{cout << "No" <<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int n;
  cin >> n;
  set <int> s;
  FOR (i, 1, 10) FOR (j, 1, 10) s.insert (i * j);
  auto ans = s.find (n) != s.end ();
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits.h>
using namespace std;
typedef long long LL;
const double eps = 1e-6;


LL a, b, c;
LL x, y, z;

bool check(int n) {
    if (c <= 0) return false;
    if (c > INT_MAX) return false;
    LL ret1 = a*b + b*c + c*a;
    LL ret2 = a*b*c;
    if (ret1*n != ret2*4) return false;

    return true;
}
void solve(int n) {
    double target = 4.0 / n;
    for (a = 1; a <= 5000; a++) {
        double a1 = 1.0 / a;
        if (a1 > target) continue;
        for (b = 1; b <= 5000; b++) {
            double a2 = 1.0 / b;
            if (a1+a2 > target || fabs(a1+a2-target) < eps) continue;
            double tmp = target - a1 - a2;
            double tmp2 = 1 / tmp;
            c = (LL) tmp2;
            if (check(n)) {
                x = a;
                y = b;
                z = c;
            }
        }
    }
}


int main() {
//    freopen("test.txt", "r", stdin);
    int n;
    cin >> n;
    solve(n);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 1e4 + 15;
const int MAXN2 = 1e3 + 15;
const ll MOD = 1e9 + 7;
int C = 700;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd;

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

int dp[MAXN][MAXN2];

inline void solve() {
    int h, n;
    cin >> h >> n;
    vector <pair <int, int> > a(n);
    cin >> a;
    for (int i = 0; i <= h; ++i) {
        int c = i / a[0].first;
        if (i % a[0].first) {c++;}
        dp[i][0] = c * a[0].second;
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= h; ++j) {
            dp[j][i] = dp[j][i - 1];
            dp[j][i] = min(dp[j][i], dp[max(j - a[i].first, 0)][i] + a[i].second);
        }
    }
    cout << dp[h][n - 1];
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, K - Q);
    for(int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        A.at(t - 1)++;
    }
    for(int i = 0; i < N; i++) {
        if(A.at(i) > 0) {
        cout << "Yes" << endl;
        } else {
        cout << "No" << endl;
        }
    }



    return 0;
}

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

using namespace std;

#define rep(i) for(int i=0;i<4;i++)
using ll=long long;
using Token=array<int,4>;
void norm(Token& t){
    Token res = t;
    rep(_){
        Token sft = {t[(1+_)%4],t[(2+_)%4],t[(3+_)%4],t[_]};
        res = min(res, sft);
    }
    t = res;
}
ll repeat(const Token& t) {
    if (t[0] != t[2]) return 1;
    if (t[1] != t[3]) return 1;
    return t[0]==t[1]?4:2;
}
void solve() {
    int n; cin >> n;
    vector<Token> a(n);
    map<Token, ll> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
        norm(a[i]);
        cnt[a[i]]++;
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            rep(k){
                Token U = {a[j][(1+k)%4], a[j][(0+k)%4], a[i][1], a[i][0]}; norm(U);
                Token R = {a[i][1], a[j][(0+k)%4], a[j][(3+k)%4], a[i][2]}; norm(R);
                Token D = {a[i][2], a[j][(3+k)%4], a[j][(2+k)%4], a[i][3]}; norm(D);
                Token L = {a[j][(1+k)%4], a[i][0], a[i][3], a[j][(2+k)%4]}; norm(L);
                ll tmp = 1;
                ll d = cnt[U] - (a[i]==U) - (a[j]==U);
                tmp *= d>0?d:0;
                d = cnt[R] - (a[i]==R) - (a[j]==R) - (U==R);
                tmp *= d>0?d:0;
                d = cnt[D] - (a[i]==D) - (a[j]==D) - (U==D) - (R==D);
                tmp *= d>0?d:0;
                d = cnt[L] - (a[i]==L) - (a[j]==L) - (U==L) - (R==L) - (D==L);
                tmp *= d>0?d:0;
                tmp *= repeat(U);
                tmp *= repeat(R);
                tmp *= repeat(D);
                tmp *= repeat(L);
                res += tmp;
            }
        }
    }
    res /= 3;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

long long GCD(long long a, long long b){
	if(b==0) return a;
  else return GCD(b,a%b);
}

int main(){
  
  long A,B,C,D,E,aa,bb;
  cin >>A>>B>>C>>D;
  E=C*D/GCD(C,D);
  aa=B/C-(A-1)/C+B/D-(A-1)/D;
  bb=B/E-(A-1)/E;
  
  cout << B-A+1-aa+bb << endl;
  
}

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

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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


int main(){
    FIN;
    int K;  cin >> K;

    ll ans = 0;
    for(ll a=1;a<=K;a++){
        for(ll b=1;b<=K;b++){
            for(ll c=1;c<=K;c++){
                ans += gcd(gcd(a,b),c);
            }
        }
    }

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


Measured memory_bytes: 3604
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt)


    var broken = 0
    var counter = 1
    for (i in 0 until n) {
        if (an[i] == counter) {
            counter++
        } else {
            broken++
        }
    }
    if (counter == 1) {
        println(-1)
        return
    }
    println(broken)

}




Measured memory_bytes: 83056
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int N = 1e6;
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}


int32_t main(){
   
   speed_cubing 
   
   int a,b,n;
   cin>>a>>b>>n;

   int maxi = 0;

   int B = min(n,b);

   for(int x=B;x>=max(B-N,0ll);x--){
      maxi = max(maxi,(a*(x%b)-(a*x)%b)/b);
   }

   cout<<maxi;
    
   return 0;
}


Measured memory_bytes: 3584
#include "iostream"
#include "string"

int main()
{
	bool card[4][13] = {0};
	int cardn[52], n;
	char mark[52];
	std::cin >> n;

	for (int i = 0; i < n; i++)
		std::cin >> mark[i] >> cardn[i];

	for (int i = 0; i < n; i++) {
		if (mark[i] == 'S') card[0][(cardn[i]) - 1] = 1;
		if (mark[i] == 'H') card[1][(cardn[i]) - 1] = 1;
		if (mark[i] == 'C') card[2][(cardn[i]) - 1] = 1;
		if (mark[i] == 'D') card[3][(cardn[i]) - 1] = 1;
	}

	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++) {
			if (card[i][j] == 0) {
				if (i == 0) std::cout << 'S' << " " << j + 1 << std::endl;
				if (i == 1) std::cout << 'H' << " " << j + 1 << std::endl;
				if (i == 2) std::cout << 'C' << " " << j + 1 << std::endl;
				if (i == 3) std::cout << 'D' << " " << j + 1 << std::endl;
			}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

string n;
int main() {
	cin >> n;
	switch (n[n.size()-1]) {
		case '3':
			cout << "bon" << endl;
			break;
		case '0':
		case '1':
		case '6':
		case '8':
			cout << "pon" << endl;
			break;
		default:
			cout << "hon" << endl;
	}
    return 0;
}


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

const int MAXN = 11;
int N;
string S[MAXN];
string rem[MAXN][MAXN];
string mem[1<<MAXN][MAXN];

bool lt(const string &a, const string &b) {
  return a.size() < b.size() ||
    a.size() == b.size() && a < b;
}

string rec(int used, int prev) {
  string &res = mem[used][prev];
  if(isalpha(res[0])) return res;
  if(used == (1<<N)-1) return res = "";
  for(int i = 0; i < N; ++i) {
    if(used >> i & 1) continue;
    string tmp = rem[prev][i] + rec(used | (1<<i), i);
    if(lt(tmp, res)) res = tmp;
  }
  return res;
}

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) cin >> S[i];
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if(i == j) continue;
        if(S[j].find(S[i]) != string::npos) {
          swap(S[i], S[--N]);
          --i;
          break;
        }
      }
    }
    for(int i = 0; i < N; ++i) {
      rem[N][i] = S[i];
      for(int j = 0; j < N; ++j) {
        if(i == j) continue;
        for(int k = 0; k <= S[i].size(); ++k) {
          int l = S[i].size() - k;
          if(S[i].substr(k, l) == S[j].substr(0, l)) {
            rem[i][j] = "";
            while(l < S[j].size()) rem[i][j] += S[j][l++];
            break;
          }
        }
      }
    }
    fill(mem[0], mem[1<<MAXN], string(1000, '#'));
    cout << rec(0, N) << endl;
  }
  return 0;
}

Measured memory_bytes: 1684
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int a, b,c;
	int A, B, C;

	cin >> a >> b >>c;
	A = abs(b - a) + abs(c - a);
	B = abs(b - a) + abs(c - b);
	C = abs(c - a) + abs(c - b);
	cout << min(A, min(B, C)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,N) for(int i=0; i < (N); i++)
using namespace std;

int main(){
	long long N;
	cin>>N;
	vector<long long> t(N+1),x(N+1),y(N+1);
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i = 1; i <= N; i++) cin>>t[i]>>x[i]>>y[i];

	long long Dt,Dl;
	for(int i = 0; i<N ; i++){
		Dt = t[i+1] - t[i];
		Dl = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

		if(Dt - Dl < 0){
			cout<<"No"<<endl;
			break;
		}else if( (Dt - Dl) % 2 != 0 ){
			cout<< "No"<<endl;
			break;
		}
		if(i==N-1){
			cout<<"Yes"<<endl;
		}
	}
}

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

namespace ConsoleApp2
{
    class Program
    {


        static void Main(string[] args)
        {
            string[] inpu = Console.ReadLine().Split(' ');
            int N = int.Parse(inpu[0]);
            int K = int.Parse(inpu[1]);
            List<int> tree = new List<int>();
            for (int i = 1; i <= N; i++)
            {
                tree.Add(int.Parse(Console.ReadLine()));
            }
            int cou = 1;
            tree.Sort((a, b) => a - b);
            int gmin = tree.Max();
            for (int i = 0; i < tree.Count - K + 1; i++)
            {
                int addd = tree[i + K -1] - tree[i];
                if(gmin > addd)
                {
                    gmin = addd;
                }
            }

            Console.WriteLine(gmin);

        }
    }
}


Measured memory_bytes: 17452
abcde =[ int(input()) for _ in range(5)]
output = 0
min_keta = 100
for val in abcde:
    if val%10 != 0:
        min_keta = min(val%10,min_keta)
        val = (val//10 +1)*10
    output += val
if min_keta != 100:
    print(output -10 + min_keta)
else:
    print(output)


Measured memory_bytes: 2940
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int main(){
    int n; cin >> n;
    vector<Pll> da(n);
    rip(i,n,0) cin >> da[i].first >> da[i].second;
    bool ju = true;
    rip(i,n,0){
        if(da[i].first != da[i].second){
            ju = false;
            break;
        }
    }
    if(ju){
        printf("0\n");
        return 0;
    }
    ll su = 0, mi = INT_MAX;
    rip(i,n,0){
        su += da[i].first;
        if(da[i].first > da[i].second){
            chmin(mi, da[i].second);
        }
    }
    cout << su - mi << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
	public static void main(String[] args) throws Exception{
		int[] g = {0, 1,3,1,2,1,2,1,1,2,1,2,1};
		String[] s = br.readLine().split(" ");
		int a = Integer.parseInt(s[0]), b = Integer.parseInt(s[1]);
		System.out.println(g[a] == g[b] ? "Yes" : "No");
		
	}
}

Measured memory_bytes: 23124