akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int k,n;
    cin>>k>>n;
    vector<int>a(n);

    rep(i,n)cin>>a[i];

    int maxlen = 0;

    rep(i,n - 1)maxlen = max(maxlen,abs(a[i] - a[i + 1]));
    maxlen = max(a[0] + k - a[n - 1],maxlen);
    
    cout<<k - maxlen <<endl;

    return 0;
}

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

using namespace std;

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

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

    sort(h.begin(), h.end());

    int h_min = 1000000000;
    for (int i = 0; i + k - 1 < n; i++) {
        if (h_min > h[i + k - 1] - h[i]) {
            h_min = h[i + k - 1] - h[i];
        }
    }

    cout << h_min << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int n;
    cin >> n;
    cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> sum(n,0);
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&&s[i]=='C'){
            sum[i]++;
        }
    }
    for(int i=1;i<n;i++){
        sum[i]+=sum[i-1];
    }
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--,r--;
        cout << sum[r]-sum[l] << endl;
    }
    
    return 0;
}

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

using namespace std;

int main()
{
  int N;
  int x;
  vector<int> a; //多めに

  cin >> N >> x;
  for (int id = 0; id < N; id++)
  {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }

  sort(a.begin(), a.end());

  int count = 0; 
  for (int id = 0; id < N; id++)
  {
    if (x - a[id] >= 0)
    {
      x -= a[id];
      count++;
    }
    else break;
    if (id == N - 1 && x > 0) count--;
  }

  std::cout << count << "\n";
  return 0;

}


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

#define NMAX 2000000
#define AMAX 10000

int main(){

  int i, n;
  int C[AMAX+1];
  int *A, *B;
  
  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for(i=0; i<= AMAX; i++) C[i] = 0;

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

  for(i=1; i<=AMAX; i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(i=1; i<=n; i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  for(i=1; i<=n; i++){
    printf("%d", B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 16276
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    for(int i = 0;i<1251;i++){
      int aa = (int)(i * 0.08);
      int bb = (int)(i * 0.1);
      if(aa == a && bb == b){
        System.out.println(i);
        return;
      }
    }
    System.out.println(-1);
  }
}


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

class Main {
    static class UnionFind {
	int [] data;
	UnionFind(int n) {
	    data = new int[n];
	    for(int i = 0; i < n; i++) data[i] = -1;
	}
	int root(int x) {
	    if(data[x] < 0) return x;
	    data[x] = root(data[x]);
	    return data[x];
	}
	boolean find(int x, int y) { 
	    return root(x) == root(y);
	}
	void union(int x,  int y) {
	    x = root(x); 
	    y = root(y);
	    if (x != y) {
		if (data[x] < data[y]) {
		    int t = x;
		    x = y;
		    y = t;
		}
		data[x] += data[y]; 
		data[y] = x;
	    }
	}
    }
    static int n;
    public static void main(String [] args) throws Exception {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	int m = sc.nextInt();
	int [][] es = new int[m][4];
	for(int i = 0; i < m; i++) {
	    es[i][1] = sc.nextInt() - 1; // from
	    es[i][2] = sc.nextInt() - 1; // to
	    es[i][0] = sc.nextInt(); // cost
	    es[i][3] = 0;
	}
	Arrays.sort(es, new Comparator<int[]>() {
		public int compare(int [] x1, int [] x2) {
		    for(int i = 0; i < 3; i++) {
			int d = x1[i] - x2[i];
			if(d != 0) return d;
		    }
		    return 0;
		}
		public boolean equals(Object o) { return true; }
	    });
	int mn = mst(es, -1);
	// System.out.println("mst = " + mn);
	int c = 0, k = 0;
	for(int i = 0; i < es.length; i++) {
	    if(es[i][3] == 1) {
		int mm = mst(es, i);
		if(mm != mn) {
		    c += es[i][0];
		    k++;
		}
	    }
	}
	System.out.println("" + k + " " + c);
    }
    static int mst(int [][] es, int skip) {
	UnionFind uf = new UnionFind(n);
	int c = 0;
	for(int i = 0; i < es.length; i++) {
	    if(i == skip) continue;
	    if(!uf.find(es[i][1], es[i][2])) {
		c += es[i][0];
		es[i][3] = 1;
	    }
	    uf.union(es[i][1], es[i][2]);
	}
	return c;
    }
}



Measured memory_bytes: 82820
s = input()

a = list('abcdefghijklmnopqrstuvwxyz')

if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) < 26:
    for x in a:
        if s.count(x) == 0:
            print(s + x)
            break
else:
    end = False
    for i in range(25)[::-1]:
        if end:
            break
        for j in range(i+1,26)[::-1]:
            if s[i] < s[j]:
                print(s[:i]+s[j])
                end = True
                break

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int N,L[20],Max,Sum=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&L[i]);
        Sum+=L[i];
    }
    Max=L[0];
    for(int j=0;j<N;j++){
        if(Max<L[j]) Max=L[j];
    }
    if(Max<Sum-Max){
        printf("Yes\n");
    }else printf("No\n");
    return 0;
}



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

void sort(vector<pair<int, int> >& v) {
    int n = v.size();
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < n - 1 - i; j++){
            if ((v[j].first > v[j + 1].first) || (v[j].first == v[j + 1].first && v[j].second > v[j + 1].second)) {
                pair<int, int> temp = v[j];
                v[j] = v[j + 1];
                v[j + 1] = temp;
            }
        }
    }
}

int main() {
    while (true) {
        int m;
        cin >> m;
        if (m == 0) {
            break;
        }
        vector<pair<int, int> > patterns(m);
        for (int i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            patterns[i] = make_pair(y, x);
        }
        sort(patterns);
        int n;
        cin >> n;
        vector<pair<int, int> > stars(n);
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            stars[i] = make_pair(y, x);
        }
        sort(stars);
        for (int i = 0; i < n - m; i++) {
            int dy = stars[i].first - patterns[0].first, dx = stars[i].second - patterns[0].second;
            for (int j = 1; j < m; j++) {
                int ny = patterns[j].first + dy, nx = patterns[j].second + dx;
                for (int k = i + j; k < n; k++) {
                    if (ny == stars[k].first && nx == stars[k].second) {
                        break;
                    }
                    if ((ny < stars[k].first) || (ny == stars[k].first && nx < stars[k].second) || k == n - 1) {
                        goto endMatch;
                    }
                }
            }
            cout << dx << " " << dy << endl;
            break;
        endMatch:;
        }
    }
}

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

int main(int argc, const char * argv[])
{
    int d;
    while (cin >> d) {
        int area = 0;
        int cnt = 0;
        for (int i = 1; i < (600/d); i++) {
            area += d* (d*i) * (d*i);
            cnt++;
        }
        cout << area << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(x%2==0&&x%3&&x%5)return puts("DENIED"),0;
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		//aとcが直接会話出来るか確認
		if (Math.abs(a - c) <= d) {
			System.out.println("Yes");
			return;
		}

		//aとcが間接的に会話できるか確認。
		if (Math.abs(a - b) <= d && Math.abs(c - b) <= d) {
			System.out.println("Yes");

		} else {
			System.out.println("No");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vt vector
#define pb push_back
#define pob pop_back
#define vi vt<int>
#define vvi vt<vi>
#define vii vt<ii>
#define vvii vt<vii>
typedef long long ll;
#define For(i,a,b) for(int i = a; i < b; i++)
#define foR(i,a,b) for(int i = a; i <= b; i++)
#define roF(i,a,b) for(int i = a - 1; i >= b; i--)
#define Rof(i,a,b) for(int i = a; i >= b; i--)

int C[300001];
int mod = 998244353;

int binpow(int a, int b){
	if(b == 0){
		return 1;
	}
	if(b == 1){
		return a;
	}
	int temp = binpow(a,b>>1);
	if(b&1){
		return temp*temp%mod*a%mod;
	}else{
		return temp*temp%mod;
	}
}

signed main (){
	/*
	freopen(".inp","r",stdin);
	freopen(".out","w",stdout);
	*/
	int n, a, b, k, t = 0;
	cin >> n >> a >> b >> k;
	int allsum = 0;
	C[0] = 1;
	foR(i,1,n){
		C[i] = C[i-1]*(n-i+1)%mod*binpow(i,mod-2)%mod;
//		cout << binpow(i,mod-2)%mod << " ";
//		cout << C[i] << "\n";
	}
	foR(i,0,n){
		if((k-t)%b == 0 && (k-t)/b <= n){
//			cout <<"find " << i << " " << (k-t)/b << "\n";
//			cout << C[i] << " " << C[(k-t)/b] << " " << C[i]*C[(k-t)/b]%998244353 << "\n";
			allsum = (allsum + C[i]*C[(k-t)/b])%mod;
		}
		t += a;
		if(t > k){
			break;
		}
	}
	cout << allsum;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

const ll mod=1000000007;
const ll inf=1000000000000; 

#define rep(i,m,n) for(ll i=m;i<n;i++)


ll n;
vll a;

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

  cin >> n;
  a.resize(n);
  rep(i,0,n) cin >> a[i];
  
  bool flag=false;
  rep(i,0,n-1) if(a[i+1]-a[i]>1) flag=true;
  if(a[0]==1) flag=true;
  if(flag){
   cout << -1 << endl;
   return 0;
  }
  
  
  ll res=0;
  rep(i,0,n-1) {
    if(a[i+1]-a[i]==1) res++; 
    else res+=a[i+1];
  }
  
  cout << res << endl;
 
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;


int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;++i){
        int x;
        cin>>x;
        if(x>k-x)ans+=2*(k-x);
        else ans+=2*x;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

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

int main(){
  int n, i, j;
  cin >> n;
  vector<int> A(n);
  rep(p, n) cin >> A[p];
  ll sum = 0, ans = 100000000000;
  for(i=-100; i<=100; i++){
    rep(j, n){
      sum += (A[j]-i)*(A[j]-i);
    }
    ans = min(ans, sum);
    sum = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
v = input().split(' ')
X = int(v[0])
Y = int(v[1])
Z = int(v[2])
i=0

if X<Y:
    print(i)

else:
    while(X>Y+Z):
        i+=1
        X-=Y
        X-=Z
    if X<Z:
        i -=1
    print(i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL LLONG_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF 99999999
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<string, pair<int, char> > ps;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};

int n, x;
vi vec;

lli gcd(lli a, lli b){
	while(1){
		if(a == 0) return b;
		b%=a;
		if(b == 0) return a;
		a %= b;
	}
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> x;
  vec.pb(x);
  for(int i=0;i<n;i++){
  	int a;
  	cin >> a;
  	vec.pb(a);
  }

  vi difs;
  for(int i=0;i<sz(vec)-1;i++) difs.pb(abs(vec[i] - vec[i+1]));
  lli atual = difs[0];
  for(int i=1;i<sz(difs);i++){
  	atual = gcd(atual, difs[i]);
  }

  cout << atual << endl;

	// int ini = x;  

	// int com = 0, fim = 1e9;
	// while(com < fim){
	// 	int mid = (com + fim) >> 1;
	// 	if(!mid) break;
	// 	int aux = solve(mid);
	// 	if(aux <= 1) com = mid+1;
	// 	else fim = mid;
	// }

	// cout << com << endl;

  return 0;
}

Measured memory_bytes: 2548
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int n;

    while( cin >> n ){
        int count =0;
        if( n == 0 ) { break; }
        for( int a=9; 0 <= a; a-- ){
            for( int b=9; 0<=b; b-- ){
                for( int c=9; 0<=c; c-- ){
                    for( int d=9; 0<=d; d-- ){
                        if( a+b+c+d==n ){
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1160
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: u64 = iter.next().unwrap().parse().unwrap();
    let x: u64 = iter.next().unwrap().parse().unwrap();

    let lrt: Vec<u64> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();

    let sum: u64 = lrt.iter().sum();
    let min = lrt.iter().min().unwrap();

    let ans = n + (x - sum) / min;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>

int main() {
  char ch;
  char ch1[1201], ch2[27];
  int A[26] = {};
  
  while( scanf("%c", &ch) != EOF) {
      int i = 0;
      ch1[i] = ch;
          for( int j = 0; j < 27; j++) {
            ch2[j] = j + 97;
            if(ch1[i] == ch2[j] || ch1[i] == ch2[j] - 32){
              A[j] += 1;
            }
          }
      ++i;
    }

  for( int i = 0; i < 26; i++) {
    ch2[i] = i + 97;
    printf("%c : %d\n",ch2[i], A[i]);
  }

  return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<iomanip>
using namespace std;
using ld = long double;

int main() {
  ld N, D; long M; cin >> N >> M >> D;
  cout<<setprecision(15)
    <<(D>0 ? 2 : 1)*(N-D)/N/N*(M-1)<<endl;
}

Measured memory_bytes: 3748
#include<iostream>

void InsertionSort(int N,int A[]){
  int v;
  int i,j;
  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
  }
}

int main()
{
  int N;
  int i,j;
  int A[100]={0};
  std::cin>>N;
  for(i=0; i<N; i++){
    std::cin>>A[i];
  }
  for(i=1; i<=N; i++){
    InsertionSort(i,A);
    for(j=0; j<N-1; j++){
      std::cout<<A[j]<<" ";
    }
    std::cout<<A[N-1];
    std::cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll tmp = min(b-1,n);
    cout << (a*tmp)/b - 5*(tmp/b) << endl;
    

}


Measured memory_bytes: 3636
import Control.Monad
import Data.Array.IO

type Image = IOUArray (Int, Int) Char

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  a <- concat <$> replicateM n getLine
  b <- concat <$> replicateM m getLine
  imageA <- newListArray ((1, 1), (n, n)) a :: IO Image
  imageB <- newListArray ((1, 1), (m, m)) b :: IO Image
  let index = [(i, j) | i <- [1..(n-m+1)], j <- [1..(n-m+1)]]
  ans <- mapM (match m imageA imageB) index
  if or ans then putStrLn "Yes"
            else putStrLn "No"

match :: Int -> Image -> Image -> (Int, Int) -> IO Bool
match m a b (i, j) = do
  let index = [(s, t) | s <- [i..(i+m-1)], t <- [j..(j+m-1)]]
  ans <- mapM (match' a b) $ zip index [(x, y) | x <- [1..m], y <- [1..m]]
  return $ and ans

match' :: Image -> Image -> ((Int, Int), (Int, Int)) -> IO Bool
match' a b (i, j) = do
  x <- readArray a i
  y <- readArray b j
  return $ x == y


Measured memory_bytes: 37244
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;

	int a[n];
	forr(i,n) cin >> a[i];
	sort(a,a+n);
	
	vector<int>l,r;
	int ans = 0;
	int cnt = 1;
	cnt = 2;
	ans += a[n-1];
	for(int i = n - 2; i >= 0; i--){
		if(cnt + 2 <= n) ans += 2 * a[i] ,cnt += 2;
		else if(cnt + 1 <= n) ans += a[i] , cnt++;
		else break;
	}
	cout << ans;
}

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

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;

    long long int mod = 1e9+7;
    vector<long long int> alpha(26, 1);

    for(int i = 0; i < S.size(); i++)
    {
        alpha[S[i] - 'a']++;
    }

    long long int cnt = 1;
    for(int i = 0; i < 26; i++)
    {
        cnt *= alpha[i];
        cnt %= mod;
    }

    long long int ans = (cnt - 1) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
fact = prime_factorize(N)

b = []
c = fact.copy()
q = 1
for p in fact:
    if p not in b:
        while c.count(p) >= q:
            for i in range (q):
                c.remove(p)
                #print(c)
            b.append(p ** q)
            #print(b)
            q += 1
    q = 1
    #print(p)
    #print(fact)

print(len(b))


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

long long N;
long long K;
long long a[100005];
long long prefixsum[100005];
long long pprefixsum[100005];
long long tempsum;
long long ans=0;
long long totalsum;

long long psum(long long left, long long right) //sum from left to right indexes//
{
    return prefixsum[right]-prefixsum[left-1];
}

long long ppsum(long long left, long long right)
{
    return pprefixsum[right]-pprefixsum[left-1];
}

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

    for (long long i=1; i<=N; i++)
    {
        cin>>a[i];
        totalsum=totalsum+a[i];
    }

    for (long long i=1; i<=N; i++)
    {
        prefixsum[i]=prefixsum[i-1]+a[i];
    }

    for (long long i=1; i<=N; i++)
    {
        pprefixsum[i]=pprefixsum[i-1];
        if (a[i]>0)
        {
            pprefixsum[i]=pprefixsum[i]+a[i];
        }
    }

    for (long long i=1; i<=N-K+1; i++)
    {
        tempsum=psum(i, i+K-1);

        if (tempsum>=0)
        {
            tempsum=tempsum+ppsum(1, i-1)+ppsum(i+K, N);
            ans=max(ans, tempsum);
        }

        else
        {
            ans=max(ans, ppsum(1, i-1)+ppsum(i+K, N));
        }
    }

    cout<<ans;
}

Measured memory_bytes: 5932
n = int(input())
h = list(map(int, input().split()))

answer = 'Yes'

pre = 0
for i in range(n):
    if pre <= h[i]-1:
        pre = h[i]-1
    elif pre <= h[i]:
        pre = h[i]
    else:
        answer = 'No'
        break

print(answer)




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

int main() {
char u;
cin>>u;
char a='A';
if(u=='A'){a='T';}
else if(u=='G'){a='C';}
else if(u=='C'){a='G';}
cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool ara[27];
int main()
{
    string str;
    while(cin>>str)
    {
        if(str.size()<26)
        {
            memset(ara, 0, sizeof ara);
            for(int i=0; i<str.size(); i++)
                ara[str[i]-97]= 1;
            for(int i=0; i<26; i++)
                if(!ara[i])
                {
                    str+= (97+i);
                    break;
                }
            cout<<str<<endl;
        }
        else
        {
            if(str=="zyxwvutsrqponmlkjihgfedcba")cout<<-1<<endl;
            else
            {
                int ind= -1;
                memset(ara, 1, sizeof ara);
                for(int i=25; i>=0; i--)
                {
                    int flag= -1;
                    for(int j=(str[i]-96); j<=25; j++)
                    {
                        if(!ara[j])
                        {
                            flag= j;
                            break;
                        }
                    }
                    if(flag!=-1)
                    {
                        ind= i;
                        str[i]= (flag+97);
                        break;
                    }
                    else ara[str[i]-97]= 0;
                }
                for(int i=0; i<=ind; i++)
                    cout<<str[i];
                cout<<endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string n;
    cin >> n;
    for (ll i = 0; i < n.size(); i++)
    {
        if (n[i] == '7')
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

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

#define N 10000
int isPrime(int ,int );
int main(){
  int kazu,i,j,cnt=0;
  int A[N];
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<kazu;i++){
   cnt+=isPrime(A[i],kazu);
  }
  printf("%d\n",cnt);
  return 0;
}

int isPrime(int A,int kazu){
  int i;
  double sqrt_A;
  sqrt_A=sqrt(A);
  if(A==1) return 0;
  if(A==2) return 1;
  if((A%2)==0) return 0;
  else{
    i=3;
    while(i<=sqrt_A){
      if(A%i==0){
	return 0;
      }
      i+=2;
    }
    return 1;
  }
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<array<ll, 2>> f(const vector<int>& a, int n) {
    vector<array<ll, 2>> b(n - 1);
    ll s0 = 0, s1 = 0;
    int i0 = 0, i1 = 0;
    for (; i1 < n;) {
        s1 += a[i1++];
        ll x = abs(s0 - (s1 - s0));
        while (i0 < i1) {
            s0 += a[i0++];
            ll t = abs(s0 - (s1 - s0));
            if (t > x) {
                s0 -= a[--i0];
                break;
            }
            x = t;
        }
        int i = i1 - 2;
        if (i >= 0) {
            b[i][0] = s0;
            b[i][1] = s1 - s0;
            if (b[i][0] > b[i][1]) swap(b[i][0], b[i][1]);
        }
    }
    return b;
}

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

    int n;
    cin >> n;

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

    auto b0 = f(a, n);
    reverse(a.begin(), a.end());
    auto b1 = f(a, n);

    ll r = 1LL << 60;
    for (int i = 0; i <= n - 4; i++) {
        int j = n - 4 - i;
        ll m0 = min(b0[i][0], b1[j][0]);
        ll m1 = max(b0[i][1], b1[j][1]);
        ll t = abs(m1 - m0);
        //cout << b0[i][1] - b0[i][0] << ' ' << b1[j][1] - b1[j][0] << ' ' << t << endl;
        r = min(r, t);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 7296
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n, ma, mb;
int a[50], b[50], c[50];
int dp[50][500][500];

int main(){
	cin >> n >> ma >> mb;
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];

	}
	FOR(i, 0, n) {
		rep(j, 401) {
			rep(k, 401) {
				dp[i][k][j] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	FOR(i, 1, n) {
		rep(j, 401) {
			rep(k, 401) {
				dp[i][j][k] = dp[i - 1][j][k];
				if (j >= a[i - 1] && k >= b[i - 1]) {
					dp[i][j][k] = min(dp[i - 1][j - a[i - 1]][k - b[i - 1]]+c[i-1], dp[i][j][k]);//
				}
			}
		}

	}
	int ans = INF;
	FOR(j, 1,40) {//
		FOR(k, 1,400) {
			if (j*mb == k*ma) {
				ans = min(ans, dp[n][j][k]);
			}
		}
	}
	if (ans == INF)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}


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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;

void dfs(const Graph& G, int v, int& cnt) {

    bool end = true;
    for (int i = 0; i < seen.size(); i++) {
        if (!seen[i] && i !=v ) {
            end = false;
        }
    }
    if (end) {
        cnt++;
        return;
    }


    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v, cnt); // 再帰的に探索
    }

    seen[v] = false;
    return;
}

int main()
{
    int N, M; cin >> N >> M;   // 頂点数と辺数

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    seen.assign(N, false);

    int ans = 0;
    dfs(G, 0, ans);

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

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,x = map(int, input().split())
a = list(map(int, input().split()))
def sub(p,q):
    if p+q<=x:
        ans = (0, (p,q))
    elif (p+q-x)<=q:
        ans = (p+q-x, (p, x-p))
    else:
        ans = (p+q-x, (x, 0))
    return ans
ans = 0
a1,a2 = a[:2]
num, (a1,a2) = sub(a1,a2)
ans += num
for i in range(n-2):
    a1,a2 = a2, a[i+2]
    num, (a1,a2) = sub(a1,a2)
    ans += num
print(ans)

Measured memory_bytes: 87684
import itertools

N=int(input())
P=tuple(list(map(int,input().split())))
Q=tuple(list(map(int,input().split())))

a=list(itertools.permutations(range(1,N+1)))

P_in = a.index(P)
Q_in = a.index(Q)

print(abs(P_in - Q_in))


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    vll b(n-1);
    rep(i, n-1) cin >> b[i];

    ll ans = b[0]+b[n-2];
    rep(i, n-2){
        ans += min(b[i], b[i+1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<ArrayList<Edge>> graph = new ArrayList<>();
		for (int i = 0; i < n + 1; i++) {
			graph.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			int src = sc.nextInt();
			int dest = sc.nextInt();
			int len = 1;
			graph.get(src).add(new Edge(dest, len));
			graph.get(dest).add(new Edge(src, len));
		}
		djikstra(graph, n);


	}
	public static void djikstra(ArrayList<ArrayList<Edge>> graph, int n) {
		int distance[] = new int[n + 1];
		Arrays.fill(distance, Integer.MAX_VALUE);
		distance[1] = 0;
		PriorityQueue<Edge> pq = new PriorityQueue<>(new Edge());
		pq.add(new Edge(1, 1));
		HashSet<Integer> set = new HashSet<>();
		HashMap<Integer, Integer> map = new HashMap<>();
		while (!pq.isEmpty()) {
			int minVertex = pq.poll().src;
			set.add(minVertex);
			for (int i = 0; i < graph.get(minVertex).size(); i++) {
				Edge curr = graph.get(minVertex).get(i);
				if (!set.contains(curr.src)) {
					int currdist = distance[minVertex] + curr.len;
					if (currdist < distance[curr.src]) {
						distance[curr.src] = currdist;
						pq.add(new Edge(curr.src, currdist));
						map.put(curr.src, minVertex);
					}
				}
			}

		}
		for (int i = 1; i <= n; i++) {
			if (distance[i] == Integer.MAX_VALUE) {
				System.out.println("No"); return;
			}
		}
		System.out.println("Yes");
		for (int i = 2; i <= n; i++) {
			System.out.println(map.get(i));
		}
	}
}

class Edge implements Comparator<Edge> {
	int src, len;
	public Edge()
	{}
	public Edge(int a, int b) {
		src = a;
		len = b;
	}
	public int compare(Edge e1, Edge e2) {
		if (e1.len > e2.len)
			return 1;
		return -1;
	}
}



class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 103760
import heapq
K=int(input())
dist=[10**15 for i in range(K)]
dist[1]=1
q=[]
heapq.heappush(q,(0,1))
while (len(q)!=0):
    prc,src=heapq.heappop(q)
    if dist[src]<prc:
        continue
    if dist[(src+1)%K]>dist[src]+1:
        dist[(src+1)%K]=dist[src]+1
        heapq.heappush(q,(dist[(src+1)%K],(src+1)%K))
    if dist[(10*src)%K]>dist[src]:
        dist[(10*src)%K]=dist[src]
        heapq.heappush(q,(dist[(src*10)%K],(src*10)%K))
print(dist[0])


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

using namespace std;

struct edge {
	int from, to;
	edge(int from, int to) : from(from), to(to) {}
};
using node = vector<edge>;
using graph = vector<node>;
void addedge(graph& g, int from, int to, bool bidirectional = false) {
	g[from].emplace_back(edge(from, to));
	if (bidirectional) g[to].emplace_back(edge(to, from));
}

class Solution {
public:
	graph g;
	vector<int> c;
	vector<long long> ans;
	vector<int> cnt;
	long long f(int k) { return ((long long)k * (k + 1LL)) / 2; }
	int dfs(int u = 0, int p = -1) {
		int ret = 0;
		for (auto e : g[u]) {
			if (e.to == p) continue;
			int p = cnt[0] - cnt[c[u]];
			ret += dfs(e.to, u);
			int q = cnt[0] - cnt[c[u]];
			ans[c[u]] += f(q - p);
			cnt[c[u]] += q - p;
		}
		cnt[0]++;
		cnt[c[u]]++;
		return ret + 1;
	}
	void solve() {
		long long n;
		cin >> n;
		c = vector<int>(n, 0);
		ans = vector<long long>(n + 1, 0ll);
		cnt = vector<int>(n + 1, 0);
		for (int i = 0; i < n; i++) cin >> c[i];
		for (int i = 0; i < n; i++) c[i];
		g = graph(n);
		for (int i = 0; i < n - 1; i++) {
			int u, v;
			cin >> u >> v;
			addedge(g, u - 1, v - 1, true);
		}
		auto tmp = dfs();
		for (int i = 1; i <= n; i++) {
			ans[i] += f(cnt[0] - cnt[i]);
			cout << f(n) - ans[i] << "\n";
		}
		cout << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 33040
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    i64 sum = 0;
    i64 longest = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum += a[i];
        longest = std::max(longest, a[i]);
    }

    if (sum - longest > longest) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

int gcd(int x, int y) {
  return (x % y) ? gcd(y, x % y) : y;
}

signed main() {
  int N;
  cin >> N;
  int a = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        int b = gcd(i, j);
        b = gcd(b, k);
        a += b;
      }
    }
  }
  cout << a << endl;
}


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

int num_to_color(int n) {
    if (n >= 1 && n <= 399) {
        return 1;
    }
    else if (n >= 400 && n <= 799) {
        return 2;
    }
    else if (n >= 800 && n <= 1199) {
        return 3;
    }
    else if (n >= 1200 && n <= 1599) {
        return 4;
    }
    else if (n >= 1600 && n <= 1999) {
        return 5;
    }
    else if (n >= 2000 && n <= 2399) {
        return 6;
    }
    else if (n >= 2400 && n <= 2799) {
        return 7;
    }
    else if (n >= 2800 && n <= 3199) {
        return 8;
    }
    else {
        return -1;
    }
}

std::map<int, int> m;

std::vector<int> vec;
int n;
int rainbow = 0;
int max_color;
int main() {
    std::cin >> n;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    
    for (int i = 0; i < n; i++) {
        int x = num_to_color(vec[i]);
        if (x == -1) {
            rainbow++;
        }
        else {
            m[x]++;
        }
    }
    int min_color = 0;
    for (int k = 1; k <= 8; k++) {
        if (m[k] > 0) {
            min_color++;
        }
    }
    if (min_color == 0) {
        min_color = 1;
        max_color = rainbow;
    }
    else {
        max_color = min_color + rainbow;
    }
    std::cout << min_color << " " << max_color << std::endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {
	


	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		System.out.println(n <= m ? "Yes" : "No");
			




		
		
		
		
		

		


		
		
	}
	


}

 

Measured memory_bytes: 22996
package main

import (
	"fmt"
)

const intMax = 2147483647

func main() {
	var h, a int
	_, _ = fmt.Scan(&h)
	_, _ = fmt.Scan(&a)
	res := 0
	for {
		res++
		h -= a
		if h <= 0 {
			break
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, y, f, m;
    bool b1 = true;
    bool b2 = false;
    bool b3 = false;
    string s;
  	cin>>s;
    f = 0;
    m = 0;
    for (int i = 0; i< s.length(); i++){
        if (s[i] == 'A'){
            f = i;
            break;
        }
    }
    for (int i = f; i< s.length(); i++){
        if (s[i] == 'Z'){
            m = i;
            
        }
    }
    cout << m - f +1;
    
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define Max 1000000
using namespace std ;
const int N = 1e5 + 5 ;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void ReadInputOutput()
{
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
//ostringstream str ;
//str << n ;
//string s = str.str() ;
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}
unsigned long long Factorial(int n)
{
    const unsigned int M = 1000000007;
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;

    return f;
}
ll GCD(ll a, ll b)
{
    return b ? GCD(b, a % b) : a;
}
ll LCM(ll a, ll b)
{
    return a / GCD(a, b) * b;
}
vector< int > getDivisors(int n)
{
    vector< int > ret;
    for(int i = 1; i <= sqrt( n ); ++i)
    {
        if(n % i == 0)
        {
            ret.push_back(i);
            if(n / i != i)
                ret.push_back(n / i);
        }
    }
    return ret;
}
int sumDigits(int n)
{
    int sum = 0 ;
    while(n)
    {
        ll d = n % 10 ;
        sum += d ;
        n /= 10 ;
    }
    return sum ;
}
bool primes[ Max ] ;
int digitPrimes[ Max ] ;
void sieve()
{
    memset(primes, 1, Max);
    primes[ 0 ] = 0 ;
    primes[ 1 ] = 0 ;
    int cnt = 0;
    for (int i = 2; i <= (int)sqrt(Max) + 1; i++){
        if(primes[ i ])
            for (int j = i * i ; j <= Max ; j += i)
                primes[j] = false;
    }
    for (int i = 0; i <= Max ; ++i){
        if(primes[ i ] && primes[ sumDigits( i )])
            ++cnt ;
        digitPrimes[ i ] = cnt ;
    }
}
bool isPrime(ll n)
{
    for(ll i = 2 ; i * 1LL * i <= n ; ++i)
        if(n % i == 0)
            return 0;
    return n > 1;
}
int main()
{
   FastInputOutput();
   string one , two , three ;
   cin >> one >> two >> three ;
   cout << one[ 0 ] << two[ 1 ] << three[ 2 ] << endl ;


    return 0 ;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
A = list(map(int, input().split()))
D = deque()
for i in range(n):
    if i % 2 == 0:
        D.append(A[i])
    else:
        D.appendleft(A[i])
if i % 2 == 0:
    D.reverse()
print(*D)


Measured memory_bytes: 25416
import java.util.*;
import java.math.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n      = sc.nextInt();
        long dp[][]  = new long[n+100][3];
        long h[][]   = new long[n+100][3];
        
        for (int i = 0; i < n; i++) {
            for (int b = 0; b < 3; b++) {
                h[i][b] = sc.nextInt();
            }
        }
        
        
        for (int i = 0; i < n; i++) {
            for (int s = 0; s < 3; s++) {
                for (int x = 0; x < 3; x++) {
                    if (s == x) continue;
                    dp[i+1][x] = Math.max(dp[i+1][x], h[i][x] + dp[i][s]);
                }
            }
        }
        
        long ans = 0;
        for (long aa : dp[n]) {
            if (ans < aa) ans = aa;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 102748
abclist=list(map(int,input().split()))
abclist.sort()
A,B,C=abclist
#print(A,B,C)

answer=0
while(A!=B or B!=C):
  if C-B>=2:
    B+=2
  elif B-A>=2:
    A+=2
  elif C-B==1 and B-A==1:
    B+=1
    C+=1
  elif C-B==0 and B-A==1:
    B+=1
    C+=1
  elif C-B==1 and B-A==0:
    A+=1
    B+=1
  answer+=1

#print(A,B,C)
print(answer)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(long long int*)a > * (long long int*)b)return 1;
	if (*(long long int*)a < *(long long int*)b)return -1;
	return 0;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i;
	long long int a[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	qsort(a, n, sizeof(long long int), asc);
	long long int amin, amid, amax;
	amin = -1000000000000000018;
	amax = -1 * amin;
	long long int min, mid, max;
	long long int count;
	while (amax - amin > 1)
	{
		amid = (amax + amin) / 2;
		count = 0;
		for (i = 0; i < n; i++)
		{
			min = -1;
			max = n;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (a[i] >= 0)
				{
					if (a[mid] * a[i] <= amid)
						min = mid;
					else
						max = mid;
				}
				else
				{
					if (a[mid] * a[i] <= amid)
						max = mid;
					else
						min = mid;
				}
			}
			if (a[i] >= 0)
				count += max;
			else
				count += n - max;
			if (a[i] * a[i] <= amid)
				count--;
		}
		count /= 2;
		if (count < k)
			amin = amid;
		else
			amax = amid;
	}
	printf("%lld\n", amax);
	return 0;
}

Measured memory_bytes: 3324
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {
    vector<string> arr;
    map<string, bool> m;
    string s;
    int k;
    cin >> s >> k;
    string tmp;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= min(k, (int)s.size()-i); j++){
            tmp = s.substr(i, j);
            if(m[tmp] != true){
                m[tmp] = true;
                arr.push_back(tmp);
            }
        }
    }
    sort(arr.begin(), arr.end());
    cout << arr[k-1] << endl;
    return 0;
}


Measured memory_bytes: 2048