akhauriyash/Code-Regression huggingface dataset:
from collections import deque
k = int(input())
num_li = deque()
for i in range(1,10):
    num_li.append(i)
while True:
    l = len(num_li)
    if l >= k:
        print(num_li[k-1]);exit()
    else:
        k -= l
        for i in range(l):
            left = num_li.popleft()
            last = left%10
            add1,add2,add3 = 10*left+last-1,10*left+last,10*left+last+1
            if 0 < last < 9:
                num_li.append(add1)
                num_li.append(add2)
                num_li.append(add3)
            elif last == 0:
                num_li.append(add2)
                num_li.append(add3)
            else:
                num_li.append(add1)
                num_li.append(add2)


Measured memory_bytes: 9324
adjacent = (
    (1, 3),       # 0
    (0, 2, 4),    # 1
    (1, 5),       # 2
    (0, 4, 6),    # 3
    (1, 3, 5, 7), # 4
    (2, 4, 8),    # 5
    (3, 7),       # 6
    (4, 6, 8),    # 7
    (5, 7)        # 8
)

import collections

GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]

# Bidirectional search using breadth-first search
def solve(start):
    if start == GOAL:
        return 0
    # 0: forward, 1: backward
    generated_state = {tuple(start): 0, tuple(GOAL): 1}
    step = {tuple(start): 0, tuple(GOAL): 0}
    s = 0
    state1 = [(start, 0), (GOAL, 1)]
    while state1:
        state2 = state1[:]
        state1 = []
        s += 1
        for s2, d in state2:
            i = s2.index(0)
            for p in adjacent[i]:
                s1 = s2[:]
                s1[i], s1[p] = s1[p], 0
                key = tuple(s1)
                if key in generated_state:
                    if generated_state[key] != d:
                        return s + step[key]
                    continue
                state1.append((s1, d))
                generated_state[key] = d
                step[key] = s

import sys

start = list(map(int, sys.stdin.read().split()))

print(solve(start))

Measured memory_bytes: 13476
using System;
using System.Linq;

namespace testes
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            double a = double.Parse(str[0]);
            double b = double.Parse(str[1]);
            double x = double.Parse(str[2]);
            double ans = 0;
            double X = x / a; //横から見た面積
            bool flag = X <= a * b / 2; //直角三角形になるか
            if (flag)
            {
                double aa = 2 * X / b;
                double c =Math.Atan(b / aa) * 180 / Math.PI;
                ans = c;
            }
            else
            {
                double Zyoutei = (2 * X / a) - b;
                double ZZ = b - Zyoutei;
                ans = Math.Atan(ZZ / a) * 180 / Math.PI;
            }


            Console.WriteLine(ans);
        }

        public static void func(int L, int R,bool x, bool y)
        {
        }
        public static int LIS(int[] c)
        {
            // 部分数列和
            int count = 1;
            int N = c.Length;
            int[] array = new int[N];
            array[0] = c[0];

            for (int i = 1; i < N; i++)
            {
                //for (int p = 0; p < N; p++) Console.Write($"{array[p]},");
                // Console.WriteLine("");
                if (array[count - 1] < c[i])
                {
                    array[count] = c[i];
                    count++;
                    continue;
                }
                for (int j = count - 2; j >= 0; j--)
                {
                    if (array[j] < c[i])
                    {
                        array[j + 1] = c[i];
                        break;
                    }
                }
                if(array[0] > c[i])array[0] = c[i];
            }
            return count;
        }
        public static void Rotation(char[] array, int l, int r)
        {
           
            
        }


       

    }

    
}

/*
int a, b, c;
a = int.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = int.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力

string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for(int i = 0; i < N; i++) a[i] = int.Parse(str[i]);
 */


Measured memory_bytes: 11092
#include <iostream>
#include <array>

std::array<std::array<std::array<unsigned long long, 2501>, 51>, 51> dp;
std::array<unsigned, 51> x;

int main() {
  unsigned N = 0;
  unsigned A = 0;
  std::cin >> N;
  std::cin >> A;
  for (size_t i = 1; i <= N; ++i) {
    std::cin >> x[i];
  }
  for (size_t i = 0; i <= N; ++i) {
    for (size_t j = 0; j <= N; ++j) {
      for (size_t k = 0; k < 2501; ++k) {
        dp[i][j][k] = 0;
      }
    }
  }
  for(int i = 0; i <= 50; ++i) {
    dp[i][0][0] = 1;
  }
  for (size_t i = 1; i <= N; ++i) {
    for (size_t j = 1; j <= i; ++j) {
      for (size_t k = 0; k <= i * 50; ++k) {
        if (k >= x[i]) {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        } else {
          dp[i][j][k] = dp[i - 1][j][k];
        }
      }
    }
  }
  unsigned long long ret = 0;
  for (size_t i = 1; i <= N; ++i) {
    ret += dp[N][i][i * A];
  }
  std::cout << ret;
  return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, ans=0;
	cin>>N>>K;
	A.resize(N);
	for(auto &a: A) cin>>a;
	for(int i=1;i<=min(N,K);i++) for(int j=0;j<=i;j++) {
		multiset<int> t;
		int v=K-i, sum=0;
		for(int k=0;k<j;k++) t.insert(A[k]);
		for(int k=0;k<i-j;k++) t.insert(A[N-1-k]);
		while(v && t.size() && *t.begin()<0) {
			t.erase(t.begin());
			v--;
		}
		for(auto a: t) sum+=a;
		ans=max(ans,sum);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  long int A,B,K,i;
  scanf("%ld",&A);
  scanf("%ld",&B);
  scanf("%ld",&K);
  if(A>=K) A=A-K;
  else {
    i = K - A;
    A = 0;
    if(B >= i) B=B-i;
    else B=0;
  }
  printf("%ld %ld",A,B);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
int INF = 1e9;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M+1), b(M+1);
    vector<int> c(M+1, 0);
    vector<vector<int>> dp((1 << N), vector<int>(M+1, INF));
    for(int i = 1;i <= M;i++){
        cin >> a[i] >> b[i];
        for(int j = 0;j < b[i];j++){
            int ci;
            cin >> ci;
            c[i] |= 1 << (ci-1);
        }
    }
    for(int i = 0;i <= M;i++)    dp[0][i] = 0;
    for(int i = 0;i < (1 << N);i++){
        for(int j = 1;j <= M;j++){
            int s = i|c[j];
            dp[s][j] = min(dp[s][j], dp[i][j-1]+a[j]);
            dp[i][j] = min(dp[i][j], dp[i][j-1]);
        }
    }

    int ans = dp[(1 << N)-1][M];
    if(ans == INF)  cout << -1 << endl;
    else    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}


int main() {
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63\n";
    return 0;
  }
  if (n == 4) {
    cout << "2 5 20 63\n";
    return 0;
  }
  if (n == 5) {
    cout << "2 5 20 30 63\n";
    return 0;
  }
  int sum = 0;
  vector<int> a;
  int last = 0;
  for (int i = 2; i <= 30000; ++i) {
    if (i % 2 == 0 || i % 3 == 0) {
      a.push_back(i);
      sum += i;
    }
    last = i;
    if (sz(a) == n) {
      break;
    }
  }
  if (sum % 6 != 0) {
    for (int i = 0; i < sz(a); ++i) {
      int found = 0;
      for (int j = last + 1; j <= last + 12; ++j) {
        if ((sum - a[i] + j) % 6 == 0 && (j % 2 == 0 || j % 3 == 0)) {
          a.erase(a.begin() + i);
          a.push_back(j);
          found = 1;
          break;
        }
      }
      if (found) {
        break;
      }
    }
  }

  for (int i : a) {
    cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 512
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


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

	return 0;


}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)cin >> A[i];
  ll ans = 0;
  rep(i,70){
    ll a = 0, b = 0;
    rep(j,N){
      if(A[j]%2 == 0){
        a++;
        A[j] = A[j] >> 1;
      }else{
        b++;
        A[j] = A[j] >> 1;
      }
    }
    ll k = 1;
    rep(a,i){
      k *= 2;
      k %= MOD;
    }
    ans = ( ans%MOD + ( (((a%MOD)*(b%MOD))%MOD) * k )%MOD )%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5540
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main() {
  vector<int> getuDo;
  for (int i = 1; i <= 300000; i += 7) {
    getuDo.push_back(i);
  }
  for (int i = 6; i <= 300000; i += 7) {
    getuDo.push_back(i);
  }
  sort(getuDo.begin(), getuDo.end());
  getuDo.erase(getuDo.begin());

  bool notPrime[300001];
  memset(notPrime, false, sizeof(notPrime));
  for (int i = 0; i < getuDo.size(); i++) {
    for (int j = getuDo[i]*2; j <= 300000; j+=getuDo[i]) {
      notPrime[j] = true;
    }
  }
  // for (int i = 1; i <= 48; i++) {
  //   std::cout << i << ":" << notPrime[i] << std::endl;
  // }
  // return 0;

  while (true) {
    int t;
    cin >> t;
    if (t == 1) {
      break;
    }

    int n = t;
    std::cout << n << ":";
    vector<int> ans;
    for (int i = 0; i < getuDo.size(); i++) {
      if (notPrime[getuDo[i]]) {
	continue;
      }
      if (n%getuDo[i] == 0) {
	ans.push_back(getuDo[i]);
      }
    }

    for (int i = 0; i < ans.size(); i++) {
      std::cout << " " << ans[i];
    }
    std::cout << std::endl;
  }
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
int n, k, a[5005], pre[5005][5005], suf[5005][5005], ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	pre[0][0] = 1; suf[n+1][0] = 1;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=k;j++) {
			pre[i][j] |= pre[i-1][j];
			if(j >= a[i]) pre[i][j] |= pre[i-1][j-a[i]];
		}
	}
	for(int i=n;i>=1;i--) {
		for(int j=0;j<=k;j++) {
			suf[i][j] |= suf[i+1][j];
			if(j >= a[i]) suf[i][j] |= suf[i+1][j-a[i]];
		}
	}
	for(int i=1;i<=n+1;i++) {
		for(int j=1;j<=k;j++) suf[i][j] += suf[i][j-1];
	}
	for(int i=1;i<=n;i++) {
		for(int j=0;j<k;j++) {
			int X = k-j-a[i]-1;
			if(pre[i-1][j] && suf[i+1][k-j-1] - (X < 0 ? 0 : suf[i+1][X])) {ans++; break;}
		}
	}
	printf("%d\n",n-ans);
}


Measured memory_bytes: 195840
N = gets.to_i

h = Hash.new { 0 }

N.times do
  h[gets.chomp.chars[0]] += 1
end

result = 0
'MARCH'.chars.combination(3).each do |c|
  if h[c[0]] > 0 && h[c[1]] && h[c[2]]
    result += h[c[0]] * h[c[1]] * h[c[2]]
  end
end
p result

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c,d;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	//cin >> a >> b >> c;
	//cin >> a >> b >> c >> d;
	//cin >> str;
	cin >> str >> str2 >> str3;
	//cin >> n;
	string str_toupper;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	
	str_toupper = str[0];
	str_toupper += str2[0];
	str_toupper += str3[0];
	transform(ALL(str_toupper), str_toupper.begin(), ::toupper);
	cout << str_toupper << endl;

	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;
	//replace(ALL(str), ',', ' ');

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		int da = sc.nextInt();
		while(da-- > 0){
			long n = sc.nextLong();
			int count = 0;
			long max = n;
			while(true){
				if(max < 10){
					System.out.println(count);
					break;
				}
				max = solve(max);
//				if(max >= n){
//					System.out.println(-1);
//					break;
//				}
				count++;
			}
		}
	}

	private int solve(Long num) {
		String n = "" + num;
		int max = 0;
		for(int i = 1 ; i <n.length(); i++){
			int left = Integer.parseInt(n.substring(0, i));
			int right = Integer.parseInt(n.substring(i));
			int res = left * right;
			max = Math.max(max, res);
		}
		return max;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

void Main() {
	int n, x, tmp;
	long cnt = 0;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0) {
			break;
		}
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				tmp = x - (i + j);
				if (tmp > j && n >= tmp) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}
}
int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3096
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,k;
  cin >> n >> k;
  Comb comb;
  if(k >= n-1){
    cout << comb.calc(n+n-1,n-1) << endl;
    return 0;
  }
  ll ans = 0;
  ll temp = 1;
  for(int i=0;i<k+1;i++){
    temp = 1;
    temp *= comb.calc(n,i);
    temp *= comb.calc(n-1,i);
    ans += temp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


string S;
string key = "keyence";
int main(){

    cin >> S;
    int N = S.size();
    if(S == key){
        cout << "YES" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        for(int j = 1; ; j++){
            if(i + j > N) break;
            string tmp;
            if(i != 0)
                tmp += S.substr(0, i);
            if(i + j < N)
                tmp += S.substr(i + j);
            if(tmp == key){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<vector<ll>> Comtable;
ll C(ll n,ll r)
{
  if(n==r) return 1;
  if(r==0) return 1;
  if(Comtable.at(n).at(r)>0) return Comtable.at(n).at(r);
  Comtable.at(n).at(r)=C(n-1,r)+C(n-1,r-1);
  return Comtable.at(n).at(r);
}  

int main() 
{
  ll N,P; cin>>N>>P;
  ll num0=0,num1=0;
  rep(i,N)
  {
    ll A; cin>>A;
    A%=2;
    if(A==0) num0++;
    else num1++;
  }
  ll hoge=0;
  Comtable=vector<vector<ll>>(51,vector<ll>(51,0));
  for(int r=P;r<=num1;r+=2)
  {
    hoge+=C(num1,r);
  }
  cout<<(ll)pow(2,num0)*hoge<<endl;
  return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-4;
const int MOD = 1000000007;
struct P{
  double x, y, z;
};
double dist(double x, double y, double z){
  return sqrt(x*x + y*y + z*z);
}
double dist2(P p, P q){
  return dist(p.x-q.x, p.y-q.y, p.z-q.z);
}

int main(){
  int T; cin>>T;
  while(T--){
    double target[3];
    REP(i, 3) cin>>target[i];
    int N; cin>>N;
    vector<P> points(N);
    REP(i, N){
      cin>>points[i].x>>points[i].y>>points[i].z;
    }
    REP(i, N)REP(j, N)REP(k, N)if(i != j && j != k && k != i){
      double tri[3];
      tri[0] = dist2(points[i], points[j]);
      tri[1] = dist2(points[j], points[k]);
      tri[2] = dist2(points[k], points[i]);
      bool ok = true;
      REP(idx, 3){
        if(abs(tri[(idx+1)%3]/tri[idx] - target[(idx+1)%3]/target[idx]) > EPS){
          ok = false;
        }
      }
      if(ok) printf("%d %d %d\n", k+1, i+1, j+1);
    }
  }
  return 0;
}

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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;

ll dp[maxn][13];


int main()
{
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  
  dp[0][0] = 1;
  for(int i = 0 ; i < s.size(); i++)
  {
    for(int j = 0 ; j < 13; j++)
    {
      if(s[i] == '?')
      {
        for(int k = 0 ; k < 10; k++)
        {
          dp[i+1][(k + j * 10) % 13] += dp[i][j];
          dp[i+1][(k + j * 10) % 13] %= mod;
        }
      }
      else
      {
        dp[i+1][(s[i] - '0' + j * 10) % 13] += dp[i][j];
        dp[i+1][(s[i] - '0' + j * 10) % 13] %= mod;
      }
    }
  }

  cout << dp[s.size()][5] << endl;
  
  return 0;
}

Measured memory_bytes: 13912
#include <stdlib.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int N;
    int K;
    int sum=1;

    cin >> N >> K;

    for(int i=0;i<N;i++){
        if(sum > K){
            sum = sum + K;
        }
        else{
            sum = sum * 2;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

vector<int> vec;

int n,k;
int c[4];
int main(void){
    rep(i,3){
        int a,b;
        cin>>a>>b;
        //d(a)d(b)
        a--; b--;
        c[a]++;
        c[b]++;
        //rep(i,4){d(i)d(c[i])}
    }
    rep(i,4){if(c[i]>2){cout<<"NO"<<endl; return 0;}}
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=105;
int n,m,K,mo;
int C[N][N],f[N][N],g[N][N];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s; 
}
int main(){
	//n=98; m=99; K=100; mo=998244353;
	scanf("%d%d%d%d",&n,&m,&K,&mo);
	For(i,0,N-1) C[i][0]=1;
	For(i,1,N-1) For(j,1,i)
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	f[0][0]=1;
	For(i,1,K){
		For(j,0,n) For(k,0,m) f[j][k]=1ll*f[j][k]*power(i,(n-j)*(m-k))%mo*power(K-i+1,mo-1-j*k)%mo;
		memset(g,0,sizeof(g));
		For(j,0,n) For(k,0,m) For(jj,0,n-j)
			g[j+jj][k]=(g[j+jj][k]+1ll*f[j][k]*C[jj+j][j])%mo;
		memset(f,0,sizeof(f));
		For(j,0,n) For(k,0,m) For(kk,0,m-k)
			f[j][k+kk]=(f[j][k+kk]+1ll*g[j][k]*C[kk+k][k])%mo;
		For(j,0,n) For(k,0,m) f[j][k]=1ll*f[j][k]*power(K-i+1,j*k)%mo;
		if (K!=i){
			For(j,0,n) For(k,0,m) f[j][k]=1ll*f[j][k]*power(K-i,mo-1-j*k)%mo;
			memset(g,0,sizeof(g));
			For(j,0,n) For(k,0,m) For(jj,0,n-j)
				g[j+jj][k]=(g[j+jj][k]+1ll*f[j][k]*(jj&1?mo-C[jj+j][j]:C[jj+j][j]))%mo;
			memset(f,0,sizeof(f));
			For(j,0,n) For(k,0,m) For(kk,0,m-k)
				f[j][k+kk]=(f[j][k+kk]+1ll*g[j][k]*(kk&1?mo-C[kk+k][k]:C[kk+k][k]))%mo;
			For(j,0,n) For(k,0,m) f[j][k]=1ll*f[j][k]*power(i,mo-1-(n-j)*(m-k))%mo*power(K-i,j*k)%mo;
		}
		/*For(j,0,n) For(k,0,m) if (f[j][k])
			printf("VF %d %d %d %d\n",i,j,k,f[j][k]);
		For(j,0,n) For(k,0,m) if (g[j][k])
			printf("VG %d %d %d %d\n",i,j,k,g[j][k]);*/
	}
	printf("%d",f[n][m]);
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int i;
  cin >> n;
  vector<string> a;
  int c_ac=0,c_wa=0,c_tle=0,c_re=0;

  for(i =0;i<n;i++)
  {
    string s ;
    cin >> s;
    a.push_back(s);
  }
  for(i =0;i<n;i++)
    {
      if(a[i] == "AC")
        c_ac++;
      else if(a[i]=="WA")
        c_wa++;
      else if(a[i] == "TLE")
        c_tle++;
      else 
        c_re++;
    }
  cout << "AC" << "  " << "x" << "  " << c_ac << endl; 
  cout << "WA" << "  " << "x" << "  " << c_wa << endl; 
  cout << "TLE" << "  " << "x" << "  " << c_tle << endl;  
  cout << "RE" << "  " << "x" << "  " << c_re << endl; 
}

Measured memory_bytes: 7464
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 998244353
#define N 900010 
using namespace std;

int a,b,n; ll k;
int fac[N],inv[N];
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)
			ans=(ll)ans*bs%mdn;
		bs=(ll)bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	if(n<m)	return 0;
	return (ll)fac[n]*inv[m]%mdn*inv[n-m]%mdn;
}
void upd(int &x,int y){x=(x+y)%mdn;} 
int main()
{
	int ans=0;
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)	fac[i]=(ll)fac[i-1]*i%mdn;
	inv[n]=ksm(fac[n],mdn-2);// printf("%d\n",inv[n]);
	for(int i=n-1;i;i--)	inv[i]=(ll)inv[i+1]*(i+1)%mdn;
	for(int i=0;i<=n&&(ll)i*a<=k;i++)
	{
		if((k-a*i)%b==0)
		{
			ll bi=(k-a*i)/b;
			upd(ans,(ll)C(n,i)*C(n,bi)%mdn);
		}
	}
	printf("%d\n",ans);
	return 0;
}
/**
300000 300000 300000 0
*/


Measured memory_bytes: 5376
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,m;
	long long mon[100000+5],hero[100000+5];
	cin>>n;
	m=n+1;
	for(int i=0;i<m;i++){
		scanf("%lld",&mon[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&hero[i]);
	}
	long long sum=0;
	for(int i=0;i<n;i++){
		long long temp=mon[i];
		sum+=mon[i];
		mon[i]-=hero[i];
		if(mon[i]<0){
			if(abs(mon[i])<mon[i+1]){
				sum+=abs(mon[i]);
				mon[i+1]+=mon[i];
			}
			else {
				sum+=mon[i+1];
				mon[i+1]=0;
			}
		}
		else {
			sum-=temp;
			sum+=hero[i];
		} 
	} 
	
	
	printf("%lld\n",sum);

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    string ans = "";
    if (s[s.size()-1] == 's'){
        ans = s + "es";
    } else {
        ans = s + "s";
    }
    cout << ans << endl;
}



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

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

    ll x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    ll kyo[n - 1];
    for(int i = 0; i < n - 1; i++){
        kyo[i] = x[i + 1] - x[i];
    }

    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(kyo[i] * a <= b){
            ans += kyo[i] * a;
        }else{
            ans += b;
        }
    }    

    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(ll i =0;i<n;++i)

int main(){
  int n,q;
  cin>>n>>q;
  int pos=1;
  REP(i,q){
      int t;cin>>t;
      int k;cin>>k;
     
      if(t==0){
           int tar;
            if(pos+k-1>n)tar=pos+k-1-n;
            else tar=pos+k-1;
            cout<<tar<<endl;
      }else{
          k++;
        int tar;
        if(pos+k-1>n)tar=pos+k-1-n;
        else tar=pos+k-1;
        pos=tar;
      }
  }
}



Measured memory_bytes: 3104
function Main(input) {
    var A = input.split(' ');
    var cost = 0;

    A = A.map((s) => parseInt(s));
    A = A.sort();  

    for (var i = 0 ; i < A.length - 1 ; ++i) {
        cost += Math.abs(A[i] - A[i+1]);
    }

    console.log(cost);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	int n=10;
	while(cin>>a>>b){
	    c=a+b;
	    n=10;
	    for(int i = 0;i<7;i++){
 
	        if(c%n == c){
	            cout<<i+1<<endl;
	            break;
	        }
 
	        n=n*10;
	    }
	}
	return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

int x, b = 2, ans = 1, num = 0;

int main() {
	cin >> x;
	while (x >= b * b) {
		num = b;
		while (1) {
			num *= b;
			if (x >= num) {
				ans = max(num, ans);
			}
			else {
				break;
			}
		}
		b++;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;

        vector<ll> s(m), ma(n), mi(n);
        REP(i, m) {
            cin >> s[i];
            ll k;
            cin >> k;
            REP(j, k) {
                ll a;
                cin >> a;
                ma[a-1] += s[i];
                if(k == 1) mi[a-1] += s[i];
            }
        }

        ll mi1=LLINF, idx1=-1, mi2=LLINF;
        REP(i, n) {
            if(mi1 > mi[i]) {
                mi2 = mi1;
                mi1 = mi[i];
                idx1 = i;
            } else if(mi2 > mi[i]) {
                mi2 = mi[i];
            }
        }

        ll ret = 0;
        REP(i, n) chmax(ret, ma[i] - (i==idx1?mi2:mi1));
        cout << ret+1 << endl;
    }

    return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,A[3]; cin>>n>>A[0]>>A[1]>>A[2];
    vector<pi> Q(n);
    rep(i,n){
        string s; cin>>s;
        Q[i] = mp(s[0]-'A', s[1]-'A');
    }
    vector<char> ans(n);
    rep(i,n){
        int x = Q[i].fi;
        int y = Q[i].se;
        if (A[x]==0 && A[y]==0){
            cout<<"No\n";
            return 0;
        }
        int decide = x;
        if (A[x]==1 && A[y]==1){
            if (i+1<n && (Q[i+1].fi==y || Q[i+1].se==y))
                decide = y;
        }else if(A[x]>=A[y]){
            decide = y;
        }
        ans[i] = "ABC"[decide];
        (decide==x)?(A[x]++, A[y]--):(A[x]--, A[y]++);
    }
    cout<<"Yes\n";
    rep(i,n) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T inf = numeric_limits<T>::max();
    using P     = pair<T, int>;
    int n       = G.size();
    vector<T> d(n, inf);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c   = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<pair<int, lint>>> edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edges[u].emplace_back(v, 1);
        edges[v].emplace_back(u, 1);
    }
    vector<lint> distf = dijkstra(0, edges);
    vector<lint> dists = dijkstra(n - 1, edges);
    lint cnt           = 0;
    for (int i = 0; i < n; ++i) {
        if (distf[i] <= dists[i])
            cnt++;
    }
    if (cnt > n / 2)
        cout << "Fennec"
             << "\n";
    else
        cout << "Snuke"
             << "\n";
    return 0;
}

Measured memory_bytes: 9820
X, K, D = map(int, input().split())

if(X > 0):
    if(X-K*D >= 0):
        print(X-K*D)
    else:
        l = X//D
        X = X-D*(l+1)
        K = K-l-1
        if(K % 2 == 0):
            print(abs(X))
        else:
            print(abs(X+D))
elif(X < 0):
    if((X+K*D) <= 0):
        print(abs(X+K*D))
    else:
        l = -X//D
        X = X + D*(l+1)
        K = K-l-1
        if(K % 2 == 0):
            print(abs(X))
        else:
            print(abs(X-D))
else:
    if(K % 2 == 0):
        print(0)
    else:
        print(abs(D))


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

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())

using namespace std;

int main() {
	int n, g;
	cin >> n >> g;
	int ans = 0;
	int a = 1;
	while (a < g) {
		a--;
		a += n;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[10][8] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"};
	int n, a, i, j;
	while (cin >> n)
	{
		if (n < 0) break;
		char t[8] = "0000000";
		for (i = 0; i < n; i++)
		{
			cin >> a;
			for (j = 0; j < 8; j++)
			{
				if (t[j] == s[a][j])	t[j] = '0';
				else					t[j] = '1';
			}
			t[7] = '\0';
			cout << t << endl;
			strcpy(t, s[a]);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
 

vector <int > H;

int N; 
int A[2001];
int B[2001];
int main()
{
  cin >> N;
  H.resize(N);
  REP(i,N){
    cin >> H[i];
    A[H[i]]++;
  }
  sort(H.rbegin(),H.rend());
  int a = 0;
  B[0] = N;
  FOR(i,1,2000){
    a += A[i];
    B[i] = N - a;
  }
  int ans = 0;
  REP(i,N-2){
    FOR(j,i+1,N-1){
      int k = H[i]-H[j];
      ans += max(B[k] - j - 1,0);
    }
  }
  cout << ans;
}


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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	ll n;cin>>n;
	ll res=0;
	for(int i=1;i<=n;++i)
		res+=i*(n/i+1)*(n/i)/2;
	cout<<res<<endl;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void)
{
	int a, b;
	scanf("%d", &b);
	scanf("%d", &a);
	int all = a;
	for (int i = 1;i < b;i++) {
		all *= a - 1;
	}
	printf("%d", all );
		return 0;
}				


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2) {
        out("No");
        return 0;
    }
    int j = n / 2;
    rep(i, n / 2) {
        if (s[i] != s[j]) {
            out("No");
            return 0;
        }
        j++;
    }
    out("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast


    string str;
    cin>>str;

    int total = count(str.begin(), str.end(), '2');

    cout<<total;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<bool> ok(300, true);
    for (int i = 0; i < (int)s.size(); ++i) {
        for (int j = 0; j < (int)t.size(); ++j) {
            if (i >= j && s[i] != t[j]) {
                ok[i - j] = false;
            }
        }
    }
    int ret = 200;
    for (int i = 0; i < 100; ++i) {
        if (ok[i])
            ret = min(ret, max((int)s.size(), i + (int)t.size()));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        int n;
        double p;
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        
        if(n == 1){
            p = 1;
        }else if((n % 2) == 0){
            p = 0.5;
        }else{
            p = (double) ((n - 1) / 2 + 1) / n;
        }
        
        System.out.println(p);
    }
}


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

int main(){
    int R; cin >> R;
    string ans;

    if(R < 1200){
        ans = "ABC";
    }
    else if(R < 2800){
        ans = "ARC";
    }
    else{
        ans = "AGC";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int A[3][3];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> A[i][j];

    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int val;
        cin >> val;
        for (int r = 0; r < 3; r++)
            for (int c = 0; c < 3; c++)
                if (A[r][c] == val)
                    A[r][c] = 0;
    }

    bool bingo = false;

    for (int r = 0; r < 3; r++) {
        if (!A[r][0] && !A[r][1] && !A[r][2])
            bingo = true;
    }

    for (int c = 0; c < 3; c++) {
        if (!A[0][c] && !A[1][c] && !A[2][c])
            bingo = true;
    }

    bingo |= (!A[0][0] && !A[1][1] && !A[2][2]);
    bingo |= (!A[0][2] && !A[1][1] && !A[2][0]);

    cout << (bingo ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

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

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            swap(p[i],p[j]);
            bool isok=true;
            for(int k=0;k+1<n;k++) isok=isok&&(p[k]<p[k+1]);
            if(isok){
                cout<<"YES"<<endl;
                return 0;
            }

            swap(p[i],p[j]);
        }
    }
    
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256