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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
      if (N % i == 0) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x; cin>>x;
  
  while(true) {
    if(is_prime(x)) {
      cout<<x;
      return 0;
    } else {
      ++x;
    }
  }
}

Measured memory_bytes: 3608
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let ds = Array.init n (fun _ -> Scanf.scanf "%d\n" (fun d -> d)) in
  Array.to_list ds
  |> List.sort compare
  |> List.fold_left (fun (n, prev) d ->
      ((if prev < d then 1 + n else n), d)) (0, 0)
  |> fst
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

struct node{
	node *left;
	node *right;
	int key;
};

struct tree{
	node *nil;
	node *root;
};

void insert(tree *t, int id){
	node *x, *y, *n;
	n = new node;
	n->key = id;
	n->left = t->nil;
	n->right = t->nil;
	x = t->root;
	while(x != t->nil){
		y = x;
		if(id > x->key){
			x = x->right;
		}
		else{
			x = x->left;
		}
	}
	if(id > y->key){
		y->right = n;
	}
	else{
		y->left = n;
	}
}


void printIn(tree *t, node *n){
	if (n == t->nil){
		return ;
	}
	else{
		printIn(t, n->left);
		printf(" %d", n->key);
		printIn(t, n->right);
	}
}

void printPre(tree *t, node *n){
	if (n == t->nil){
		return ;
	}
	else{
		printf(" %d", n->key);
		printPre(t, n->left);
		printPre(t, n->right);
	}
}

int main(void){
	tree *t;
	t = new tree;
	char str[10];
	int i,id,n;
	scanf("%d", &n);
	
	t->root = new node;

	t->root->left = t->nil;
	t->root->right = t->nil;
	
	for(i=0;i<n;i++){
		if(i==0){
			scanf("%s %d", str, &(t->root->key));
		}
		else{
			scanf("%s", str);
			if(str[0] == 'i'){
				scanf("%d", &id);
				insert(t, id);
			}
			else{
				printIn(t, t->root);
				printf("\n");
				printPre(t, t->root);
                                printf("\n");

			}
		}
	}
	return 0;
}

Measured memory_bytes: 18296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

#define MAX_N 105

char str[MAX_N];
int len,t;
bool ok;

int main(){
    scanf("%s",str);
    ok = true;
    t = 1;
    len=(int)strlen(str);
    if(len == 1){
        ok = false;
    }
    sort(str,str+len);
    for(int i = 0;i < len;i++){
        if(str[i] == str[i+1]) {
            t++;
        }
        else if(t%2){
            ok = false;
            break;
        }
        else{
            t = 1;
        }
    }
    if(ok)  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
import std.range;

void solve(int[] table) {
  auto answer =
    ['A': [1, 11, 10],
     'B': [10, 20, 30],
     'C': [1, 2, 3],
     'D': [10, 9, 19],
     'E': [1, 11, 12],
     'F': [10, 11, 21],
     'G': [1, 10, 9],
     ];
  foreach(i; 1..9) {
    foreach(j; 1..9) {
      int curr = j + i * 10;
      if (table[curr] == 1) {
        foreach(char c, list; answer) {
          bool ans = true;
          foreach(x; list) if ((x + curr) < table.length && table[x + curr] != 1) ans = false;
          if (ans) {writeln(c); break;}
        }
        goto end;
      }
    }
  }
 end:;
}

void main() {
  while(true) {
    int[] table;
    table ~= repeat(0).take(10).array;
    foreach(i; 0..8) {
      table ~= [0] ~ readln().chomp.array.map!((x) => x.to!(int) - '0').array ~  [0];
    }
    table ~= repeat(0).take(10).array;
    solve(table);
    readln();
    if(stdin.eof()) break;
  }
}

Measured memory_bytes: 1092
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z;
    string s1,s2;
    cin>>s1>>s2;p=0;
    for(i=0;i<s1.size()-s2.size()+1;i++){
            a=0;
        for(j=0;j<s2.size();j++){
            if(s1[i+j]==s2[j])
            a++;
        }
        p=max(a,p);
    }
    cout<<s2.size()-p<<endl;
    return EXIT_SUCCESS;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int N;
  cin >> N;
  int A[N];
  rep(i,N){
    cin >> A[i];
    if(A[i] % 2 == 0){
      if(A[i] % 3 == 0 || A[i] % 5 == 0){
        continue;
      }
      else{
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()

#define MAX_N 1000000
static const int nil = -1;

typedef struct point_tbl
{
	int id;
	int x, y;
} point;

typedef struct node_tbl
{
	int location;
	int l, r;
} node;

point p[MAX_N];
node t[MAX_N];
int pid[MAX_N];
int n;
int np;
int n_pid;

int
cmpx_func(const void *l_, const void *r_)
{
	const point* l = (const point*) l_;
	const point* r = (const point*) r_;

	if (l->x < r->x)
		return -1;

	if (l->x > r->x)
		return 1;

	return 0;
}

int
cmpy_func(const void *l_, const void *r_)
{
	const point* l = (const point*) l_;
	const point* r = (const point*) r_;

	if (l->y < r->y)
		return -1;

	if (l->y > r->y)
		return 1;

	return 0;
}

int
makeKDTree(int l, int r, int depth)
{
	if (l >= r)
		return nil;

	if (r - l >= 2)
	{
		if (depth % 2 == 0)
			qsort(&p[l], r - l, sizeof(point), cmpx_func);
		else
			qsort(&p[l], r - l, sizeof(point), cmpy_func);
	}

	int mid = (l + r) / 2;
	int s = np++;
	t[s].location = mid;
	t[s].l = makeKDTree(l, mid, depth + 1);
	t[s].r = makeKDTree(mid + 1, r, depth + 1);
	return s;
}

void
find(int v, int sx, int tx, int sy, int ty, int depth)
{
	int x = p[t[v].location].x;
	int y = p[t[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty)
		pid[n_pid++] = p[t[v].location].id;

	if (depth % 2 == 0)
	{
		if (t[v].l != nil)
		{
			if (sx <= x)
				find(t[v].l, sx, tx, sy, ty, depth + 1);
		}

		if (t[v].r != nil)
		{
			if (x <= tx)
				find(t[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
	else
	{
		if (t[v].l != nil)
		{
			if (sy <= y)
				find(t[v].l, sx, tx, sy, ty, depth + 1);
		}

		if (t[v].r != nil)
		{
			if (y <= ty)
				find(t[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
}

int
cmpi_func(const void *l_, const void *r_)
{
	const int* l = (const int*) l_;
	const int* r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

int
main(int argc, char** argv)
{
	int x, y;
	int sx, sy;
	int tx, ty;
	int q;
	int i, j;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%d %d", &x, &y);
		p[i].id = i;
		p[i].x = x;
		p[i].y = y;
		t[i].l = t[i].r = nil;
	}

	np = 0;
	int root = makeKDTree(0, n, 0);

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		n_pid = 0;
		find(root, sx, tx, sy, ty, 0);
		qsort(pid, n_pid, sizeof(int), cmpi_func);

		for (j = 0; j < n_pid; ++j)
			printf("%d\n", pid[j]);

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 20608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>

using namespace std;

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int solve(int n, int m, int d[])
{
	int result[200000];
	result[0] = 0;
	for(int i = 0; i < m; i++){
		result[d[i]] = 1;
	}
	for(int i = 1; i <= n; i++){
		result[i] = 50000;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < m; j++){
			if(d[j] <= i) result[i] = min(result[i - d[j]] + 1, result[i]);
		}
	}
	return result[n];
}



int main()
{
	int n, m;
	int d[20];
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> d[i];
	}
	cout << solve(n, m, d) << endl;
	return 0;
}

Measured memory_bytes: 1360
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

void read(int &v){int k=0,l=1;char ch;ch=getchar();while (ch>'9' || ch<'0'){if (ch=='-') l=-1;ch=getchar();}while (ch>='0' && ch<='9') k=k*10+ch-'0',ch=getchar();v=l*k;}
void print(int v){if (v<0) putchar('-'),v=-v;if (v>9) print(v/10);putchar(v%10+'0');}
int max(int a, int b) { return a>b ? a: b;}
int min(int a, int b) { return a<b ? a: b;}

static int flag[2505];
static int l, r, ans;

int main() {
        read(l), read(r);
        ans = 1e9;
        if (r - l + 1 >= 2019) puts("0");
        else {
                for (int i = l; i <= r; ++i ) flag[i % 2019] = 1;
                for (int i = 1; i <= 2019; ++i )
                        for (int j = i + 1; j <= 2019; ++j )
                                if (flag[i] && flag[j]) ans = min(ans, i * j % 2019);
                print(ans);
        }
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,q,v[1000006],w[1000006],n1;
ll dp[1025][100001]={0};
ll f(ll wei,ll val,ll now)
{
	if(wei<0) return 0;
	if(now<n1) return dp[now][wei]+val;
	ll a1=f(wei-w[now],val+v[now],now/2);
	ll a2=f(wei,val,now/2);
	return max(a1,a2);
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)	scanf("%lld%lld",&v[i],&w[i]);
	for(ll i=w[1];i<=100000;i++)	dp[1][i]=v[1];
	n1=sqrt(n);
	for(ll i=2;i<n1;i++)
	{
		for(ll j=0;j<w[i];j++) dp[i][j]=dp[i/2][j];
		for(ll j=w[i];j<=100000;j++) dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
	}
	scanf("%lld",&q);
	while(q--)
	{
		ll vv,l;
		scanf("%lld%lld",&vv,&l);
		printf("%lld\n",f(l,0,vv));
	}
}

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

int main(){
    double n;
    int a = 0;
    cin >> n;

    char str[256];
    for (int i = 0; i < n; i++) {
        cin >> str;
    }

    for (int i = 0; i < n; i++){
        if ( str[i] == 'R' ) {
            a++;
        }
    }

    if( a > (n / 2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
 
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
 
const ll MOD = 1000000007;
 
int main()
{
 
	ll N, K;
	cin >> N >> K;
 
	vec A;
 
	for (ll i = 1; i <= sqrt(N); ++i)
	{
		A.emplace_back(N / i);
	}
 
	for (ll i = sqrt(N); i > 0; --i)
	{
		if (N / i == i)continue;
		A.emplace_back(i);
	}
	
	for (ll i = 0; i < A.size() - 1; ++i)
	{
		A[i] -= A[i + 1];
	}
 
	reverse(A.begin(), A.end());
 
	for (auto& a : A) { a %= MOD; }
 
	vec B(A.size() + 1,0);
 
	for(ll i=0;i<A.size();++i)
	{
		B[i] = A[i];
	}
 
	for (ll i = 0; i < K-1; ++i)
	{
		vec tmp(B.size(), 0);
		for (ll j = 0; j < tmp.size(); ++j)
		{
			tmp[0] = (tmp[0] + B[j]) % MOD;
			tmp[tmp.size() - j - 1] = (tmp[tmp.size() - j - 1] - B[j] + MOD) % MOD;
		}
 
		for (ll j = 1; j < tmp.size(); ++j)
		{
			tmp[j] += tmp[j - 1];
			tmp[j] %= MOD;
		}
 
		for (ll j = 0; j < A.size(); ++j)
		{
			tmp[j] *= A[j];
			tmp[j] %= MOD;
		}
		B = tmp;
	}
 
	ll ans = 0;
	for (ll i = 0; i < B.size(); ++i)
	{
		ans += B[i];
		ans %= MOD;
	}
	cout << ans << endl;
	
 
	
 
	return 0;
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end
void nol(vector<pair<int,int>>& p){
  for(int i=1;i<p.size();i++){
      p[i].first-=p[0].first;
      p[i].second-=p[0].second;
    }
    p[0]=make_pair(0,0);
}
void rot(vector<pair<int,int>>& p){
  rep(i,p.size()){
    swap(p[i].first,p[i].second);
    p[i].second*=-1;
  }
}
void solve(){
  while(1){
    int n;
    cin>>n;
    if(!n)return;
    int m;
    cin>>m;
    vector<pair<int,int>> base(m);
    rep(i,m){
      int a,b;
      cin>>a>>b;
      base[i]=make_pair(a,b);
    }
    nol(base);
    for(int i=1;i<=n;i++){
      cin>>m;
      vector<pair<int,int>> p(m);
      rep(i,m){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(a,b);
      }
      if(m!=base.size())continue;
      nol(p);
      rep(_,4){
        int a=0;
        for(int i=2;i<m;i++){
          if(base[i].first!=p[i].first)
            a++;
          if(base[i].second!=p[i].second)
            a++;
        }
        if(!a){cout<<i<<endl;goto END;}
        rot(p);
      }
      reverse(p.begin(),p.end());
      nol(p);
      rep(_,4){
        int a=0;
        for(int i=2;i<m;i++){
          if(base[i].first!=p[i].first)
            a++;
          if(base[i].second!=p[i].second)
            a++;
        }
        if(!a){cout<<i<<endl;goto END;}
        rot(p);
      }
      END:;
    }
    cout<<"+++++"<<endl;
  }
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3136
s = list(input()) #sys.stdin.readlineは最後が改行

def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

while True:
    cc = my_index(s,'C')
    ff = my_index(s,'F')
    if cc == -1 or ff ==-1:
        print('No')
        exit()
    if cc < ff:
        print('Yes')
        exit()
    else:
        s.pop(ff)


Measured memory_bytes: 2940
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        e[b].append(a)

    table = [True for _ in range(n)]
    perm = [1]
    for i in range(k - 2, -1, -1):
        perm.append(perm[-1] * i % MOD)

    table[0] = False
    que = collections.deque(e[0])
    ans = k
    for i in range(len(e[0])):
        table[e[0][i]] = False
        ans *= k - i - 1
        ans %= MOD

    while len(que) > 0:
        for _ in range(len(que)):
            q = que.popleft()
            cnt = 0
            for i in range(len(e[q])):
                tmp = e[q][i]
                if table[tmp]:
                    table[tmp] = False
                    cnt += 1
                    que.appendleft(tmp)
            ans *= perm[min(len(perm) - 1, cnt)]
            ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 107952
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if (x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    const int m = 1000000007;
    long long n10 = 1, n9 = 1, n8 = 1, ans;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        n10 = n10 * 10 % m;
        n9 = n9 * 9 % m;
        n8 = n8 * 8 % m;
    }
 
    ans = n10 - (n9 * 2 - n8);
    
    while (ans < 0) {
		ans += m;
	}
	
    cout << ans << endl;
}

Measured memory_bytes: 3632
// ai > biを満たすbiのうち最小のもの
// 以外をすべて0に出来る気がする
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    int mi = 1<<30;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a > b)   mi = min(mi, b);
        sum += a;
    }
    cout << (mi==1<<30 ? 0 : sum-mi) << endl;
    return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc128/tasks/abc128_b

#include <bits/stdc++.h>
#define psi pair<string, int>
#define fi first
#define se second
using namespace std;

struct Entry {
    string name;
    int score;
    int index;
};

bool compare(const Entry& l, const Entry& r) {
    return l.name < r.name; 
}

bool compare2(const Entry& l, const Entry& r) {
    return l.score > r.score; 
}
int main() {
    int N;
    cin >> N;
    Entry a[N+1];
    for(int i = 1; i <= N; i++) {
        cin >> a[i].name >> a[i].score;
        a[i].index = i;
    }


    sort(a+1, a+N+1, compare2);
    stable_sort(a+1, a+N+1, compare);

    for(int i = 1; i <= N; i++) {
       // cout << cute.name << " " << cute.score << endl;
        cout << a[i].index << endl;
    }



    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

// int main(){
// 	boost;
//     string str;
//     cin>>str;
//     if(str[0]=='7'||str[1]=='7'||str[2]=='7')
//         cout<<"Yes";
//     else
//         cout<<"No";
// 	return 0;
// }

// int main(){
// 	boost;
//     int n;
//     cin>>n;
//     ll ans = 0;
//     for(int i = 1;i<=n;i++){
//         if(i%3!=0&&i%5!=0)
//             ans = ans + i;
//     }
//     cout<<ans;
// 	return 0;
// }

int main(){
	boost;
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            for(int k = 1;k<=n;k++){
                ans = ans + gcd(i,gcd(j,k));
            }
        }
    }
    cout<<ans;
	return 0;
}



Measured memory_bytes: 3648
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.StringTokenizer

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextInt()

    var sum = 1
    repeat(n) {
        if (sum < k) sum *= 2
        else sum += k
    }
    println(sum)


}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}




Measured memory_bytes: 31268
def resolve():
    N = int(input())
    CSF = [list(map(int, input().split(" "))) for i in range(N-1)]
    for i in range(N-1):
        time = 0
        for j in range(i, N-1):
            n = 0
            while True:
                if CSF[j][1] + n*CSF[j][2] >= time:
                    break
                n += 1
            time = CSF[j][0] + CSF[j][1] + n*CSF[j][2]
        print(time)
    print(0)



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 42092
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	string S;
	cin >> S;
	int len = strlen(&S[0]), ans = 0;
	for (int i = 0; i < (len / 2); i++) {
		if (S[i] != S[len - i - 1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

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

edge = [[] for i in range(N)]

for i in range(M):
	A, B = map(int, input().split())
	A -= 1
	B -= 1
	edge[A].append(B)
	edge[B].append(A)

ans = 0
color = [-1] * N
nextcolor = 0
for st in range(N):
	if color[st] != -1:
		continue
	q = deque()
	q.append(st)
	color[st] = nextcolor
	nextcolor += 1
	count = 1
	while len(q) > 0:
		node = q.popleft()
		for child in edge[node]:
			if color[child] != -1:
				continue
			color[child] = color[node]
			count += 1
			q.append(child)
	ans = max(ans, count)

print(ans)


Measured memory_bytes: 45248
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> price(n);
  rep(i,n) cin >> price.at(i);
  sort(price.begin(), price.end());
  int ans = 0;
  rep(i,k) ans = ans + price.at(i);
  cout << ans;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1));
		}
	}
}


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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 1e9 )+7;
const int oo   = INT_MAX;

const int LOG2 = 22;

int n, q, k;
vpii graph[ MAXN ];

int d[ MAXN ];
int dp[ MAXN ][ LOG2 ];
ll val[ MAXN ][ LOG2 ];

void init( ) {
  for( int i = 0; i < MAXN; ++i ) {
    graph[ i ].clear( );
  }
}

void dfs( int u, int p = 0 ) {
  d[ u ] = d[ p ]+1;
  dp[ u ][ 0 ] = p;
  for( auto& e : graph[ u ] ) {
    if( e.FI != p ) {
      dfs( e.FI, u );
      val[ e.FI ][ 0 ] = e.SE;
    }
  }
}

ll query( int u, int v ) {
  ll r = 0;
  if( d[ u ] > d[ v ] ) {
    swap( u, v );
  }
  for( int j = LOG2-1; j >= 0; --j ) {
    if( d[ u ] <= d[ dp[v][j] ] ) {
      r += val[ v ][ j ];
      v = dp[ v ][ j ];
    }
  }
  if( u == v ) {
    return r;
  }
  for( int j = LOG2-1; j >= 0; --j ) {
    if( dp[ u ][ j ] != dp[ v ][ j ] ) {
      r += val[ u ][ j ];
      u = dp[ u ][ j ];
      r += val[ v ][ j ];
      v = dp[ v ][ j ];
    }
  }
  r += val[ u ][ 0 ];
  r += val[ v ][ 0 ];
  return r;
}

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( ".in", "r", stdin );
    //freopen( ".out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n ) {
    #ifdef LOCAL
      init( );
    #endif
    for( int i = 1; i < n; ++i ) {
      int u, v, c; cin >> u >> v >> c;
      graph[ u ].PB( { v, c } );
      graph[ v ].PB( { u, c } );
    }
    val[ 1 ][ 0 ] = 0;
    dfs( 1 );
    for( int j = 1; j < LOG2; ++j ) {
      for( int i = 1; i <= n; ++i ) {
        val[ i ][ j ] = val[ i ][ j-1 ]+val[ dp[i][j-1] ][ j-1 ];
        dp[ i ][ j ] = dp[ dp[i][j-1] ][ j-1 ];
      }
    }
    cin >> q >> k;
    while( q-- ) {
      int u, v; cin >> u >> v;
      cout << query( u, k )+query( v, k ) << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 38144
import sys

inf = 1<<60
ans = inf

def solve():
    H, W = map(int, input().split())
    
    calc(H, W)
    calc(W, H)

    print(ans)

def calc(H, W):
    global ans
    x = W // 3

    s0 = x * H
    s1 = H * ((W - x + 1) // 2)
    s2 = H * ((W - x) // 2)

    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

    s1 = (W - x) * ((H + 1) // 2)
    s2 = (W - x) * (H // 2)

    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

    x = (W + 2) // 3

    s0 = x * H
    s1 = H * ((W - x + 1) // 2)
    s2 = H * ((W - x) // 2)

    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

    s1 = (W - x) * ((H + 1) // 2)
    s2 = (W - x) * (H // 2)

    ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int L[N];

    for (int i = 0; i < N; i++){
        scanf("%d", &L[i]);
    }

    int Longest = 0;
    int sum = 0;

    for (int i = 0; i < N; i++){

        if(Longest < L[i]){
            Longest = L[i];
        }
    }

    for (int i = 0; i < N; i++){
        sum += L[i];
    }

    if(Longest < (sum - Longest)){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define N5 100007
#define ll long long int
int N;
vector<string> A;
vector<pair<int,string> > ans;
int main()
{
	cin >> N;
	A.resize(N);
	REP(i,N){
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	ans.push_back(make_pair(1,A[0]));
	FOR(i,1,N){
		if(A[i-1]==A[i]){
			ans.back().first++;
		} else{
			ans.push_back(make_pair(1,A[i]));
		}
	}

	sort(ans.begin(),ans.end());
	int m = ans.back().first;
	vector <string> ans2;

	REP(i,ans.size()){
		pair<int,string> p = ans[ans.size()-i-1];
		if(p.first != m) break;
		ans2.push_back(p.second);
	}
	sort(ans2.begin(),ans2.end());
	REP(i,ans2.size()){
		cout << ans2[i] << endl;
	}

}




Measured memory_bytes: 22000
while 1:
    M = int(input())
    if M == 0:
        break
    S = []
    for i in range(M):
        t, *score = map(int, input().split())
        frame = rd = cum = 0
        L = len(score)
        res = sum(score)
        for i in range(L):
            s = score[i]
            if rd == 0:
                cum = s
                if s == 10:
                    res += score[i+1] + score[i+2]
                    frame += 1
                else:
                    rd = 1
            else:
                cum += s
                if cum == 10:
                    res += score[i+1]
                frame += 1
                rd = 0
            if frame == 9:
                break
        S.append((-res, t))
    S.sort()
    for x, y in S:
        print(y, -x)


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
using namespace std;
 
/*int calc(int n){
  if(n == 0)
    return 2;
  else if(n == 1)
    return 1;
  else
    return calc(n - 2) + calc (n - 1);
}*/
 
int main(void){
  
  int N;
  cin >> N;
  
  vector<long>luca(87,0);
  
  luca[0] = 2;
  luca[1] = 1;
  
  for(int i=2;i<87;i++){
    luca[i] = luca[i-2] + luca[i-1];
  }
  cout << luca[N] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    vvi c(26,vi(2,0));
    lli d;
    cin >> d;
    vvi s(26,vi(d));
    vi ans(d);
    rep(i, 26) cin >> c[i][0];//c[i][1]には使われた日を記録
    rep(i, d) rep(j, 26) cin >> s[j][i];
    rep(i,d){
        lli pi=0 ;
        for (lli j = 0; j < 26; j++)
        {
            pi -= c[j][0] * (i - c[j][1]);
        }
        lli sum = -INF;
        lli prev = -INF;
        lli mem = 0;
        rep(j,26){
            sum = max(sum, pi + c[j][0] * (i - c[j][1]) + s[j][i]);
            if(sum!=prev){
                prev = sum;
                mem = j;
            }
        }
        c[mem][1] = i;
        ans[i] = mem+1;
    }
    vout(ans);
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(ll i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(100000+5,INF64));
    dp[0][0] = 0;
    
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j <= 100000; j++){
            if(j-v[i]>=0) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    ll ans = 100000;
    while(dp[N][ans]>W) ans--;
    cout << ans << endl;
}


Measured memory_bytes: 83164
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}
int gcd_arr(vector<int> &a){
  int n = a.size();
  for(int i=n-2; i>=0; i--){
    a[i] = gcd(a[i], a[i+1]);
  }
  return a.front();
}

int main(void){
    long long int i=0,j,h,c=0,n,m,x[100000],dp[100000],ans=0;
    string s;
    cin >> n >> m;
    for(i=0;i<m;i++)
    {
        cin >> x[i];
    }
    sort(x,x+m);
    for(i=0;i<m-1;i++)
    {
        dp[i]=abs(x[i]-x[i+1]);   
    }
    sort(dp,dp+m-1);
    for(i=0;i<m-n;i++)
    {
        ans+=dp[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


int n, m, q;
vector<int> a(50), b(50), c(50), d(50);
ll ans;

ll solve(vector<int> A){
    ll tmp = 0;
    rep(i, q){
        if( ( A[b[i]] - A[a[i]] ) == c[i]){
            tmp += d[i];
        }
    }
    return tmp;
}

void dfs(vector<int> A){
    if (A.size() == n+1){
        ll tmp = solve(A);
        ans = max(ans, tmp);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m){
        dfs(A);
        A.back()++;
    }
    return;
}

int main(){
    cin >> n >> m >> q;
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    ans = 0;
    vector<int> A(1, 1);
    dfs(A);
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
        int n,i,j,tmp;
        scanf("%d", &n);

        int l[2*n];
        char str[1024];
        char *adr;

        while( getchar() != '\n');
        if(fgets(str, 1024, stdin) == NULL){
                printf("No String");
        }

        adr = strtok(str, " ");
        l[0] = atoi(adr);
        for(i = 1; i < 2*n; i++){
                adr = strtok(NULL , " \n");
                if(adr != NULL){
                        l[i] = atoi(adr);
                }
        }

        for(i = 0; i < 2*n; i++){
                for(j = i + 1; j < 2*n; j++){
                        if(l[i] > l[j]){
                                tmp = l[i];
                                l[i] = l[j];
                                l[j] = tmp;
                        }
                }
        }

        tmp = 0;
        for(i = 0; i < 2*n; i+=2){
                tmp += l[i];
        }
        printf("%d\n", tmp);
        return 0;
}


Measured memory_bytes: 128
import numpy as np

n = int(input())
a_list = list(map(int, input().split()))


a_nparray=np.array(a_list)
i_nparray=np.array(range(1,len(a_list)+1))

bi_nparray=a_nparray-i_nparray

b=int(np.median(bi_nparray))

ans=0
for i in range(len(a_list)):
  ans += abs(a_list[i]-(b+(i+1)))

print(ans)



Measured memory_bytes: 34192
# ####################################################################
# import io
# import sys

# _INPUT = """\
# abcdefg
# abcdefg
# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################

S = input()
T = input()

ans = len(T)
# _p(len(S))
# _p(len(T))

for i in range(len(S)-len(T)+1):
  k = 0
  # _p("i=",i)
  for j in range(len(T)):
    if S[i+j] != T[j]: k += 1
  # _p(ans, k)
  ans = min(ans, k)

print(ans)



Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    string s;
    cin >> n >> s;

    ll cnt = 0; // 最後に出力する')'の個数
    rep(i, n) {
        if(s[i] == '(') {
            cnt++;
        }
        else if(s[i] == ')') {
            cnt--;
            if(cnt < 0) {
                cout << '(';
                cnt = 0;
            }
        }
    }

    rep(i, n) {
        cout << s[i];
    }
    
    rep(i, cnt) {
        cout << ')';
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 256
N = int(input())
 
ABcount = 0
Acount = 0
Bcount = 0
Aset = set()
Bset = set()
for i in range(N):
    s = input()
 
    if s[0] == "B":
        Bcount += 1
        Bset.add(s)
 
    if s[-1] == "A":
        Acount += 1
        Aset.add(s)
    
    buf = ""
    for char in s:
        if buf + char == "AB":
            ABcount += 1
        buf = char

if Acount > Bcount:
    print(ABcount + Bcount)
elif Acount < Bcount:
    print(ABcount + Acount)
else:
    if Aset == Bset and len(Aset) != 0:
        print(ABcount + Acount - 1)
    else:
        print(ABcount + Acount)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<double, double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a) int((a).size())
#define pb push_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n)               \
  for (int vari = 0; vari < (n)-1; ++vari) \
    for (int varj = vari + 1; varj < (n); ++varj)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define found(s, e) ((s).find(e) != (s).end())
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
#define cons make_pair

ll gcd(ll a, ll b) {
  while (a) swap(a, b %= a);
  return b;
}

const ll MOD = 1000000007LL;

ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/
  return MUL(x, POW(y, MOD - 2));
}
ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }

#include <vector>
using namespace std;

vector<int> primes;
vector<int> smallest_prime_factor;

int sieve(int nmax) {
  primes.clear();
  smallest_prime_factor.assign(nmax + 1, 0);

  // ここではあえて愚直な書き方
  for (int n = 2; n <= nmax; ++n) {
    if (!smallest_prime_factor[n]) {
      primes.push_back(n);
      for (int kn = n; kn <= nmax; kn += n) {
        if (!smallest_prime_factor[kn]) {  // ←このチェックをせずに上書きを続けると largest_prime_factor[]
                                           // が出来上がる
          smallest_prime_factor[kn] = n;
        }
      }
    }
  }
  return primes.size();
}

vector<ii> factorize(int M) {
  sieve(32000);
  vector<ii> res;
      // int sq = sqrt(M);
      int x = M;
  for (int p : primes) {
    int cnt = 0;
    while (x % p == 0) { x /= p; ++cnt; }
    if (cnt) res.pb(ii(p, cnt));
  }
  if (x != 1) res.pb(ii(x, 1));
  return res;
}

ll solve(int N, int M) {
  vector<ii> fac = factorize(M);
  int F = fac.size();
#ifdef DEBUG
  cerr << M << fac << F << endl;
#endif
  ll ans = 1;

  for (ii p : fac) {
    int k = p.second;
    ll c = comb(N-1+k, N-1);
    ans = MUL(ans, c);
  }
  return ans;
}

int main() {
  int N, M;
  cin >> N >> M;
  cout << solve(N, M) << endl;
  // fprintf(stderr, "[[ %d %d ]]\n", _s_pow2, _assign_mul);
  return 0;
}


Measured memory_bytes: 384
#134_D
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0 for _ in range(n+1)]
for i in range(n,0,-1):
    if i>n//2:
        b[i]=a[i]
    else:
        b[i]=int(sum([b[k] for k in range(i*2,n+1,i)])%2!=a[i])
print(sum(b))
if sum(b)>0:
    ans=[]
    for i in range(1,n+1):
        if b[i]==1:
            ans.append(i)
    print(*ans)

Measured memory_bytes: 14132
#include "bits/stdc++.h"
using namespace std;
int main()
{
	long long n, a = 0, b = 0;
	scanf("%lld", &n);
	long long m[n];
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", &m[i]);
	}
	for(int i = 0; i < n; ++i)
	{
		long long j;
		scanf("%lld", &j);
		if(m[i] >= j)
		{
			b += m[i] - j;
		}
		else
		{
			a += (j - m[i] + 1) / 2;
			b += (j - m[i]) % 2;
		}
	}
	if(a >= b)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

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

using P = pair<int,int>;

int main(){
    string s;
    cin >> s;
    int ans = 0, n = s.size();
    for(int i=0;i<n;i++){
        if(i%2==1 && s[i] == 'g') ans++;
        if(i%2==0 && s[i] == 'p') ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size()){
		cout<<"GREATER"<<endl;
	}
	
	else if(a.size()<b.size()){
		cout<<"LESS"<<endl;
	}
	else{
		for(int i=0;i<a.size();i++){
			if(a[i]>b[i]){
				cout<<"GREATER"<<endl;
				return 0;
			}
			
			else if(a[i]<b[i]){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}
}

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

int main() {
  long int N,b,r,a;
  cin >> N >> b >> r;
  long int count =0;
  count = floor(N/(b+r));
  a = count*b;
  long int amari = N%(b+r);
  if (amari>=b){cout << a+b << endl;}
  else{cout << a+amari << endl;}
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,k;
  cin >>n >> k;
  map<int,int>mp;
  rep(i,10){
    mp[i]++;
  }
  rep(i,k){
    int d;
    cin >> d;
    mp[d]--;
  }
  while(true){
    bool ok=true;
    string s=to_string(n);
    rep(i,s.size()){
      if(mp[s[i]-'0']>0)continue;
      else{
        n++;
        ok=false;
        break;
      }
    }
    if(ok){
      cout<<n<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mp, ans = {}, 0
for i in range(n):
    if(a[i] in mp.keys()):
        mp[a[i]] += 1
    else:
        mp[a[i]] = 1
for k in mp.keys():
    ans += k * mp[k]
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    if(b not in mp.keys()):
        mp[b] = 0
        print(ans)
        continue
    if(c in mp.keys()):
        mp[c] += mp[b]
    else:
        mp[c] = mp[b]
    ans += (c-b) * mp[b]
    mp[b] = 0
    print(ans)

Measured memory_bytes: 85568
n, k = (int(i) for i in input().split())
p = [int(i) for i in input().split()]

_sum = 0
for i in range(k):
    p[i] = (p[i]+1) / 2
    _sum += p[i]
_max = _sum
for i in range(k, n):
    p[i] = (p[i]+1) / 2
    _sum += p[i]
    _sum -= p[i-k]
    _max = max(_sum, _max)
    
print(_max)
        
           
    

Measured memory_bytes: 25188
n, x, y = map(int, input().split())

dic = {i: 0 for i in range(1, n)}
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        dist = min(j - i, abs(i - x) + abs(j - y) + 1)
        dic[dist] += 1


for i in range(1, n):
    print(dic[i])


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

int main() {
   int W,H,x,y,r;
   cin>> W >> H >> x >> y >> r;
   if((x-r)>=0&&(y-r)>=0&&(x+r)<=W&&(y+r)<=H){
   cout<< "Yes" <<endl;
   } else {
   cout<< "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3116
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);
        boolean[] P = new boolean[3];
        P[SC.nextInt()-1] = true;
        P[SC.nextInt()-1] = true;

        for(int i=0;i<3;i++){
            if(P[i])continue;
            System.out.println(i+1);
        }
    }

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


Measured memory_bytes: 21204
from copy import deepcopy
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
dist = []
for i in range(N+1):
    dist.append(abs(A[i]-A[i+1]))
S = sum(dist)
for i in range(1,N+1):
    print(S+abs(A[i+1]-A[i-1])-abs(A[i]-A[i+1])-abs(A[i-1]-A[i]))

Measured memory_bytes: 14560
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;

class Matrix{
private:
	ll m[3][3];
public:
	Matrix(){memset(m, 0, sizeof(m));}
	Matrix(ll m11, ll m12, ll m13, ll m21, ll m22, ll m23, ll m31, ll m32, ll m33){
		m[0][0] = m11; m[0][1] = m12; m[0][2] = m13;
		m[1][0] = m21; m[1][1] = m22; m[1][2] = m23;
		m[2][0] = m31; m[2][1] = m32; m[2][2] = m33;
	}
	ll &at(int i, int j){return m[i][j];}
	Matrix mul(Matrix o, ll mod){
		Matrix out;
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				for (int k = 0; k < 3; ++k){
					out.at(i, j) += (m[i][k]*o.at(k, j)) % mod;
				}
			}
		}
		return out % mod;
	}
	Matrix operator%(ll mod){
		Matrix out;
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				out.at(i, j) = m[i][j] % mod;
			}
		}
		return out;
	}
};

Matrix eye(){
	return Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
}

Matrix powMat(Matrix a, ll n, ll mod){
	if (n == 0) return eye();
	else if (n == 1) return a;
	else if (n % 2 == 0){
		Matrix tmp = powMat(a, n/2, mod);
		return tmp.mul(tmp, mod);
	}
	else return a.mul(powMat(a, n-1, mod), mod);
}

void printMat(Matrix a){
	for (int i = 0; i < 3; ++i){
		for (int j = 0; j < 3; ++j){
			printf("%ld ", a.at(i, j));
		}
		printf("\n");
	}
}

ll l, a, b, m, c[19], t, ans;
Matrix p, q;

int main(){
	cin >> l >> a >> b >> m;
	c[0] = 0;
	t = 1;
	for (int d = 1; d <= 18; ++d){
		t *= 10;
		if (t > a) c[d] = min(l, (t - 1 - a) / b + 1);
		else c[d] = 0;
	}
	for (int d = 0; d < 18; ++d){
		c[d] = c[d+1] - c[d];
	}
	p = {1, 0, 0, 1, 1, 0, 0, b, 1};
	q = eye();
	for (int d = 0; d < 18; ++d){
		p.at(0, 0) *= 10;
		q = q.mul(powMat(p % m, c[d], m), m);
	}
	ans = (q.at(1, 0)*(a%m)) % m;
	ans = (ans + q.at(2, 0)) % m;
	printf("%ld", ans);
}

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

int main(){
	string S;
	cin>>S;
	int length=0;
	int ansarr[1000];
	while(S!="0"){
		int ans=0;
		for(int i=0;i<S.length();++i){
			ans+=(int)S[i]-48;
		}
		ansarr[length]=ans;
		length++;
		cin>>S;
	}
	for(int i=0;i<length;++i)cout<<ansarr[i]<<endl;
}


Measured memory_bytes: 3172
#include<cstdio>
#include<cstring>
#include<algorithm>
using std::min;
#define reg register
#define INF 0X3F3F3F3F
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg int res=0;
	while(ch<'0'||'9'<ch)f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')res=10*res+ch-'0',ch=getchar();
	return f?-res:res;
}

const int MAXN=300+5;
const int MAXM=(MAXN*(MAXN-1))>>1;

struct Graph{
	int M[MAXN][MAXN];
	inline void Init(reg int n){
		reg int i;
		memset(M,0X3F,sizeof(M));
		for(i=1;i<=n;++i)
			M[i][i]=0;
		return;
	}
	inline void Floyd(reg int n){
		reg int i,j,k;
		for(k=1;k<=n;++k)
			for(i=1;i<=n;++i)
				if(i!=k)
					for(j=i+1;j<=n;++j)
						if(j!=k)
							M[i][j]=M[j][i]=min(M[i][j],M[i][k]+M[k][j]);
		return;
	}
};

int n,m,l,Q;
Graph G1,G2;

int main(void){
	reg int i,j;
	n=read(),m=read(),l=read();
	G1.Init(n);
	for(i=1;i<=m;++i){
		static int a,b,c;
		a=read(),b=read(),c=read();
		G1.M[a][b]=G1.M[b][a]=c;
	}
	G1.Floyd(n);
	G2.Init(n);
	for(i=1;i<=n;++i)
		for(j=i+1;j<=n;++j)
			if(G1.M[i][j]<=l)
				G2.M[i][j]=G2.M[j][i]=1;
	G2.Floyd(n);
	Q=read();
	while(Q--){
		static int s,t;
		s=read(),t=read();
		printf("%d\n",G2.M[s][t]==INF?-1:G2.M[s][t]-1);
	}
	return 0;
}

Measured memory_bytes: 1280