akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, M, tmp, sum;
  cin >> N >> M;
  vector<ll> v;
  sum = 0;
  rep(i,N){
    cin >> tmp;
    sum += tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end(), greater<ll>());
  
  if(v[M-1]*4*M>=sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector < int > v(n);
	vector < int > u(n);
	for (int i = 0; i < n; i++)
		cin>>v[i];
	for (int i = 0; i < n; i++)
		cin>>u[i];
	
	for (int i = 0; i < n; i++) {
		if (u[i] == v[i]) continue;
		if (v[i] < u[i]) break;
		for (int j = 0; j < n; j++)	
			swap(v[j], u[j]);
		break;
	}
	
	int cnt = 0;
	while (true) {
		bool f = true;
		for (int i = 0; i < n && f; i++)
			if (u[i] != v[i]) f = false;
		if (f) break;
		cnt++;
		std::next_permutation(v.begin(), v.end());
	}
	cout<<cnt;
}


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

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            var ks = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = ks[0];
            var Y = ks[1];
            
            for(int i =0;i <= N; i++)
            {
                for(int j = 0; j <= N-i; j++)
                {
                    if(i*10000 + j*5000 + (N-i-j)*1000 == Y)
                    {
                        Console.WriteLine($"{i} {j} {N-i-j}");
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
        

    }
    

    

}


Measured memory_bytes: 13140
/** Author: Nicklaus **/
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
#define PI 3.14159265358979324

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min((b/a),c)<<endl;
	return 0;
}

Measured memory_bytes: 256
fun <T> permutationIndexOf(sortedList: List<T>, predicate: (List<T>, Int) -> Boolean): Pair<List<T>, Int> {
    val queue = mutableListOf<List<T>>()
    queue.add(arrayListOf<T>())
    var index = 0
    while (queue.isNotEmpty()) {
        val p = queue.removeAt(0)

        if (p.size == sortedList.size) {
            index++

            if (predicate(p, index)) {
                return Pair(p, index)
            }

            continue
        }

        for (item in (sortedList - p)) {
            queue.add(p + item)
        }
    }

    return Pair(emptyList(), -1)
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    val (a, pc) = permutationIndexOf((1..n).toList()) { pp, c -> p.joinToString("") == pp.joinToString("") }
    val (b, qc) = permutationIndexOf((1..n).toList()) { qp, d -> q.joinToString("") == qp.joinToString("") }
    Math.abs(pc - qc).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 85952
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n, d;

int dis(int *p, int *q) {
    int ret = 0;
    for (int i = 0; i < d; i++) {
        ret += (p[i] - q[i]) * (p[i] - q[i]);
    }
    return ret;
}

bool is_square_num(int num) {
    for (int i = 1; i <= 127; i++) {
        if (i * i == num) {
            return true;
        }
        if (num < i * i) {
            return false;
        }
    }
    return false;
}

int main() {
    cin >> n >> d;
    int points[n][d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> points[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int distance = dis(points[i], points[j]);
            if (is_square_num(distance)) {
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int N, A;
	cin >> N >> A ;
	if (N % 500 <= A)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn solve(target: i32, seq: &Vec<i32>) -> bool {
    if target.abs() > 8000 { return false; }
    let mut dp = vec![false; 10000];
    dp[0] = true;
    for v in seq {
        let v = *v;
        if v == 0 { continue; }
        let mut ndp = vec![false; 10000];
        for i in 0..8001 {
            if !dp[i] { continue; }
            if i as i32 + v <= 8000 { ndp[i + v as usize] = true; }
            ndp[(i as i32 - v).abs() as usize] = true;
        }
        dp = ndp;
    }
    dp[target.abs() as usize]
}

fn main() {
    let s: String = read();
    let mut s = s.chars().collect::<Vec<char>>();
    s.push('T');
    let mut x: i32 = read();
    let y: i32 = read();
    let mut seq = vec![vec![]; 2];
    {
        let mut dir = 0;
        let mut cnt = 0;
        for c in s {
            if c == 'F' {
                cnt += 1;
            } else {
                seq[dir].push(cnt);
                cnt = 0;
                dir ^= 1;
            }
        }
    }
    if !seq[0].is_empty() {
        x -= seq[0][0];
        seq[0].remove(0);
    }
    println!("{}", if solve(x, &seq[0]) && solve(y, &seq[1]) { "Yes" } else { "No" });
}

Measured memory_bytes: 4476
#include <iostream>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <set>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int64_t> a;
	for (int i = 0; i < n; ++i) {
		int64_t ai;
		cin >> ai;
		a.push_back(ai);
	}
	set<int64_t> divs;
	for (int64_t i = 1; i <= (int64_t)sqrt(a[0]+1.0); ++i) {
		if (a[0] % i == 0) {
			divs.insert(i);
			divs.insert(a[0]/i);
		}
	}
	for (int64_t i = 1; i <= (int64_t)sqrt(a[1] + 1.0); ++i) {
		if (a[1] % i == 0) {
			divs.insert(i);
			divs.insert(a[1] / i);
		}
	}
	vector<int64_t> candidate;
	for (auto ite = divs.begin(); ite != divs.end(); ite++) {
		int64_t val = (*ite);
		int notdiv = 0;
		for (unsigned int i = 0; i < a.size(); ++i) {
			if (a[i] % val != 0) {
				notdiv++;
			}
			if (notdiv >= 2) {
				break;
			}
		}
		if (notdiv < 2) {
			candidate.push_back(val);
		}
	}
	sort(candidate.begin(), candidate.end());
	cout << candidate[candidate.size()-1] << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin >> a >> b;
  int an = a[0] -'0';
  int bn = b[0] -'0';
  string sa,sb;
  rep(i,an) sa+=b[0];
  rep(i,bn) sb+=a[0];
  if(sa < sb) cout << sa << endl;
  else cout << sb << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
//Write a program which calculates the cube of a given integer x.
extern "C"
{
#include <stdio.h>

#define CUBIC   (3)

int calc(const int x, const int num);

int main(void)
{
    int x;
    int ans = 0;
    scanf("%d", &x);

    ans = calc(x, CUBIC);

    printf("%d\n", ans);

    return (0);
}

//Calc a cubic of x.
int calc(const int x, const int num)
{
    if (1 > num) {
        return 1;
    }

    return x * calc(x, (num - 1));
}
}

Measured memory_bytes: 2684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#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()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    REP(i,n) ans *= 3;
    ll tmp = 1;
    REP(i,n){
        int x;
        cin >> x;
        if (x % 2 == 0){
            tmp *= 2;
        }
    }
    cout << ans - tmp << endl;

    return 0;
}


Measured memory_bytes: 256
// 23/01/20 // 10:51 PM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(1e3) + 10;
const int INF  = 0x3f3f3f3f;
const int MOD  = (int)(1e9) + 7;

int h, w;
char grid[MAXN][MAXN];
int memo[MAXN][MAXN];

int solve(){

    memo[h][w]=1;

    for(int i=h; i>=1; i--){
        for(int j=w; j>=1; j--){
            if(grid[i][j]=='#' || (i==h && j==w)) continue;

            memo[i][j] = (memo[i+1][j] + memo[i][j+1])%MOD;
        }
    }


    return memo[1][1];
}

int main(){

    cin >> h >> w;

    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++)
            cin >> grid[i][j];

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

vvector<int> edges;
vector<int> found_time;
vector<int> finish_time;

int dfs(int place, int time){
	++time;
	found_time[place] = time;
	foreach(i, edges[place]){
		if(found_time[i]>=0)continue;
		time = dfs(i, time);
	}
	++time;
	finish_time[place] = time;
	return time;
}

int main(){
	int n;
	cin >> n;
	edges.resize(n);
	found_time.resize(n, -1);
	finish_time.resize(n, -1);
	rep(i, n){
		int t;
		int time;
		cin >> t >> time;
		--t;
		rep(j, time){
			int to;
			cin >> to;
			--to;
			edges[t].push_back(to);
		}
	}
	int time = 0;
	rep(i, n){
		if(found_time[i]<0)time = dfs(i, time);
	}
	rep(i, n){
		output(i+1);
		output(found_time[i]);
		output(finish_time[i]);
		outendl();
	}
	return 0;
}



Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int VV,SS,ans,N,V[50],S[50];
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> V[i];
        VV += V[i];
    }
    for (int i=0;i<N;i++){
        cin >> S[i];
        SS += S[i];
    }
    for (int g=0;g<N;g++){
        for (int i=0;i<N;i++){
            if (VV - SS < (VV - V[i]) - (SS - S[i])){
                VV -= V[i];
                SS -= S[i];
                V[i] = 0;
                S[i] = 0;
            }
        }
    }
    ans = VV - SS;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	rep(i,10){
		rep(j,10){
			if(i*j==n) return cout<<"Yes"<<endl, 0;
		}
	}
	cout << "No" << endl;
  return 0;
}


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

struct Node {
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};
struct Node *root;
struct Node *NIL;

struct Node *find(struct Node *u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

void insert(int k){
  //printf("insert ok!\n");
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}
  
int main(){
  int n, i, x;
  char com[10];
  struct Node *t;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

    

  



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

int main()
{
    set<int> s;
    int q;
    cin >> q;
    while (q--)
    {
        int x, y;
        cin >> x >> y;
        if (x == 0)
        {
            s.insert(y);
            cout << s.size() << endl;
        }
        if (x == 1)
        {
            cout << s.count(y) << endl;
        }
        if (x == 2)
        {
            s.erase(y);
        }
    }
    return 0;
}


Measured memory_bytes: 12348
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n,m;cin >> n >> m;
	bool verdict[n];
	map<int,int> ma;
	memset(verdict, 0,sizeof verdict);
	forn(i, m){
		int q;string ver;cin >> q >> ver;
		if(verdict[q - 1]){}
		else {
			if(ver[0] == 'A'){verdict[q - 1] = 1;}
			else ma[q - 1]++;
		}
	}
	int crct = 0, wrng = 0;
	forn(i, n){ 
		if(verdict[i])crct++,wrng += ma[i];
	}
	cout << crct << " " << wrng;
	return 0;
}


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

int main(){
    string a = "abcdefghijklmnopqrstuvwxyz";
    map<char,int> cnt;
    for(int i = 0; i < a.size(); i++){
        cnt[a[i]] = 0;
    }
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        cnt[s[i]]++;
    }
    for(int i = 0; i < a.size(); i++){
        if(cnt[a[i]] == 0){
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, h, w; cin >> n >> h >> w;

    int a = n - h;
    int b = n - w;
    if(a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }
    a++;
    b++;
    cout << a * b << endl;

     return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n,m;
  cin>>n>>m;
  if(n==m){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include <iostream> 
#include <algorithm>
#include <cmath>
#include <vector>  
#define ll long long

using namespace std;

pair<ll, ll> count_reduce(int x, ll n) {
    ll count = 0;
    if (n == 1) {
        return make_pair(0, x);
    }
    pair<ll, ll> result = count_reduce(x, n/2);
    ll num = result.first; ll left = result.second;
    count += 2 * num;
    if (left >= 5){
        count += 2;
        left = (2 * left - 9) ;
    }
    else {
        count += 1;
        left = 2 * left;
    }

    if (n & 1 == 1)
    {
        if(left + x > 9) {
            count += 2;
            left = (left + x) - 9;
        } else {
            left = left + x;
            count += 1;
        }
    }
        
    return make_pair(count, left);
}

int main() {
    int M;
    cin >> M;
    ll D[M], C[M];
    ll out[M];
    for (int i = 0; i < M; i++) {
        ll d,c;
        cin >> d >> c;
        D[i] = d;C[i] = c; 
    } 

    ll count = 0;
    for (int i = 0; i < M; i++) {
        pair<ll, ll> result = count_reduce(D[i],C[i]);
        count += result.first;
        out[i] = result.second;
    }

    ll lh = out[0];
    for (int i = 1; i < M; i++) {
        ll rh = out[i];
        if ((lh + rh) > 9) {
            count += 2;
            lh = (lh + rh - 9);
        }
        else{
            lh = lh + rh;
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

class BIT//1-index
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {//1~iまでの和
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {//bit[i]にxを足す更新
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};


int main(){
	int n,k;
	cin>>n>>k;
	vector<LL> a(n);
	vector<LL> b(n+1,0);
	map<LL,LL> mp;
	LL ans=0;
	FOR(i,0,n){
		cin>>a[i];
		a[i]-=k;
		b[i+1]=a[i];
		b[i+1]+=b[i];
		mp[b[i+1]]++;
		if(b[i+1]>=0)ans++;
		//cerr<<" "<<b[i+1]<<endl;
	}
	int idx=1;
	for(auto &x:mp){
		x.ND=++idx;
	}
	int last=n+10;
	BIT bit(last+1);
	cerr<<"test:"<<ans<<endl;
	FOR(i,0,n){
		ans+=bit.sum(mp[b[i+1]]);
		bit.add(mp[b[i+1]],1);
		//cerr<<i<<" "<<ans<<endl;
	}

	cout<<ans<<endl;

    return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 n;
  cin >> n;
  vector<u32> a(n);

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

  u64 ans = 0;
  for (u64 idx = 1; idx < n; idx++) {
    if (a[idx] < a[idx - 1]) {
      ans += (a[idx - 1] - a[idx]);
      a[idx] = a[idx - 1];
    }
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 700;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o')
      ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  int n = cin.nextInt();
    int[] score = new int[n];
	  for (int i = 0; i < n * (n - 1) / 2; i++)
	  {
	    int a = cin.nextInt() - 1, b = cin.nextInt() - 1, c = cin.nextInt(), d = cin.nextInt();
	    if (c > d)
	    {
	      score[a] += 3;
	    }
      else if (c < d)
      {
        score[b] += 3;
      }
      else
      {
        ++score[a];
        ++score[b];
      }
	  }
    for (int i = 0; i < n; i++)
    {
      int res = 1;
      for (int j = 0; j < n; j++)
      {
        if (score[i] < score[j])
        {
          ++res;
        }
      }
      Console.WriteLine(res);
    }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

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

#define PI acos(-1)

int main() {
  int A, B, H, W;
  cin >> A >> B >> H >> W;

  double short_deg = (H * (360.0 / 12.0)) + (W * (360.0 / 12.0 / 60.0));
  double long_deg = (W * (360.0 / 60.0));

  double deg = min(abs(short_deg- long_deg), 360.0 - abs(short_deg- long_deg));

  cout << setprecision(20) << sqrt((A * A) + (B * B) - (2 * A * B * cos((deg / 180) * PI))) << endl;
  return 0;
}


Measured memory_bytes: 4252
///*.......................Shadman Sakib Utshob............................*///

#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 Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define seecontent(v) cout << (#v) << " is "; for(auto x : v) { cout << x << " ";} cout << "\n\n";
#define inf             1e10
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;
#define maxn 300005

int dx[]= {-1,0,1,0}; //up,right,down,left
int dy[]= {0,1,0,-1};

int main()
{
    Boost;
    ll x=1,a,b,c,d,y,z=0,w,i,j,k,l,p,q,m,n,*ans;
    int ar[10];
    cin>>a>>b>>c>>d;
    ar[1]=a;
    ar[2]=b;
    ar[3]=c;
    ar[4]=d;
    x=max(a,b);
    y=min(a,b);
    z=max(c,d);
    w=min(c,d);
    //i=x*y;
    j=x*z;
    k=x*w;
    l=y*z;
    p=y*w;
    //q=z*w;
    vector<ll>v;
    //v.pb(i);
    v.pb(j);
    v.pb(k);
    v.pb(l);
    v.pb(p);
    //v.pb(q);

    //seecontent(v)
    sort(all(v));
    cout<<v[v.size()-1]<<endl;





    return 0;

}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int h,w,grid[102][102],vis[102][102];
int dx1[6]={0,1,-1,1,0,1};
int dx2[6]={-1,0,-1,1,-1,0};
int dy[6]={-1,-1,0,0,1,1};

int rec(int x,int y){
  vis[y][x]=1;
  int res=0;

  for(int i=0;i<6;i++){
    int nx=x+(y%2?dx1[i]:dx2[i]),ny=y+dy[i];
    if(nx<0 || ny<0 || w+1<nx || h+1<ny)continue;
    if(grid[ny][nx])res++;
    if(!vis[ny][nx])res+=rec(nx,ny);
  }

  return res;
}

int main(void){

  cin >> w >> h;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> grid[i][j];
      vis[i][j]=grid[i][j];
    }
  }
  cout << rec(0,0) << endl;

  return 0;
}

Measured memory_bytes: 1556
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

ll N;
ll K;
vl p;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> K;
    p = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> p[i];
    }
    solve();
}

// 1 <= K <= N <= 1000
// 1 <= p_i <= 1000
// 入力中の値はすべて整数である。

// ll N, ll K, vl p
// 果物の最小の合計価格を表す整数を出力せよ。
void solve(){
    sort(all(p));
    ll sum=0;
    rep(i,K){
        sum+=p[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

map<int, int64_t> dp[310][310];
int main() {
	dp[0][0][0] = 0;
	int N, K; cin >> N >> K;
	int64_t h[N]; rep(i,N) cin >> h[i];
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j <= K; ++j) {
			for(auto &e : dp[i][j]) {
				int64_t k = e.first;
				// cerr << k << endl;
				// yaranai
				if(dp[i + 1][j].count(h[i])) {
					dp[i + 1][j][h[i]] = min(dp[i + 1][j][h[i]], dp[i][j][k] + max<int64_t>(0, h[i] - k));
				} else {
					dp[i + 1][j][h[i]] = dp[i][j][k] + max<int64_t>(0, h[i] - k);
				}
				// cerr << i + 1 << " " << j << " " << h[i] << " " << dp[i + 1][j][h[i]] << endl;
				// yaru
				if(dp[i + 1][j].count(k)) {
					dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k], dp[i][j][k]);
				} else {
					dp[i + 1][j + 1][k] = dp[i][j][k];
				}
				// cerr << i + 1 << " " << j + 1 << " " << k << " " << dp[i + 1][j + 1][k] << endl;
			}
		}
	}
	int64_t ans = LINF;
	for(int i = 0; i <= K; ++i) {
		for(auto e : dp[N][i]) {
				ans = min(ans, e.second);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 288896
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int N;
ll X;
ll len[51];
ll p[51];

ll P(int L, ll X) {
  if (L == 1) {
    if (X <= 4)
      return X - 1;
    else
      return 3;
  }
  if (X == 1) return 0;

  if (X <= len[L - 1] + 1) {
    return P(L - 1, X - 1);
  } else if (X > len[L - 1] + 2) {
    return P(L - 1, X - (len[L - 1] + 2)) + 1 + p[L - 1];
  } else if (X == len[L - 1] + 2) {
    return P(L - 1, X - 2) + 1;
  } else {
    // if (X == len[L])
    return len[L - 1] * 2 + 1;
  }
  return 0;
}

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

  len[0] = 1, len[1] = 5;
  p[0] = 1, p[1] = 3;
  for (int i = 1; i <= 50; i++) {
    len[i] = len[i - 1] * 2 + 3;
    p[i] = 2 * p[i - 1] + 1;
  }

  cout << P(N, X) << endl;
  return 0;
}


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

int main() {

    int a, b,t;

    scanf("%d %d %d", &a, &b,&t);
    
    printf("%d",(t/a)*b);
    

    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
using namespace std;
 
//int mod=(int)(1e9+7);
 
void solve()
{   
	int n,k;
	cin>>n>>k;
	int array[n];
	for(int i=0; i<n; i++)
		cin>>array[i];
	sort(array, array+n);
	int ret=0;
	for(int i=0; i<k; i++)
		ret += array[i];
	cout<<ret<<endl;
}
 
signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
  // int t;cin>>t;
  // for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;
 
return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='1')s[i]='9';
    else s[i]='1';
  }
  cout << s << endl;
  return 0;
}


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

int arr[3][3];

int main()
{
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
         {
             cin >> arr[i][j];
         }   
    }
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    vector<int> vr;
    vector<int> vc;
    for(int k = 0; k < n; k++)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (arr[i][j] == a[k])
                {
                    arr[i][j] = -1;
                    break;
                }
            }
        }
    }
    if(arr[0][0] == -1 && arr[1][1]  == -1 && arr[2][2] == -1)
    {
        cout << "Yes";
        return 0;
    }   
    if(arr[0][2] == -1 && arr[1][1] == -1 && arr[2][0] == -1)
    {
        cout << "Yes";
        return 0;
    }
    for(int i = 0; i < 3; i++)
    {
        if(arr[i][0] == -1 && arr[i][1] == -1 && arr[i][2] == -1)
        {
            cout<<"Yes";
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if (arr[0][i] == -1 && arr[1][i] == -1 && arr[2][i] == -1)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}  

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		if(a % 2 == 0) {
			int ans = a / 2;
			ans = ans - 1;
			System.out.println(ans);
		}else {
			int ans = a / 2;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 35640
#include <stdio.h>

int main(void){
	int n;
	int f[45];
	int i;

	scanf("%d", &n);
	for (i = 0; i <= n; i++){
		if (i <= 1)
			f[i] = 1;
		else if (i > 1)
			f[i] = f[i - 1] + f[i - 2];
	}

	printf("%d\n", f[n]);

	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>
#include <utility>

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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
    int N;
    cin >> N;
    long X[1000000];
    long L[1000000];
    for (int i = 0; i < N; i++)
    {
        //scanf("%d%d", X+i, L+i);
        cin >> X[i] >> L[i];
    }

    pair<long, long> robots[1000000];
    for (int i = 0; i < N; i++)
    {
        robots[i] =(make_pair(X[i] + L[i], X[i] - L[i]));
    }

    int ans = 0;
    sort(robots, robots + N);
    long current = -10000000000;
    for (int i = 0; i < N; i++)
    {
        if (current <= robots[i].second)
        {
            ans++;
            current = robots[i].first;
        }
    }
    // 結果表示
    cout << ans << endl;
}

Measured memory_bytes: 23296
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
    int n,sum;
    double x,ave;
    while(1){
        cin >> n;
        int a[n];
        for(int i = 0;i < n;i++) a[i] = 0;
        sum = 0;
        ave = 0;
        x = 0;
        if(n == 0) break;
        for(int i = 0;i < n;i++){
            cin >> a[i];
            sum += a[i];
        }
        ave = 1.0 * sum /n;
        for(int i = 0;i < n;i++){
            x += pow(a[i]-ave,2)/n;
        }
        cout << fixed << setprecision(8);
        cout << sqrt(x) << endl;
    }


    return 0;
}


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


using namespace std;

int gcd3(int a, int b, int c){
    int d;
    d = gcd(a,b);
    return(gcd(d,c));
}

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

int main(){
    int n;
    cin >> n;
    ll sum=0;
    //地道に3重ループ
    rep(i,n){
        rep(j,n){
            rep(k,n){
                sum += gcd3(i,j,k);
            }
        }
    }
    cout << sum << endl;
    return 0;
    
}




/*
int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   cout << "最大公約数:" << gcd(a, b) << endl;
   cout << "最大公約数:" << gcd3(a, b, c) << endl;
   return 0;
}
*/

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

long long cnt = 0;

void InsertionSort(int A[], const int N, const int g) {
    for (int i = g; i < N; ++i) {
        int var = A[i];
        int j = i - g;
        for (; j >= 0 && A[j] > var; j -= g) {
            A[j + g] = A[j];
            cnt++;
        }
        A[j + g] = var;
    }
}

void ShellSort(int A[], int n) {
    vector<int> G;
    for (int i = 1;;) {
        if (i > n) {
            break;
        }

        G.push_back(i);
        i = 3 * i + 1;
    }

    for (int i = G.size() - 1; i >= 0; --i) {
        InsertionSort(A, n, G[i]);
    }

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; --i) {
        if (i == G.size() - 1) {
            cout << G[i];
        } else {
            cout << ' ' << G[i];
        }
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    int A[1000000];
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    ShellSort(A, n);

    cout << cnt << endl;
    for (int i = 0; i < n; ++i) {
        cout << A[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 7044
// Frog 1- Atcoder DP 

#include<bits/stdc++.h>

using namespace std;

int main(){
	long int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int dp[n]={0};
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
from sys import stdin
import math

def I(): return int(stdin.readline().rstrip())


k = I()

ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        tmp = math.gcd(i,j)
        if tmp != 1 :
            for w in range(1,k+1):
                ans += math.gcd(tmp,w)
        else:
            ans += k

print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 6;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    ll n;
    cin >> n;
    ll res = modpow(10, n, MOD) + modpow(8, n, MOD) - 2LL * modpow(9, n, MOD) + 2LL * MOD;
    res = (res + MOD) % MOD;
    cout << res << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
    char a[10],b[10],c[10];
    int la, lb, lc;
    scanf("%s%s%s",&a,&b,&c);
	printf("%c",toupper(a[0]));
	printf("%c",toupper(b[0]));
	printf("%c\n",toupper(c[0]));
    return 0;
}

Measured memory_bytes: 1708
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(200000000)


# my functions here!

#入力

def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    A,B,M=pin()
    a=list(pin())
    b=list(pin())
    ans=min(a)+min(b)
    
    for i in range(M):
       x,y,z=pin()
       ans=min(ans,a[x-1]+b[y-1]-z)
    print(ans)
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 1
3 3
3 3 3
1 2 1"""
        output = """5"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 1 2
10
10
1 1 5
1 1 10"""
        output = """10"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2 2 1
3 5
3 5
2 2 2"""
        output = """6"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

Measured memory_bytes: 21140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	ll k;
	ll ans=0;
	cin>>k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				ans+=__gcd(__gcd(i,j),l);
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;
    vector<pp> v;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            int d=0;
            while(n%i==0)
            {
                d++;n/=i;
            }
            v.push_back({i,d});
        }
    }
    if(n!=1)v.push_back({n,1});
    int ans=0;
    for (int i = 0; i < v.size(); ++i)
    {
        int d=0;int j=1;
        for(;;j++)
        {
            if(v[i].second>=d+j)
            {
                d+=j;
            }
            else break;
        }
        j--;
        ans+=j;
    }
    cout << ans;
    }

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    string a,b;
    cin>>a;
    string x,y,z;
    for(int i=0;i<4;i++) x+=a[i];
    y+=a[5],y+=a[6];
    z+=a[8],z+=a[9];
    int ye=stoi(x),mo=stoi(y),da=stoi(z);
    if(ye>2019 or (ye==2019 and mo>4) or (mo==04 and da>30)) cout<<"TBD" el;
    else cout<<"Heisei" el;
}

main()
{
//    fastio();
      _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3604