akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())
flag = 0
for n_i in range(N - M + 1):
    for n_j in range(N - M + 1):
        for m_i in range(M):
            for m_j in range(M):
                if A[n_i + m_i][n_j + m_j] == B[m_i][m_j]:
                    continue
                break
            else:
                continue
            break
        else:
            flag = 1
            break
    else:
        continue
    break
if flag == 1:
    print("Yes")
else:
    print("No")

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

int main() {
    string ss;
    cin >> ss;
    string ans = "Yes";

    for (int i=0; i<ss.size(); i++) {
        if (i%2==1) {
            if (ss.at(i) == 'R') {
                ans = "No";
                break;
            }
        }
        else {
            if (ss.at(i) == 'L') {
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long n,i,j,l,a=0;
	int nn[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
	
	while (1) {
		scanf("%ld",&n);
		if (getchar() == EOF)break;
		
		for(i=2;i<=n;i++){
			if(i>997){
				for(j=0;i>nn[j]&&j<168;j++){
					if(i%nn[j]==0)break;
				}
				if(j==168)a++;
			}
			else{
				for(l=2;l<i;l++){
					if(i%l==0)break;
				}
				if(l==i){
					a++;
				}
			}
				
		}
		printf("%ld\n",a);
		a=0;
	}
	
	
	return 0;
	
}

Measured memory_bytes: 408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

typedef long long ll;
using namespace std;

int main() {
    
    string s;
    cin >> s;
    
    int n = s.size();
    
    ll ans = 0;
    int index = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            ans += i - index;
            index++;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 640
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N,K=mis()
    A=lmis()
    A.sort()
    #
    fs = factorials_list(N, N1097)
    invs = invs_list(N, fs, N1097)
    #
    ans = 0
    for i in range(N):
        if K-1 <= i:
            ans += (A[i] - A[N-1-i]) * comb_from_list(i, K-1, N1097, fs, invs)
    print(ans % N1097)

main()


Measured memory_bytes: 16988
N, M, C = gets.split(' ').map(&:to_i)
B = gets.split(' ').map(&:to_i)

ans = 0
N.times do
  a = gets.split(' ').map(&:to_i)
  val = C
  M.times do |i|
    val += a[i] * B[i]
  end
  ans += 1 if val > 0
end

puts ans

Measured memory_bytes: 1788
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<ll> a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < 3*n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    for(int i=n;i<3*n;i++){
        b.push_back(a[i]);
    }
    sort(ALL(b));
    ll ansa=0;
    for(int i=0;i<n;i++){
        ansa+=b[i];
    }
    priority_queue<ll> af;
    priority_queue<ll,vector<ll>,greater<ll> > be;
    ll ansb=0;
    //ll ansa=0;
    for(int i=0;i<n;i++){
        be.push(a[i]);
        ansb+=a[i];
    }
    for(int i=n;i<3*n;i++){
        if(af.size()<n){
            af.push(a[i]);
            //ansa+=a[i];
        }
        else{
            if(af.top()>a[i]){
                //ansa-=af.top();
                //ansa+=a[i];
                af.pop();
                af.push(a[i]);
            }
        }
    }
    //cout << ansb <<" "<<ansa<< "\n";
    int count=n-1;
    ll ans=ansb-ansa;
    for(int i=n;i<2*n;i++){
        if(be.top()<a[i]){
            ansb-=be.top();
            ansb+=a[i];
            be.pop();
            be.push(a[i]);
        }
        if(b[count]>=a[i]){
            count++;
            ansa-=a[i];
            ansa+=b[count];
        }
        else{
            auto iter=lower_bound(ALL(b),a[i]);
            b.erase(b.begin()+(iter-b.begin()));
        }
        //cout << ansb <<" "<<ansa<< "\n";
        ans=max(ansb-ansa,ans);
    }
    cout << ans<< "\n";
}



Measured memory_bytes: 8684
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> key;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j, b) {
      int c;
      cin >> c;
      --c;
      s |= 1<<c;
    }
    key.emplace_back(s, a);
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  rep(s, 1<<n) {
    rep(i, m) {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

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

void solve(long long N, std::vector<long long> a)
{
    long long A = 0, B = 0;
    sort(a.begin(), a.end(), greater<long long>());
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
            A += a[i];
        else
            B += a[i];
    }
    cout << A - B << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    int K,n;
    cin >> K;
    n = s.length();
    set<string> st;
    char ch = 'a';
    for(int i = 0; i <= 25; i++){
        char temp = ch + i;
        for(int j = 0; j < n; j++){
            if(s[j] == temp){
                string T = string() + s[j];
                st.insert(T);
                for(int m = 1; m < K; m++){
                    if(j+m < n){
                        T += s[j+m];
                        st.insert(T);
                    }
                }
            }
        }
        if(st.size() > K) break;
    }
    auto ite = st.begin();
    int count = 1;
    string ans;
    for(; ite != st.end(); ite++){
        if(count == K){
            ans = *ite;
            break;
        }
        count++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func PrntLect(H, W int) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Print("#")
		}
		fmt.Println()
	}

	
}

func main() {
	H := 1
	W := 1

		for {
			fmt.Scan(&H)
			fmt.Scan(&W)
				if H == 0 && W == 0 {
					break
				}
			PrntLect(H, W)
			fmt.Println()
		}
}


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

int main() {
    int N; cin >> N;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    int n = sizeof(L) / sizeof(L[0]);
    sort(L, L + n);
    int sum = 0;
    bool canMakePolygon = false;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            if (sum > L[i]) {
                canMakePolygon = true;
            }
        } else {
            sum += L[i];
        }
    }
    if (canMakePolygon) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);


int main() {
    ll C;
    cin>>A>>B>>C>>K;
    while(B <= A) {
        B *= 2;
        --K;
    }
    while(C <= B){
        C *= 2;
        --K;
    }
    cout<<(K >= 0 ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3532
// abc054b: Template Matching
#include <bits/stdc++.h>
using namespace std;
using vs = vector<string>;

#define rep(i,n) for(int i=0;i<(n);i++)
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

bool page(int ox, int oy, vs &map, vs &man){
  int n=man.size();
  rep(y,n)
    if(map[oy+y].substr(ox,n) != man[y]) return false;
  return true;
}

int main(){
  int n, m; in(n); in(m);
  vs a(n), b(m);
  rep(i,n) in(a[i]);
  rep(i,m) in(b[i]);
  int org_n = n-m+1;
  rep(oy,org_n)
    rep(ox,org_n)
      if(page(ox,oy,a,b)){ oute("Yes"); return 0; }
  oute("No");
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  vi l(n+1), r(n+1);
  rep(i, 0, n) l[i+1] = max(l[i], a[i]);
  for(int i = n; i > 0; i--) r[i-1] = max(r[i], a[i-1]);

  rep(i, 0, n){
    cout << max(l[i], r[i+1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pii pair<ll,ll>
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
      boost;
      int n,m;
      cin>>n>>m;
      char s[100][100];
      bool b=true;
      for(int i=0;i<100;i++)
      {
            for(int j=0;j<100;j++)
            {
                  if(i<50)
                  {
                        s[i][j]='.';
                  }
                  else
                  {
                        s[i][j]='#';
                  }
            }
      }
      n--;
      m--;
      for(int i=0;i<49 && b;i+=2)
      {
            for(int j=0;j<100;j+=2)
            {
                  if(m--)
                  {
                        s[i][j]='#';
                  }
                  else
                  {
                        b=false;
                        break;
                  }
            }
      }
      b=true;
      for(int i=51;i<100 && b;i+=2)
      {
            for(int j=0;j<100;j+=2)
            {
                  if(n--)
                  {
                        s[i][j]='.';
                  }
                  else
                  {
                        b=false;
                        break;
                  }
            }
      }
      cout<<"100 100"<<endl;
      for(int i=0;i<100;i++)
      {
            for(int j=0;j<100;j++)
            {
                  cout<<s[i][j];
            }
            cout<<endl;
      }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) REP(i,n+1)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RREP(i,n+1)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PERM(c) sort(ALL(c)); for(bool cp = true;cp;cp = next_permutation(ALL(c)))
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1E9+7;
int dx[] = {1,0,-1,0}; int dy[] = {0,1,0,-1};
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
struct union_find{//rank,経路圧縮で高速化
  vector<long long> data;//そのノードがrootであれば-（集合のサイズ）を表し、そうでなければ親ノードidを示す。
  union_find(long long size):data(size,-1){}//コンストラクタ,size個のノードを作成し、-1で初期化
  long long root(long long a){//根を探す,経路圧縮
    return data[a] < 0 ? a : data[a]=root(data[a]);
  }
  bool find(long long a,long long b){//a,bが同じ集合に属するか調べる
    return root(a) == root(b);
  }
  bool unite(long long a,long long b){//小さい方の木の根に大きい方の根を上書きする
    a = root(a),b = root(b);
    if(a==b) return false;//根が同じなら終了,uniteが失敗したことを出力
    if(data[a]<data[b]) swap(a,b); //集合サイズの大きい方の根に低い方の根をつける
    data[b] += data[a];//集合サイズを統合
    data[a] = b;//yの親にxをつける
    return true;//unite成功を出力
  }
  long long size(long long a){//aが属する集合のサイズを出力
    return -data[root(a)];
  }
};
signed main(){
  int n,q;
  cin >> n >> q;
  union_find a(n);
  REP(i,q){
    int con,x,y;
    cin >> con >> x >> y;
    if(con==0){
      a.unite(x,y);
    }else{
      cout << a.find(x,y) << endl;
    }
  }
}



Measured memory_bytes: 3180
n = int(input())
s = list(input())

L = [0] * n
R = [0] * n

# 左にある W
for i in range(1, n):
    if s[i - 1] == 'W':
        L[i] = L[i - 1] + 1
    else:
        L[i] = L[i - 1]

# 右にある W
for i in range(n - 2, -1, -1):
    if s[i + 1] == 'E':
        R[i] = R[i + 1] + 1
    else:
        R[i] = R[i + 1]

res = 1 << 29
for i in range(n):
    res = min(res, L[i] + R[i])

print(res)

Measured memory_bytes: 67696
/*
author : wajiul
problem-link: https://atcoder.jp/contests/abc094/submissions/15116281
claim: 
   C(N+1 , r ) = C(N, r) + C(N , r - 1);
   => C(N + 1 , r) >= C(N , r); 
*/
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 998244353;
const int inf = 1e18;
const int Maxn = 20010;


int Pow(int x , int y , int mod){
  int res = 1;
  while(y>0){
      if(y&1)
          res = (res*x) % mod;
      y=y>>1;
      x = (x*x) % mod;
  }
  return res % mod;
}

signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int N;
  cin >> N;
  map<int,int> Cnt;
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d[i];
    Cnt[d[i]]++;
  }
  int ans = d[0] == 0 && Cnt[0] == 1;
  for(int i = 1; i <= N; i++) {
    ans = (ans * Pow(Cnt[i-1] , Cnt[i] , Mod)) % Mod;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 9984
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M;
typedef pair<int, pair<int, int> > P;
P B[100005];
unordered_map<int, int> Um;
P Ans[100005];

int main() {
  INCANT;
  cin >> N >> M;
  int p,y;
  rep(i, M) {
    cin >> p >> y;
    B[i]=P(y, make_pair(p, i));
  }
  sort(B,B+M);
  rep(i, M) {
    P p =B[i];
    int state = p.second.first;
    Um[state]++;
    int d = Um[state];
    Ans[i] = P(p.second.second, make_pair(state, d));
  }
  sort(Ans, Ans+M);
  rep(i, M) {
    P p = Ans[i];
    cout << setfill('0') << right << setw(6) << p.second.first;
    cout << setfill('0') << right << setw(6) << p.second.second << endl;
  } 
  return 0;
}

Measured memory_bytes: 7972
#include<stdio.h>
#include<math.h>
int main(){
    int a, b, i, j, n, d;
    int count = 0;
    scanf("%d %d", &n, &d);
    a = n/(d*2+1)+1;
    if(n%(d*2+1)== 0)a--;
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    
    long long int r=0;
    long long int l=0;
    long long int p;
    string ans;
    if(N>r) {
        r = 1;
        p = 1;
        while(r<=N) {
            r += p;
            p *= 4;
        }
        l = r-p/4;
    } else if(N<l) {
        l = -1;
        p = 2;
        while(l>=N) {
            l -= p;
            p *= 4;
        }
        r = l+p/4;
    }
    
    if(r-l<1) {
        ans = "0";
    } else {
        ans = "1";
    }

    bool flag= N>0 ? true : false;
    while(r-l>1) {
        long long int mid=(r+l)/2;
        
        if(N>0) {
            if(N<mid) {
                r = mid;
                if(flag) {
                    ans += "1";
                    flag = false;
                } else {
                    ans += "0";
                    flag = true;
                }
            } else {
                l = mid;
                if(flag) {
                    ans += "0";
                    flag = false;
                } else {
                    ans += "1";
                    flag = true;
                }
            }
        } else {
            if(N<=mid) {
                r = mid;
                if(flag) {
                    ans += "1";
                    flag = false;
                } else {
                    ans += "0";
                    flag = true;
                }
            } else {
                l = mid;
                if(flag) {
                    ans += "0";
                    flag = false;
                } else {
                    ans += "1";
                    flag = true;
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //char now,pre,c;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a;
        sum+=a;
    }
    if(sum>=n) cout<<"Yes";
    else cout<<"No";
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,count = 0;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    if(count%2==0){
      c = c - b;
      count++;
      }
    else{
      a = a - d;
      count++;
      }
    }
    if(a<=0)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
    }

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll A, B;
    char op;
    cin >> A >> op >> B;
    if (op == '+') {
        cout << A + B << endl;
    }
    else {
        cout << A - B << endl;
    }
}

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

#define Max 500000
#define R -1
#define s1 "insert"
#define s2 "print"

typedef struct{
  int parent;
  int left;
  int right;
  int key;
}Node;

Node T[Max];
int root=-1;

void insert(int cnt){
  int x=root;
  int y=R;

  while(x!=R){
    y=x;
    if(T[cnt].key< T[x].key){
      x=T[x].left;
    }else{
      x=T[x].right;
    }
  }
  T[cnt].parent=y;

  if(y==R){
    root=cnt;
  }else if(T[cnt].key < T[y].key){
    T[y].left=cnt;
  }else{
    T[y].right=cnt;
  }
}
void order1(int q){
  if(q==R) return;
  order1(T[q].left);
  printf(" %d",T[q].key);
  order1(T[q].right);
}

void order2(int q){
  if(q == R) return;
  printf(" %d",T[q].key);
  order2(T[q].left);
  order2(T[q].right);
}

int find(int q){
  int k=root;
  while(k!=R && q!=T[k].key){
    if(q<T[k].key) k=T[k].left;
    else k=T[k].right;
  }
  return k;
}



int main(int argc, char const *argv[]) {
  int n,i,x;
  char s[7];

  scanf("%d",&n);
  for (i = 0; i < n; i++) T[i].right=T[i].left=T[i].parent=R;

  for (i = 0; i < n; i++) {
    scanf("%s",s);
    if(strcmp(s,"find")==0){
      scanf("%d",&x);
      if(find(x)==R){
        printf("no\n");
      }else{
        printf("yes\n");
      }
    }else if(strcmp(s,"insert")==0){
      scanf("%d",&T[i].key);
      insert(i);
    }else if(strcmp(s,"print")==0){
      order1(0);
      printf("\n");
      order2(0);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 8428
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        k: usize,
    }

    let mut count: usize = 1;
    let mut now: usize = 7 % k;
    let mut appear: HashMap<usize, bool> = HashMap::new();
    loop {
        if now == 0 {
            println!("{}", count);
            break
        }
        if appear.get(&now) != None {
            println!("-1");
            break
        }
        appear.insert(now, true);

        now = (now * 10 + 7) % k;
        // now = now * 10 + 7;
        count += 1;
    }

}


Measured memory_bytes: 54284
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

	P((int)n/3);
	ret 0;
}

Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table(5*10**3)

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

def H(n, r):
    return comb(n - 1 + r, r)

n, k = map(int, sys.stdin.readline().split())

def main():
    res = [None] * (k + 1)
    for i in range(1, k+1):
        if i > n - k + 1:
            for j in range(i, k+1):
                res[j] = 0
                break
        res[i] = comb(n-k+1, i) * H(i, k-i) % MOD
    
    return res[1:]
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, m, x;
  cin >> n >> m >> x;
  int b = 0;
  
  vector<int> a(m);  
  rep(i, 0, m) {
    cin >> a.at(i);
    if(a.at(i) < x)
      b++;
  }  
  
  cout << min(b, m-b) << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


Measured memory_bytes: 256
N, M = map(int,input().split())

NA = [0] * N

for c in range(M):
    d =  int(input())
    A = input().split()

    for b in A:
        NA[int(b)-1] = 1

ANS = 0

for d in NA:
    if d == 0:
        ANS += 1

print(ANS)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

struct DisjointSet {
    vector<int> par; //根.連結成分の根にはその成分の要素数を符号反転して保存する．

    DisjointSet(int n) : par(n, -1) {} //.0-indexed 
    void init(int n) {par.assign(n, -1);}// 初期化

    int root(int x) {
        if (par[x] < 0) return x; //根が負なら自身が根．
        else return par[x] = root(par[x]); //径路圧縮
    }
    
    // 連結判定
    bool issame(int x, int y) { return root(x) == root(y); }

    bool unite(int x, int y) { // 結合が行われればtrue.行われなければfalse.
        x = root(x); y = root(y); // 径路圧縮
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); 
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int64_t size(int x){ return -par[root(x)]; }
};

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


int n, q; cin >> n >> q;
DisjointSet DS(n);

rep(_, 0, q){
    int com, x, y; cin >> com >> x >> y;
    if (com) {
        if (DS.issame(x, y)) cout << "1\n";
        else cout << "0\n";
    }
    else DS.unite(x, y);
}


}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．




Measured memory_bytes: 3268
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(ll i=a;i<=b;++i)
#define bfor(i,a,b) for(ll i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=998244353;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=300000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll fact[N + 5];
ll ifact[N + 5];

ll ncr(ll n,ll r)
{
  if(n<r || n<0 || r<0)return 0;
  if(r==0 || r==n)return 1LL;
  ll ret  = fact[n];
  ret*= ifact[r];
  ret%= mod;
  ret*= ifact[n-r];
  ret%= mod;
  return ret;
}
int main()
{
  fact[0] = ifact[0] = 1;
  afor(i,1,N)
  {
    fact[i] = (fact[i-1] * i)%mod;
    ifact[i] = fp(fact[i],mod-2,mod);
  }

  finp;
  ll n,A,B,K;
  ll ans = 0;
  cin>>n>>A>>B>>K;


  afor(na,0,K/A)//no of A's
  {
    ll rem = K - na*A;
    if(rem%B)continue;
    ll nb = rem/B;
    ans+= (ncr(n,na)*ncr(n,nb))%mod;
    ans%= mod;
  }
  
  cout<<ans;
return 0;
}

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

using namespace std;

int main(void)
{
    long long L, R, d;
    cin >> L;
    cin >> R;
    cin >> d;
    long long count = 0;
    for (size_t i = L; i < R + 1; i++)
    {
        if (i % d == 0)
        {
            count++;
        }
    }

    cout << count << endl;
}

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

int main(){
	int A,B,C,D;
	scanf("%1d%1d%1d%1d",&A,&B,&C,&D);
	if(A+B+C+D==7){
		printf("%d+%d+%d+%d=7\n",A,B,C,D);
	}
    else if(A-B+C+D==7){
		printf("%d-%d+%d+%d=7\n",A,B,C,D);
	}
	else if(A+B-C+D==7){
		printf("%d+%d-%d+%d=7\n",A,B,C,D);
	}
	else if(A+B+C-D==7){
		printf("%d+%d+%d-%d=7\n",A,B,C,D);
	}
	else if(A-B-C+D==7){
		printf("%d-%d-%d+%d=7\n",A,B,C,D);
	}
	else if(A+B-C-D==7){
		printf("%d+%d-%d-%d=7\n",A,B,C,D);
	}
	else if(A-B+C-D==7){
		printf("%d-%d+%d-%d=7\n",A,B,C,D);
	}
	else if(A-B-C-D==7){
		printf("%d-%d-%d-%d=7\n",A,B,C,D);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int n,m,ans = 0,cnt2 = 0;
    cin >> n >> m;
    vector<int> k(m),p(m);
    vector<vector<int> > s(m,vector<int>(n));
    rep0(i, m){
        cin >> k[i];
        rep0(j, k[i]){
            cin >> s[i][j];
        }
    }
    rep0(i, m)cin >> p[i];
    rep0(i, (1 << n)){
        rep0(j, m){
            int cnt = 0;
            rep0(r, k[j]){
                if(((int)i >> (s[j][r] - 1)) & 1){
                    ++cnt;
                }
            }
            if(p[j] == (cnt % 2))++cnt2;
        }
        if(cnt2 == m)++ans;
        cnt2 = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,i,j,k;
    scanf("%d %d",&a,&b);
    if(a<b){
        k=b;
    j=a;
    }
    else {
            j=b;
    k=a;
    }
    for(i<0;i<k;i++){
        printf("%d",j);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int w,a,b;
  cin>>w>>a>>b;
  int x=a;
  int y=b;
  a=min(a,y);
  b=max(b,x);
  if(a+w>b) cout<<"0"<<endl;
  else cout<<b-(a+w)<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans=0,sum=0;
    int r=0;
    rep(l,N){
        while(r<N && sum+A[r] == (sum^A[r])){
            sum+=A[r++];
        }
        ans+=r-l;
        sum-=A[l];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

alias Point = Tuple!(long, "x", long, "y", int, "i");

void main() {
    
    auto N = readln.chomp.to!int;
    auto P = new Point[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!int);
        P[i] = Point(s[0], s[1], i);
    }
    
    P.sort!((a, b) => a.x == b.x ? a.y < b.y : a.x < b.x);
    Point[] ch1, ch2;
    foreach (i; 0..N) {
        while (ch1.length >= 2 && rot(ch1[$-2], ch1[$-1], P[i]) <= 0) ch1.popBack;
        ch1 ~= P[i];
    }
    foreach_reverse (i; 0..N) {
        while (ch2.length >= 2 && rot(ch2[$-2], ch2[$-1], P[i]) <= 0) ch2.popBack;
        ch2 ~= P[i];
    }

    auto ch = ch1 ~ ch2;
    ch = ch.uniq.array;
    ch.popBack;
    int M = ch.length.to!int;

    auto ans = new real[](N);
    ans.fill(0);

    foreach (i; 0..M) {
        auto a = ch[(i-1+M)%M];
        auto b = ch[i];
        auto c = ch[(i+1)%M];
        ans[ch[i].i] = PI - angle(a, b, c);
    }

    if (M == 2) {
        ans[ch[0].i] = 0.5;
        ans[ch[1].i] = 0.5;
    }

    foreach (a; ans) {
        writefln("%.09f", a / ans.sum);
    }
}

real angle(Point a, Point b, Point c) {
    auto a1 = a.x - b.x;
    auto a2 = a.y - b.y;
    auto c1 = c.x - b.x;
    auto c2 = c.y - b.y;
    auto cs = (a1 * c1 + a2 * c2) / (sqrt(1.0L*a1*a1+a2*a2) * sqrt(1.0L*c1*c1+c2*c2));
    return acos(cs);
}

long rot(Point a, Point b, Point c) {
    // a -> b -> c の向き
    // 正なら左、負なら右、0なら同一直線状
    return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

long dist2(Point a, Point b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}


Measured memory_bytes: 380
from itertools import permutations
dishes = [int(input()) for _ in range(5)]
res = 10 ** 3
for di in permutations(dishes):
    tmp = 0
    for d in di:
        if tmp % 10 != 0:
            tmp += (10 - tmp % 10)
        tmp += d
    res = min(res, tmp)
print(res)

Measured memory_bytes: 9172
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
//#define mod 13
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	int N = S.size();
	reverse(S.begin(), S.end());
	int ten = 1;
	//int dp[100010][13] = { 0 };
	vector<VI>dp(N + 1, VI(13, 0));
	dp[0][0] = 1;

	REP(i, N) {
		if (S[i] != '?') {
			int a = S[i] - '0';
			a = a * ten%13;
			REP(j, 13) {
				dp[i + 1][(j + a) % 13] += dp[i][j];
				dp[i + 1][(j + a) % 13] %= mod;
			}
		}
		else {
			REP(k, 10) {
				int a = k;
				a = a * ten%13;
				REP(j, 13) {
					dp[i + 1][(j + a) % 13] += dp[i][j];
					dp[i + 1][(j + a) % 13] %= mod;
				}
			}
		}
		

		ten *= 10;
		ten %= 13;
	}
	//cout << dp[1][5] << endl;
	//cout << dp[2][5] << endl;
	cout << dp[N][5] << endl;
	return 0;
}



Measured memory_bytes: 13648
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int i,j,k,m,n,ans;
int a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i==1) ans=a[1];
		else ans^=a[i];
	}
	if(ans==0) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 640
n=int(input())

def solve():
    inf=10**7
    dp=[inf]*(n+1)
    dp[0]=0
    #まず6だけでDP
    for i in range(1,n+1):
        power=1
        while power<=i:
            dp[i]=min(dp[i],dp[i-power]+1)
            power*=6
    #print(dp)

    #次に9だけでDPして良ければ更新される
    for i in range(1,n+1):
        power2=1
        while power2<=i:
            dp[i]=min(dp[i],dp[i-power2]+1)
            power2*=9
    return dp[n]

print(solve())

Measured memory_bytes: 3828
n, k = map(int,input().split())

def b10_to_n(x, n):
    s = str()
    while True:
        xx = x // n
        s += str(x % n) 
        x = xx
        if x == 0:
            break
    return s

ans = b10_to_n(n, k)
print(len(ans))

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long long v[4];
	for (int i = 0; i < 4; ++i)
		cin >> v[i];
	bool ok = false;
	long long m;
	for (int i = 0; i < 2; ++i) {
		for (int j = 2; j < 4; ++j) {
			if (!ok) {
				m = v[i] * v[j];
				ok = true;
			} else {
				m = max(m, v[i] * v[j]);
			}
		}
	}
	cout << m;

}


Measured memory_bytes: 3632
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define mod 1000000007
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00%jousu(10,y00)) / jousu(10, y00-1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}


int main() {
	int n;
	cin >> n;
	for (int i = 9; i >=1; i--) {
		if (n % i == 0) {
			if (n / i < 10) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


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

int main(){
  int N;
  double ans;
  cin>>N;
  if((N%2)==0){
    ans=1.0/2;
  }else{
    ans=((N-1.0)/2.0+1.0)/N;
  }
  cout<<ans;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
int gcd(int a, int b)
{
    if(a == 0) return b;
    return gcd(b%a, a);
}
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    int l = (x*360)/(gcd(x, 360));
    // outline(l);
    outline(l/x);
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h; cin >> h;
    int k; ll ans=0;
    k = log2(h);
    ll p=2;
    for(int i=0; i<k;i++){
        ans += p;
        p*=2;
    }
    ans++;
    cout << ans << endl;
}

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

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

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

    rep(i, 26){
        string ne = s+(char)('a' + i);
        if(t == ne){
            puts("Yes");
            return 0;
        }
    }

    puts("No");

    return 0;
}

Measured memory_bytes: 3652
import math
from numba import jit

K = int(input())


@jit
def apt(N):
    cnt = 0
    for i in range(1, K+1):
        for j in range(1, K + 1):
            for k in range(1, K + 1):
                cnt += math.gcd(k, math.gcd(i, j))
    return cnt


print(apt(K))


Measured memory_bytes: 111580
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_S 10001
#define MAX_T 501

int main(){
    int n,q,S[MAX_S],T[MAX_T];
    
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> S[i];
    cin >> q;
    for(int i = 0 ; i < q ; i++) cin >> T[i];
    
    sort(S,S+n);
    sort(T,T+q);
    
    int cnt = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < q ; j++){
            if(S[i]==T[j]){
                cnt++;
                T[j] = -1;
                break;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(void){
  int n,i,a,si=0,ans;
  set<int> s;
  set<int>::iterator ite;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    ite=s.find(a);
    if (ite==s.end()){
      si++;
      s.insert(a);
    }
  }
  cout << si-((n-si)%2) << endl;
  return 0;
}

Measured memory_bytes: 4992