akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <tuple>
#include <boost/multiprecision/cpp_int.hpp>

using bigint=boost::multiprecision::cpp_int;

using lli=long long int;
const lli mod=1000000007;

constexpr lli mod_normalize(lli a){
  return ((a%mod)+mod)%mod;
}

constexpr lli mod_inv(lli a){
  lli b=mod, u=1, v=0, tmp=0;
  while(b){
    lli t = a/b;
    a -= t*b;
    tmp = a; a = b; b = tmp; //swap(a, b);
    u -= t*v;
    tmp = u; u = v; v = tmp; //swap(u, v);
  }
  return mod_normalize(u);
}

bigint gcd_mod(bigint a, bigint b){
  if(a%b == 0) return b;
  return gcd_mod(b, a%b);
}

bigint lca_mod(bigint a, bigint b){
  bigint gcdab = gcd_mod(a, b);
  return a/gcdab*b;
}

int main(){
  int N;
  std::cin >> N;
  std::vector<lli> a_arr(N);
  for(int i = 0; i < N; i++) std::cin >> a_arr[i];

  bigint lca_a = a_arr[0];
  for(int i = 1; i < N; i++){
    lca_a = lca_mod(lca_a, a_arr[i]);
  }
  lli llca = static_cast<lli>(lca_a%mod);
  lli ans = 0;
  for(int i = 0; i < N; i++){
    lli tmp = (llca*mod_inv(a_arr[i]))%mod;
    ans = (ans+tmp)%mod;
  }

  std::cout << mod_normalize(ans) << std::endl;

  return 0;
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

M, D = MAP()

cnt = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        d1, d10 = j%10, j//10
        if d1 < 2 or d10 < 2:
            continue
        if d1*d10 == i:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
import Data.List
import Data.List.Split
import Control.Monad
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
main = mapM_ (print . solve) . chunksOf 3 . map (map read . words) . lines =<< getContents
solve [[n,c],as,bs] = dp VU.! (idx n c)  where
  ps = V.fromList . map VU.fromList . transpose . map f2 . transpose . map f1 $ [0..maximum bs] where
    f1 = scanl (\a b->a*b`mod`m) 1 . replicate c
    f2 = scanl1 (\a b->(a+b)`mod`m)
  qs = V.fromList $ zipWith (\b a->VU.fromList $ map (\k->(p b k-p a k+m)`mod`m) [0..c]) bs $ map pred as
    where p i j = ps V.! i VU.! j
  idx i j = i*(c+1)+j
  dp = VU.create $ do
    dp <- VM.replicate ((c+1)*(n+1)) 0
    VM.write dp (idx 0 0) 1
    forM_ [1..n] $ \i ->
      forM_ [0..c] $ \j ->
        forM_ [0..j] $ \k -> do
          a <- VM.read dp (idx i j)
          b <- VM.read dp (idx (i-1) (j-k))
          VM.write dp (idx i j) ((a+b*(qs V.! (i-1) VU.! k))`mod`m)
    return dp
m = 1000000007

Measured memory_bytes: 44028
#include <stdio.h>

long long factorial(int n);

int main(){
    int n;
    scanf("%d", &n);
    printf("%lld\n", factorial(n));
    
    return 0;
}

long long factorial(int n){
    if (n == 0) return 1;
    else return (n * factorial(n - 1));
}

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

int main() {
    int N;
    double M;
    cin >> N >> M ;
    int A[N];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    double sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += A[i];
    }
    
    sort(A, A + N, std::greater<>());

    bool success = true;
    for (int i = 0; i < M; i++)
    {
        if (A[i] < sum / 4 / M ) {
            success = false;
            break;
        }
    }
        
    if (success){
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= x; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define REPZ(i, x) for (int i = 0; i <= x; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
using namespace std;
#define DUMPOUT cerr
// vector
template < typename T > istream &operator>>(istream &is, vector< T > &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// pair
template < typename T, typename U >
ostream &operator<<(ostream &os, pair< T, U > &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template < typename T >
ostream &operator<<(ostream &os, const vector< T > &vec) {
  os << "{";
  REP(i, (int)vec.size())
  os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
  os << "}";
  return os;
}
// map
template < typename T, typename U >
ostream &operator<<(ostream &os, map< T, U > &map_var) {
  os << "{";
  FORA(itr, map_var) {
    os << *itr;
    itr++;
    if (itr != map_var.end())
      os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template < typename T > ostream &operator<<(ostream &os, set< T > &set_var) {
  os << "{";
  FORA(itr, set_var) {
    os << *itr;
    itr++;
    if (itr != set_var.end())
      os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { DUMPOUT << endl; }
template < class Head, class... Tail >
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if (sizeof...(Tail) > 0)
    DUMPOUT << ", ";
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define DUMP(...)                                                              \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                              \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl  \
          << "    ",                                                           \
      dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define DUMP(...)
#endif

#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN
//----//
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int r;
  cin >> r;
  print(r * r);
}

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

int main(){
  int N; 
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; i++){
    cin >> D.at(i);
  }
  sort(D.begin(), D.end());
  reverse(D.begin(), D.end());
  int count = 1;
  for(int i = 0; i < N - 1; i++){
  	if(D.at(i) > D.at(i + 1)) count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B, C, D;
	int th, ta, ah, aa;
	if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
	th = A;
	ta = B;
	ah = C;
	aa = D;
	for (;;) {
		ah -= ta;
		if (ah <= 0) {
			puts("Yes");
			return 0;
		}
		th -= aa;
		if (th <= 0) {
			puts("No");
			return 0;
		}
	}
}


Measured memory_bytes: 1648
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int fir = int.Parse(s.Substring(0, 2));
        int sec = int.Parse(s.Substring(2, 2));
        if (isMonth(fir) && isMonth(sec)) Console.WriteLine("AMBIGUOUS");
        if (isMonth(fir) && !isMonth(sec)) Console.WriteLine("MMYY");
        if (!isMonth(fir) && isMonth(sec)) Console.WriteLine("YYMM");
        if (!isMonth(fir) && !isMonth(sec)) Console.WriteLine("NA");
    }
    static bool isMonth(int n) => 1 <= n && n <= 12;
}


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

int main(){
    int K;
    cin >> K;
    int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << num[K-1];
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    Ass = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

    day = 0
    numMatch = 0
    ps = set(range(N))
    isReadys = [0] * N
    iAs = [-1] * N
    while True:
        day += 1
        p2s = set()
        for p in ps:
            iAs[p] += 1
            if iAs[p] == N-1: continue
            q = Ass[p][iAs[p]]
            if isReadys[q] and Ass[q][iAs[q]] == p:
                isReadys[q] = 0
                p2s.add(p)
                p2s.add(q)
                numMatch += 1
            else:
                isReadys[p] = 1
        if numMatch >= N*(N-1)//2:
            print(day)
            break
        if not p2s:
            print(-1)
            break
        ps = p2s

solve()


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int main() {

	FAST;

	int n;
	cin >> n;
	int r = n % 1000;
	if (r == 0) r = 1000;
	int ans = 1000 - r;
	cout << ans << '\n';
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  string ans = "Yes";
  if (N != M)
    ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
  long long a, b, c, n, i, j,s=0;
  scanf("%lld",&n);
  for(i=1;i<=n;i++)
  {
      if(i%3==0 || i%5==0)
      {
          s+=0;
      }else
      {
          s+=i;
      }
      
  }
  printf("%lld",s);
}


Measured memory_bytes: 2112
N, M, V, P = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
total = [0]*N
total[0] = S[0]

for i in range(1, N):
    total[i] = total[i-1]+S[i]

if total[N-P]-total[0]+(V-P)*M <= (S[0]+M)*(N-P) and S[0]+M >= S[N-P]:
    ans = N
else:
    ok = N-1
    ng = 0
    while ng+1 < ok:
        mid = (ok+ng)//2
        if mid > N-P:
            ok = mid
        elif total[N-P]-total[mid]+(V-(P+mid))*M <= (S[mid]+M)*(N-P-mid) and S[mid]+M >= S[N-P]:
            ok = mid
        else:
            ng = mid
    ans = N-ok
print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
    string s;
    bool a=false, b=false, c=false;
    cin>>s;
    for(char i:s){
        if(isdigit(i)) a=true;
        if(islower(i)) b=true;
        if(isupper(i)) c=true;
    }
    if(!(s.size()>5&&a&&b&&c))cout<<"IN";
    cout<<"VALID"<<endl;
}

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

int main()
{
    char ch;
    cin>>ch;
    if(ch>='A' && ch<='Z')
        cout<<'A'<<endl;
    else
    {
        cout<<'a'<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
 int x,y,a,b;
 cin>>x>>y>>a>>b;
if((x*y>=a*b))
    cout<<x*y<<endl;
else
    cout<<a*b<<endl;
}






Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	c := make([]city, m)
	for i := range c {
		c[i].id = i
		c[i].p = readInt()
		c[i].y = readInt()
	}

	x := make([]int, n+1)
	for i := range x {
		x[i] = 1
	}

	sort.Sort(sortByYear(c))
	for i := range c {
		p := c[i].p
		c[i].z = x[p]
		x[p]++
	}

	sort.Sort(sortById(c))
	for i := range c {
		printf("%06d%06d\n", c[i].p, c[i].z)
	}

}

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

type city struct {
	id, p, y, z int
}

type sortByYear []city

func (s sortByYear) Len() int {
	return len(s)
}

func (s sortByYear) Less(i, j int) bool {
	return s[i].y < s[j].y
}

func (s sortByYear) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type sortById []city

func (s sortById) Len() int {
	return len(s)
}

func (s sortById) Less(i, j int) bool {
	return s[i].id < s[j].id
}

func (s sortById) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}


Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    int count = 0;
    for(int i=min(A,B); i>0; i--)
    {
    	if(A%i==0&&B%i==0) count++;
    	if(count==K)
    	{
    	  cout << i << endl;
          return 0;
        }
    }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
     char s[200005];
     cin>>s;
     int i,l,d=0;
     l=strlen(s);
     for(i=0;i<l;i++)
     {
         d+=(s[i]-48);
     }
     if(d%9==0)
     {
         printf("Yes\n");
     }
     else
     {
         printf("No\n");
     }
}


Measured memory_bytes: 3732
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n;
	cin >> n;
	int ct = 0;
	for(int i = 1; i <= n; i++)
		if((int)log10(i) % 2 == 0) ++ct;

	cout << ct;
	
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 512
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    print(N // 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;

int main() {
	vector<int> v;
	int N;
	cin >> N;
	int in;
	int total = 0;
	int now = 0;
	for (int i = 0;i < N;i++) {
		cin >> in;
		v.push_back(in);
		total += abs(now - in);
		now = in;
	}
	total += abs(v[N - 1]);
	now = 0;
	cout << total - (abs(v[0]) + abs(v[0]-v[1])) + abs(v[1]) << endl;
	now = v[1];
	for (int i = 1;i < N-1;i++) {
		cout << total - (abs(v[i - 1] - now) + abs(now - v[i + 1])) + abs(v[i - 1] - v[i + 1]) << endl;
		now = v[i + 1];
	}
	cout << total - (abs(v[N-2]-now) + abs(now)) + abs(v[N-2]) << endl;
}

Measured memory_bytes: 1784
#3~len(N)の重複組み合わせSでも楽に解ける
from collections import deque
N=int(input())
d=deque(["3","5","7"])
A=["3","5","7"]
c=0
while True:
  s=d.popleft()
  if int(s)>N:
    print(c)
    exit()
  if len(set(s))==3:
    c+=1
  d.extend([s+i for i in A])

Measured memory_bytes: 49052
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int flag=0;
    for(int i=0;i<=n/4;i++){
        for(int j=0;j<=n/7;j++){
            if(4*i+7*j==n){
                flag=1;
                break;
            }
        }
    }
    if(flag==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll a, b;
    cin>>a>>b;
    cout<<a*(a-1)/2+b*(b-1)/2;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=210;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,a[maxn];
ll ans;
int main()
{
	read(n);
	n<<=1;
	for(rg int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	for(rg int i=1;i<=n;i+=2) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

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

struct st { int x, y, cnt; };
int H, W;
int vs[1000][1000];
queue<st> que;
int ans;
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

int main()
{
  cin >> H >> W;
  rep(i, H) rep(j, W) {
    char c;
    cin >> c;
    if (c == '#') {
      que.push({i, j, 0});
      vs[i][j] = 1;
    }
  }

  while (!que.empty()) {
    int x = que.front().x, y = que.front().y, cnt = que.front().cnt; que.pop();
    ans = max(ans, cnt);
    rep(i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= H || ny >= W || vs[nx][ny]) continue;
      que.push({nx, ny, cnt+1});
      vs[nx][ny] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16272
import numpy as np

n, m = map(int, input().split())
x = [int(x) for x in input().split()]

p = np.sort(np.array(x))
dif = np.sort(p[1:] - p[:-1])
if n > 1:
    print(np.sum(dif[: 1 - n]))
else:
    print(np.sum(dif))

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

struct card {
	int num;
	char suit;
	bool operator!=(const card& o2){
		return ( num != o2.num )||( suit != o2.suit );
	}
};

void show(card arr[], int N){
	for(int i=0; i<N; i++)
		if(i<N-1)
			cout<<arr[i].suit<<arr[i].num<<' '<<flush;
		else
			cout<<arr[i].suit<<arr[i].num<<flush;
	cout<<endl;
}

bool stable(card arr_st[], card arr[], int N){
	for(int i=0; i<N; i++)
		if(arr_st[i] != arr[i]) return false;
	return true;
}

void swap(int& a, int& b){
	int t=a;
	a=b;
	b=t;
}

int BubbleSort(card*, int);
int SelectionSort(card*, int);

int main()
{

	int N;cin>>N;

	card* arr_bub=new card[N];
	for(int i=0; i<N; i++){
		cin>>arr_bub[i].suit;
		cin>>arr_bub[i].num;
	}
	card* arr_sel=new card[N];
	for(int i=0; i<N; i++){
		arr_sel[i].suit=arr_bub[i].suit;
		arr_sel[i].num=arr_bub[i].num;
	}

	int count;
	count=BubbleSort(arr_bub, N);
	show(arr_bub, N);
	cout<<"Stable"<<endl;

	count=SelectionSort(arr_sel, N);
	show(arr_sel, N);
	cout<<( stable(arr_bub, arr_sel, N)? "Stable" : "Not stable")<<endl;

}


int BubbleSort(card* arr, int N)
{

	int counter=0;

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

		for(int j=0; j<N-i-1; j++) {
			if( arr[j].num > arr[j + 1].num )
				swap(arr[j], arr[j + 1]);
			counter++;
		}

//		show(arr, N);
	}
	return counter;
}

int SelectionSort(card* arr, int N){

	int mini,counter=0;
	for(int i=0; i<N-1; i++) {
		mini=i;

		for(int j=i+1; j<N; j++) {

			mini= (arr[mini].num > arr[j].num)? j : mini;

		}

		if(mini != i){
			swap( arr[mini], arr[i] );
			counter++;
		}
		//show(arr, N);
	}
	return counter;
}

Measured memory_bytes: 1192
H,W=map(int,input().split())
A=[]
for i in range(H):
  A.append(input())
#print(A)

sw=0
for i in range(H):
  tmp=0
  for j in range(W-1):
    if A[i][j]=="#" and A[i][j+1]==".":
      tmp=1
    if tmp==1 and A[i][j]=="." and A[i][j+1]=="#":
      sw=1
#print(sw)

if sw==1:
  print("Impossible")
else:
  l=[]
  r=[]
  for i in range(H):
    ll=0
    for j in range(W-1):
      if A[i][j]=="." and A[i][j+1]=="#":
        ll=j+1
        break
    l.append(ll)
    
    rr=W-1
    for j in range(W-1):
      if A[i][j]=="#" and A[i][j+1]==".":
        rr=j
        break
    r.append(rr)
#  print(l)
#  print(r)

  sw2=0
  for i in range(len(r)-1):
    if r[i]!=l[i+1]:
      sw2=1
  print("Impossible" if sw2==1 else "Possible")

Measured memory_bytes: 3064
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>
#include <iomanip>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    double W;
    double H;
    
    cin >> W;
    cin >> H;

    double x,y;
    cin >> x;
    cin >> y;

    double menseki;

    menseki = W * H;
    menseki = menseki / 2;

    int flag = 0;
    if(W/2 == x) flag = 0;
    if(H/2 == y) flag = 0;

    if( y / (W -x) == H/W ) flag = 0;
    if( y / x == H/W ) flag = 0;

    if(W/2 == x && H/2 == y) flag = 1;


    int xx,yy;
    xx = W;
    if(x==xx) flag = 0;
    xx = 0;
    if(x==xx) flag = 0;
    yy = H;
    if(y == yy) flag = 0;
    yy = 0;
    if(y == yy) flag = 0;
    

    cout << to_string(menseki);
    cout << " ";
    cout << flag;

}

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

int main() {
  int a, b, n;
  cin >> a >> b;
  n = a * b;
  
  if (n % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
a = input()
longs = int(len(a))
if(longs % 2 == 0):
    b = a[:int(longs/2)]
    c = a[int(longs/2):]
    twolongs = int(longs/2)
else:
    b = a[:int(longs/2)+1]
    c = a[int(longs/2):]
    twolongs = int(longs/2)+1
#print(b,c)
count = 0
for i in range(twolongs):
    if(b[i]==c[twolongs-i-1]):
        continue
    else:
        count +=1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>


const long long MOD_CONST = 1000000007;


using namespace std;

int main() {
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		
	}

	
	vector<vector<int>> L(w, vector<int>(h));
	vector<vector<int>> R(w, vector<int>(h));
	vector<vector<int>> D(w, vector<int>(h));
	vector<vector<int>> U(w, vector<int>(h));

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			//cout << i << " " << j << endl;
			if (s[j][i] == '#') {
				L[i][j] = 0;
			}
			else if (i == 0) {
				L[i][j] = 1;
			}
			else {
				L[i][j] = L[i-1][j] + 1;
			}
			//cout << L[i][j] << endl;
			
		}
	}
	
	for (int i = w-1; i >=0; i--) {
		for (int j = 0; j < h; j++) {
			if (s[j][i] == '#') {
				R[i][j] = 0;
			}
			else if (i == w-1) {
				R[i][j] = 1;
			}
			else {
				R[i][j] = R[i+1][j] + 1;
			}

		}
	}

	for (int i = 0; i < w; i++) {
		for (int j = h-1; j >=0; j--) {
			if (s[j][i] == '#') {
				D[i][j] = 0;
			}
			else if (j == h-1) {
				D[i][j] = 1;
			}
			else {
				D[i][j] = D[i][j+1] + 1;
			}

		}
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (s[j][i] == '#') {
				U[i][j] = 0;
			}
			else if (j == 0) {
				U[i][j] = 1;
			}
			else {
				U[i][j] = U[i][j-1] + 1;
			}

		}
	}

	int max = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			int tmp = L[i][j]+ R[i][j] + D[i][j] + U[i][j]-3;
			if (tmp > max) {
				max = tmp;
			}
		}
	}
	cout << max << endl;

}

Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17);


signed main(){
    int a,b,q;
    cin >> a >> b >> q;
    pair<int,int> A[MAX],B[MAX];
    REP(i,a){
        scanf("%lld",&(A[i+1].fi) );
    }
    REP(i,b) scanf("%lld",& (B[i+1].fi) );
    A[0].fi = -INF;
    B[0].fi = - INF;
    A[0].se = INF;
    B[0].se = INF;
    A[a+1].fi = INF;
    B[b+1].fi = INF;
    A[a+1].se = INF;
    B[b+1].se = INF;

    int id = 0;
    while( A[1].fi > B[id + 1].fi ) id ++;
    FOR(i,1,a+1){
        if( abs (A[i].fi - B[id].fi)  < abs(A[i].fi - B[id +1].fi)){
            A[i].se = abs (A[i].fi - B[id].fi); 
        }
        else{
            A[i].se = abs(A[i].fi - B[id +1].fi);
            id ++;
        }
    }



    id = 0;
    while( B[1].fi > A[id + 1].fi ) id ++;
    FOR(i,1,b+1){
        if( abs (B[i].fi - A[id].fi)  < abs(B[i].fi - A[id +1].fi)){
            B[i].se = abs (B[i].fi - A[id].fi); 
        }
        else{
            B[i].se = abs(B[i].fi - A[id +1].fi);
            id ++;
        }
    }








    REP(i,q){
        int tmp;
        scanf("%lld",&tmp);
        int ng = 0,ok = a+1;
        while(ng + 1 < ok){
            int mid = (ng + ok)/ 2;
            if( A[mid].fi < tmp) ng = mid;
            else ok = mid; 
        }
        int a_id = ok-1;
        ng = 0;
        ok = b+1;
        while(ng + 1 < ok){
            int mid = (ng + ok)/ 2;
            if( B[mid].fi < tmp) ng = mid;
            else ok = mid; 
        }        
        int b_id = ok-1;
/*
        int ans = min( abs(tmp-A[a_id].fi) + A[a_id].se , abs(tmp-B[b_id].fi) + B[b_id].se);
        ans = min( ans , abs(tmp - A[a_id +1].fi) + A[a_id +1].se);
        ans = min( ans , abs(tmp-B[b_id +1].fi) + B[b_id+1].se );
*/
        int ans = INF;
        FOR(j,a_id , a_id +2){
            FOR(k,b_id , b_id + 2){
                int res = min( abs(A[j].fi-tmp) + abs(A[j].fi - B[k].fi), abs(B[k].fi-tmp)+ abs(A[j].fi - B[k].fi) );
                ans = min(ans,res);
            }
        }  
        printf("%lld\n",ans);
    }

}

Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
 
int main(){
  int n;
  cin >> n;
 
  int d = 0; //Nはd桁の正整数
  for(int i=6; i>0; i--){
    if(n >= pow(10,i-1)){
      d = i;
      break;
    }
  }
//  cout << d << endl;
  int sum = 0;
  //1～10^dの中の個数
  for(int i=1; i<d; i++){
    if(i%2==1){
      sum += 9 * pow(10, i-1);
//      cout << sum << endl;
    }
  }
  //10^d～nまでの個数
  if(d%2==1){
    sum += n - pow(10, d-1) + 1;
  }
    
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template <class T> inline bool  chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
#define INF (1e18)

void out(int x){
    int count=5,y=x;
    while(x/10 != 0){
        count--;
        x/=10;
    }
    for(int i=0;i < count;i++)
    {
        cout << '0';
    }
    cout << y;
}
int main(){
int n,m;
cin>>n>>m;
map<pair<int,int>,int>ma;
vector<vector<int>> f(n+1,vector<int>(0));
vector<pair<int,int>> num;
for(int i=0;i<m;i++){
    int p,y;
    cin>>p>>y;
    f.at(p).push_back(y);
    num.push_back(make_pair(p,y));
}
for(int i=0;i<n+1;i++){
sort(f.at(i).begin(),f.at(i).end());
}
for(int i=1;i<n+1;i++){
    for(int j=0;j<f.at(i).size();j++){
        ma[make_pair(i,f.at(i).at(j))]=j+1;
    }
}
for(int i=0;i<m;i++){
    out(num.at(i).first);
    out(ma[make_pair(num.at(i).first,num.at(i).second)]);
    cout<<endl;
}
}


Measured memory_bytes: 13940
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
	double r;
	cin >> r;
	printf("%.10f %.10f \n", r * r * M_PI, 2 * r * M_PI);
	//cout << r * r << endl;
	//cout << r * r * M_PI << " " << 2 * r * M_PI << endl;
	//cin >> r;
	return 0;
}


Measured memory_bytes: 3196
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;

    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int A = 5e2 + 2;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    double r;
    cin >> r;
    cout << setprecision(6) << fixed << 2.0 * acos(-1) * r;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)\

int main()
{
  LL a,b,c,k,s;
  cin>>a>>b>>c>>k;
  if(a<k)
      {if(a+b>=k)
      s=a;
      else
      if(a+b<k)
      s=a-(k-a-b);}
      else
      s=k;
  cout<<s<<endl;
  return 0;
}








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

vector<bool>flag(100005);
vector<int>cnt(100005);

int main() {
	for (int i = 2; i <= 100000; i++)if (!flag[i])for (int j = i + i; j <= 100000; j += i)flag[j] = true;
	for (int i = 3; i <= 100000; i += 2)if (!flag[i] && !flag[(i + 1) / 2])cnt[i]++;
	for (int i = 3; i <= 100000; i++)cnt[i] += cnt[i - 1];
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		cout << cnt[r] - cnt[l-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split()))
if n%2==1:
  l=l[n-1::-2]+l[1::2]
  for i in range(n):
    print(l[i],end=" ")
else:
  l=l[n-1::-2]+l[::2]
  for i in range(n):
    print(l[i],end=" ")

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

#define int long long
#define MOD 1000000007

int n, m;

int dp[100010] = {};

int solve(){
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 2;

    int s = 2;
    for(int i = 1;i < n;i++){
        dp[i+s] = dp[i+s-1]-dp[max(0ll, i+s-1-m)];
        dp[i+s] %= MOD;
        dp[i+s] = (dp[i+s] + dp[i+s-1])%MOD;
    }

    return (MOD+dp[s+n-1]-dp[max(0ll,s+n-1-m)])%MOD;
}

signed main(){
    cin >> n >> m;

    int all = 1;
    for(int i = 0;i < n;i++){
        all = (all * 2) % MOD;
    }

    int none = solve();

    cout << (MOD+all-none)%MOD << endl;
    return 0;
}



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

using namespace std;
#define LL long long

int N,M;
string S;

int main(){
	cin>>N>>M;
	for(int i=0;i<max(N,M);i++)S+=to_string(min(N,M));
	cout<<S<<endl;
	return 0;
}

/*
#include<iostream>
#include<algorithm>

using namespace std;
#define LL long long

int N,M;

int main(){
	cin>>N>>M;
	cout<<(N==M?"Yes":"No")<<endl;
	return 0;
}


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    vector <pair<int,int>> p(100010);
    rep(i,n){
        int a,b; cin>>a>>b;
        p[i] = {b,a};
    }
    sort(p.begin(),p.end(),greater<pair <int,int>>());
    
    stack <pair <int,int>> stk;
    vector <int> cnt(100100);
    int x = 0;
    int ans = 0, d = 0;
    for(int i=0;i<k;i++){
        d += p[i].F;
        cnt[p[i].S-1]++;
        if(cnt[p[i].S-1] == 1) x++;
        else stk.push({p[i].F,p[i].S});
    }
    ans = x*x + d; 
    for(int i=k;i<n;i++){
        if(cnt[p[i].S-1]) continue;
        if(stk.size()== 0) break; 
        auto tmp = stk.top(); stk.pop();
        if(cnt[tmp.S-1]==1) continue;
        x++;
        d += p[i].F; d -= tmp.F;
        cnt[tmp.S-1]--;
        cnt[p[i].S-1]++;
        chmax(ans, x*x + d);
    }
    cout<<ans<<endl;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int s[100005];
int main()
{
    int n; cin >> n;
    int a[n]; 
    rep(i,n) cin >> a[i];
    int r = 0;  int s = 0;
    ll ans = 0;
    for(int l = 0; l < n; l++){
        while (r < n && ((s + a[r]) == (s ^ a[r]))){
            s += a[r];
            r++;
        }
        ans += (r-l);
        if(l == r) r++;
        else s -= a[l];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
	printf("No\n");
	exit(0);
}
void yes(){
	printf("Yes\n");
	exit(0);
}

int n; 
int a[112345];
map<int, int> mp;
vpii v;

int main(){
	scanf("%d", &n);
	REP(i, n){
		scanf("%d", a+i);
		mp[a[i]]++;
	}
	if(n%3){
		if(mp.size() > 1 || a[0]!=0) no();
		else yes();
	} else {
		for(auto &p:mp) v.EB(p.second, p.first);
		sort(v.begin(), v.end());
		if(mp.size()==1){
			if(a[0]!=0) no();
			else yes();
		} else if(mp.size()==2){
			if(v[0].first==n/3 && v[0].second==0) yes();
			else no();
		} else if(mp.size()==3){
			if(v[0].first!=n/3) no();
			if(v[1].first!=n/3) no();
			if((v[0].second ^ v[1].second)!= v[2].second) no();
			yes();
		} else no();
	}
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

vector<long long> factorial(2,1);
int nckmodp(int n,int k,int p){
  if(n < k || n <= 0 || k < 0)return 0;
  while(factorial.size() <= n){
    long long i = factorial.size();
    factorial.push_back(i*factorial[i-1]%p);
  }
  long long n1 = factorial[n],n2 = factorial[k],n3 = factorial[n-k];
  vector<long long> a2,a3;
  FOR(i,0,31){
    a2.push_back(n2);
    a3.push_back(n3);
    n2 = (n2*n2)%p;
    n3 = (n3*n3)%p;
  }
  n2 = 1;
  n3 = 1;
  FOR(i,0,31){
    if((1 << i)&(p-2)){
      n2 *= a2[i];
      n3 *= a3[i];
      n2 %= p;
      n3 %= p;
    }
  }
  return (n1*n2%p)*n3%p;
}

int main(){
  ll N,M;
  ll ans = 1;
  cin >> N >> M;
  ll m = M;
  vector<ll> v;
  set<int> s;
  for(int i = 2;i*i <= M;i++){
    while(m%i == 0){
      v.push_back(i);
      s.insert(i);
      m /= i;
    }
  }
  if(m != 1){
    v.push_back(m);
    s.insert(m);
  }
  sort(ALL(v));
  for(auto x:s){
    ll n = upper_bound(ALL(v),x)-lower_bound(ALL(v),x);
    ans *= nckmodp(n+N-1,n,INF);
    ans %= INF;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll INF = 1e18 + 10 ; 
int main(){
    fastio
    int a , b ;
    cin >> a >> b ; 
    int cnt = 0 ; 
    int cur = 1;
    while(cur < b){
        cur += a - 1 ;
        cnt++;
    }
    cout << cnt << endl;
    return 0 ;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(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) long long(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 = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[55][55][2505]; // i枚目まででj枚使って総和kを作る通り数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,a; cin>>n>>a;
  vll x(n);
  rep(i,n) cin>>x[i];
  
  memset(dp,-1,sizeof(dp));
  dp[0][0][0]=1;
  // rep(i,n+1) dp[i][0][0]=1;
  
  rep(i,n){
    rep(j,i+1){
      rep(k,2505){
        if(dp[i+1][j][k]==-1) dp[i+1][j][k]=dp[i][j][k];
        else if(dp[i][j][k]!=-1) dp[i+1][j][k]+=dp[i][j][k];
      }
    }
    
    
    rep(j,i+1){
      rep(k,2505){
        
        if(dp[i][j][k]==-1) continue;
        if(k+x[i]>2500) continue;
        
        if(dp[i+1][j+1][k+x[i]]==-1){
          dp[i+1][j+1][k+x[i]]=dp[i][j][k];
          // cout<<i<<' '<<j<<' '<<k<<' '<<dp[i+1][j+1][k+x[i]]<<endl;
        }else{
          dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
          // cout<<dp[i+1][j+1][k+x[i]]<<endl;
        }
      }
    }
  }
  
  // rep(i,n+1){
  //   rep(j,a+1){
  //     cout<<dp[n][i][j]<<' ';
  //   }
  //   cout<<endl;
  // }
  
  ll ans=0;
  for(ll i=1; i<=n; i++){
    ll sum=i*a;
    if(dp[n][i][sum]!=-1) ans+=dp[n][i][sum];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 62852
/*
For Bantako San
By shyyhs.

Using hash to insert and search for a perticular number.
Every insert and search is O(1) ideally.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
#define ll long long
#define Hsize 100009
#define MAXN 210001 
ll sumZ=0; //sum from the beginning
int Ai; //This is Ai in the problem, we use it only once so array is not necessary.
int N; //N in the problem

struct T
{
    ll number,times;
    int next;
}hashBucket[MAXN];
int top=0;
int hashIndex[Hsize];


//x->hash(x)
inline int hashFunc(ll x)
{
    if (x<0) x=-x;
    return (x%100007);
}

//add the current sumZ to the hash table
void addToHash(ll sumZ)
{
    int index, HsumZ, beginP;
    HsumZ = hashFunc(sumZ);
    for (beginP=index=hashIndex[HsumZ]; hashBucket[index].next>0; index=hashBucket[index].next)
        if (hashBucket[index].number == sumZ) // there is already that number in the hashbucket
            break;
    if (hashBucket[index].number==sumZ)
        hashBucket[index].times+=1;
    else
    {
        hashIndex[HsumZ]=(++top);
        hashBucket[top].number = sumZ;
        hashBucket[top].times = 1;
        hashBucket[top].next = beginP;
    }
}

void init()
{
    memset(hashBucket,-1,sizeof(hashBucket));
    scanf("%d",&N);
    addToHash(0);
    for (int i=0; i<N; ++i)
    {
        scanf("%d",&Ai);
        sumZ=sumZ+Ai;
        addToHash(sumZ);
    }
}

void work()
{
    ll answer=0;
    for (int i=1; i<=top; ++i)
        answer=answer+(((hashBucket[i].times)*(hashBucket[i].times-1))/2) ;
    cout<<answer<<endl;
}
    
int main()
{
    init();
    work();
    return 0;
}


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

void solve(long long A, long long B, long long C){
	long long res;
	if (C <= A+B) {
		res = B+C;
	} else {
		res = 2*B+A+1;
	}
	printf("%lld\n", res);
}

int main(){
	long long A;
	long long B;
	long long C;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&C);
	solve(A, B, C);
	return 0;
}


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

int n, m, max_a;
int a[100000];

bool check(int k) {
	int num = 1, sum = 0;
	for(int i = 0; i < n; i++) {
		sum += a[i];
		if(sum > k) {
			num++;
			sum = a[i];
		}
	}
	return num <= m;
}

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

	while(cin >> m >> n, m) {
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		max_a = *max_element(a, a + n);

		int ng = max_a - 1, ok = max_a * n;
		while(abs(ng - ok) > 1) {
			int mid = (ng + ok) / 2;
			if(check(mid)) ok = mid;
			else ng = mid;
		}

		cout << ok << endl;
	}
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

typedef long long ll;
#define pii pair<int, int>

using namespace std;

/////////////////////////////////////////////////

int N;
vector<pii> town;

double distance(pii i, pii j)
{
    return sqrt(pow((i.first - j.first), 2) + pow((i.second - j.second), 2));
}

int fact(int n)
{
    if(n == 1) return 1;
    else return n * fact(n-1);
}

void input()
{
    cin >> N;
    town = vector<pii>(N);
    rep(i, N)
    {
        cin >> town[i].first >> town[i].second;
    }
}

void solve()
{
    double sum = 0;
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    do
    {
        pii last = town[v[0]];
        for(int i = 1; i < N; i++)
        {
            sum += distance(last, town[v[i]]);
            last = town[v[i]];
        }
    } while (next_permutation(v.begin(), v.end()));
    
    cout << setprecision(15) << sum / fact(N) << endl;
}

/////////////////////////////////////////////////

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

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



ll mod = 1e9 + 7;

int main(){
  string s;
  cin >> s;
  ll n = s.size();


  vector<ll> dpUnder(n+1, 0);
  vector<ll> dpEq(n+1, 0);

  dpEq[0] = 1;
  rep1(l, n){
    // a[l] + b[l] = 0
    if(s[l-1] == '0'){
      dpUnder[l] += dpUnder[l-1];
      dpEq[l] += dpEq[l-1];
    }
    else {
      dpUnder[l] += dpUnder[l-1] + dpEq[l-1];
    }    
    // a[l] + b[l] = 1
    if(s[l-1] == '0'){
      dpUnder[l] += 2*dpUnder[l-1];
    }
    else {
      dpUnder[l] += 2*dpUnder[l-1];
      dpEq[l] += 2*dpEq[l-1];
    }
    dpUnder[l] %= mod;
    dpEq[l] %= mod;
  }
  
  cout << (dpUnder[n]+dpEq[n])%mod << endl;



  return 0;
}

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

int main(){
    int X;
    cin >> X;
    int beki;
    int mx = 0;
    for(int i=1; i<100; i++){
        for(int jj=2; jj<10; jj++){
            beki = 1;
            rep(k,jj) beki *= i;
            if(beki <= X) mx = max(mx,beki);
        }
    }

    cout << mx << endl;
}   

Measured memory_bytes: 256