akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  cout<<ngcd(a)<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >>x;
    cout <<1-x;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
// #define int long long
#define pb push_back
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

int A;
int B;




signed main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);


    scanf("%d", &A);
    scanf("%d", &B);

    printf("%d\n", (A+B<24)?A+B:A+B-24);

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int b[n-1];
  for ( int i = 0; i < n-1; i++ ) {
    cin >> b[i];
  }

  int ans = b[0]+b[n-2];
  for ( int i = 0; i < n-2; i++ ) {
    ans += min(b[i], b[i+1]);
  }

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


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		try {
			String[] tmp = scanner.nextLine().split(" ");
			int[] line = Stream.of(tmp).mapToInt(Integer::parseInt).toArray();
			int correctNum = line[0];
			int correctYen = line[1];

			for (int x = 0; x <= correctNum; x++) {
				for (int y = 0; y <= correctNum - x; y++) {
					int z = correctNum - (x + y);

					int sumYen = 10000 * x + 5000 * y + 1000 * z;
					if (sumYen == correctYen) {
						int num = x + y + z;
						if (correctNum == num) {
							System.out.print(String.valueOf(x) + " " + String.valueOf(y) + " " + String.valueOf(z));
							return;
						}
					}
				}
			}
			System.out.print("-1 -1 -1");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			scanner.close();
		}
	}
}


Measured memory_bytes: 28236
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

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


int main(){
    ll A, B, C;
    ll K;
    cin >> A >> B >> C;
    cin >> K;

    ll need = 0;
    while(B <= A){
        B *= 2;
        need++;
    }
    while(C <= B){
        C *= 2;
        need++;
    }

    if(need <= K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
n, m = map(int,input().split())
h = list(map(int,input().split()))
neighbor = [[0] for _ in range(n)]
good = 0

for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    neighbor[a].append(h[b])
    neighbor[b].append(h[a])

for i in range(n):
    my_height = h[i]
    neighbor_height = neighbor[i]
    if all(my_height > x for x in neighbor_height):
        good += 1

print(good)

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

//Compiler version g++ 6.3.0

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.length()<=n){
      cout << s << "\n";
    } else {
      cout << s.substr(0,n) << "...\n";
    }
    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, N, K);
    i64 ans = 0;
    rep(i, N) {
        var(int, h);
        ans += (h >= K ? 1 : 0);
    }
    outl(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
const int N = 200'000;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> adj(N);
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(N / 2 + y);
        adj[N / 2 + y].push_back(x);
    }
    vector<bool> vis(N);
    ll visL = 0, visR = 0, ecount = 0;
    function<void(int)> dfs = [&](int u) {
        vis[u] = true;
        (u < N / 2 ? visL : visR)++;
        ecount += adj[u].size();
        for(int v : adj[u]) {
            if(not vis[v]) {
                dfs(v);
            }
        }
    };
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        if(not vis[i]) {
            visL = 0, visR = 0, ecount = 0;
            dfs(i);
            if(visL >= 2 and visR >= 2) {
                ans += visL * visR - ecount / 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;

int main() {
  map<ii, ll> cc;
  ll h, w, n;
  cin >> h >> w >> n;
  for (int i = 0; i < n; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    for (int j = -2; j <= 0; j++) {
      for (int k = -2; k <= 0; k++) {
        if (a+j >= 0 && b+k >= 0 && a+j+2 < h && b+k+2 < w) {
          cc[ii(a+j, b+k)]++;
        }
      }
    }
  }
  ll count[10]; memset(count, 0, sizeof count);
  ll sum = 0;
  for (const auto &kv : cc) {
    count[kv.second]++;
    sum++;
  }
  count[0] = (h-3+1)*(w-3+1)-sum;
  for (int i = 0; i < 10; i++) {
    cout << count[i] << endl;
  }
}


Measured memory_bytes: 56448
#include <iostream>

using namespace std;

const int MAX_A = 100000;
int COUNT[MAX_A] = {0};

int main() {
    int n;
    int a;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == 0) {
            COUNT[a]++;
            COUNT[a + 1]++;
        }
        else {
            COUNT[a - 1]++;
            COUNT[a]++;
            COUNT[a + 1]++;        
        }
    }

    int max = 0;
    
    for (int i = 0; i < MAX_A; i++) {
        if (COUNT[i] > max) {
            max = COUNT[i];
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 640
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int n, k, ans = 0;
    
    cin >> n >> k;
    
    int i = 0;
    while(1)
    {
        if((int)(n / pow(k, i)) == 0)
        {
            ans = i;
            break;
        }
        
        i++;
        
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import networkx as nx

N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
maxA = max([max(A[i]) for i in range(N)])

G = nx.DiGraph()
G.add_node('source',demand=-K*N)
G.add_node('sink',demand=K*N)
G.add_edge('source','sink',weight=maxA, capacity=K*N)
for i in range(N):
  for j in range(N):
    G.add_edge(i,N+j,weight=maxA-A[i][j],capacity=1)
    
for i in range(N):
  G.add_edge('source',i,weight=0,capacity=K)
  G.add_edge(N+i,'sink',weight=0,capacity=K)
  
flowCost,flowDict = nx.network_simplex(G)
ans=[['.']*N for _ in range(N)]
for i in flowDict.keys():
  if i in ('source','sink'):continue
  for j in flowDict[i].keys():
    if j in ('source','sink'):continue
    if flowDict[i][j]:
      ans[i][j-N] = 'X'

print(maxA*K*N-flowCost)
for i in range(N):
  print(''.join(ans[i]))

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

int main()
{
	vector<vector<char>> vec(3, vector<char>(3));
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> vec.at(i).at(j);
		}
	}
	for (int i = 0; i < 3; i++)
	{
		cout << vec.at(i).at(i);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll A, ll B) {
  int H = 100, W = 100;
  vector<string> res(H, string(W, '.'));
  REP(i,H/2) REP(j,W) res[i][j] = '#';
  REP(i,H/4) REP(j,W/2) {
    if (A > 1) { res[i * 2][j * 2] = '.'; --A; }
    if (B > 1) { res[H - 1 - i * 2][j * 2] = '#'; --B; }
  }
  cout << H << " " << W << endl;
  REP(i,H) cout << res[i] << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll B;
	ll A;
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		double mountain = 0;
		double max =0;
		double min= 1000000;

		while (stdin.hasNext()){
			mountain = stdin.nextDouble();
			if(max < mountain) {
				max = mountain;
			} if (min > mountain) {
				min = mountain;
			}
		}
		System.out.println(max - min);

	}

}

Measured memory_bytes: 27512
#include<stdio.h>

int main(){
    int i,x,y,tmp;
    for(i=0;i<3000;i++){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0) break;
        else if(x<y)printf("%d %d\n",x,y);
        else printf("%d %d\n",y,x);
            }
    return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t> list;
    int64_t keta = 0, tmp = 26, NN = N;
    while (NN > 0)
    {
        NN -= tmp;
        keta++, tmp *= 26;
    }
    int keta2 = keta;
    keta--;
    while (keta >= 0)
    {
        N -= pow(26, keta);
        keta--;
    }
    while (N != 0)
    {
        list.push_back(N % 26);
        N /= 26;
    }
    list.resize(keta2);
    reverse(list.begin(), list.end());
    for (auto x : list)
    {
        cout << (char)('a' + x);
    }
}

Measured memory_bytes: 4104
#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[i];
    }
    int ans = 1000000000;
    for(int i = 0; i < N; i++){
        int cnt = 0;
        while(A[i] >= 0){
            if(A[i] % 2 != 0) break;
            A[i] /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

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

namespace ABC102_B_Maximum_Difference
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] a = Console.ReadLine().Split(' ');
			
			List<int> aArr = new List<int>();
			for (int i = 0; i < n; i++) {
				aArr.Add(int.Parse(a[i]));
			}
			
			Console.WriteLine(aArr.Max() - aArr.Min());
		}
	}
}

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N / 1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - (n1 * 1000 + n2 * 100)) / 10;
  n4 = (N - (n1 * 1000 + n2 * 100 + n3 * 10));
  if (((n1 == n2) && (n2 == n3)) || ((n2 == n3) && (n3 == n4))){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  //cout << n1 << n2 << n3 << n4 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double sumKakuritsu = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= k) {
                sumKakuritsu += (double)1 / n;
                continue;
            }
            int num = i;
            int jou = 0;
            while (num < k) {
                num *= 2;
                jou++;
            }
            
            sumKakuritsu += ((double)1 / n) * Math.pow(0.5,jou);
        }
        
        System.out.println(sumKakuritsu);
    }
}

Measured memory_bytes: 21588
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int ans = Long.toString(a).length();
        for(long i=1; i*i<=a; i++) {
            if(a%i ==0 ) {
                int length = Long.toString(a/i).length();
                if(ans > length) {
                    ans = length;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
    string s;
    cin >> s;
    if((s[0] == 'A' && s[1] == 'A' && s[2] == 'A') || (s[0] == 'B' &&
                                                       s[1] == 'B' &&
                                                       s[2] == 'B'))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  unordered_map<int,int> map;
  rep(i, N) {
    int a; cin >> a;
    map[a]++;
  }
  
  vector<int> vec(0);
  for(auto p : map) vec.push_back(p.second);
  
  sort(all(vec));
  
  int S = vec.size();
  int ans = 0;
  int i = 0;
  while(S > K) {
    ans += vec[i];
    i++;
    S--;
  }
  cout << ans << endl;
  

}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,a,b;
string s[111];
void init() {
  a=b=0;
  for(int i=0; i<n; i++) {
    s[i]="";
    for(int j=0; j<x; j++) {
      if(j) for(int k=0; k<y; k++) s[i]+='.';
      for(int k=0; k<m; k++) s[i]+='.';
    }
  }
}
 
void print() {
  for(int i=0; i<n; i++) cout << s[i] << endl;
  cout << "#" << endl;
}
 
void next() {
  a++;
  if(a==n) {
    a=0;
    b++;
  }
  if(b==x) {
    print();
    init();
  }
}
 
int main() {
  while(cin >> n && n) {
    cin >> x >> m >> y;
    string t;
    getline(cin,t);
    init();
    while(getline(cin,t)) {
      if(t=="?") {
        if(a||b) print();
        cout << t << endl;
        break;
      }
      int k=0;
      for(int i=0; i<t.size(); i++) {
        s[a][b*(m+y)+k]=t[i];
        k++;
        if(k==m) {
          k=0;
          next();
        }
      }
      if(k||t=="") next();
    }
  }
  return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>
int gcd(int x,int y){if(!y) return x;return gcd(y,x%y);}
main(){
    int k;long long ans=0;scanf("%d",&k);for(int a=1;a<=k;a++) for(int b=1;b<=k;b++) for(int c=1;c<=k;c++) ans+=gcd(a,gcd(b,c));
    return printf("%lld\n",ans),0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int r;
  cin>>r;
  cout<<r*r<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,a,n,b=0;
  cin>>h>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    b+=a;
  }
  if(h<=b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
a, b, c, d = map(int, input())
if a + b + c + d == 7:
    print(a, "+", b, "+", c, "+", d, "=", 7, sep="")
elif a + b + c - d == 7:
    print(a, "+", b, "+", c, "-", d, "=", 7, sep="")
elif a + b - c + d == 7:
    print(a, "+", b, "-", c, "+", d, "=", 7, sep="")
elif a + b - c - d == 7:
    print(a, "+", b, "-", c, "-", d, "=", 7, sep="")
elif a - b + c + d == 7:
    print(a, "-", b, "+", c, "+", d, "=", 7, sep="")
elif a - b + c - d == 7:
    print(a, "-", b, "+", c, "-", d, "=", 7, sep="")
elif a - b - c + d == 7:
    print(a, "-", b, "-", c, "+", d, "=", 7, sep="")
elif a - b - c - d == 7:
    print(a, "-", b, "-", c, "-", d, "=", 7, sep="")

Measured memory_bytes: 3064
H, W = list(map(int, input().split()))
n1 = None
n2 = None
if W % 2 == 0:
    n1 = W // 2
    n2 = n1
else:
    n1 = W // 2 + 1
    n2 = n1 - 1
o1 = None
o2 = None
if H % 2 == 0:
    o1 = H // 2
    o2 = H // 2
else:
    o1 = H // 2 + 1
    o2 = H // 2
if min(H, W) > 1:
    print(n1 * o1 + n2 * o2)
else:
    print(1)

Measured memory_bytes: 38256
X=int(input())
MAX,MIN=0,0
diff=0
while diff<=10**9:
    MAX+=1
    diff=MAX**5-(MAX-1)**5
diff=0
while diff<=10**9:
    MIN-=1
    diff=MIN**5-(MIN-1)**5
for A in range(MIN,MAX):
    for B in range(MIN,MAX):
        if A**5-B**5==X:
            print(A,B)
            exit()

Measured memory_bytes: 9180
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u)
{
    for (int v = nt[u]; v < n; v++)
    {
        nt[u] = v + 1;
        if (M[u][v])
            return v;
    }
    return -1;
}

void dfs_visit(int r)
{
    for (int i = 0; i < n; i++)
        nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (!S.empty())
    {
        int u = S.top();
        int v = next(u);
        if (v != -1)
        {
            if (color[v] == WHITE)
            {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else
        {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs()
{
    for (int i = 0; i < n; i++)
    {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int u = 0; u < n; u++)
    {
        if (color[u] == WHITE)
            dfs_visit(u);
    }
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main()
{
    int u, k, v;

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

    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long

using namespace std;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool)*this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t)v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { ll x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned)1e9 + 7>;
V<Mint> fact, ifact, inv, powB;
void init(int n, int B = 2) {
  fact.resize(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = i * fact[i - 1];
  }
  ifact.resize(n + 1);
  ifact[n] = 1 / fact[n];
  for (int i = n; i > 0; --i) {
    ifact[i - 1] = i * ifact[i];
  }
  inv.resize(n + 1);
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    int q = Mint::p() / i;
    inv[i] = -q * inv[Mint::p() - i * q];
  }
  powB.resize(n + 1);
  powB[0] = 1;
  for (int i = 0; i < n; ++i) {
    powB[i + 1] = powB[i] * B;
  }
}
Mint comb(int n, int r) {
  if (r < 0 or r > n) return 0;
  return fact[n] * ifact[r] * ifact[n - r];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;
  std::cin >> N >> K;
  init(N);
  for (size_t i = 1; i < K+1; i++) {
    Mint ans = comb(N - K + 1, i) * comb(K - 1, i - 1);
    std::cout << ans << '\n';
  }

  return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define time 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int N=16;
ll dpx[N][1<<N],dpy[N][1<<N];
ll x[N],y[N],p[N];

ll ans[N];
int n;

int runtimeTerror()
{
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>x[i]>>y[i]>>p[i];
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<(1<<n);++j)
		{
			dpx[i][j]=p[i]*abs(x[i]);
			for(int k=0;k<n;++k)
			{
				if(j&(1<<k))
					amin(dpx[i][j],p[i]*abs(x[i]-x[k]));
			}
		}
	}
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<(1<<n);++j)
		{
			dpy[i][j]=p[i]*abs(y[i]);
			for(int k=0;k<n;++k)
			{
				if(j&(1<<k))
					amin(dpy[i][j],p[i]*abs(y[i]-y[k]));
			}
		}
	}
	for(int i=0;i<n;++i)
		ans[i]=1e18;
	for(int i=0;i<(1<<n);++i)
	{
		for(int mask=i;;mask=(mask-1)&i)
		{	
			ll val=0;
			int mask2=(~mask)&i;
			for(int j=0;j<n;++j)
			{
				val+=min(dpx[j][mask],dpy[j][mask2]);
			}
			amin(ans[popcount(i)],val);
			if(mask==0)
				break;
		}
	}
	for(int i=0;i<=n;++i)
		cout<<ans[i]<<"\n";
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		runtimeTerror();
	return 0;
}

Measured memory_bytes: 11436
(function main() {
  let line = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('');
  // 初めの上昇と平坦を除去
  while (line.length > 0 && line[0] !== '\\') line.shift();
  // 終わりの下降と平坦を除去
  while (line.length > 0 && line[line.length - 1] !== '/') line.pop();

  let height_list = [0];
  let current_height = 0;
  line.forEach(function(e, i){
      if (e === '\\') current_height -= 1
      else if (e === '/') current_height += 1
      height_list.push(current_height);
  });

  let h, sum = 0;
  let holes = [];
  for (;height_list.length > 1;) {
    if (h = makeHole(height_list)) {
      sum += h;
      holes.push(h);
    }
  }

  console.log(sum);
  console.log(holes.length && holes.length + ' ' + holes.join(' '));
})();

function makeHole(list) {
    begin = list.shift();
    if (list[0] < begin && begin <= list.reduce((a, b) => Math.max(a, b), -100000)) {
    let area = 0;
      while (!(list.length === 0 || begin <= list[0])) area += begin - list.shift();
      return area;
    }
    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> vec(m);
  rep(i,m) {
    cin >> vec.at(i).first >> vec.at(i).second;
  }
  int l = 0;
  int r = 100001;
  rep(i,m) {
    l = max(l, vec.at(i).first);
    r = min(r, vec.at(i).second);
  }
  cout << max(r-l+1,0) << endl;
  return 0;
}

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

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

	bool ok = false;
	for (int num1 = 1; num1 < 10; num1++) {
		for (int num2 = 1; num2 < 10; num2++) {
			if (num1 * num2 == n)ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;


// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}


LL fact(int a)
{
    LL f = 1;
    for (int i = 1; i <= a; ++i) {
        f = (f * i) % MOD;
    }
    return f;
}

int choose(int a, int b) 
{
    LL fa = fact(a);
    LL i1 = modinv(fact(b), MOD);
    LL i2 = modinv(fact(a-b), MOD);
    return (fa * i1 % MOD) * i2 % MOD;
}

int main()
{
    LL N, M, K;
    cin >> N >> M >> K;
    
    LL dxSum = 0;
    for (int dx = 1; dx < M; ++dx) {
        dxSum = (dxSum + dx * (M-dx)) % MOD; 
    }
    dxSum = dxSum * (N * N % MOD) % MOD;

    LL dySum = 0;
    for (int dy = 1; dy < N; ++dy) {
        dySum = (dySum + dy * (N-dy)) % MOD; 
    }
    dySum = dySum * (M * M % MOD) % MOD;

    LL ans = choose(N*M-2, K-2) * ((dxSum + dySum) % MOD) % MOD;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    s = 'S' + s + 'S'
    cnt = 0
    tmp = 0
    for i in s:
        if i == 'S':
            cnt = max(cnt, tmp)
            tmp = 0
        else:
            tmp += 1
    print(cnt)


main()


Measured memory_bytes: 9956
from collections import deque
n=int(input())
a=list(map(int,input().split()))
head=False
d = deque()
for i in range(n):
    if head==True:
        d.appendleft(a[i])
    else:
        d.append(a[i])
    head = not head
if head==True:
    d=list(d)
    print(*d[::-1])
else:
    print(*d)

Measured memory_bytes: 25412
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	M = v.back();
	v.pop_back();
	if (accumulate(v.begin(), v.end(), 0LL) > M) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
for i in range(N + 1):
    for j in range(N + 1- i):
        if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
            print(i, j, N - i - j)
            exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
N = int(input())



if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9 :
    print("hon")

elif N%10==0 or N%10==1 or N%10==6 or N%10==8 :
    print("pon")
    
else:
    print("bon")

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

int ar[10004];

int main()
{
  int n, x, y, ans=0, c=0, i, k, res=1e7, mx=0;
   cin>>n;

   for(i=0; i<n; i++)
   {
    cin>>ar[i];
    c+=ar[i];
    mx=max(mx,ar[i]);
   }
   int mid=ceil(c/n);
  for(int j=mid; j<=mx; j++)
  {
    ans=0;
   for(i=0; i<n; i++)
   {
    ans+=abs((j-ar[i])*(j-ar[i]));
   }
   res=min(res,ans);
  }

   cout<<res<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
    
root=[int(i) for i in range(n)] 
rank=[0]*n    
def find(x):
    if root[x]==x:
        return x 
    else:
        return find(root[x])

for i in range(m):
    x,y,z=map(int,input().split())
    fx=find(x-1)
    fy=find(y-1)
    if rank[fx]>=rank[fy]:
        root[fy]=fx
        if rank[fx]==rank[fy]:
            rank[fx]+=1
    else:
        root[fx]=fy 
a=[]
for i in range(n):
    a.append(find(i)) 
print(len(set(a)))

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

  char s;
  cin>>s;
  if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
  }


  


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=998244353;

int fun(int n){
    int c=0;
    int x=1;
    while(n>=x){
        n-=x;
        c++;
        x++;
    }
    return c;
}
void solve(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
        return;
    }
    int ans=0;
    for(ll i=2;i*i<=n;i++){
        int c=0;
        while(n%i==0){
            c++;
            n/=i;
        }
        ans+=fun(c);
    }
    if(n>1)
    ans++;
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3652
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

if sum(a)<sum(b):
    print(-1)
    exit()

c=[0]*n
for i in range(n):
    c[i] = a[i] - b[i]
c.sort()

num = 0
l = 0
r = n-1
while(c[l]<0):
    num += c[l]
    l += 1
    if num < 0:
        num+= c[r]
        r -= 1

print(n-1 - r + 1 + l + 1 - 2)


Measured memory_bytes: 18620
#include <bits/stdc++.h>
#define DIM 1007
#define INF 1000000000000000007LL
#define modulo 1000000007
using namespace std;

long long n,m,d[DIM][DIM];
char a[DIM][DIM];

int main()
{
    cin>>n>>m;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            cin>>a[i][j];

    d[0][1] = 1;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(a[i][j] == '.')
                d[i][j] = (d[i-1][j] + d[i][j-1])%modulo;

    cout<<d[n][m];
    return 0;
}


Measured memory_bytes: 9088
fun main(args: Array<String>) {

    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.split("").toTypedArray()

    s.forEachIndexed { index, c ->
        if (index == k) print(c.toLowerCase()) else print(c)
    }
}


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

template<typename T>
map<T, int> prime_factorize(T n) {
    T tmp = n;
    map<T, int> mp;
    for (T i = 2; i * i <= n; ++i) {
        ll cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt) mp[i] = cnt;
    }
    if (tmp != 1) mp[tmp] = 1;
    return mp;
}

void solve() {

  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  /*
  int n = 10000;
  vector<int> a(n);
  rep(i, n) a[i] = 1000000 - i;
  */
  map<int, int> mp;
  vector<ll> x2(n, 1);
  rep(i, n) {
    auto mp2 = prime_factorize(a[i]);
    for (auto e : mp2) {
      chmax(mp[e.F], e.S);
      (x2[i] *= modpow(e.F, e.S, mod) % mod) %= mod;
    }
  }
  // for (auto e : mp) cout << e.F << " " << e.S << endl;
  // cout << sz(mp) << endl;

  ll x = 1;
  for (auto e : mp) {
    (x *= modpow(e.F, e.S, mod)) %= mod;
  }

  int ans = 0;
  rep(i, n) {
    // x/x2i
    ll tmp = x * modpow(x2[i], mod - 2, mod) % mod;
    add(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int k=s.nextInt();
		
		int l=s.nextInt();
		int r=s.nextInt();
		
		int p=0;
		
		for(int i=k;i<=r;i=i+k)
		{
			if(i>=l&&i<=r)
			{
				p=1;
				break;
			}
		}
		
		if(p==1)
		{
			System.out.println("OK");
		}
		else
		{
			System.out.println("NG");
		}
		
	}
	
}

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


void solve(long long K){
    auto c = vector<string>();

    for (char i = '1'; i <= '9'; i++) {
        string t{i};
        c.push_back(t);
    }

    int start = 0;
    int end = 9;
    int t_count = 0;
    while (1) {
        t_count = 0;
        for (int j = start; j < end; j++) {
            for (char i = '0'; i <= '9'; i++) {
                string m = c[j];
                if (abs(m[m.size()-1] - i) <= 1) {
                    m.append(1, i);
                    c.push_back(m);
                    t_count++;
                }
            }
        }
        if (c.size() >= 100000) {
            break;
        }
        start = end;
        end = start + t_count;
    }

    // for (int i = 10; i < 100; i++) {
    //     cout << c[i] << endl;
    // }

    cout << c[K-1] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 13936
import math

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

MOD = 10 ** 9 + 7

def comb(n, r):
	f = math.factorial
	return f(n) // (f(n - r) * f(r))

for k in range(1, K + 1):
	if N - K + 1 < k:
		print(0)
		continue
	print(comb(K - 1, k - 1) * comb(N - K + 1, k) % MOD)


Measured memory_bytes: 3316
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> usd(n, 0);
    for(int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        while(d--) {
            int x;
            cin >> x;
            x--;
            usd[x] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(!usd[i]) ans++;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3164
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P){
    int i = 0;
    for(int j=0;j<k;j++){
        llong s = 0;
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000*10000;
    llong mid;
    while(right-left>1){
        mid=(left+right)/2;
        int v = check(mid); 
        if(v>=n) right=mid;
        else left = mid;
    }
    
    return right;
}

main(){
    cin>>n>>k;
    for(int i = 0;i<n;i++) cin>>T[i];
    llong ans = solve();
    cout<<ans<<endl;
}


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

bool IsPrime(int n)
{
  for(int j=2; j*j<=n; j++)
  {
    if(n%j == 0)
    {
      return false;
    }
  }
      return true;
}


int main(void)
{
  int n, i, a, j=0;

  cin >> n;
  for(i=0; i<n; i++)
  {
    cin >> a;
    
    if(IsPrime(a))
    { 
      j++;
    }
   }

   cout << j << endl;
   return 0;
}



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

int main()
{
	int a, b;
	bool x = true, y = false;
	
	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0){
			break;
		}
		if (y){
			printf("\n");
		}
		y = true;
		
		for (int i = a; i <= b; i++){
			if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0){
				printf("%d\n", i);
				x = false;
			}
		}
		if (x == true){
			printf("NA\n");
		}
		x = true;
	}
	
	return (0);
}

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

int main() {
	char a, b;
	cin >> a >> b;

	if (a == 'H')
		cout << b << endl;

	else {
		if (b == 'H')
			cout << "D" << endl;

		else
			cout << "H" << endl;
	}
}


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

int main(void){
	char s[101];
	int n;
	int i;
	int f;

	scanf("%s",s);
	n = strlen(s);

	f=0;
	for(i=0;i<n;i++){
		if(i%2==0){
			if(s[i] == 'L'){
				f = 1;
			}
		}else{
			if(s[i] == 'R'){
				f = 1;
			}

		}
	}

	if(f == 1){
		printf("No\n");
	}else{
		printf("Yes\n");
	}



	return 0;
}




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

using namespace std;

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

  string s, t;
  cin >> s >> t;

  string ans = "No";
  for (unsigned int i = 0; i < s.size(); ++i) {
    // cerr << s << '\n';
    if (s == t) {
      ans = "Yes";
      break;
    }
    s = s.back() + s.substr(0, s.size() - 1);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3644