akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char a[100];
	int n,k;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>k;
	for(int i=0;i<n;i++){
		if(a[i]!=a[k-1]){
			a[i]='*';
		}
	}
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var mark = new string[]{"S","H","C","D"};
        var nums = new string[]{"1","2","3","4","5","6","7",
                             "8","9","10","11","12","13"};
        var flag = new bool[52];
        for(var f = 0;f < 52;f++){
            flag[f] = false;
        }
        
        var n = int.Parse(Console.ReadLine());
        
        for(var i = 0;i < n;i++){
            var line = Console.ReadLine().Split(' ');
            var index = Array.IndexOf(mark,line[0]) * 13 + Array.IndexOf(nums,line[1]);
            flag[index] = true;
        }
        for(var i = 0;i < 52;i++){
            if(!flag[i]){
                Console.WriteLine($"{mark[i / 13]} {nums[i % 13]}");
            }
        }
    }
}



Measured memory_bytes: 7784
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var S = Str;
		var T = Str;
		var g = GCD(N, M);
		var f = true;
		for (var i = 0; i < g; i++) f &= S[N / g * i] == T[M / g * i];
		WriteLine(f ? N / g * (long)M : -1);
	}
	public static int GCD(int n, int m)
	{
		while (m > 0)
		{
			var c = n % m;
			n = m;
			m = c;
		}
		return n;
	}
}


Measured memory_bytes: 13792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/

/*==================================================*/
/*function*/


/*==================================================*/

int main() {
    int X;

    cin>>X;

    int ans = 1;
    for(int i  = 1; i*i <= X; i++){
        int t = i;
        while(t*i <= X){
            t *= i;
            if(i==1) break;
        }
        ans = max(ans, t);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split(' ')]

""" if K % 2 != 0:
    quotient = N // K
    print(quotient**3)
elif K % 4 == 0:
    pass    
 """

count = 0
for a in range(1, N + 1):
    if (2 * a) % K == 0:
        q_max = (N + a) // K
        q_min = ceil((a + 1) / K)
        q_num = (q_max - q_min) + 1
        count += q_num**2
    else:
        continue
print(count)


Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

/**
* ------------- ここからコード -------------
*/

int main(void) {

	int N, D;
	cin >> N >> D;
	int ans = 0;
	rep(i, N) {
		double x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= D) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

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;
}

 
int main(void){
	
	int N;
	
	cin >> N;
	
	ll a[N][3];
	
	rep(i, N)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	
	ll dp[110000][3];

	rep(i, 110000)
		rep(j, 3)
			dp[i][j] = 0;

	rep(i, N){
		rep(j, 3){
			rep(k, 3){
				if(j != k)
					chmax(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	ll ans = 0;
	rep(i, 3)
		chmax(ans, dp[N][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define NIL -1
#define MAX 30
using namespace std;

struct Node { int parent, left, right, sibling; };

Node defaultNode = { NIL, NIL, NIL, NIL };

vector<Node> T(MAX, defaultNode);

vector<int> D(MAX, 0);
vector<int> H(MAX, 0);

void setDepth(int u, int p) {
  D[u] = p;
  if (T[u].left != NIL) {
    setDepth(T[u].left, p + 1);
  }
  if (T[u].right != NIL) {
    setDepth(T[u].right, p + 1);
  }
};

int setHeight(int u) {
  int h1, h2;
  h1 = h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }
  return H[u] = max(h1, h2);
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, l, r;
    cin >> u >> l >> r;
    T[u].left = l;
    T[u].right = r;
    if (l != NIL) {
      T[l].parent = u;
      if (r != NIL) T[l].sibling = r;
    }
    if (r != NIL) {
      T[r].parent = u;
      if (l != NIL) T[r].sibling = l;
    }
  }

  int root;

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) {
    int degree = 0;
    if (T[i].left != NIL) degree++;
    if (T[i].right != NIL) degree++;
    cout << "node " << i << ": parent = " << T[i].parent << ", sibling = " <<
    T[i].sibling << ", degree = " << degree << ", depth = " << D[i] << ", height = " << H[i] << ", ";
    if (T[i].parent == NIL) cout << "root" << endl;
    else if (T[i].left == NIL && T[i].right == NIL) cout << "leaf" << endl;
    else cout << "internal node" << endl;
  }
};



Measured memory_bytes: 3100
N = int(input())
S = input()
lis = []
Wcounter = 0
Ecounter = 0
for s in S:
    lis.append(Ecounter)
    if s == 'E':
        Ecounter += 1
for index, s in enumerate(S[::-1]):
    lis[N - 1 - index] += Wcounter
    if s == 'W':
        Wcounter += 1
max_num = 0
for num in lis:
    max_num = max(max_num, num)
print(N-1-max_num)

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

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            int K = Integer.parseInt(br.readLine());
            String input = br.readLine();

            if(K >= input.length()){
              System.out.println(input);
            }else{
              input = input.substring(0, K);
              input = input + "...";
              System.out.println(input);
            }
        }

    }
}

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

using namespace std;

vector< string > s;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n)
            break;


        for (int i = 0; i < n; ++i) {
            string ss;
            cin >> ss;
            s.push_back(ss);
        }
        for (int i = 0; i < n; ++i) {
            int j = 0;
            for (; s[i][j] == '.'; ++j) { }
            if (j)
                s[i][j - 1] = '+';
        }
        bool frag = true;
        while (frag) {
            frag = false;
            for (int i = 0; i < n - 1; ++i) {
                for (int j = 0; j < s[i].length(); ++j) {
                    if (s[i][j] == '.' && s[i + 1].length() > j && (s[i + 1][j] == '+' || s[i + 1][j] == '|')){
                        s[i][j] = '|';
                        frag = true;
                    }
                    if (s[i][j] == '+')
                        break;
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < s[i].length(); ++j) {
                if (s[i][j] == '.')
                    s[i][j] = ' ';
                if (s[i][j] == '+')
                    break;
            }
        }
        for (int i = 0; i < n; ++i) {
            cout << s[i] << endl;
        }
        while (s.size() > 0) {
            s.pop_back();
        }

        
        
    }
    return 0;
}

Measured memory_bytes: 1992
// by Balloons
#include <cstdio>
#include <cstring>
#include <map>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=3e5+5;
int n,a[maxn],b[maxn];
map<int,int>mp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	int t1=b[n/2],t2=b[n/2+1];
	for(int i=1;i<=n;i++){
		if(i<=n/2)mp[b[i]]=t2;
		else mp[b[i]]=t1;
	}
	for(int i=1;i<=n;i++)printf("%d\n",mp[a[i]]);
	
	return 0;
}


Measured memory_bytes: 12928
N = list(map(int, input().split()))
N.sort()

if (N[1] - N[0])%2 == 0:
    result = int((N[1] - N[0])/2) + N[2] - N[1]

else:
    result = int((N[1] - N[0])/2) + N[2] - N[1] + 2 

print(result)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
class Main{
	static int yn=0;//YES,NO→0,Yes,No→1,yes,no→2
	static Scanner scan=new Scanner(System.in);
	public static void main(String[]args) {
		/*通常出力→pl(String),
		 Yes,No出力→plyn(Yes→1,No→0)
		 入力→sc();void
		 */
		int a=sc();
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=sc();
		}
		int c=sc();
		if(c>a) {
			plyn(0);
			return;
		}
		int d[]=new int[c];
		for(int i=0;i<c;i++) {
			d[i]=sc();
		}
		Arrays.sort(b);
		Arrays.sort(d);
		int len=b.length;
		int count=0;
		for(int i=0;i<len;i++) {
			if(count==c) {
				break;
			}
			if(d[count]==b[i]) {
				count++;
			}
		}
		if(count==c) {
			plyn(1);
		}
		else {
			plyn(0);
		}
	}
	
	public static int sc() {
		int sc=scan.nextInt();
		return sc;
	}
	public static void pl(String str) {
		System.out.println(str);
	}
	public static void plyn(int a) {
		if(yn==0) {
			if(a==1) {
		System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
		else if(yn==1){
			if(a==1) {
				System.out.println("Yes");
				}
			else {
				System.out.println("No");
			}
		}
		else if(yn==2){
			if(a==1) {
				System.out.println("yes");
				}
			else {
				System.out.println("no");
			}
		}
	}
}

Measured memory_bytes: 93160
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
(x,y) = map(int,input().split())

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


if ( 2 * y - x ) % 3 != 0:
    print(0)
    exit(0)
if ( 2 * x - y ) % 3 != 0:
    print(0)
    exit(0)

a = ( 2 * y - x ) // 3
b = ( 2 * x - y ) // 3

if a < 0  or b < 0 : 
    print(0)
    exit(0)

print(comb(a+b,a,m))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s,t;
	cin >> s >>t;
	int n = s.size();
	int m = t.size();
	vector<vector<int>> dp(n+1,vector<int>(m+1,0));
	for(int i = 0; i <= n; i++) {
		dp[i][0] = 0;
	}
	for(int i = 0; i <= m; i++) {
		dp[0][i] = 0;
	}

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if (s[i] == t[j]){
				dp[i+1][j+1] =max(max(dp[i][j+1],dp[i+1][j]),dp[i][j]+1);
			}
			else{
				dp[i+1][j+1]=max(max(dp[i][j+1],dp[i+1][j]),dp[i][j]);
			}
		}
	}
	// cout << dp[n][m] << endl;

	int i = n;
	int j = m;
	string ans;
	while(i>0&&j>0){
		if(dp[i][j] == dp[i -1][j]){//sのi番目は使わないということ
			i--;
		}
		else if(dp[i][j] ==dp[i][j-1]){//tのj番目は使わない
			j--;
		}
		else{
			ans.pb(s[i - 1]);
			i--;
			j--;
		}
	}
	reverse(ALL(ans));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35584
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    long[][] dp = new long[n][n];
    for(int i=0;i<n;i++)dp[i][i]=a[i];
    for(int i=n-2;i>=0;i--){
      for(int j=i+1;j<n;j++)
        dp[i][j]=Math.max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
    }
    System.out.println(dp[0][n-1]);
  }
}

Measured memory_bytes: 130828
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<memory>
using namespace std;

int main()
{
	int i, j, k, n, m,h,w,sum=0;
	int d[20][20] = { 0 }, M[209][209] = { 0 };
	cin >> h >> w;
	for (i = 0; i <= 9; i++)
		for (j = 0; j <= 9; j++)
			cin >> d[i][j];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			cin >> M[i][j];
	for (k = 0; k <= 9; k++)
		for (i = 0; i <= 9; i++)
			for (j = 0; j <= 9; j++)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
		{
			if (M[i][j] != -1 && M[i][j] != 1)sum += d[M[i][j]][1];
		}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string S;
  std::cin >> S;
  if (S == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

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

	cout<<n<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	long A, B, K;

	cin >> A >> B;

	long c = abs(A - B);

	if (c % 2 != 0) {
		cout << "IMPOSSIBLE\n";
		return 0;
	}

	K = max(A, B) - (c / 2);

	cout << K << '\n';

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N, M = read_ints()
# ぐぐ→き
# きぐ→き
# きき→ぐ

# 偶数と奇数を選ぶ数を全体から引けば良い

tmp = [2] * N + [1] * M
ans = 0
for a, b in combinations(tmp, r=2):
    ans += (a + b) % 2 == 0
print(ans)


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N,K;
  cin>>N>>K;
  ll ans=0;
  for(ll i=K;i<=N+1;i++) {
    ans+=i*(2*N-i+1)/2-i*(i-1)/2+1;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}
    

  
  
  


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
 
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(); int X= in.nextInt();
 
        int[] cost = new int[N];
 
        for(int i = 0; i < N; i++){
            cost[i] = in.nextInt();
            X-=cost[i];
        }
 
 
        Arrays.sort(cost);
 
        int add = 0;
        while(X >= cost[0]) {
            add++;
            X-=cost[0];
        }
 
        System.out.println(N + add);
 
    }
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26;

int d;
int c[A],s[D][A],last[A],mx[D];

int nxt(int i,int j)
{
    for(;i<d;i++)
        if(mx[i]==j)
            return i;
    return d;
}

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

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]>s[i][best])
                best=j;
        mx[i]=best;
    }
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*(nxt(i+1,j)-i)>
               s[i][best]+c[best]*(i-last[best])*(nxt(i+1,best)-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3744
def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 0
    for i in range(n//r + 1):
        if i*r > n:
            break
        for j in range(n//g + 1):
            if r*i + g*j > n:
                break
            if (n-(r*i + g*j)) % b==0:
                res += 1           
    print(res)

if __name__ == '__main__':
    main()


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

public class Main {

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

    private void solve() {
        int n = sc.nextInt();

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; ++j) {
                for (int k = 1; k <= n; ++k) {
                    ans += gcd(gcd(i, j), k);
                }
            }
        }
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 32936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9+1;

int main(){
  int n, L;
  cin >> n >> L;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int l = -1, r = -1;
  for (int i = 0; i < n-1; i++) {
    if (a[i] + a[i + 1] >= L) {
      l = i;
      r = i + 1;
      break;
    }
  }

  if (l == -1) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for (int i = 0; i < l; i++) {
    cout << i + 1 << endl;
  }
  for (int i = n-2; i >= l; i--) {
    cout << i + 1 << endl;
  }

  return 0;
} 

Measured memory_bytes: 1280
from typing import List
from collections import Counter


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


def count_answer(counter):
    ans = 0
    for count in counter.values():
        i = 1
        while count >= i:
            ans += 1
            count -= i
            i += 1
    return ans


if __name__ == "__main__":
    prime_factors = Counter(prime_factorize(int(input())))
    print(count_answer(prime_factors))


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

int main() {
  int j = 0;
  int N;
  cin >> N;
  vector<int> file(N);
  for(int i = 0; i < N; i++){
    cin >> file.at(i);
  }
  for(int i = 0; i < N; i++){
    if(file.at(i) % 2 == 0){
       if(file.at(i) % 6 == 0 or file.at(i) % 10 == 0){
       }
      else{
        j ++;
    }
  }
  }
  if(j > 0){
    cout << "DENIED";
  }
  else{
    cout << "APPROVED";
  }
}



Measured memory_bytes: 256
#include<string>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    rotate(s.begin(), s.begin()+1, s.end());
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 5)
        cout << 0 << endl;
    else if (a >= 13)
        cout << b << endl;
    else
        cout << b / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;

$_ = <>;
chomp;
if(m/^.*keyence$/){
  print "YES\n";
  exit(0);
}
if(m/^k.*eyence$/){
  print "YES\n";
  exit(0);
}
if(m/^ke.*yence$/){
  print "YES\n";
  exit(0);
}
if(m/^key.*ence$/){
  print "YES\n";
  exit(0);
}
if(m/^keye.*nce$/){
  print "YES\n";
  exit(0);
}
if(m/^keyen.*ce$/){
  print "YES\n";
  exit(0);
}
if(m/^keyenc.*e$/){
  print "YES\n";
  exit(0);
}
if(m/^keyence.*$/){
  print "YES\n";
  exit(0);
}
print "NO\n";
exit(0);


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

int n;

int a[42];

long long go(int x, long long sum) {
  if (x == n) return sum;
  long long cur = 0;
  long long ans = 0;
  for (int i = x; i < n; i++) {
    cur = cur * 10 + a[i];
    ans += go(i + 1, sum + cur);
  }
  return ans;
}

int main() {
  int c = getchar();
  while (c <= 32) {
    c = getchar();
  }
  while (c > 32) {
    a[n++] = c - '0';
    c = getchar();
  }
  printf("%lld\n", go(0, 0));
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 1000700
int n,k,ct,p[N],q[N],rp[N],rq[N],s[N],rs[N],vis[N],st[N],as[N],s1[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)scanf("%d",&q[i]);
	if(k==1){for(int i=1;i<=n;i++)printf("%d ",p[i]);return 0;}
	if(k<=6)
	{
		for(int i=3;i<=k;i++)
		{
			for(int j=1;j<=n;j++)s[p[j]]=q[j],p[j]=q[j];
			for(int j=1;j<=n;j++)q[j]=s[j];
		}
		for(int i=1;i<=n;i++)printf("%d ",q[i]);return 0;
	}
	for(int i=1;i<=n;i++)rp[p[i]]=i,rq[q[i]]=i;
	for(int i=1;i<=n;i++)s1[i]=rp[q[p[rq[i]]]];
	for(int i=3;i<=(k-1)%6+7;i++)
	{
		for(int j=1;j<=n;j++)s[p[j]]=q[j],p[j]=q[j];
		for(int j=1;j<=n;j++)q[j]=s[j];
	}
	for(int i=1;i<=n;i++)if(!vis[i])
	{
		ct=0;st[ct=1]=i;vis[i]=1;
		for(int j=s1[i];j!=i;j=s1[j])st[++ct]=j,vis[j]=1;
		for(int j=1;j<=ct;j++)as[st[j]]=st[(j-2+(k-1)/6)%ct+1];
	}
	for(int i=1;i<=n;i++)rs[as[i]]=i;
	for(int i=1;i<=n;i++)printf("%d ",rs[q[as[i]]]);
}

Measured memory_bytes: 21632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a+b+c - max(max(a,b),c)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

struct StronglyConnectedComponents{
    vector<vector<int>> g;
    vector<vector<int>> to,from;
    vector<int> comp,order,used;
    StronglyConnectedComponents(vector<vector<int>> &g):
    g(g),to(g.size()),from(g.size()),comp(g.size(),-1),used(g.size()){
        for(int i=0;i<g.size();i++){
            for(auto x:g[i]){
                to[i].push_back(x);
                from[x].push_back(i);
            }
        }
    }
    int operator[](int k){
        return comp[k];
    }
    void dfs(int now){
        if(used[now]) return ;
        used[now]=true;
        for(int x:to[now])dfs(x);
        order.push_back(now);
    }
    void rdfs(int now,int cnt){
        if(comp[now]!=-1) return ;
        comp[now]=cnt;
        for(int x:from[now]) rdfs(x,cnt);
    }
    vector<vector<int>> build(){
        vector<vector<int>> t;
        for(int i=0;i<to.size();i++) dfs(i);
        reverse(order.begin(),order.end());
        int ptr=0;
        for(int i:order)if(comp[i]==-1)rdfs(i,ptr),ptr++;
 
        t.resize(ptr);
        for(int i=0;i<g.size();i++){
            for(auto v:to[i]){
                int x=comp[i],y=comp[v];
                if(x==y) continue;
                t[x].push_back(y);
            }
        }
        return t;
    }
};

signed main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
    }

    StronglyConnectedComponents scc(g);
    auto t=scc.build();
    vector<vector<int>> belong(t.size());
    rep(i,n)belong[scc[i]].push_back(i);
    cout<<belong.size()<<"\n";
    rep(i,belong.size()){
        cout<<belong[i].size();
        for(auto u:belong[i]) cout<<" "<<u;
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 146400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,i,j=0;
    char s[11],t[12];
    cin>>s;
    cin>>t;
    c=strlen(s);
    for(i=0;i<c;i++)
    {
        if(s[i]==t[i])
            j++;
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(c==j)
        cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3]) {
		if (s[4] == s[5]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int64 x; cin >> x;
	int64 money = 100;
	int64 cnt = 0;
	for (int i = 0; i < INF; ++i) {
		if (money < x) {
			cnt++;
			money = money + (int64)(money * 0.01);
		} else {
			break;
		}
	}
	cout << cnt << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 string s,t  ; cin>>s>>t  ;
 ll ans=0;
  rep(i,3) {
  
  if(s[i]==t[i]) ans++;
  }
  
  cout<< ans <<endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>                                             
#include <stack>                                                
#include <string>                                               
#include <cstdlib>                                              
using namespace std;                                            
                                                                
int main() {                                                    
  string s;                                                     
  int a, b;                                                     
  stack<int> ab;                                                
  while (cin >> s) {                                            
    if (s[0]=='+') {                                            
      a = ab.top();                                             
      ab.pop();                                                 
      b = ab.top();                                             
      ab.pop();                                                 
      ab.push(a+b);                                             
    } else if (s[0]=='-') {                                     
      b = ab.top();                                             
      ab.pop();                                                 
      a = ab.top();                                             
      ab.pop();                                                 
      ab.push(a-b);                                             
    } else if (s[0]=='*') {                                     
      a = ab.top();                                             
      ab.pop();                                                 
      b = ab.top();                                             
      ab.pop();                                                 
      ab.push(a*b);                                             
    } else if (s[0]=='\n') {                                    
      break;                                                    
    } else {                                                    
      ab.push(atoi(s.c_str()));                                 
    }                                                           
  }                                                             
  cout << ab.top() << endl;                                     
  return 0;                                                     
}                           

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

using ll=string;
ll to_ll(string exp){
    ll res="";
    bool top0=false;
    for(int i=0;i<exp.size();i++){
        if(top0) return "-1";
        if(exp[i]=='?'){
            res+=('9');
        }
        else if(isdigit(exp[i])){
            res+=exp[i];
            top0=(i==0 && exp[i]=='0');
        }
        else{
            return "-1";
        }
    }
    return res;
}

bool isGood(char x,char y){
    return x==y || x=='?';
}
bool isOK(const string& exp,int p,char com){
    bool comb=isGood(exp[0],com);
    bool parb=isGood(exp[1],'(') && isGood(exp.back(),')');
    bool commab=isGood(exp[p],',');
    return comb && parb && commab;
}

string mymax(string l,string r){
    if(l=="-1") return r;
    if(r=="-1") return l;
    if(l.size()<r.size()) return r;
    if(r.size()<l.size()) return l;
    return max(l,r);
}
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<vector<ll>> dp(n,vector<ll>(n+1,"-1"));
    for(int k=1;k<=n;k++){
        for(int l=0;l+k<=n;l++){
            string exp=s.substr(l,k);
            ll res=to_ll(exp);
            if(k>=6){
                for(int p=3;p+2<k;p++){
                    if(isOK(exp,p,'L') && dp[l+2][l+p]!="-1" && dp[l+p+1][l+k-1]!="-1"){
                        res=mymax(res,dp[l+2][l+p]);
                    }
                    if(isOK(exp,p,'R') && dp[l+2][l+p]!="-1" && dp[l+p+1][l+k-1]!="-1"){
                        res=mymax(res,dp[l+p+1][l+k-1]);
                    }
                }
            }
            dp[l][l+k]=res;
        }
    }
    if(dp[0][n]=="-1") cout<<"invalid"<<endl;
    else cout<<dp[0][n]<<endl;
    
    return 0;
}


Measured memory_bytes: 3292
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    aa=[]
    for i in range(n):
        aa.append((i+1,a[i]))
    aa.sort(key=lambda x:x[1])
    b=[]
    for i in range(n):
        b.append(aa[i][0])
    return b

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(' '.join(map(str,ans)))


Measured memory_bytes: 24840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main () {
	int A, B, K;

	cin >> A >> B >> K;
	if (K >= B-A+1){
		for(int i = A; i <=B; i ++){
			
		}
	
	}
	for(int i = A; i <=B; i ++){
		if (i < A+K){
			cout << i << endl;
		}
		else if (i > B-K){
			cout << i << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  using ull = unsigned long long;
  ull a, b, x;
  cin >> a >> b >> x;
  ull ans = b / x - a / x;
  if (a % x == 0) {
    ans++;
  }

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

Measured memory_bytes: 256
#include <stdio.h>

int primoein(int x){
  for(int i=2; i<x; i++)
  {
    if (x%i == 0 )
      return 1;
  }
  return 0;  //significa que ele é primo.
}

int main () {
  int x;
  scanf("%d", &x);

  while (primoein(x))
      x++;

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

return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key
 
//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;
 
int dx[5]={-2,-1,0,+1,+2},dy[5]={-2,-1,0,+1,+2};
int n,m,r1,c1,r2,c2,dp[1005][1005];
string s[1005];
 
 
void solve(){
    cin>>n>>m>>r1>>c1>>r2>>c2;
    rep(i,0,n) cin>>s[i];
    rep(i,0,n) rep(j,0,m) dp[i][j]=LLONG_MAX;
    r1--;r2--;c1--;c2--;
    dp[r2][c2]=0;
 
 
    priority_queue<pair<int,pair<int,int>>> q;
 
    q.push(mp(0,mp(r2,c2)));
 
    while(sz(q)){
        auto d=-q.top().x;
        auto pos=q.top().y;
        q.pop();
 
        rep(i,0,5){
            rep(j,0,5){
                if(!dx[i] and !dy[j]) continue;
 
                int x=dx[i]+pos.x;
                int y=dy[j]+pos.y;
                if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') continue;
                
 
                if((abs(dx[i])==1 and !dy[j]) or (abs(dy[j])==1 and !dx[i])){
                    if(dp[x][y]>d){
                        dp[x][y]=d;
                        q.push(mp(-d,mp(x,y)));
                    }
                }
                else{
                    if(dp[x][y]>d+1){
                        dp[x][y]=d+1;
                        q.push(mp(-d-1,mp(x,y)));
                    }
                }
            }
        }
    }
 
    if(dp[r1][c1]==LLONG_MAX) cout<<-1;
    else cout<<dp[r1][c1];
}
 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 12760
#include<stdio.h>

#include <stdlib.h>



int cmp_int(const void *a, const void *b){

    return *(int*)a - *(int*)b;

}

int main(){

	int n,l[200];

	int k[101]={0};

	int i,j,cnt=0;

	int ans = 0;



	scanf("%d",&n);

	for(i=n*2;i--;scanf("%d",&l[i]));

	qsort(l,2*n,sizeof(int),cmp_int);

	

	for(i=0;i<2*n;i++){

		for(j=i;j<2*n;j++){

			if(l[i]==l[j]){

				k[l[i]]++;

			}else break;

		}

		i = j-1;

	}

	for(i = 1;i < 101;i++){

		ans += k[i]/2*i;

		k[i] = k[i]%2;

	}

	for(i=101;--i;){

		if(k[i]){

			cnt++;

			if(cnt==2){

				ans += i;

				cnt = 0;

			}

		}

	}

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

	return 0;

}

		

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC134 B
int main() {
	int N, D;
	cin >> N >> D;

	int cover = 2 * D + 1;
	int ans = 1;
	while (cover < N) {
		cover += 2 * D + 1;
		ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

int main(void)
{
	int n,big;

	cin>>n;

	int a[n];

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

		if (i) {
			big = __gcd(big, a[i]);
		}
		else {
			big = a[i];
		}
	}

	cout<<big<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

ll ngcd(vector<ll> a){
    ll res;
    res = a.at(0);
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a.at(i), res);
    }
    return res;
}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  using P = pair<int, int>;
  int n;
  vector<int> f, primes; //f.at(x)はxの最小素因数
  Sieve(int n=1):n(n), f(n+1) {
  f[0] = f[1] = -1;
  for (ll i = 2; i <= n; ++i) {
    if (f[i]) continue; //ここでf[i]==0なら素数
    primes.push_back(i);
    f[i] = i;
    for (ll j = i*i; j <= n; j += i) {
  if (!f[j]) f[j] = i;
    }
  }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) { //xの素因数を小さい順に列挙
  vector<int> res;
  while (x != 1) {
    res.push_back(f[x]);
    x /= f[x];
  }
  return res;
  }
  vector<P> factor(int x) {
  vector<int> fl = factorList(x);
  if (fl.size() == 0) return {};
  vector<P> res(1, P(fl[0], 0));
  for (int p : fl) { //ここでランレングス圧縮
    if (res.back().first == p) {
  res.back().second++;
    } else {
  res.emplace_back(p, 1);
    }
  }
  return res;
  }
};
// Sieve sieve(N);でN以下の各自然数の最小素因数を調べ上げる
// sieve.factor(M)でMの素因数分解

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数
    // 割れる限り割り続ける
    while (N % a == 0) {
     ++ex;
      N /= a;
    }
    // その結果を push
    res.push_back({a, ex});
  }
  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    Sieve sieve(1000009);
    set<int> primes;
    bool pc = true;
    rep(i, N){
        vector<pair<int, int>> pf = sieve.factor(A.at(i));
        rep(j, sz(pf)){
            if(primes.count(pf.at(j).first)){
                pc = false;
                break;
            }
            else{
                primes.insert(pf.at(j).first);
            }
        }
        if(!pc){
            break;
        }
    }
    if(pc){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    if(ngcd(A) == 1){
        cout << "setwise coprime" << endl;
    }
    else{
        cout << "not coprime" << endl;
    }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

map<ll, int> enumpr(ll n) {
	map<ll, int> v;
	
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			v[i]++;
			n /= i;
		}
	}
	if (n > 1) v[n]++;
	return v;
}

vector<int> prime_cnt;
int cnt;

void just(int index, int sum) {
	if (sum > 75) return;
	if (index == prime_cnt.size()) {
		if (sum == 75) cnt++;
	} else {
		repe(i, prime_cnt[index]) {
			just(index + 1, sum * (i + 1));
		}
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	
	map<ll, int> memo;
	FORE(i, 2, n) {
		auto V = enumpr(i);
		for (auto &v: V) {
//			cout << v.first << " " << v.second << endl;
			memo[v.first] += v.second;
		}
	}
	for (auto &num: memo) {
//		cout << num.first << " " << num.second << endl;
		prime_cnt.push_back(num.second);
	}
	
	cnt = 0;
	just(0, 1);
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

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<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int dp[1005][10], mmon[] = { 1,2,4 }, ans;
int main() {
	int n;
	string h;
	cin >> n >> h;
	dp[0][1] = 1;
	for (int i = 1; i <= n; ++i) {
		int mon;
		if (h[i - 1] == 'J') mon = 0;
		else if (h[i - 1] == 'O') mon = 1;
		else mon = 2;
		for (int j = 0; j < 8; ++j) {
			if (mmon[mon] & j) {
				for (int k = 0; k < 8; ++k) {
					if (j&k) {
						dp[i][j] += dp[i - 1][k];
					}
					dp[i][j] %= 10007;
				}
			}
		}
	}
	for (int i = 0; i < 8; ++i) {
		ans += dp[n][i];
		ans %= 10007;
	}
	cout << ans << endl;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    if(n%x==0)COUT((n/x)*t);
    else COUT((n/x)*t+t);
}

Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
    int n, x;

    scanf("%d", &n);

    if(n < 10){
        x = n;
    } else{
        x = n % 10;
    }

    if(x == 3){
        printf("bon");
    } else if(x == 0 || x == 1 || x == 6 || x == 8 ){
        printf("pon");
    } else{
        printf("hon");
    }

    return 0;

}


Measured memory_bytes: 3232