akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    int n; cin >> n;
    vector<int> x(n), y(n), t(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i];
        t[i] = i;
    }
    double sum = 0;
    int cnt = 0;
    do
    {
        rep(i, n - 1)
        {
            sum += sqrt(pow(x[t[i+1]] - x[t[i]], 2) + pow(y[t[i+1]] - y[t[i]], 2));
        }
        cnt++;
    } while (next_permutation(all(t)));
    cout << fixed << setprecision(10) << sum / cnt << endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE

const int LOCAL = 0;
string str="RRBBRBBBRR";

int n;

int ask(vector<int> vs){
  cout<<"?";
  for(int v:vs) cout<<" "<<v+1;
  cout<<endl;

  if(LOCAL){
    int cnt=0;
    for(int v:vs)
      if(str[v]=='R') cnt++;
    return cnt*2>n;
  }

  string T;
  cin>>T;
  assert(T!="-1"s);
  return T=="Red"s;
}

int ask2(int k){
  vector<int> vs(n);
  for(int i=0;i<n;i++){
    vs[i]=i;
    if(i>=k) vs[i]+=n;
  }
  return ask(vs);
}

signed main(){
  if(LOCAL){
    assert(str.size()%2==0);
    n=str.size()/2;
  }else{
    cin>>n;
  }

  vector<int> vvvs(n);
  for(int i=0;i<n;i++) vvvs[i]=i;

  int Y=ask(vvvs);
  int X=!Y;

  vector<int> memo(n+1,-1);
  memo[0]=X;
  memo[n]=Y;

  int L=0,R=n;
  while(L+1<R){
    int M=(L+R)>>1;
    int res=ask2(M);
    memo[M]=res;
    if(res==X) L=M;
    else R=M;
  }
  assert(memo[L]!=memo[R]);

  string ans(n*2,'#');
  string BASE="BR";
  ans[L+0]=BASE[!memo[L]];
  ans[L+n]=BASE[ memo[L]];

  //cout<<L<<endl;

  {
    vector<int> vs;
    for(int i=0;i<L;i++) vs.emplace_back(i+0);
    for(int i=R;i<n;i++) vs.emplace_back(i+n);

    for(int i=0;i<L;i++){
      vs.emplace_back(i+n);
      ans[i+n]=BASE[ask(vs)];
      vs.pop_back();
    }
    for(int i=R;i<n;i++){
      vs.emplace_back(i+0);
      ans[i+0]=BASE[ask(vs)];
      vs.pop_back();
    }
  }
  {
    vector<int> vs;
    for(int i=0;i<L;i++) vs.emplace_back(i+n);
    for(int i=R;i<n;i++) vs.emplace_back(i+0);

    for(int i=0;i<L;i++){
      vs.emplace_back(i+0);
      ans[i+0]=BASE[ask(vs)];
      vs.pop_back();
    }
    for(int i=R;i<n;i++){
      vs.emplace_back(i+n);
      ans[i+n]=BASE[ask(vs)];
      vs.pop_back();
    }
  }

  if(LOCAL) assert(str==ans);

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


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

typedef pair <int, int> ii;

const int Maxn = 3005;
const int Inf = 1000000000;

int n, t;
ii ab[Maxn];
int dp[Maxn];

bool Less(const ii &a, const ii &b)
{
    return a.first < b.first;
}

int main()
{
    fill(dp, dp + Maxn, -Inf);
    dp[0] = 0;
    scanf("%d %d", &n, &t);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &ab[i].first, &ab[i].second);
    sort(ab, ab + n, Less);
    for (int i = 0; i < n; i++)
        for (int j = t - 1; j >= 0; j--) {
            int nj = min(t, j + ab[i].first);
            dp[nj] = max(dp[nj], dp[j] + ab[i].second);
        }
    int res = -Inf;
    for (int i = 0; i <= t; i++)
        res = max(res, dp[i]);
    printf("%d\n", res);
    return 0;
}


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

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}


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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }


const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ---------------------------------------------------------------------------- -------------- 


void solve(){	
	ll n; cin>>n; 
	v64 a; 
	v64 divs; 
	for(ll d=2;d*d<=n;d++){
		if((n-1)%d==0){
			a.push_back(d); 
			a.push_back((n-1)/d); 
		}
		if(n%d==0){
			divs.push_back(d); 
			divs.push_back(n/d); 
		}
	}
	if(n-1>1) a.push_back(n-1); 
	if(n>1) divs.push_back(n); 
	for(ll d:divs){
		ll N=n; 
		while(N%d==0){
			N/=d; 
		}
		if(N%d==1){
			a.push_back(d); 
		}
	}
	sort(all(a)); 
	// for(int i:a) pr(i); 
	a.erase(unique(all(a)),a.end()); 
	cout<<sz(a)<<endl; 
}



int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // freopen("student.in","r",stdin); 
  // freopen("student.out","w",stdout); 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}



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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}

int n;
const int maxn = 1e6;
int dp[maxn][2][2];

int go(int id, bool zero, bool nine) {
    if (id == n) {
        return zero & nine;
    }
    int &ref = dp[id][zero][nine];
    if (~ref) {
        return ref;
    }
    int ans = 0;
    ans = add(ans, mul(8, go(id + 1, zero, nine)));
    ans = add(ans, go(id + 1, 1, nine));
    ans = add(ans, go(id + 1, zero, 1));
    return ref = ans;
}


void solve() {
    memset(dp, -1, sizeof dp);
    cin >> n;
    cout << go(0, 0, 0) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 97236
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
#print(A)
W=[0]*N
W[0]=abs(A[0])
c=abs(A[N-1])
for i in range(N-1):
    W[i+1]=abs(A[i+1]-A[i])
#print(W[N-1])

S=sum(W)
print(S-W[0]-W[1]+abs(A[1])+c)
for i in range(1,N-1):
    print(S-W[i]-W[i+1]+abs(A[i+1]-A[i-1])+c)

print(S-W[N-1]+abs(A[N-2]))

Measured memory_bytes: 13920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        new Main().solve();

    }

    private void solve() {
        InputReader sc = new InputReader();
        String n = sc.next();
        int v = 0;
        for (int i = 0; i < n.length(); i++) {
            v += n.charAt(i) - '0';
        }
        v = Math.max((n.length() - 1) * 9 + (n.charAt(0) - '0' - 1), v);

        System.out.println(v);
    }

    static class InputReader extends BufferedReader {
        StringTokenizer st = new StringTokenizer("");

        public InputReader() {
            super(new InputStreamReader(System.in));
        }

        public InputReader(String s) {
            super(new StringReader(s));
        }

        String next() {
            try {
                while (!st.hasMoreTokens())
                    st = new StringTokenizer(readLine());
            }
            catch (IOException e) {
                throw new RuntimeException(e);
            }
            return st.nextToken();
        }

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


Measured memory_bytes: 22996
#include<stdio.h>

int main(void)

{

int a,b,d,r;

double f;

scanf("%d %d",&a,&b);

if(1<=a && b<=1E+9){


d=a / b;

r=a % b;

f=(double)a / (double)b;

printf("%d %d %lf\n",d,r,f);

}


return 0;

}

Measured memory_bytes: 636
#include<iostream>

using namespace std;

int main(void){
  long long s, ans = 0;
  cin >> s;
  if(s <= 4) cout << "04494"[s] << endl;
  else{
    while(s > 1){
    	ans++;
    	if(s&1){
          s *= 3;
          s++;
        }else{
          s >>= 1;
        }
    }
    cout << ans + 2 << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

    vector<int> b(n, 0);

    for (int i = n-1; i >= n/2; --i) {
        b[i] = a[i];
    }

    for (int i = n/2 - 1; i >= 0; --i) {
        int sum = 0;

        for (int j = i+1; j <= n; j += i+1) {
            sum += b[j-1];
        }

        if (sum % 2 == a[i]) {
            b[i] = 0;
        } else {
            b[i] = 1;
        }
    }

    int sum = 0;

    for (int i = 0; i < n; ++i) {
        if (b[i] == 1) {
            ++sum;
        }
    }

    cout << sum << endl;
    for (int i = 0; i < n; ++i) {
        if (b[i] == 1) {
            cout << i + 1 << ' ';
        }
    }

    cout << endl;
}

Measured memory_bytes: 2432
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s;
    bool ansb = false;
    cin >>s;
    if(s[2]==s[3]){
        if(s[4]==s[5]){
            ansb = true;
        }
    }
    if(ansb){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 760
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    s = S()
    d = collections.defaultdict(int)
    for c in s:
        d[c] += 1

    if max(d.values()) == 1:
        return 'yes'
    return 'no'


print(main())


Measured memory_bytes: 5456
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int x=0,a=0,b=0;
  cin >> x >> a >> b;
  if(max(a,x)-min(a,x)<max(x,b)-min(x,b)){
    cout << "A" << endl;
  }else{
    cout << "B" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char a[101], b[101];
	int la, lb;
	scanf("%s", a);
	scanf("%s", b);
	la = strlen(a);
	lb = strlen(b);
	if(la>lb)
		printf("GREATER");
	else if(la<lb)
		printf("LESS");
	else
	{
		if(strcmp(a,b)==0)
			printf("EQUAL");
		else if(strcmp(a,b)<0)
			printf("LESS");
		else
			printf("GREATER");
	}
	return 0;
}

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

void mergeSort(int* list, int left, int right);

unsigned long count = 0;

int main() {
	int n, * a;
	scanf("%d", &n);
	a = (int*)malloc(n * sizeof(int));
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	
	mergeSort(a, 0, n);

	printf("%lld\n", count);
	return 0;
}

void mergeSort(int* list, int left, int right) {
	if (left + 1 < right) {
		int middle = (left + right) / 2;
		mergeSort(list, left, middle);
		mergeSort(list, middle, right);

		int nL = middle - left,
			nR = right - middle,
			*l = malloc((nL + 1) * sizeof(int)),
			*r = malloc((nR + 1) * sizeof(int));
		for (int i = 0; i < nL; i++)
			l[i] = list[left + i];
		for (int i = 0; i < nR; i++)
			r[i] = list[middle + i];
		l[nL] = INT_MAX, r[nR] = INT_MAX;
		int i = 0, j = 0;
		for (int k = left; k < right; k++)
			if (l[i] > r[j])
				list[k] = r[j++], count += nL - i;
			else
				list[k] = l[i++];
		free(l);
		free(r);
	}
}


Measured memory_bytes: 2988
S = input()
A = int(S[:2])
B = int(S[2:])
f_a = False
f_b = False
if A >= 1 and A <= 12:
  f_a = True
if B >= 1 and B <= 12:
  f_b = True
if f_a:
  if f_b:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if f_b:
    print('YYMM')
  else:
    print('NA')


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

#define NIL -1

typedef vector<int> Adj_list;
typedef vector<Adj_list> Adj_lists;
typedef vector<int> Group_ids;

void set_group_ids(const Adj_lists& adj_lists, Group_ids& group_ids){

  int id = -1;
  for(int i=0; i<adj_lists.size(); i++){
    if(group_ids.at(i) != NIL) continue;
    else id++;

    queue<int> q;
    q.push(i);

    while(!q.empty()){
      // visit top of queue
      const int& visit = q.front();
      const Adj_list& adj_list = adj_lists.at(visit);

      // push adjecent node which is not visited yet
      for(const int& adj : adj_list){
        if(group_ids.at(adj) == NIL){
          q.push(adj);
        }
      }

      group_ids.at(visit) = id;
      q.pop();
    }
  }
}

int main(){

  int n, m;
  scanf("%d %d", &n, &m);

  Adj_lists adj_lists(n);
  for(int i=0; i<m; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    adj_lists.at(a).push_back(b);
    adj_lists.at(b).push_back(a);
  }

  Group_ids group_ids(n+1, NIL);
  set_group_ids(adj_lists, group_ids);

  int q;
  scanf("%d", &q);
  for(int i=0; i<q; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    if(group_ids.at(a) == group_ids.at(b)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



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

using namespace std;

const int nax = 2e5+1;
const int off = 1e5;
vector<int> stones;

bool dp[nax];

int main(){
  dp[off+0]=1;
  int n,k;
  cin >> n >> k;
  int s;
  for(int i = 0; i < n; i++){
    cin >> s;
    stones.push_back(s);
  }
  for(int i = 1+off; i < nax; i++){
    dp[i] = 1;
    for(int j = 0; j < n; j++){
      if(dp[i-stones[j]]==1){
        dp[i] = 0;
        break;
      }
    }
  }
  if(dp[k+off]==0)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split()))
        adj[A].append(B)
        adj[B].append(A)

    # 2 ** n の事前計算
    pow_2 = [1 for _ in range(N + 1)]
    for i in range(1, N + 1):
        pow_2[i] = pow_2[i - 1] * 2 % MOD

    # 分子：sum_{i} (node i が穴あき度の値としてカウント対象になるような塗り方)
    # node_num[(node, dir_node)]: nodeから見てdir_node方向に存在するノードの数
    #         5               6
    #        (6)             (6)
    #         |               |
    #        (1)             (1)
    # 0(6)-(1)1(4)-(3)2(3)-(4)3(1)-(6)4
    node_num = defaultdict(int)

    def dfs(node=0, parent=None):
        child_list = [n for n in adj[node] if n != parent]
        if len(child_list) == 0:
            node_num[(node, parent)] = N - 1
            node_num[(parent, node)] = 1
            return 1
        n_descendant = 1  # self
        for child in child_list:
            n_descendant += dfs(child, node)
        if parent is not None:
            node_num[(node, parent)] = N - n_descendant
            node_num[(parent, node)] = n_descendant
        return n_descendant

    dfs()

    numer = 0
    for node in range(N):
        if len(adj[node]) <= 1:
            # 端（次数1）のノードはカウント対象にならない
            continue
        cnt_not = 0  # node が穴あき度の値としてカウントされないケース
        for dir_node in adj[node]:
            # dir_node方向のノードは自由、それ以外の方向のノードは全部白
            cnt_not += pow_2[node_num[(node, dir_node)]]
        cnt_not -= len(adj[node]) - 1  # 「全部白塗り」の重複カウントを除去
        numer += pow_2[N - 1] - cnt_not  # node自身は白でないとカウントされないので、全体のパターン数が2 ** (N-1)

    # 分母：2 ** N （全部の塗り方）
    denom = pow_2[N]

    # 答え
    print(numer * mod_inv(denom, MOD) % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 295712
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int N;
    cin>>N;
    ll h,n,w;
    for(h=1;h<=3500;++h)for(n=1;n<=3500;++n)if(4*h*n > N*(h+n)){
        if((N*n*h)%(4*h*n - N*(h+n)) == 0){w = (N*h*n)/(4*n*h - N*(h+n)); cout << h << " " << n << " " << w << endl;
                                           return 0;
                                          }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
const int maxn=1e6+2;
int p[maxn];
bool vis[maxn];
int prime[maxn];
int k;
void setprime()
{
    for(int i=2; i<=1e6; i++)
    {
        prime[++k]=i;
        if(!vis[i])
        {
            for(int j=i+i; j<=1e6; j+=i)
               vis[j]=1;
        }
    }

}
int getans(int x)
{
    int l=1,r=1e8;
    int ans=-1;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(mid*(mid+1)/2>=x){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    if(x==ans*(ans+1)/2) return ans;
    else return ans-1;
}
int main()
{
    setprime();
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    bool flag=0;
    ll m=n;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }
    if(!flag)
    {
        cout<<1<<endl;
        return 0;
    }
    for(int i=1;i<=k&&prime[i]<=n;i++){
        while(n%prime[i]==0){
            p[prime[i]]++;
            n/=prime[i];
        }
    }
    int ans=0;
    if(n!=1) ans++;
    for(int i=2;i<=1e6;i++)
        if(p[i])
          ans+=getans(p[i]);

   cout<<ans<<endl;
}


Measured memory_bytes: 8512
N = list(map(int,input().split()))
S = list(input())
for i in S:
    if i == "E":
        N[0],N[2],N[3],N[5] = N[3],N[0],N[5],N[2]
    elif i == "W":
        N[3],N[0],N[5],N[2] = N[0],N[2],N[3],N[5]
    elif i == "S":
        N[0],N[1],N[4],N[5] = N[4],N[0],N[5],N[1]
    else:
        N[4],N[0],N[5],N[1] = N[0],N[1],N[4],N[5]
print(N[0])


Measured memory_bytes: 5600
#include<iostream>

using namespace std;
#define rep(i,n) for(int i = 0; i<(int)(n);i++)
#define rep1(i,n) for(int i = 1; i<(int)(n); i++)

int main (void){

    int a,b;
    int flag = 0;
    int temp = 0; //check
    cin  >> a>>b;

    if((a+ b)>16){
        cout<<":(";
        return 0;
    }

    int array[16];

    rep(i,16){
        array[i] = 0;
    }

    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    int m = (a-b) * 2 - 1;

    if((16 -(a - b)) < m){
        
        cout<<":(";
        return 0;
    }

    int n = a+b;
   
    rep(i,n){
        if((i % 2) == 0 && a > 0){          //A
            array[i] = 1;
            if(array[i] == temp){
                flag = 1;
               // cout<<i <<"abreak"<<endl;
                break;
            }
            temp = array[i];
            a--;
            //cout<<"a:"<<a<<endl;

        }else if((i % 2 ) == 1 && b > 0){   //B
            array[i] = -1;
            if(array[i] == temp){
                flag = 1;    
               // cout<<i<< "bbreak"<<endl;
                break;
            }
            temp = array[i];
            b--;
          //  cout<<"b:"<<b<<endl;
        }else if((i % 2) == 1 && b <= 0){
            array[i] = 0;
            // cout<< "kittaa";
        }
        
    }
    if(flag == 1){
        cout << ":(";
    }else cout<<"Yay!";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   int ans = 0;
   f(i,k,n+2){
      ans += 1+n*(n+1)/2-(n-i)*(n-i+1)/2-(i-1)*i/2;
      ans %= MOD;
      // cout << ans << '\n';
      while(ans<0) ans += MOD;
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  for (int i=1; i<=5; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3560
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve();

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

void solve(){
    /* (´~`) */
    ll n;cin>>n;
    vl x1(n),y1(n),x2(n),y2(n);
    rep(i,n)cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];

    vl cx,cy;
    rep(i,n){
        cx.push_back(x1[i]);
        cx.push_back(x2[i]);
        cy.push_back(y1[i]);
        cy.push_back(y2[i]);
    }
    sort(all(cx));
    sort(all(cy));
    cx.erase(unique(all(cx)),cx.end());
    cy.erase(unique(all(cy)),cy.end());
    map<ll,ll> mx,my;
    rep(i,cx.size())mx[cx[i]]=i;
    rep(i,cy.size())my[cy[i]]=i;

    vvl dp(cx.size(),vl(cy.size()));
    rep(i,n){
        ++dp[mx[x1[i]]][my[y1[i]]];
        --dp[mx[x2[i]]][my[y1[i]]];
        --dp[mx[x1[i]]][my[y2[i]]];
        ++dp[mx[x2[i]]][my[y2[i]]];
    }
    rep(i,cx.size())rep(j,cy.size()-1)dp[i][j+1]+=dp[i][j];
    rep(i,cy.size())rep(j,cx.size()-1)dp[j+1][i]+=dp[j][i];

    ll ans=0;
    rep(i,cx.size())rep(j,cy.size()){
        if(dp[i][j])ans+=(cx[i+1]-cx[i])*(cy[j+1]-cy[j]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 128740
import java.util.*;
public class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int lastRank = sc.nextInt();
      int lastScore = sc.nextInt();
      for ( int i = 1; i < n; i++ ) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ( a > lastRank ) {
           lastRank = a;
           lastScore = b;
        }
      }
      System.out.println(lastRank + lastScore);
  }
}

Measured memory_bytes: 62444
H, W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
ans = [[0]*W for k in range(H)]
c = []

for k in range(N):
    c += [k+1]*a[k]
now = 0

for k in range(H):
    if k%2 == 0:
        for l in range(W):
            ans[k][l] = c[now]
            now += 1
    else:
        for l in range(W-1,-1,-1):
            ans[k][l] = c[now]
            now += 1
for e in ans:
    print(*e)


Measured memory_bytes: 42224
#include <iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<queue>
#include<unordered_set>
#include<algorithm>
#include<iomanip>
#include <set>
#define ll long long int
using namespace std;
const ll mod=1e9+7;
double pi=3.1415926535;

ll gcd(ll a,ll b){if(b == 0){return a;} return gcd(b, a % b);}
ll power(ll a,ll n){ll res=1;while(n){if(n%2){res=res*a;}n=n/2;a=a*a;}return res;}
bool checkprime(ll n){for(ll i=2;i*i<=n;i++){if(n%i==0){return false;}}return true;}
ll mpow(ll a,ll n){ll res=1;while(n){if(n%2){res=(res*a)%mod;}a=(a*a)%mod;n=n/2;}return res;}


void solve()
{
	int n;
	cin>>n;
	if(n>=30){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}
int main()
{
	
	ll t=1;
    //cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


	//for(int i=1;i<=ma;i++){cout<<dp[i]<<" ";if(dp[i]==1){cnt++;}}
	//cout<<endl;

Measured memory_bytes: 3628
s = input()
result = [0]*len(s)
r_end = 0
l_head = 1
i = 0
while i <len(s):
	r_count = 0
	l_count = 0
	while i<len(s) and s[i]=='R':
		i += 1
		r_count += 1
	r_end = i-1
	l_head = i
	while i<len(s) and s[i]=='L':
		i += 1
		l_count += 1
	result[r_end] += int(round(r_count/2+0.1))
	result[l_head] += r_count//2
	result[r_end] += l_count//2
	result[l_head] += int(round(l_count/2+0.1))
for i in range(len(s)):
	print(result[i],end=' ')

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string s;
    cin >>s;
    if(s[0]=='a'||s[0]=='i'||s[0]=='u'||s[0]=='e'||s[0]=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
	return 0;
}


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

int main()
{
	long long int length = 0, temp, n;
	while (cin >> n, n) {
		length = 0;
		priority_queue<long long int> pq;
		for (int i = 0; i < n; i++) {
			cin >> temp;
			length += temp;
		}
		for (int i = 0; i < n - 1; i++) {
			cin >> temp;
			pq.push(temp);
		}
		long long int max = length * n;
		while (n > 1) {
			length += pq.top();
			pq.pop();
			n--;
			if (max < length * n)
				max = length * n;
		}
		cout << max << endl;
	}
	return 0;
}

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

int main() {
    std::string s;
    std::cin >> s;

    int i = 0, s_len = s.length();
    while (i < s_len) {
        if (s[i] == ',') {
            s[i] = ' ';
        }
        i++;
    }

    std::cout << s << std::endl;

    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int n,k;
	cin>>n>>k;
	cin>>s;
	k--;
	s[k]=char(s[k]-'A'+'a');
	cout<<s<<endl;
}


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

int main(void){
    int a, b, c, max = 0;
    scanf("%d %d %d", &a, &b, &c);
    if(a>max) max = a;
    if(b>max) max = b;
    if(c>max) max = c;
    printf("%d", max*10+a+b+c-max);
}


Measured memory_bytes: 128
#ifndef DUAL_SEGMENT_TREE_HPP
#define DUAL_SEGMENT_TREE_HPP

#include <vector>
#include <cstdint>

//===
template<class Monoid>
struct DualSegmentTree {
    using T = typename Monoid::value_type;
    std::vector<T> lazy;

    DualSegmentTree() = default;
    explicit DualSegmentTree(uint32_t n):
        lazy(n << 1, Monoid::identity()) {};

    inline int size() {
        return (int)(lazy.size() >> 1);
    };
    
    inline void propagate(uint32_t k) {
        if (k >= size()) return;
        lazy[(k << 1) | 0] = Monoid::operation(lazy[(k << 1) | 0], lazy[k]);
        lazy[(k << 1) | 1] = Monoid::operation(lazy[(k << 1) | 1], lazy[k]);
        lazy[k] = Monoid::identity();
    };
    inline void push_down(uint32_t k) {
        for (uint32_t i = 31; i > 0; i--) propagate(k >> i);
    };
 
    // [l, r)
    void update(uint32_t l, uint32_t r, T op) {
        l += size();
        r += size();
        push_down(l);
        push_down(r - 1);
         
        while (l < r) {
            if (l & 1) lazy[l] = Monoid::operation(lazy[l], op), l++;
            if (r & 1) --r, lazy[r] = Monoid::operation(lazy[r], op);
 
            l >>= 1;
            r >>= 1;
        }
    };

    T get(uint32_t k) {
        k += size();
        push_down(k);
        return lazy[k];
    };
 
    T operator [] (uint32_t k) {
        return  get(k);
    };
};
//===

#endif

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include "bits/stdc++.h"
using i64 = long long;
using namespace std;

struct Monoid {
    using value_type = i64;

    static i64 operation(i64 a, i64 b) {
        if (b == 0) return a;
        return b;
    };
    static i64 identity() {
        return 0;
    };
};

int main() {
    i64 n, q;
    cin >> n >> q;
    i64 com, x;

    i64 ans = (n - 2) * (n - 2);
    DualSegmentTree<Monoid> r(n + 1);
    DualSegmentTree<Monoid> d(n + 1);
    r.update(0, n + 1, n);
    d.update(0, n + 1, n);

    repeat(i, q) {
        cin >> com >> x;

        if (com == 1) {
            int st = d[x];
            ans -= st - 2;

            if (r[0] >= x) {
                r.update(0, st + 1, x);
            }
        }
        else {
            int st = r[x];
            ans -= st - 2;

            if (d[0] >= x) {
                d.update(0, st + 1, x);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9588
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(2*n);
  for(auto &a:A)cin>>a;
  sort(ALL(A));
  ll ans=0;
  for(int i=0;i<2*n;i+=2)ans+=A[i];
  cout<<ans<<endl;
  return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		long cnt = 0;
		long w = 0;
		for(int i=N-1;i>=0;i--){
			if(S[i] == 'W'){
				w++;
			} else {
				cnt += w;
			}
		}
		Console.WriteLine(cnt);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11616
s=list(input())
count1=0
count2=0
for i in range(0,len(s),2):
    if s[i]==str(0):
        count1+=1
    if s[i]==str(1):
        count2+=1
for i in range(1,len(s),2):
    if s[i]==str(1):
        count1+=1
    if s[i]==str(0):
        count2+=1
print(min(count1,count2))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a1,a2,a3;
  int p;
  
   cin >> n;
   a1 = n / 100;
   a2 = ( n % 100 ) / 10;
   a3 = ( n % 10 );
   p = a1 + a2 + a3;
  
   cout << p << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	int nN;
	cin >> nN;
	long lnNDummy = nN * 100;
	long lnX = lnNDummy / 108;
	long lnXAmr = lnNDummy%108;

	if (0 == lnXAmr)
		cout << lnX;
	else
	{
		long lnCalc = (long)floor((lnX + 1)*1.08);
		if(nN == lnCalc)
			cout << lnX + 1;
		else
			cout << ":(";

	}
	return 0;
}


Measured memory_bytes: 256
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def a():
    a,b = mi()
    d,r = divmod(a,b)
    f = a/b
    print(f"{d} {r} {format(f,'.7f')}")

def resolve():
    a()

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 5632
def main():
    from math import ceil

    N, K = map(int, input().split())
    *A, = map(int, input().split())

    def binary_search(*, ok, ng, func):
        for _ in range(60):
            mid = (ok + ng) / 2
            if func(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def is_ok(mid):
        cnt = 0
        for x in A:
            q, r = divmod(x, mid)
            cnt += q
            if r == 0:
                cnt -= 1
        return cnt <= K

    ma = max(A)
    res = binary_search(ok=ma, ng=0, func=is_ok)

    print(ceil(res))


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  int x = 1, cnt = 0;
  while (x != 2) {
    x = a.at(x - 1);
    cnt++;
    if (cnt == 100001) {
      cout << - 1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(m):
  u,v=map(int,input().split())
  g[u-1].append(v-1)
  g[v-1].append(u-1)
for x in g[0]:
  for y in g[x]:
    if y==n-1:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')


Measured memory_bytes: 38320
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

ll dp[100100][3];

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    rep(i,N) cin >> A[i] >> B[i] >> C[i];
    // A -> 0, B -> 1, C -> 2
    for(int i=0;i<N;++i){
        dp[i+1][0] = max(dp[i+1][0],max(dp[i][1]+B[i],dp[i][2]+C[i])); 
        dp[i+1][1] = max(dp[i+1][1],max(dp[i][0]+A[i],dp[i][2]+C[i])); 
        dp[i+1][2] = max(dp[i+1][2],max(dp[i][0]+A[i],dp[i][1]+B[i])); 
    }

    cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stack>
#include <set>
using namespace std;

int main(void) {
    int L;cin>>L;
    set<int> cats; // 横穴に入った猫を保存
    stack<int> caves; // 横穴を表す
    for (int i = 1; i <= L; i++) {
        int c;cin>>c;
        if (c > 0) {
            // すでに入っているのに入ろうとしたらアウト
            if (cats.find(c) != cats.end()) {
                cout << i << endl;
                return 0;
            }
            cats.insert(c);
            caves.push(c);
        } else {
            int c_real = (-1) * c;//猫の番号

            if (cats.find(c_real) == cats.end()) {
                // そのような猫が横穴に入っていないのであればアウト
                cout << i << endl;
                return 0;
            }
            int last_cat = caves.top();
            // 出ようとした猫が横穴の出口にいなかったらアウト
            if (c_real != last_cat) {
                cout << i << endl;
                return 0;
            }
            set<int>::iterator it = cats.find(c_real);
            cats.erase(it);
            caves.pop();
        }
    }
    cout << "OK" << endl;

    return 0;
}


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

const int MaxN = 1000 + 5;

int N, T, A;
int H[MaxN];
int t[MaxN];

void init() {
    scanf("%d %d %d", &N, &T, &A); A *= 1000;
    for (int i = 1; i <= N; ++i) scanf("%d", &H[i]);
}

void solve() {
    for (int i = 1; i <= N; ++i)
        t[i] = 1000 * T - 6 * H[i];

    int ansi = 1;
    for (int i = 2; i <= N; ++i)
        if (abs(A - t[i]) < abs(A - t[ansi])) ansi = i;
    cout << ansi << endl;
}

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

Measured memory_bytes: 256
program equilateral
  implicit none
  integer :: h, w, a(0:600,0:600) = 0, i, j, k, d
  integer :: x(0:600,0:600) = 0, y(0:600,0:600) = 0
  integer(8) :: ans = 0_8
  character(300) :: s
  read(*,*) h, w
  do i = 1, h
    read(*,*) s
    s = trim(adjustl(s))
    do j = 1, w
      if (s(j:j) == "#") a(i+j-1,i-j+w) = 1
    end do
  end do
  do i = 1, h+w
    do j = 1, h+w
      x(i,j) = x(i,j-1)+a(i,j)
      y(i,j) = y(i-1,j)+a(i,j)
    end do
  end do
  do i = 0, h+w
    do j = 0, h+w
      do k = j+1, h+w
        d = k-j
        if (a(i,j)*a(i,k) == 1) then
          if (i-d >= 0) ans = ans+int(x(i-d,k)-x(i-d,j-1)-a(i-d,k)-a(i-d,j),8)
          if (i+d <= h+w) ans = ans+int(x(i+d,k)-x(i+d,j-1)-a(i+d,k)-a(i+d,j),8)
        end if
        if (a(j,i)*a(k,i) == 1) then
          if (i-d >= 0) ans = ans+int(y(k,i-d)-y(j-1,i-d),8)
          if (i+d <= h+w) ans = ans+int(y(k,i+d)-y(j-1,i+d),8)
        end if
      end do
    end do
  end do
  write(*,'(i0)') ans
  stop
end program equilateral

Measured memory_bytes: 4480
def gcd(x,y):
  if x<y: x,y=y,x
  while True:
    tmp=x%y
    if tmp==0:
      return y
    x,y=y,tmp

K=int(input())
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    tmp=gcd(b,a)
    for c in range(1,K+1):
      ans+=gcd(c,tmp)
print(ans)

Measured memory_bytes: 9140
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    for (int i = 1; i <= 5; ++i)
    {
        int xi; cin >> xi;
        if (xi == 0)
        {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 3580
N = int(input())
A = [int(i) for i in input().split()]


def gcd(a: int, b: int) -> int:
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


L = [0] * N
R = [0] * N
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i-1])
    R[N-i-1] = gcd(R[N-i], A[N-i])

for i in range(N):
    if i == 0:
        ans = R[i]
    elif i == N-1:
        ans = max(ans, L[i])
    else:
        ans = max(ans, gcd(L[i], R[i]))

print(ans)


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

int main() {
  int N; int K;
  cin >> N >> K;
  
int dev; int extr;
dev = (N - 1) / (K -  1);
extr = (N - 1) % (K -  1);

  int ans;
if(extr == 0) ans = dev;
else ans = dev + 1;

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

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc027/tasks/agc027_b
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// fn range_cost(l: usize, r: usize, sum: &Vec<Vec<u64>>) -> u64 {
//     let s = sum[1][r] - sum[1][l];
//     let t = sum[0][r] - sum[0][l];
//     s - t * l as u64 * 2
// }

fn main() {
    input! {
        n: usize, t: u64,
        x: [u64; n]
    };

    let mut sum = vec![0; n + 1];
    for i in 1..n + 1 {
        let s0 = sum[i - 1];
        sum[i] = s0 + x[i - 1];
    }

    let mut ans = 1e18 as u64;
    let base_cost = sum[n] * 5 + t * (n as u64);

    for cur in 1..n + 1 {
        if cur * 2 > n {
            let mut cost = cur as u64 * t;
            ans = min(ans, cost);
            break;
        }
        let left = n - cur * 2;

        let dan = left / cur;
        let par = left % cur;

        assert!(par + dan * cur == left);

        let mut cost = 0;
        if par >= 1 {
            cost += (2 * (dan + 1)) as u64 * sum[par];
        }
        for d in 0..dan {
            let l = par + cur * d;
            let r = par + cur * (d + 1);
            cost += (2 * (dan - d)) as u64 * (sum[r] - sum[l]);
        }
        cost += cur as u64 * t;
        ans = min(ans, cost);
    }
    ans += base_cost;
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;


int main(){
	map<char,vector<int> > ma;
	string s,t;
	cin >> s >> t;
	
	for(int i=0;i<s.size();++i){
		if(ma.find(s[i]) == ma.end()){
			vector<int> v;
			v.push_back(i+1);
			ma[s[i]] = v;
//			cout << "not find" <<endl;
		}else{
			ma[s[i]].push_back(i+1);
//			cout << "find" <<endl;
		}
	}
	
	map<char,vector<int> >::iterator it = ma.begin();
	while(it != ma.end()){
		sort(it->second.begin(),it->second.end());
//		cout << it->second.size() << endl;
/*		cout << it->first <<" : ";
		for(int i=0;i<it->second.size();++i){
			cout << " " << it->second[i] ;
		}cout << endl;*/
		it++;
	}
	
	ll res = -1;
	ll count = 0;
	ll cp = -1;
	for(int i=0;i<t.size();++i){
		char c = t[i];
		if(ma.find(c) == ma.end()){
			res = -1;
			break;
		}
		vector<int>::iterator it = upper_bound(ma[c].begin(),ma[c].end(),cp);
		if(it != ma[c].end()){
			cp = *it;
		}else{
			cp = ma[c][0];
			count++;
		}
//		cout << count  << " " << s.size() << " " << cp << endl;
		res = count*s.size() + cp;
	}
	
	cout << res << endl;
	
	
	return 0;
}



Measured memory_bytes: 1216
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int mod=1e9+7;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

const int N=400+10;

int n,c,a[N],b[N];
int sum[N][N],dp[N][N];

int main() {
    n=read(),c=read(); int mx=0;
    for (re int i=1;i<=n;++i) a[i]=read(),mx=max(mx,a[i]);
    for (re int i=1;i<=n;++i) b[i]=read(),mx=max(mx,b[i]);
    for (re int i=0;i<=c;++i)
        for (re int j=1;j<=mx;++j)
            sum[i][j]=(sum[i][j-1]+qpow(j,i))%mod;
    dp[0][0]=1;
    for (re int i=1;i<=n;++i)
        for (re int j=0;j<=c;++j)
            for (re int k=0;k<=j;++k)
                dp[i][j]=(dp[i][j]+1ll*dp[i-1][j-k]*(sum[k][b[i]]-sum[k][a[i]-1]+mod)%mod)%mod;
    printf("%d\n",dp[n][c]);
    return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>

int main() {
    int N, K;
    std::cin >> N >> K;
    int min = std::min(N, K - 1);
    double ans = 0.0;
    for (int i = 1; i <= min; ++i) {
        int j = i;
        double power = 1;
        while (j < K) {
            j *= 2;
            power *= 2;
        }
        ans += 1 / power;
    }
    if (K <= N) {
        ans += N - K + 1;
    }
    ans /= N;
    std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int amari = (X - A) % B;
		System.out.println(amari);
	}

}


Measured memory_bytes: 21844