akhauriyash/Code-Regression huggingface dataset:
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=t(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),3),n=r[0],o=r[1],u=r[2],i=1;i<=o;i++){if(n*i%o==u)return void console.log("YES")}console.log("NO")}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 11468
#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(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,a=0,b=0,ans=0,sa=0;
    cin>>n;
    rep(i,n){
        string s;
        char rep='X';
        cin>>s;
        if(s[0]=='B'&&s[s.size()-1]=='A') sa++;
        else if(s[0]=='B') b++;
        else if(s[s.size()-1]=='A') a++;
        rep(j,s.size()){
            if(rep=='A' && s[j]=='B') ans++;
            rep=s[j];
        }
    }
    if(sa==0){
        ans+=min(a,b);
    }
    else{
        if(a+b!=0){
            ans+=sa+min(a,b);
        }
        else{
            ans+=sa-1;
        }
    }
    out(ans);
}

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

int main(){

    vector<int> a(3);

    cin>> a[0] >> a[1] >> a[2];

    sort(a.begin(),a.end());

    cout << a[2]*10+a[1]+a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
void solve(){
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10)
    cout << a * b << endl;
    else 
    cout << -1 << endl;
}
int main(){
    solve();
    return 0;
}

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

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

    int flag = 0;

    for(int i = a; i <= b; i++){
        if(i % k == 0){
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        cout << "NG" << endl;
    }else{
        cout << "OK" << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// 二項係数を用いる
const int MAX = 1000100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

  // テーブルを作る前処理
  /* facが普通の階乗を求めている。invが逆数を求めている。finvが逆数の階乗を求めている。*/
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

  // 二項係数を計算する
long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll n, k;

int main() {
    cin >> n >> k;
    COMinit();
    vector<ll> A(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    ll ans = 0;

    for(int i = 0; i < n; ++i) {
        int all = n-i-1; int sub = k-1;
        ll nextadd = COM(all, sub);
        ll nextsub = COM(all, sub);
        // cout << "i " << nextadd << endl;
        nextadd *= A.at(n-1-i);
        nextsub *= A.at(i);
        nextadd %= MOD;
        nextsub %= MOD;
        ans += nextadd;
        ans %= MOD;
        ans -= nextsub;
        if(ans < 0) ans += MOD;
        else ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 24448
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    bool f(string s)
    {
        return s.length % 2 == 0 && s[0 .. $ / 2] == s[$ / 2 .. $];
    }

    foreach_reverse (i; 0 .. S.length)
    {
        if (f(S[0 .. i]))
        {
            writeln(i);
            return;
        }
    }
}


Measured memory_bytes: 3596
i = input().split()
n = int(i[0])
k = int(i[1])

if k < 0:
    print("NO")

else:
    x = n % 2
    y = n / 2
    if x > 0:
        y += 1

    if y >= k:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)
else:
    print("error")


Measured memory_bytes: 9048
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

adj = defaultdict(list)
for i, (a, b) in enumerate(ab):
	a -= 1
	b -= 1
	adj[a].append((b, i))
	adj[b].append((a, i))

k = max([len(li) for li in adj.values()])
print(k)

ans = [-1] * (n - 1)

def dfs(u, p_col):
	col = 1
	for v, i in adj[u]:
		if ans[i] != -1:
			continue
		if col == p_col:
			col += 1
		ans[i] = col
		dfs(v, col)
		col += 1


dfs(0, -1)

print(*ans, sep="\n")


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

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

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;
  sort(ALL(s));

  cout << (s == "abc" ? "Yes" : "No") << endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
vector<bool> isPr;
void isPrime( ll n ){
  isPr.assign(n+1,true);
  isPr.at(0) = false;
  isPr.at(1) = false;
  isPr.at(2) = true;
  for(ll now=2;now<=n;++now){
    if( isPr.at(now) ){
      if( (double)now >= sqrt(n) ) return;
      ll cnt = 2;
      while( now*cnt <= n ){
        isPr.at(now*cnt) = false;
        cnt++;
      }
    }
  }
}

int main(){
  ll q;
  cin >> q;
  isPrime(100000);
  vector<ll> sum(100001);
  ll now = 0;
  for(ll i=1;i<=100000;i+=2){
    if( isPr.at(i) && isPr.at((i+1)/2) ){
      ++now;
      sum.at(i) = now;
    }else{
      sum.at(i) = now;
    }
  }
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    ll ans;
    if( isPr.at(l) && isPr.at((l+1)/2) ){
      ans = sum.at(r)-sum.at(l)+1;
    }else{
      ans = sum.at(r)-sum.at(l);
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

size_t binary_knapsack(vector<size_t> w, vector<size_t> v, size_t c) {
    vector<size_t> dp(c+1);
    size_t n=w.size();
    for (size_t i=0; i<n; i++)
        for (size_t j=c; j>=w[i]; --j)
            if (dp[j] < dp[j-w[i]] + v[i])
                dp[j] = dp[j-w[i]] + v[i];

    return dp[c];
}

int main() {
    size_t N, W;
    scanf("%zu %zu", &N, &W);

    vector<size_t> v(N), w(N);
    for (size_t i=0; i<N; ++i)
        scanf("%zu %zu", &v[i], &w[i]);

    printf("%zu\n", binary_knapsack(w, v, W));
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int cnt = 1;
    sort(a.begin(),a.end());
    for(int i = 0; i < n - 1; i++){
        if(a[i] < a[i + 1])
        cnt++;
    }
    cout << cnt << endl;
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N;
  cin >> N;
  cout << (N - 1) / 2 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        switch (s.size()) {
            case 3:
                ans += 2;
                break;
            case 2:
                ans += 1;
                break;
            case 1:
                ans += 0;
                break;
        }
    }
    cout << ans << endl;
}

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

typedef pair<int,int> P;

int main(){
  int n,m;
  int s,t;
  int x,y;
  int grid[101][101];

  while(cin >> n && n){
    cin >> m;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)grid[i][j] = 1<<25;

    cin >> s;
    for(int i=0;i<s;i++){
      cin >> x >> y;
      grid[x][y] = 0;
      queue<P> q;
      q.push(P(x,y));
      while(q.size()){
	P p = q.front();q.pop();
	x=p.first, y=p.second;

	int dx[6]={1,0,-1,1,0,1},dy[6] = {-1,-1,0,0,1,1};
	if(y&1)dx[0] = dx[5] = -1;
	for(int i=0;i<6;i++){
	  int sx = x+dx[i],sy = y+dy[i];
	  if(sx<=0 || sy<=0 || n<sx || m<sy)continue;
	  if(grid[sx][sy]>grid[x][y]+1){
	    grid[sx][sy] = grid[x][y] + 1;
	    q.push(P(sx,sy));
	  }
	}
      }
    }

    int ans = 0;
    cin >> t;
    for(int i=0;i<t;i++){
      cin >> x >> y;
      int hoge = 1;
      int tmp[101][101];
      for(int j=0;j<n;j++)
	for(int k=0;k<m;k++)tmp[j][k] = grid[j][k];

      grid[x][y] = 0;
      queue<P> q;
      q.push(P(x,y));
      while(q.size()){
	P p = q.front();q.pop();
	x=p.first, y=p.second;

	int dx[6]={1,0,-1,1,0,1},dy[6] = {-1,-1,0,0,1,1};
	if(y&1)dx[0] = dx[5] = -1;
	for(int i=0;i<6;i++){
	  int sx = x+dx[i],sy = y+dy[i];
	  if(sx<=0 || sy<=0 || n<sx || m<sy)continue;
	  if(grid[sx][sy]>grid[x][y]+1){
	    grid[sx][sy] = grid[x][y] + 1;
	    hoge++;
	    q.push(P(sx,sy));
	  }
	}
      }
      ans = max(ans,hoge);
      for(int j=0;j<n;j++)
	for(int k=0;k<m;k++)grid[j][k] = tmp[j][k];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val S = next().map { it - '0' }
    fun count(v: List<Int>, d: Int): Int {
        var c = 0
        v.forEachIndexed { index, n -> c += if (index % 2 == d) if (n == 1) 1 else 0 else if (n == 0) 1 else 0 }
        return c
    }
    println(Math.min(count(S, 0), count(S, 1)))
}
fun next() = readLine()!!

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

namespace AtCoder.Question
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var x = ReadHelper.ReadValue<string>();
            Console.WriteLine(x.ToLower() == x ? "a" : "A");
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 26372
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([data[i]*(data[i]-1)//2 for i in data if data[i]>=2]))


Measured memory_bytes: 63000
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n;
vector<ll> a, dp;
unordered_map<ll, ll> mp;

void solve() {
    ll ans = 0;
    each(i, mp) {
        if (i.first == 0) {
            ll temp = 1;
            while (i.second > 1) {
                temp += i.second;
                i.second--;
            }
            ans += temp;
        } else {
            ans += (i.second * (i.second - 1) / 2);
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    a.resize(n);
    dp.resize(n + 1);
    dp[0] = 0;
    rep(i, n) {
        cin >> a[i];
        dp[i + 1] = dp[i] + a[i];
        mp[dp[i + 1]]++;
    }
    solve();
    return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for ( int i = (a); i < (n); ++i)
#define REP(i,n) for( int i = 0; i < (n); ++i )
#define ALL(obj) (obj).begin(), (obj).end()

int main()
{
    int N,K;
    cin >> N >> K;

    queue<double> s;

    REP(i,K) {
        s.push(0.0);
    }

    double max = 0.0;
    double sum = 0.0;
  
    REP(i,N) {
        double v;
        cin >> v;
        double e = (v+1.0)/2.0;
        
        sum -= s.front();
        s.pop();
        sum += e;
        s.push(e);

        if( max < sum ) {
            max = sum;
        }
    }

    cout << fixed << max << endl;
    return 0;
}


Measured memory_bytes: 1920
package main

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

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readInt()

	var res int64
	for i := 1; i <= n; i++ {
		switch {
		case i%15 == 0:
			continue
		case i%3 == 0:
			continue
		case i%5 == 0:
			continue
		default:
			res = res + int64(i)
		}
	}

	fmt.Println(res)
}

/*-------------------inputs-------------------*/

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 readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}


Measured memory_bytes: 1756
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double n, a, b, c, d, ans = 0;
	for (int i = 0; i < 2; i++) {
		cin >> a >> b >> c >> d;
		ans = max(ans, a + b + c + d);
	}
	cout << ans << endl;
	cin >> n;
}



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

using namespace std;

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	
	vector<int> a(m);
	for(int i=0; i < m; i++) {
		cin >> a[i];
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		int sum = 0;
		
		for(int j=0; j < m; j++) {
			int val;
			cin >> val;
			
			sum += val * a[j];
		}
		
		if(sum + c > 0) cnt++;
	}
	
	cout << cnt;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  string A = "Three";
  
  for(int i = 0; i<N; i++){
    cin >> S;
    if(S == "Y"){
      A = "Four";
    }
  }
  
  cout << A << endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



int p;
int n;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int cnt[MX];
int h[MX];
int pw[MX];

int powmod(int a, int b) {
	if (b == 0)
		return 1;
	int res = powmod(a, b / 2);
	res = res * res % p;
	if (b & 1)
		res = res * a % p;
	return res;
}


int rev(int x) {
	return powmod(x, p - 2);
}

void stupid() {
	str s;
	int cnt = 0;
	cin >> s;
	fx(x, s) {
		x -= '0';
		if (x % p == 0)	++cnt;
	}
	int res = 0;
	fi(0, n) {
		res += cnt;
		if(s[i] % p == 0) --cnt;
	}
	cout << res << '\n';
	exit(0);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   		
   	cin >> n >> p;
   	if (10 % p == 0) {
   		stupid();
   	}
   	pw[0] = 1;
   	fi(1, MX) pw[i] = 10 * pw[i - 1] % p;
   	str s;
   	cin >> s;
   	fx(x, s) x -= '0';
   	h[0] = 0;
   	cnt[0] = 1;
   	fi(1, n + 1) {
   		h[i] = (h[i - 1] * 10 + s[i - 1]) % p; 
   		dbg(h[i]);
   		++cnt[h[i] * rev(pw[i]) % p];
   	}
   	int res = 0;
   	fi(0, n) {
   		--cnt[h[i] * rev(pw[i]) % p];
   		int need = h[i] * rev(pw[i]) % p;
   		res += cnt[need];
   	}
   	cout << res << '\n';
}

Measured memory_bytes: 4628
import math

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j>=0 and A[j]>v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    print(m)
    show(g)
    for i in range(0, m):
        insertionSort(A, n, g[i]) 

def show(A):
    L = list(map(str, A))
    print(" ".join(L))

n = int(input())
A = [int(input()) for i in range(n)]

shellSort(A, n)
print(cnt)
for i in A:
    print(i)


Measured memory_bytes: 45580
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main() {
    SS(int,N,M,R)
    SV(int,r,R);
    vvl dist(N, vector<ll>(N, MOD));
    rep(i,M){
        SS(ll,a,b,c);
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }
    rep(i,N)rep(j,N)rep(k,N)chmin(dist[j][k], dist[j][i] + dist[i][k]);

    ll ans = MOD;
    sort(all(r));
    do {
        ll candi = 0;
        rep(i,R-1)candi += dist[r[i]-1][r[i+1]-1];
        chmin(ans, candi);
    } while(next_permutation(r.begin(), r.end()));

    p(ans);
}

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

int main() {
	// your code goes here
	string s1,s2;
	cin>>s1;
	cin>>s2;
	if(s2.size()!=s1.size()+1){
		cout<<"No"<<endl;
	}
	for(int i=0;i<s1.size();i++){
		if(s1[i]==s2[i])
		   continue;
		   else{
		   	cout<<"No"<<endl;
		   	return 0;
		   }
	}
	if(s2.size()==s1.size()+1)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3136
coin = [int(input()) for _ in range(3)]
X = int(input())
A = []
for i in range(coin[0]+1):
  for j in range(coin[1]+1):
    for k in range(coin[2]+1):
      A.append(500*i+100*j+50*k)
ans = A.count(X)
print(ans)


Measured memory_bytes: 48368
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int c[30];
signed main(void)
{
	string s;
	cin >> s;
	REP(i, s.size()) c[s[i]-'a']++;
	REP(i, 26) if(c[i] > 1) {cout << "no" << endl; return 0;}
	cout << "yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> nums;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	nums.pb(x);
    }
    sort(nums.begin(), nums.end());
    vector<int> ans;
    for(int i = 0; i <= n - k; ++i){
    	int j = i + k - 1;
    	int y = nums[j] - nums[i];
    	ans.pb(y);
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
	return 0;
} 

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int a,b; cin>>a>>b;
    int diff = a - 2*b;
    diff = max(0LL,diff);
    cout<<diff<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define N 200008
using namespace std;
int n,a[N],l1,l2,ans[N],as;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		ans[a[i]]=ans[a[i]-1]+1;
		as=max(as,ans[a[i]]);
	}
	cout<<n-as;
	return 0;
}

Measured memory_bytes: 1792
#!python3
import sys
sys.setrecursionlimit(1000000)

from heapq import heappush, heappop, heapify

iim = lambda: map(int, input().rstrip().split())

def resolve():
    H, N = iim()
    AB = [tuple(iim()) for i in range(N)]
    inf = float("inf")
    AB.sort(key=lambda a: (a[0]/a[1], -a[0]), reverse=True)

    def memo(f):
        cache = {}
        def wrapper(*a):
            if a in cache:
                return cache[a]
            b = f(*a)
            cache[a] = b

            return b

        return wrapper

    @memo
    def calc(h):
        if h <= 0: return 0

        bi = inf
        for a, b in AB:
            bj = b + calc(h - a)
            if bi > bj:
                bi = bj
            else:
                break
        return bi

    print(calc(H))



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 27712
// luogu-judger-enable-o2
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<queue>
#define int long long
using namespace std;
int a[100001],b[100001];
priority_queue <int,vector<int>,greater<int> > q;
priority_queue <int> p;
main() {
	int m,ans=0,L,zz,js=0,res1=0,res2=0,tot1=0,tot2=0;
	cin>>m;
	for(int i=1; i<=m; i++) {
		cin>>L;
		if(L==2)
			(ans%2)?printf("%lld %lld\n",p.top(),(ans-ans/2)*p.top()-res2+res1-ans/2*p.top()+js):printf("%lld %lld\n",min(p.top(),q.top()),(ans/2)*min(p.top(),q.top())+res1-res2-(ans/2)*min(p.top(),q.top())+js);
		else {
			int hh;
			ans++;
			cin>>hh>>zz;
			js+=zz;
			q.push(hh);
			res1+=hh;
			p.push(q.top());
			res1-=q.top();
			res2+=q.top();
			q.pop();
			if(ans%2==0)
				res2-=p.top(),res1+=p.top(),q.push(p.top()),p.pop();
//			cout<<res1<<res2<<js<<endl;
		}
	}
	return 0;
}

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

void test(string ABCD, string op, string &answer){
    if(op.size() == 3){
        int sum = ABCD.at(0) - '0';

        for(int i = 0; i < 3; i++){
            if(op.at(i) == '+') sum += ABCD.at(i+1) - '0';
            if(op.at(i) == '-') sum -= ABCD.at(i+1) - '0';
        }

        if(sum == 7) answer = op;
    }

    if(0 <= op.size() && op.size() < 3){
        op.push_back('+');
        test(ABCD, op, answer);
        op.pop_back();

        op.push_back('-');
        test(ABCD, op, answer);
        op.pop_back();
    }
}

int main() {
    string ABCD;
    cin >> ABCD;

    string op = "";
    string answer;
    test(ABCD, op, answer);

    cout << ABCD.at(0);
    for(int i = 0; i < 3; i++){
        cout << answer.at(i) << ABCD.at(i+1);
    }
    cout << "=7" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    string S;
    cin >> S;
    if(S.at(1) == 'R')cout << "ABC" << endl;
    else{
        cout << "ARC" << endl;
    }

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long,long>
#define pdd pair<double,double>
#define ff first
#define ss second
#define w(x) int x; cin>>x; while(x--)
using namespace std;
ll mod = 1e9+7;
void ffast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{
    ffast();
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)
    	for(int j=0;j<w;j++)
    		cin>>a[i][j];
    ll dp[h][w];
    memset(dp,0,sizeof dp);
    dp[0][0] = 1;
    for(int j=1;j<w;j++){
    	if(a[0][j]=='#')
    		break;
    	dp[0][j] = 1;
    }
    for(int i=1;i<h;i++){
    	if(a[i][0]=='#')
    		break;
    	dp[i][0] = 1;
    }
    for(int i=1;i<h;i++){
    	for(int j=1;j<w;j++){
    		if(a[i][j]=='#')
    			continue;
    		dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
    	}
    }
    // for(int i=0;i<h;i++){
    // 	for(int j=0;j<w;j++)
    // 		cout<<dp[i][j]<<" ";
    // 	cout<<endl;
    // }
    cout<<(dp[h-1][w-1]+mod)%mod;
}

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

//
// int main() {
//   char ch[19];
//   int n = 19;
//   rep(i, n) {
//     scanf("%s", &ch[i]);
//   }
//   rep(i,n) {
//     if (i == 5 || i == 13) {
//       printf(" ");
//     } else {
//       printf("%s", ch[i] );
//     }
//   }
//   return 0;
// }

int main() {
  string s;
  cin >> s;
  int N = 19;
  rep(i, N) {
    if ( i == 5 || i==13) cout << " ";
    else cout << s[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[5][4][11]={'0'},n,b,f,r,v,i,j,k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d%d%d",&b,&f,&r,&v);
        a[b][f][r]+=v;
    }
    for(i=1;i<5;i++)
    {
        for(j=1;j<4;j++)
        {
            for(k=1;k<11;k++)     
            {
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }    
        if(i<4)
        {
            printf("####################\n");
        }
    }
    return 0;
}


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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    cout << setprecision(16) << fixed;

    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(n), rG(n);
    vector<ll> in(n);
    while(m--) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
    }

    ll rr = 0;
    {
        vector<ll> cache(n, -1);
        auto dfs = [&](auto dfs, ll cur) {
            if(cache[cur] >= 0) return cache[cur];
            
            ll r = 0;
            for(auto &v: G[cur])
                r = max(r, 1 + dfs(dfs, v));
            rr = max(rr, r);
            return cache[cur] = r;
        };
        for(ll i=0; i<n; i++)
            dfs(dfs, i);
    }
    
    cout << rr << endl;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll x[5];
    rp(i, 0, 5) cin >> x[i];
    rp(i, 0, 5) if (x[i] == 0) ce(i + 1);
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, k; cin >> n >> k;
    vector<int> A(n);
    REP(i, n){
        int tmp; cin >> tmp;
        A[i] = min(tmp, abs(k - tmp)) * 2;
    }
    int ans = whole(accumulate, A, 0);
    cout << ans << endl;
}

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

int a, b;

void init() {
	scanf("%d%d", &a, &b);
	return ;
}

void solve() {
	if(a > 9 || b > 9) {
		printf("-1");
		return ;
	}
	printf("%d", a*b);
	return ;
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll N;

int solve() {
  ll ans = 1;
  ll over = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    if (a == 0) { cout << "0" << endl; return 0; }
    if ((ld)ans > pow((ld)10.0, (ld)18.0) / (ld)a) {
      over = 1;
    } else {
      ans *= a;
    }
  }
  if (over == 1) {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

int main() {
  cin >> N;
  solve();
  return 0;
}


Measured memory_bytes: 3648
#[warn(dead_code)]
fn read<T: std::str::FromStr>() -> T {
   let mut s = String::new();
   std::io::stdin().read_line(&mut s).ok();
   s.trim().parse().ok().unwrap()
}

#[warn(dead_code)]
fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
   let s = read::<String>();
   s.split(delimiter)
      .map(|e| e.parse().ok().unwrap())
      .collect::<Vec<T>>()
}

fn main() {
    let _n = read::<i32>();
    let aa = readn::<i32>(" ");
    let mut ans = Vec::<i32>::new();
    ans.push(0);
    for a in aa {
        ans.push(0);
        ans[a as usize - 1] += 1;
    }
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 4484
#include<bits/stdc++.h>
using namespace std;
main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans;
  if(a<=b) ans=a;
  else ans=b;
  if(c<=d) ans+=c;
  else ans+=d;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

bool eq(vector<ll>& a, vector<ll>& b){
  ll n = SZ(a);
  REP(i,n){
    if(a[i] != b[i]){
      return false;
    }
  }
  return true;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n), q(n);
  REP(i,n){
    cin >> p[i];
  }
  REP(i,n){
    cin >> q[i];
  }
  ll a = -1, b = -1;
  vector<ll> ord(n);
  iota(ALL(ord),1);
  ll cnt = 1;
  do{
    if(eq(ord,p)){
      a = cnt;
    }
    if(eq(ord,q)){
      b = cnt;
    }
    cnt++;
  }while(next_permutation(ALL(ord)));
  cout << abs(a-b) << endl;
}

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

#define MOD 1000000007

ll factorial(ll a) {
  ll ret = 1;
  for(ll i = 1; i <= a; i++) {
    ret = ret * i % MOD;
  }

  return ret;

}

int main() {
  int N, M;
  cin >> N >> M;

  if(N > M) {
    swap(N, M);
  }

  if(N + 1 < M) {
    cout << 0 << endl;
    return 0;
  }

  if(N + 1 == M) {
    ll ans = 1;
    ans = factorial(N) * factorial(M) % MOD;
    cout << ans << endl;
    return 0;
  }

  ll ans = 1;
  ans = factorial(N) * factorial(M) * 2 % MOD;
  cout << ans << endl;
  return 0;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef int I;
int main() {
    lli n;
    cin>>n;
    lli a[n],i,sum=0;
    for(i=0;i<n;i++)
     cin>>a[i];
     sort(a,a+n);
     for(i=0;i<n-1;i++)
     sum=sum+a[i];
     if(sum>a[n-1])
     cout<<"Yes"<<"\n";
     else
     cout<<"No"<<"\n";
}
  

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <random>
#include <array>
#include <chrono>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

using llint=long long;

llint scoring(vector<llint> c,
            vector<vector<llint>> s,
            vector<llint> result,
            llint d=365){
    
    if(c.size()!=s[0].size()||s.size()!=result.size()){
  
        return -1;
    }else{
        llint score=0;
        vector<llint>held(26,1);
        REP(i,d){
            score+=s[i][result[i]-1];
            REP(j,26){
                if(j+1!=result[i]){
                    held[j]++;
                    
                }else{held[j]=0;}
                score-=c[j]*held[j];
            }
        }
         
        return score;
    }
 }

int main(){
    chrono::system_clock::time_point start, end;
    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    start = chrono::system_clock::now();
    llint d;
    cin>>d;
    std::uniform_int_distribution<> rand26(1, 26),randd(0,d-1);        // [0, 99] 範囲の一様乱数
    
    llint anum=26;
    vector<llint> c(anum);
    
    REP(i,anum){
        cin>>c[i];
    }
    vector<vector<llint>> s(d,vector<llint>(anum));
    REP(i,d){
        REP(j,anum){
            cin>>s[i][j];
        }
    }
    vector<llint> result(d);

    REP(i,d){
        result[i]=rand26(mt);
    }
    double time;
    auto newresult=result;
    while(( time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(
        ( chrono::system_clock::now()) - start).count()
        ))<1900000.){
        newresult=result;
        REP(i,20){
            newresult[randd(mt)]=rand26(mt);
        }
        if(scoring(c,s,newresult,d)>scoring(c,s,result,d)){
            result=newresult;
        }
        //cout<<"unko"<<endl;
    }
   //  cout<<scoring(c,s,result,d)<<endl;
    REP(i,d){
        cout<<result[i]<<endl;
    }
}


Measured memory_bytes: 3452
#include <map>
#include <iostream>
#include <vector>
using namespace std;
map<string,int> item;
map<string,vector<string> > rec;

int saiki(string str){
	int ret = 0;
	if(rec[str].size()){
		for(int i=0;i<rec[str].size();i++){
			ret += saiki(rec[str][i]);
		}
	}else{
		ret+=item[str];
	}
	if(item[str]&&item[str]<ret)ret=item[str];
	return ret;
}

int main(){
	int n,m,t;
	string s,rs;
	while(cin >> n && n){
		item.clear();
		rec.clear();
		for(int i=0;i<n;i++){
			cin >>	s;
			cin >> item[s];
		}
		cin >> m;
		for(int i=0;i<m;i++){
			cin >> rs >> t;
			for(int j=0;j<t;j++){
				cin >> s;
				rec[rs].push_back(s);
			}
		}
		cin >> s;
		cout << saiki(s) << endl;
	}
}

Measured memory_bytes: 0
H, W, K = map(int, input().split())
s = ['' for i in range(H)]
for i in range(H):
    s[i] = input()
now = 1
ans = [[] for i in range(H)]
count = 0
flag = False
for i in range(H):
    gokei = s[i].count('#')
    shap = 0
    if gokei >= 1:
        flag = True
        for j in range(W):
            ans[i].append(now)
            if j == W-1:
                now += 1
            elif s[i][j] == '#' and shap < gokei-1:
                now += 1
                shap += 1
            elif s[i][j] == '#' and shap == gokei-1:
                shap += 1
    elif gokei == 0 and flag:
        ans[i] = ans[i-1]
    elif gokei == 0 and flag == False:
        count += 1
for i in range(count):
    ans[i] = ans[count]
for i in range(H):
    print(*ans[i])


Measured memory_bytes: 7552
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N; cin>>N;
  vector<pair<int, int>> cities(N); for (auto& city : cities) {
    cin>>city.first>>city.second;
  }
  double sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      auto dx = cities[i].first-cities[j].first;
      auto dy = cities[i].second-cities[j].second;
      sum += sqrt(dx*dx+dy*dy);
    }
  }
  auto ans = sum*2/N;
  cout << fixed << setprecision(7) << ans << endl;

  return 0;
}


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

int main()
{
    int r, c;
    cin >> r >> c;
    int data[r+1][c+1];
    for (int i = 0; i <= c; i++)
        data[r][i] = 0;
    
    for (int i = 0; i < r; i++)
    {
        data[i][c] = 0;
        for (int j = 0; j < c; j++)
        {
            cin >> data[i][j];
            data[i][c] += data[i][j];
            data[r][j] += data[i][j];
        }
    }
    
    
    
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            if (i == r) data[i][c] += data[i][j];
            if (j == c)
            {
                if (i == r)
                {
                    cout << data[i][j] / 2;    
                }
                else
                {
                    cout << data[i][j];
                }
            }
            else
            {
            cout << data[i][j] << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    string S;cin >> S;
    bool ans = true;
    if(N % 2 != 0)ans = false;

    rep(i,N/2)if(S[i] != S[i + N/2])ans = false;

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

signed main() {
  string x;cin>>x;
  int div=0;
  for(int i=0;i<x.size();i++) {
     div+=(int)(x[i] - '0');
  }
  if(stoi(x)%div==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
   
  return 0;
  
}

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

int main() {
  int n;
  int x;
  int t;
  ll d;
  cin >> n >> x >> t >> d;
  int ans;
  ans = ceil(n / x);
  if (n % x != 0) {
    ans++;
  }
  ans *= t;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644