akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline


class UnionFind:
    __slots__ = ["nodes"]

    def __init__(self, n: int) -> None:
        self.nodes = [-1]*n

    def get_root(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            self.nodes[x] = self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x: int, y: int) -> bool:
        root_x, root_y = self.get_root(x), self.get_root(y)
        if root_x != root_y:
            bigroot, smallroot = \
                (root_x, root_y) if self.nodes[root_x] < self.nodes[root_y] else (root_y, root_x)
            self.nodes[bigroot] += self.nodes[smallroot]
            self.nodes[smallroot] = bigroot
            return True
        else:
            return False


def kruskal(n: int, edges: list) -> int:
    edges.sort()
    tree = UnionFind(n)
    total = 0
    cnt = 0
    for w, s, t in edges:
        if tree.unite(s, t):
            cnt += 1
            total += w
            if cnt == n - 1:
                break

    return total


V, E = map(int, readline().split())
edges = []
append = edges.append
for _ in [None]*E:
    s, t, w = map(int, readline().split())
    append((w, s, t))
print(kruskal(V, edges))

Measured memory_bytes: 25704
from itertools import product

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
visited = []

def dfs(p):
    if s[p[0]][p[1]] == '.':  # p[0]gatate , p[1] gayoko
        return None

    temp = [1 if s[p[0]+y][p[1]+x] == '#' else 0 for (x, y) in [[1, 0], [0, 1], [0, -1], [-1, 0]] if 0 <= y+p[0] < h and 0 <= x+p[1] < w]
    if sum(temp) <= 0:
        print('No')
        exit(0)


for i in range(len(s)):
    for j in range(len(s[0])):
        dfs([i, j])
print('Yes')


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define int long long    // %d=>%lld
#define pb push_back
#define INF (1e9+7)
#define llINF 1e17
#define EPS 1e-9
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

int n,m;



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

    if(abs(n-m)>1){
        cout<< 0<< endl;
        return 0;
    }

    int ans=1;

    if(n !=m){
        for(int i = 0;i < n;i++){
            ans=ans*(i+1)%1000000007;
        }
        for(int i = 0;i < m;i++){
            ans=ans*(i+1)%1000000007;
        }
    }else{
        for(int i = 0;i < n;i++){
            ans=ans*(i+1)%1000000007;
        }
        for(int i = 0;i < m;i++){
            ans=ans*(i+1)%1000000007;
        }
        ans=ans*2%1000000007;
    }

    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a > b:
  a,b = b,a
m = 10**9
a+=m
b+=m
a+=v*t
b+=w*t
if a >= b:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define int long long
string str;
int dp[666][666];
int a[666];int k;
int dfs(int pos,int state,bool lead/*前导零*/,bool limit/*数位上界变量*/){
	if(pos==-1) return k==state;
	if(!limit && !lead && dp[pos][state]!=-1) return dp[pos][state];
	int up=limit?a[pos]:9;
	int ans=0;
	for(int i=0;i<=up;i++){
		if(i==0&&lead){
			ans+=dfs(pos-1,state,lead,limit&& i==a[pos]);
		}else{
			ans+=dfs(pos-1,state+((i == 0?0:1)),i==0&&lead,limit&& i==a[pos]);
		}
	}
	if(!limit && !lead) dp[pos][state]=ans;
	return ans;
}
signed main(){
	memset(dp,-1,sizeof(dp));
	cin>>str>>k;int cnt=0;
	for(int i=str.size()-1;i>=0;i--) a[cnt++]=(str[i]-'0');
	cout<<dfs(cnt-1,0,true,true);
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int v = 0;
  rep(i, n) v ^= a[i];

  cout << (v == 0 ? "Yes" : "No") << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

int n, k;
ll ans;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);

  scanf("%d%d", &n, &k);

  if(k%2 == 1){ // odd
    // a,b,c must be divisible by k
    ll d = n/k;
    ans = d*d*d;
  } else{
    // a,b,c must be divisible by k/2 or k
    ll zero(0), half(0);

    rep(i, 1, n+1){
      if(i%k == 0){
        zero++;
      } else if(i%(k/2) == 0){
        half++;
      }
    }
    ans = zero*zero*zero + half*half*half;
  }
  printf("%lld\n", ans);
}


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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;

const int MAXN = 1000*1000 + 7;
const int SS = 1<<20;
const int MOD = 1000*1000*1000 + 7;

int tab[MAXN];
int n;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	int T;
	//cin >> T;
	T = 1;
	while(T--)
	{
		string s;
		cin >> n;
		int times = 0;
		bool res = false;
		for(int i=1; i<=n; i++)
		{
			int a, b;
			cin >> a >> b;
			if( a != b )
			{
				times = 0;
				continue;
			}
			times++;
			if(times >= 3)
				res = true;
		}
	cout << (res ? "Yes" : "No") << '\n';
	}
	return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint X,Y;
  cin >> X >> Y;
  if(X%Y==0) cout << -1 << endl;
  else cout << X << endl;
}

Measured memory_bytes: 256
/**
*
* Author : MeGa
*
*/
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string.h>

using namespace std;

vector<int>v;
int n;
long long a,b;
long long solve(long long mid){

    long long aa = mid;
    long long dif = a-b;
    for(int i = 0; i < v.size(); i ++){
        long long cur = v[i]-(b*mid);
        
        if(cur > 0){
            long long val = (cur+dif -1)/ dif;
            if( val > aa)
                return false;
            else{
                 aa-= val;
            }
        }
    }
    
    return true;

}

int main(){

#ifndef ONLINE_JUDGE
    //freopen("in","r",stdin);
#endif
     ios::sync_with_stdio(false);
     cin.tie(0);
     priority_queue<pair<int,int> >pq;
     
     
     cin>>n>>a>>b;
     
     for(int i = 0 ; i < n; i ++){
        int s;
        cin>>s;
        v.push_back(s);
     }
     
     
     sort(v.begin(),v.end());

     long long left = 0  , right = 1e9+10;
     long long ans = 0;
     while(left < right){
         long long mid = left + (right - left)/2;
        // cerr<<mid<<endl;
         if(solve(mid)){
             right = mid-1;
             ans = mid;
         }else{
             left = mid + 1;
         }
     }
     
     
     if(solve(ans-1)){
         cout<<ans-1<<endl;
     }else{
         cout<<ans<<endl;
     }
    


     


    
   

}

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

public class MainApp
{
    static public void Main(string[] args)
    {
        string read = Console.ReadLine();
        string[] split = read.Split(' ');
        int a = int.Parse(split[0]);
        int b = int.Parse(split[1]);
        int c = a * b * (a + b);
        if (c % 3 == 0) Console.WriteLine("Possible");
        else Console.WriteLine("Impossible");

    }

}

Measured memory_bytes: 11092
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <string>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>

using namespace std;

string S;

bool hasbit(long long bit, int b)
{
    return bit & (1 << b);
}

long long g(long long bit, int bitsize)
{
    if (bit == 0)
        return stoll(S);

    long long sum = 0;
    int last = 0;
    for (int i = 0; i < bitsize; i++)
    {
        if (hasbit(bit, i))
        {
            sum += stoll(S.substr(last, i + 1 - last));
            last = i + 1;
        }
    }
    sum += stoll(S.substr(last, S.size() - last));
    return sum;
}

int main(int argc, const char **argv)
{
    cin >> S;
    int bitsize = S.size() - 1;
    int N = pow(2, bitsize) - 1;
    long long sum(0);
    for (int i = 0; i <= N; i++)
    {
        long long s = g(i, bitsize);
        sum += s;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
def calc_waru(n):
    return n/2
N = int(input())
A = list(map(int, input().split()))
cnt = 0
flag = 0
while True:
    for i in A:
        if i % 2 != 0:
            flag = 1
    if flag == 0:
        A = list(map(calc_waru, A))
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    int ans1,ans2;
    ans1 = A*B;
    ans2 = 2*(A+B);
    cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 3172
import numpy as np

N, K = map(int, input().split())
A = np.sort(list(map(int, input().split())))
F = np.sort(list(map(int, input().split())))[::-1]

l, r = 0, 10**12
m = (l + r) // 2

while True:
  if np.maximum(A - m//F, 0).sum() <= K:
    r = m
  else:
    l = m
  
  m = (l + r) // 2
  if r == l + 1:
    if np.maximum(A - l//F, 0).sum() <= K:
      x = l
    else:
      x = r
    break

print(x)

Measured memory_bytes: 38768
#include<stdio.h>
int main()
{
    int a,b,c;
	//整数の入力
    scanf("%d %d",&a,&b);
  	c=a*b;
  	if (c%2==1){
      printf("Odd");
    }
  	else if (c%2==0){
     printf("Even");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct Matrix{
	int h, w;
	vector<llint> mat;
	Matrix(){
		h = w = 0;
	}
	Matrix(int h, int w){
		this->h = h, this->w = w;
		mat.resize(h*w);
	}
	llint& at(int i, int j){
		return mat[w*(i-1)+(j-1)];
	}
	static Matrix ident(int size){
		Matrix ret(size, size);
		for(int i = 1; i <= size; i++) ret.at(i, i) = 1;
		return ret;
	}
	Matrix operator*(Matrix& ope){
		Matrix ret(h, ope.w);
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= ope.w; j++){
				for(int k = 1; k <= w; k++){
					ret.at(i, j) += at(i, k) * ope.at(k, j) % mod;
					ret.at(i, j) %= mod;
				}
			}
		}
		return ret;
	}
	Matrix pow(llint n){
		if(n == 0) return ident(h);
		if(n % 2){
			return pow(n-1) * (*this);
		}
		else{
			Matrix tmp = pow(n/2);
			return tmp * tmp;
		}
	}
	void print(){
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cout << at(i, j) << " ";
			}
			cout << endl;
		}
	}
};

llint T;
llint n;
Matrix mat(21, 21);

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 1; i <= 10; i++){
		if(i % 2) mat.at(i+1, i) = 1;
		else{
			mat.at(i-1, i) = 1;
			if(i < 10) mat.at(i+2, i) = 1;
			else mat.at(11, i) = 1;
		}
	}
	for(int i = 11; i <= 21; i++){
		mat.at(i, i) = 1;
		if(i < 21) mat.at(i+1, i) = 1;
	}
	
	cin >> T;
	for(int t = 0; t < T; t++){
		cin >> n;
		if(n < 5){
			cout << 0 << endl;
			continue;
		}
		
		Matrix pmat = mat.pow(n+10);
		cout << pmat.at(21, 2) << endl;
	}
	
	return 0;
}

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

int main() {
  int k;cin>>k;
  int ans=0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        ans+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 100010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

const double INF=1e18;
typedef long long ll;
int x[N];


int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,a,b; scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	
	ll ans=0;
	for (int i=2;i<=n;i++)
	{
		ans+=min(1ll*(x[i]-x[i-1])*a,1ll*b);
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 640
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int x;cin>>x;
  cout<<a[x-1];
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

int a;
int b;
int c;


scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a<b && b<c) {printf("%d %d %d\n",a,b,c);}
else if(a<c && c<b) {printf("%d %d %d\n",a,c,b);}
else if(b<a && a<c) {printf("%d %d %d\n",b,a,c);}
else if(b<c && c<a) {printf("%d %d %d\n",b,c,a);}
else if(c<a && a<b) {printf("%d %d %d\n",c,a,b);}
else if(c<b && b<a) {printf("%d %d %d\n",c,b,a);}

else if(a==b && b<c) {printf("%d %d %d\n",a,b,c);}
else if(a==c && c<b) {printf("%d %d %d\n",a,c,b);}
else if(b==c && c<a) {printf("%d %d %d\n",b,c,a);}

else if(a==b && b>c) {printf("%d %d %d\n",c,a,b);}
else if(a==c && c>b) {printf("%d %d %d\n",b,a,c);}
else if(b==c && c>a) {printf("%d %d %d\n",a,b,c);}



else if(a==b && b==c) {printf("%d %d %d\n",a,b,c);}
//else if(a==b && b==c) {printf("%d %d %d\n",a,b,c)}
//else if(a==b && b==c) {printf("%d %d %d\n",a,b,c)}

return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int n, m;
int s[5], c[5];

int pow(int x, int y){
    int res = 1;
    for (int i = 0; i < y; i++){
        res *= x;
    }
    return res;
}

bool f(int x){
    string num = to_string(x);
    rep(i, m){
        if (num[s[i]] - '0' != c[i]){
            return false;
        }
    }
    return true;
}

int main(){
    cin >> n >> m;
    rep(i, m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    if(n == 1 && f(0)){
        cout << 0 << endl;
        return 0;
    }
    for (int i = pow(10, n - 1); i < pow(10, n); i++){
        if (f(i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(a<b) {
        if(b<c)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("No\n");
    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

inline void add(ll &x, ll y) { x += y; if (x >= MOD) x -= MOD; }

const int MX = 70000;

ll mod_pow(ll x, ll k)
{
	ll res = 1;
	for (; k; k /= 2, x = x * x % MOD) {
		if (k & 1) {
			res = res * x % MOD;
		}
	}
	return res;
}

int N, M;
ll dp[20][1 << 16];
ll fac[MX], ifac[MX];

ll comb(int n, int k) {
	if (n < 0 || k < 0 || k > n) return 0;
	return fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main() {
	fac[0] = ifac[0] = 1;
	rep(i, MX-1) {
		fac[i+1] = fac[i] * (i+1) % MOD;
		ifac[i+1] = mod_pow(fac[i+1], MOD - 2);
	}

	cin >> N >> M;

	vi A(M);
	rep(i, M) cin >> A[i];
	reverse(ALL(A));

	dp[0][0] = 1;
	rep(i, M) {
		rep(j, 1 << N) {
			if (dp[i][j] == 0) continue;
			add(dp[i+1][j], dp[i][j]);
			int u = (1 << N) - A[i];
			rep(k, N) if ((j >> k) & 1) u -= (1 << k);
			rep(k, N) if (!((j >> k) & 1)) {
				add(dp[i+1][j|(1<<k)], dp[i][j] * comb(u, (1 << k)-1) % MOD * fac[1 << k] % MOD);
			}
		}
	}

	ll ret = 0;
	rep(i, 1 << N) {
		int num = 0;
		rep(j, N) if ((i >> j) & 1) num += (1 << j);
		ll t = dp[M][i] * fac[(1 << N) - 1 - num] % MOD;

		if (__builtin_popcount(i) & 1) {
			t = MOD - t;
		}

		ret = (ret + t) % MOD;
	}

	ret = ret * (1 << N) % MOD;
	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 9600
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    ans += 1
print(ans)

Measured memory_bytes: 9120
n = int(input())
a = list(map(int,input().split()))
a.sort()
num = a[-1]
ans = a[0]
diff = abs(num/2-a[0])
for i in range(1,n-1):
    comp = abs(num/2-a[i])
    if diff >= comp:
        diff = comp
        ans = a[i]
print(num, ans)


Measured memory_bytes: 14428
using System;

class sample6{
    static void Main(string[] args){

            string[] str_number = Console.ReadLine().Split(' ');
            int a = int.Parse(str_number[0]);
            int b = int.Parse(str_number[1]);
            int c = int.Parse(str_number[2]);

            if((a < 0) || (b < 0) || ( c < 0 )){
                Console.WriteLine("数値は0以上の値を入力してください。");
                Environment.Exit(0);
            }else if((a > 100) || (b > 100) || (c > 100)){
                Console.WriteLine("数値は100以下の値を入力してください。"); 
                Environment.Exit(0);
            }
            
            if( a < b && b < c){
                Console.WriteLine("Yes");
            }else{ 
                 Console.WriteLine("No");
            }
    }
}


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

vector<vector<int>> to;
vector<int> ans;

void dfs(int v, int p = -1) {
    for (int u : to[v]) {
        if (u == p)
            continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    to.resize(N);
    ans.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }

    dfs(0);

    rep(i, N) cout << ans[i] << "\n";

    return 0;
}

Measured memory_bytes: 23424
import math
from collections import defaultdict

N = int(input())
MOD = 10**9+7

d = defaultdict(int)
d[1] = 0

for i in range(2, N+1):
    for j in range(2, N+1):
        while i % j == 0:
            i //= j
            d[j] += 1

ans = 1
for i in d.values():
    ans = (ans*(i+1)) % MOD
print(ans)


Measured memory_bytes: 39792
#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 LL long long

int n,m;
string s,t;

int mygcd(int a,int b){
  if(b==0) return a;
  return mygcd(min(a,b),max(a,b)%min(a,b));
}

int main(){
  cin>>n>>m>>s>>t;
  int g = mygcd(n,m);
  int n_del=n/g,m_del=m/g;
  int p=0,q=0;
  REP(i,n/n_del){
    if(s[p]!=t[q]){
      cout<<-1<<endl;
      return 0;
    }
    p+=n_del;
    q+=m_del;
  }
  cout<<(LL)n*(LL)(m/g)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
ll 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;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};


vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}

int main() {
    ll a, b, k; cin >> a >> b >> k;
    a -= k;
    if (a < 0) {
        b += a;
    }
    if (a < 0) a = 0;
    if (b < 0) b = 0;

    cout << a << ' ' << b << endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2;i*i<=n;i++){
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i==0){
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    return res;
}


int main(){
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    auto f=factorize(g);
    int ans=f.size()+1;
    cout<<ans<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int num1=0,num2=0;
  rep(i,s.size()){
    if( i%2 == 0 ){
      if( s.at(i) != '0' ) num1++;
    }else{
      if( s.at(i) != '1' ) num1++;
    }
  } 
  
  rep(i,s.size()){
    if( i%2 == 0 ){
	  if( s.at(i) != '1' ) num2++;
    }else{
      if( s.at(i) != '0' ) num2++;
    }
  }
  cout << min(num1,num2) << endl;
  return 0;
}


Measured memory_bytes: 512
//Classic
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin
#define X INT_MAX
#define N INT_MIN
////////////////////////////////////////////////////////////////

void jabru() {

	int x; cin >> x;
	if (x)cout << 0 << endl;
	else
		cout << 1 << endl;
}

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


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		jabru();


	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???


Measured memory_bytes: 3652
for _ in range(50):
    m, f, r = map(int, input().split())

    if (m == -1) and (f == -1) and (r == -1):
        break

    if (m == -1) or (f == -1):
        print("F")
        continue

    s = m + f

    if s >= 80:
        print("A")
    elif 80 > s >= 65:
        print("B")
    elif 65 > s >= 50:
        print("C")
    elif 50 > s >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif 30 > s:
        print("F")



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

const ll MOD = 1000000007;
ll dp[201010][2];
ll dp2[201010][2];
ll base[201010];

void solve() {
    string S, T;
    cin >> S >> T;
    int N = S.size();

    base[0] = 1;
    REP(i, N) base[i+1] = base[i] * 10 % MOD;

    dp2[0][0] = 1;

    REP(i, N) REP(j, 2) {
        ll b = base[N-i-1];
        REP(nd, 10) {
            if (T[i] != '?' && nd != T[i] - '0') continue;
            if (!j && nd > S[i] - '0') continue;
            (dp[i+1][j||(nd<S[i]-'0')] += (dp[i][j] + b * nd % MOD * dp2[i][j] % MOD)) %= MOD;
            (dp2[i+1][j||(nd<S[i]-'0')] += dp2[i][j]) %= MOD;
        }
    }

    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
}

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



Measured memory_bytes: 11284
n,m=list(map(int,input().split()))
a=[]
for i in range(n):
    l=list(map(int,input().split()))
    a.append(l[1::])

sum=0
for j in range(m):
    flg=True
    for i in range(n):
        #print(a[i])
        if a[i].count(j+1)==0:
         flg=False   
    if flg:
        sum+=1

print(sum)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define mp make_pair
using namespace std;
int t, n, q, l = 0, r = 123456, x = 2147483647, q1;
pair<int, int>t1[123456], t2[12345], t3[1234], t4[123], t5[12];
void f1() {
	r++;
	while (l < r) {
		if (l % 10000 == 0 && l + 10000 <= r) {
			t5[l / 10000] = mp(t, x);
			l += 10000;
		}
		else if (l % 1000 == 0 && l + 1000 <= r) {
			t4[l / 1000] = mp(t, x);
			l += 1000;
		}
		else if (l % 100 == 0 && l + 100 <= r) {
			t3[l / 100] = mp(t, x);
			l += 100;
		}
		else if (l % 10 == 0 && l + 10 <= r) {
			t2[l / 10] = mp(t, x);
			l += 10;
		}
		else {
			t1[l] = mp(t, x); l++;
		}
	}
}
int f2(int i) {
	int t = t1[i].first, x = t1[i].second;
	i /= 10;
	if (t < t2[i].first) {
		t = t2[i].first; x = t2[i].second;
	}
	i /= 10;
	if (t < t3[i].first) {
		t = t3[i].first; x = t3[i].second;
	}
	i /= 10;
	if (t < t4[i].first) {
		t = t4[i].first; x = t4[i].second;
	}
	i /= 10;
	if (t < t5[i].first) {
		t = t5[i].first; x = t5[i].second;
	}
	return x;
}
signed main() {
	cin >> n >> q;
	for0(i, n)t1[i] = mp(0, x);
	for (t = 1; t <= q; t++) {
		cin >> q1;
		if (q1) {
			int i; cin >> i; cout << f2(i) << endl;
		}
		else {
			cin >> l >> r >> x;	f1();
		}
	}
}


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

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

old_a = -1
ans = 0

for i in range(n):
        ans += b[a[i]-1]
        if old_a == a[i] - 1:
                ans += c[old_a - 1]

        old_a = a[i]

print(ans)


Measured memory_bytes: 3064
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(S):
    if len(S)==2:
        return S
    else:
        return S[::-1]
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,t,re,wq[103];
    scanf("%d",&t);
    for(g=0;g<t-1;g++)
        scanf("%d",&wq[g]);
    re=wq[0]*2;
    for(g=1;g<t-1;g++)
        if(wq[g]>=wq[g-1])re+=wq[g];
        else re+=(wq[g]*2-wq[g-1]);
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::VecDeque;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector<T>(c:usize) -> VecDeque<T>
where
    T: std::str::FromStr,
{
    let mut v: VecDeque<T> = VecDeque::with_capacity(c);

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push_back(buf);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let mut v = input_vector::<isize>(n+2);
    let mut anslist: Vec<isize> = Vec::with_capacity(n);
    v.push_back(0);
    v.push_front(0);

    let mut sum = 0;
    for z in 0..n + 1 {
        sum += (v[z] - v[z + 1]).abs();
    }

    for z in 1..n + 1 {
        if v[z - 1] < v[z] && v[z] < v[z + 1] || v[z - 1] > v[z] && v[z] > v[z + 1] {
            anslist.push(0);
        } else {
            anslist.push(cmp::min((v[z + 1] - v[z]).abs(), (v[z - 1] - v[z]).abs()));
        }
    }
    for z in anslist {
        p(sum - 2 * z);
    }
}

Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int A,B,T;cin>>A>>B>>T;
    ll ans = 0;
    REP(i,T+1){
        if (i%A==0) ans+= B;
    }
    cout<<ans-B<<endl;
    return 0;
}

Measured memory_bytes: 256
inputs = []
loop do
    input = gets.split(" ")
    if input[0] == "-1" && input[1] == "-1" && input[2] == "-1"
        break
    end
    inputs << input
end

inputs.each do |input|
    m, f, r = input[0].to_i, input[1].to_i, input[2].to_i

    if m == -1 || f == -1
        puts "F"
    elsif m + f >= 80
        puts "A"
    elsif m + f >= 65
        puts "B"
    elsif m + f >= 50 || (m + f >= 30 && r >= 50)
        puts "C"
    elsif m + f >= 30
        puts "D"
    else
        puts "F"
    end
end


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

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }

    ll ans = 0;
    bitset<60> bit;
    rep(0, d, 60)
    {
        ll num0 = 0, num1 = 0;
        rep(0, i, N)
        {
            bit = A.at(i);
            if (bit.test(d))
            {
                num1++;
            }
            else
            {
                num0++;
            }
        }
        ans += (((num0 * num1) % MOD) * (((ll)1 << d) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
struct UnionFind {
    vector <int> d;
    UnionFind(int n = 0): d(n , -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x , y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};
int main(){
    int n , m;
    cin >> n >> m;
    UnionFind t(n);
    for(int i = 0; i < m; i++){
        int a , b;
        cin >> a >> b;
        --a;
        --b;
        t.unite(a , b);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans , t.size(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] alpha = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
				'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
		int[] countList = new int[alpha.length];

		String str;
		while((str = br.readLine())!= null){
			char[] input = str.toLowerCase().toCharArray();
			for(int i=0; i<input.length;i++){
				for(int j=0;j<alpha.length;j++){
					if(input[i]==alpha[j]){
						countList[j] +=1;
					}
				}
			}
		}

		for(int i=0;i<alpha.length;i++){
			System.out.println(alpha[i] + " : " + countList[i]);
		}
	}
}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	ll n, m, mx = INT_MIN;
	cin >> n >> m;
	ll a[n][3];
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	for (ll i = 0; i < 8; i++)
	{
		vector<ll>v;
		for (ll j = 0; j < n; j++)
		{
			ll s = 0;
			for (ll k = 0; k < 3; k++)
			{
				if ((i / (1 << k)) % 2 == 0)
				{
					s += a[j][k];
				}
				else
				{
					s -= a[j][k];
				}
			}
			v.push_back(s);
		}
		sort(v.begin(), v.end(), greater<ll>());
		ll sum = 0;
		for (ll i = 0; i < m; i++)
			sum += v[i];
		mx = max(mx, sum);

	}
	cout << mx << endl;



}


Measured memory_bytes: 256
N,M = map(int,input().split())
light = [[int(i) for i in input().split()] for i in range(M)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**N):
    switch = list((str(bin(i)[2:])).zfill(N))
    all_on = True
    for j in range(M):
        on = 0
        for k in range(1,len(light[j])):
            if switch[light[j][k] - 1] == "1":
                on += 1
        if on % 2 != p[j]:
            all_on = False
            break
    if all_on == True:
        ans += 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<char> a(6);
  int x = 0;
  for (int i=0; i<6; i++) {
    cin >> a.at(i);
  }
  if (a.at(3) == a.at(2)) {
    x++;
  }
  if (a.at(5) == a.at(4)) {
    x++;
  }
  if (x == 2) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
// F - Small Products
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	long long n, k;
	cin >> n >> k;
	int m = sqrt(n);

	vector<vector<long long> > s(k, vector<long long>(m + 1)), b(k, vector<long long>(m + 1));
	for (int i = 1; i <= m; i++) {
		s[0][i] = i;
		b[0][i] = b[0][i - 1] + n / i - (i == m ? m : n / (i + 1));
	}
	for (int i = 1; i < k; i++)
		for (int j = 1; j <= m; j++) {
			s[i][j] = (s[i][j - 1] + s[i - 1][m]) % MOD;
			s[i][j] = (s[i][j] + b[i - 1][m] - b[i - 1][j - 1] + MOD) % MOD;
			b[i][j] = (b[i][j - 1] + s[i - 1][j] * (n / j - (j == m ? m : n / (j + 1))) % MOD) % MOD;
		}

	cout << (s[k - 1][m] + b[k - 1][m]) % MOD << endl;

	return 0;
}


Measured memory_bytes: 50056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    rep(i,n){
        int a;
        cin >> a;
        que.push(a);
    }
    rep(i,m){
        int a = que.top();
        que.pop();
        a /= 2;
        que.push(a);
    }
    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
from collections import Counter
C=Counter()

h,w=map(int,input().split())
for _ in range(h):
	C+=Counter(input())

one=[]
two=[]
four=[]
twolim=(h//2)*(w%2)+(w//2)*(h%2)
twocnt=0
for k,v in C.items():
	while v>=4:
		v-=4
		four.append(k)
	if v>=2:
		twocnt+=1
		if twocnt>twolim:
			print("No")
			exit()
		two.append(k)
	if v%2:
		if one or h%2==w%2==0:
			print("No")
			exit()
		one.append(k)
print("Yes")		
		
"""
ans=[""]*h

for i in range(h//2):
	c=0
	while c<w//2:
		c+=1
		x=four.pop()
		ans[i]+=x
		ans[~i]+=x
	if w%2:
		if two:
			x=two.pop()
			ans[i]+=x
			ans[~i]+=x
		else:
			x=four.pop()
			ans[i]+=x
			ans[~i]+=x
			four.append(x)
if h%2:
	for x in two+four+four+one:
		ans[h//2]+=x
for l in ans:
	print(l+l[:w//2][::-1])
"""

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

int dx[31];

int main(){
	int n;
	dx[1] = 1;
	dx[2] = 2;
	dx[3] = 4;
	for(int i = 4; i <= 30; i++){
		dx[i] = dx[i - 3] + dx[i - 2] + dx[i - 1];
	}
	while(cin >>n){
		if(n == 0) break;
		int day, year;
		day = dx[n] / 10;
		if(dx[n] % 10 != 0) day++;
		year = day / 365;
		if(day % 365 != 0) year++;
		cout <<year <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j,k;
  string s;
  char ans[6][10]={"the","the.","this","this.","that","that."};
  while(getline(cin,s)){
    int n=0;
    rep(i,s.size())if(s[i]==' ')n++;
    n++;
    vector<string> word(n);
    i=0;
    rep(j,n){
      while(s[i]!=' '&&s[i]!='\0')
	word[j].push_back(s[i]),i++;
      i++;
    }
    rep(k,26){
      bool c=false;
      rep(i,n)rep(j,word[i].size())
	if(word[i][j]=='z')word[i][j]='a';
	else if(word[i][j]<='z' && word[i][j]>='a')
	  word[i][j]=word[i][j]+1;
      rep(i,n)rep(j,6)
	if(word[i]==ans[j]){
	  c=true;
	}
      if(c){
	rep(i,n){
	  if(i)cout<<" ";
	  cout<<word[i];
	}
	cout<<endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 1000
using namespace std;


int main(){

	int n,k,x,c=0,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(x >= k)
			c++;
	}


	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc137/tasks/abc137_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    set<string> tbl;
    unordered_map<string,ll> cnt;
    REP(i,N){
        string s; cin>>s;
        sort(s.begin(),s.end());
        ++cnt[s];
    }
    ll ans=0;
    for(auto& d:cnt){
        if(d.second>=2){
            ans += d.second * (d.second-1)/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin>>k>>n;
  vector<int> v(n);
  for(auto&x : v)cin>>x;
  int ans=0;
  for(int i=0;i<n-1;i++){
    ans = max(ans,abs(v[i]-v[i+1]));
  }
  ans = max(ans,abs(k - (v[n-1] -v[0])));
  cout<<k-ans;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> al = new ArrayList<>();
		
		int n, aliveSec, departSec, ans;
		
		while((n = sc.nextInt()) != 0) {
			int[] S = new int[86401];
			int begin = Integer.MAX_VALUE, end = Integer.MIN_VALUE;
			
			for(int i = 0; i < n; i++) {
				
				String[] alive = sc.next().split(":");
				String[] depart = sc.next().split(":");
				
				aliveSec = Integer.parseInt(alive[0]) * 3600 + Integer.parseInt(alive[1]) * 60 + Integer.parseInt(alive[2]);
				departSec = Integer.parseInt(depart[0]) * 3600 + Integer.parseInt(depart[1]) * 60 + Integer.parseInt(depart[2]);
				
				S[aliveSec]++;
				S[departSec]--;
				
				begin = Math.min(begin, aliveSec);
				end = Math.max(end, departSec);
			}
			
			ans = S[begin];
			for(int i = begin + 1; i <= end; i++) {
				S[i] += S[i - 1];
				ans = Math.max(ans, S[i]);
			}
			
			al.add(ans);
		}
		
		for(int i = 0; i < al.size(); i++) {
			System.out.println(al.get(i));
		}
	}
}

Measured memory_bytes: 72100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();

		long sum = 0;
		for (int a=1; a<=K; a++){
			for (int b=1; b<=K; b++){
				for (int c=1; c<=K; c++){
					sum += gcd(gcd(a,b),c);
				}
			}
		}
		System.out.println(sum);
	}

	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 27216
#include<bits/stdc++.h>
using namespace std;
int main()
{
   double n,d,c=0,p,q;
   cin>>n>>d;
   while(n--)
   {
       cin>>p>>q;
       p=p*p,q=q*q;
       p=sqrt(p+q);
       if(p<=d)
        c++;
   }
   cout<<c;
    return 0;
}



Measured memory_bytes: 3840