akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;

int h, w;
char field[50][50];
bool used[50][50];
bool per[8];
char ma[8];
map<char, int> mp;
int c;

bool dfs(int n, int rest){
	if(n == 0) {
		return rest == 0 ? true : false;
	}
	bool res = false;
	for(int i = 1; i < c; i++){
		if(per[i]) continue;
		else{
			per[i] = true;
			int ymax = 0;
			int ymin = INF;
			int xmax = 0;
			int xmin = INF;
			bool f = true;
			int cnt = 0;
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if(mp[field[j][k]] == i){
						ymax = max(ymax, j);
						ymin = min(ymin, j);
						xmax = max(xmax, k);
						xmin = min(xmin, k);
					}
				}
			}
			for(int j = ymin; j <= ymax; j++){
				for(int k = xmin; k <= xmax; k++){
					if(per[mp[field[j][k]]]){
						if(mp[field[j][k]] == i) cnt++;
					}else f = false;
				}
			}
			if(f){
				res |= dfs(n-1, rest - cnt);
				per[i] = false;
			}else{
				per[i] = false;
			}
		}
	}
	return res;
}

int main(){
	int n ;
	cin >> n;
	while(n--){
		cin >> h >> w;
		mp.clear();
		c = 1;
		int cnt = 0;
		for(int i = 0;i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> field[i][j];
				if(field[i][j] != '.') cnt++;
				if(mp[field[i][j]] == 0 && field[i][j] != '.') mp[field[i][j]] = c++;
			}
		}
		memset(per, false, sizeof(per));
		bool safe = dfs(c-1, cnt);
		if(safe){
			cout << "SAFE" << endl;
		}else{
			cout << "SUSPICIOUS" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 904
#!/usr/bin/env python3

import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
exps = []

for i in range(n):
    #exps.append(sum(list(range(1, p[i]+1)))/p[i])
    exps.append((1+p[i])/2)

exps = np.array(exps)
cumexps = exps.cumsum()
cumexps = np.insert(cumexps, 0, 0)

#print(exps)
#print(cumexps)

ans = -1
for i in range(n-k+1):
    tmp = -cumexps[i] + cumexps[i+k]
    if ans <= tmp:
        ans = tmp 

print(ans)


Measured memory_bytes: 33700
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
t = [int(input())-1 for _ in range(D)]

S = 0
last = [-1]*26
score = 0;
for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S-=c[i]*(d - last[i])
    score +=max(10**6+S,0)
    print(S)


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

int main(){
	int n, m,temp;
	while(1){
		
		cin >> n >> m;
		if(n==0 && m==0){break;}

		int s[100], p[100],suma=0,sumb=0,a,b,c=0;
		for (int i = 0; i < n; i++){
			cin >> s[i];
			suma+=s[i];
		}
		for (int i = 0; i < m; i++){
			cin >> p[i];
			sumb+=p[i];
		}
		for (int i=0;i<n;i++){
			for (int j=i+1;j<n;j++){
				if(s[i] > s[j]){
					temp = s[i];
					s[i] = s[j];
					s[j] = temp;
				}
			}
		}
		for (int i=0;i<m;i++){
			for (int j=i+1;j<m;j++){
				if(p[i] > p[j]){
					temp = p[i];
					p[i] = p[j];
					p[j] = temp;
				}
			}
		}
		for (int i=0;i<n;i++){
			for (int j=0;j<m;j++){
				a=(suma-s[i])+p[j];
				b=(sumb-p[j])+s[i];
				if(a==b){
					cout << s[i] << " " << p[j] << endl;
					c++;
					break;
				}
			}
			if(c!=0){
				break;
			}
			if(i==n-1){
				cout << -1 << endl;
			}
		}
	}
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int answer = 1e9;

    for (int start = 0; start < s.size(); start++) {
        if (start + t.size() > s.size()) {
            break;
        }
        int count = 0;
        for (int i = 0; i < t.size(); i++) {
            if (s[start + i] != t[i]) {
                count++;
            }
        }
        answer = min(answer, count);
    }
    cout << answer << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll d, g;
	cin >> d >> g;
	ll p[d], c[d];
	zep(i, 0, d){
		cin >> p[i] >> c[i];
	}
	
	ll ans = INF;
	zep(bit, 0, (1 << d)){
		ll buf = 0;
		ll s = 0;
		zep(i, 0, d){
			if(bit & (1LL << i)){
				buf += p[i];
				s += (i+1)*100*p[i]+c[i];
			}
		}
		//cout << bit << buf << " " << s << endl;
		if(s >= g){
			ans = min(buf, ans);
		}
		else{
			zep(i, 0, d){
				if(!(bit & (1LL << i))){
					ll full = (i+1)*100*p[i];
					if(g-s < full){
						ans = min(buf+(g-s+(i+1)*100-1)/((i+1)*100), ans);
						//cout << bit << i << full << g-s << endl;
						//print(ans)
					}
				}
			}
		}
		//print(ans)
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = list(map(int, input().split()))
    print(reduce(gcd, A))

main()


Measured memory_bytes: 88428
// contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef pair < ut, ut > pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
VI edges[SIZE];

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

////////////////////////////////////////////////////////////////////////////////////////////
void init() {

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

Measured memory_bytes: 13052
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int MAX = 50;

main(){
  int N, K, R;
  int aff[MAX];
  bool angly[MAX];
  cin >> N >> K;
  rep(i, N) angly[i] = false;
  rep(i, K){
    int m, u; cin >> m;
    rep(j, m){
      cin >> u; u--;
      aff[u] = i;
    }
  }

  cin >> R;
  rep(i, R){
    int p, q; cin >> p >> q;
    p--; q--;
    if ( aff[p] == aff[q] ) {
      angly[p] = angly[q] = true;
    }
  }
  int cnt = 0;
  rep(i, N) if ( angly[i] ) cnt++;
  cout << cnt << endl;

}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string t;
    cin>>t;
    int n=t.size();
    rep(i,n){
        if(t.at(i)=='?') cout<<'D';
        else cout<<t.at(i);
    }
    cout<<endl;
}/*
./problem.exe
*/

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	long long int n;	cin >> n;
	vector<char> ans;

	while( n > 0 ){
		n--;
		ans.push_back( (n % 26) + 'a' );
		n /= 26;
	}

	for( int i = ans.size(); i > 0; i-- ){
		cout << ans[i - 1];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3620
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    as := make([]int, n)
    for i := range as {
        var a int
        fmt.Scan(&a)
        as[i] = a
    }

    ls := make([]int, n)
    ls[1] = as[0]
    rs := make([]int, n)
    rs[n-2] = as[n-1]
    for i := 2; i < n; i++ {
        if i > 1 {
            ls[i] = gcd(ls[i-1], as[i-1])
        }
        if i > 1 {
            rs[n-1-i] = gcd(rs[n-i], as[n-i])
        }
    }

    var max int
    for i := 0; i < n; i++ {
        var res int
        if i == 0 {
            res = rs[0]
        } else if i == n-1 {
            res = ls[n-1]
        } else {
            res = gcd(ls[i], rs[i])
        }
        if res > max {
            max = res
        }
    }
    fmt.Println(max)
}

func gcd(a, b int) int {
    if a < b {
        a, b = b, a
    }
    for a%b != 0 {
        a, b = b, a%b
    }
    return b
}


Measured memory_bytes: 6272
def findGCD(a:int, b:int) -> int:
    # ユークリッドの互除法
    while 1:
        if a%b == 0:
            return b
        else:
            a = a%b
        
        if b%a == 0:
            return a
        else:
            b = b%a
            
from functools import reduce

n,k = map(int, input().split())
a = list(map(int, input().split()))


gcd = reduce(findGCD, a)

if k % gcd == 0 and k <= max(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14596
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn solve(h: i64, w: i64) -> i64 {
    let mut delta = i64::max_value();
    for ah in 1..h {
        let bh = (h - ah) / 2;
        let ch = h - (ah + bh);
        let mut rectangles = vec![ah * w, bh * w, ch * w];
        rectangles.sort();
        if delta > rectangles[2] - rectangles[0] {
            delta = rectangles[2] - rectangles[0];
        }

        let bh = h - ah;
        let ch = h - ah;
        let bw = w / 2;
        let cw = w - bw;
        let mut rectangles = vec![ah * w, bh * bw, ch * cw];
        rectangles.sort();
        if delta > rectangles[2] - rectangles[0] {
            delta = rectangles[2] - rectangles[0];
        }
    }
    delta
}

fn main() {
    let (h, w) = input!(i64, i64);

    let answer1 = solve(h, w);
    let answer2 = solve(w, h);
    println!("{}", if answer1 > answer2 { answer2 } else { answer1 });
}


Measured memory_bytes: 4352
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

array<int, 123> asciiBet = {};

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

	vector<char> ans;
	REP(i, n)
	{
		if (s[i] == 'B' && ans.size() > 0) ans.pop_back();
		else if (s[i] == '0' || s[i] == '1') ans.push_back(s[i]);
	}

	n = ans.size();
	REP(i, n)
	{
		cout << ans[i];
	}
	cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll N;
    bool check = true;
    cin >> N;
    ll cnt_4 = 0, cnt_2 = 0, other = 0;
    for (int i = 0; i < N; i++) {
      ll tmp = 0;
      cin >> tmp;
      if (tmp % 4 == 0) cnt_4++;
      else if(tmp%2==0){
        cnt_2++;
      }
      else{
        other++;
      }
    }
    if (cnt_2 == 0) {
      if (cnt_4 >= other - 1) check = false;
    } else {
      if (cnt_2 % 2 == 0) {
        if (cnt_4 >= other - 1) check = false;
      } else {
        if (cnt_4 >= other) check = false;
      }
    }
    if (check) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		ll N;
		cin>>N;
		cout<<N*(N-1)/2;
		return 0;
}


Measured memory_bytes: 256
n=int(input())
it=[input() for i in range(n)]
s="abcdefghijklmnopqrstuvwxyz"
ss={}
j=0
for i in s:
    ss[i]=j
    j+=1
st=[0 for i in range(26)]
for i in it[0]:
    st[ss[i]]+=1
for i in range(1,n):
    aa={}
    for j in it[i]:
        try:
            aa[j]+=1
        except:
            aa[j]=1
    k=[0]*26
    for i in aa:
        k[ss[i]]=aa[i]
    for i in range(26):
        st[i]=min(st[i],k[i])
for i in range(26):
    print(s[i]*st[i],end="")

Measured memory_bytes: 39664
N = int(input())
sp_list = [ input().split() for _ in range(N) ]
s_list = [ sp[0] for sp in sp_list ]
p_list = [ str(100 - int(sp[1])).zfill(3) for sp in sp_list]

sp_dict = {}
for i in range(N):
  key = s_list[i] + ' ' + p_list[i]
  sp_dict[key] = (i+1)

for k in sorted(sp_dict.keys()):
  print(sp_dict[k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const long long mod = 998244353;//200003;786433;1e9 + 7;
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
long long sum[1000005], ssum[1000005], f[1000005]; 

long long BinPow(long long n, int k)
{
	long long ans = 1, temp = n;
	while(k)
	{
		if(k & 1)
		{
			ans = ans * temp % mod;
		}
		temp = temp * temp % mod;
		k >>= 1;
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		long long temp;
		cin >> temp;
		sum[temp] += temp;
		ssum[temp] += (temp * temp % mod);
		sum[temp] %= mod;
		ssum[temp] %= mod;
	}
	for(int i = 1; i <= 1000000; i++)
	{
		for(int j = 2 * i; j <= 1000000; j = j + i)
		{
			sum[i] += sum[j];
			ssum[i] += ssum[j];
			sum[i] %= mod;
			ssum[i] %= mod;
		}
	}
	long long ans = 0;
	for(int i = 1000000; i >= 1; i--)
	{
		f[i] = sum[i] * sum[i] % mod - ssum[i] + mod;
		f[i] %= mod;
		f[i] = f[i] * (mod + 1) / 2 % mod;
		for(int j = 2 * i; j <= 1000000; j = j + i)
		{
			f[i] = f[i] - f[j] + mod;
			f[i] %= mod;
		}
		ans += f[i] * BinPow(i, mod - 2) % mod;
		ans %= mod;
	} 
	cout << ans;
}

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

int main() {
vector<int> a(3);
cin>>a[0]>>a[1]>>a[2];
sort(a.begin(),a.end());
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
return 0;
} 


Measured memory_bytes: 3152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        abcd: i32,
    }
    let (a, b, c, d) = (abcd / 1000,  (abcd / 100) % 10, (abcd / 10) % 10, abcd % 10);
    for bits in 0..2 << 3 {
        let (mut x, mut y, mut z) = (-b, -c, -d);
        let (mut op1, mut op2, mut op3) = ('-', '-', '-');
        if (1 << 0) & bits != 0 {
            x = b;
            op1 = '+';
        }
        if (1 << 1) & bits != 0 {
            y = c;
            op2 = '+';
        }
        if (1 << 2) & bits != 0 {
            z = d;
            op3 = '+';
        }
        if a + x + y + z == 7 {
            println!("{}{}{}{}{}{}{}=7", a, op1, b, op2, c, op3, d);
            break;
        }
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node x, int k){

  while(x != NIL && k != x->key){
    if(k<x->key) x = x->left;
    else x = x->right;
  }

  return x;

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u==NIL)return;
 
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

string s;
int Q;

int main()
{
	cin >> s >> Q;
	deque<char> que;
	for(char c : s) que.push_back(c);
	bool flag = false;
	int x, y;
	char c;
	while(Q--){
		cin >> x;
		if(x == 1){
			flag = !flag;
		}else{
			cin >> y >> c;
			if(y == 1){
				if(!flag) que.push_front(c);
				else que.push_back(c);
			}else{
				if(!flag) que.push_back(c);
				else que.push_front(c);
			}
		}
	}
	string res;
	if(flag){
		while(!que.empty()){
			res += que.back();
			que.pop_back();
		}
	}else{
		while(!que.empty()){
			res += que.front();
			que.pop_front();
		}
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 1412
def check(ss, r, c):
    for_chk = ((-1, 0), (0, -1), (0, 1), (1, 0))
    H = len(ss)
    W = len(ss[0])
    for ri, ci in for_chk:
        rc = r + ri
        cc = c + ci
        if 0 <= rc and rc < H and 0 <= cc and cc < W:
            if ss[rc][cc] == "#":
                return True
    return False


def resolve():
    H, W = [int(i) for i in input().split()]
    ss = [list(input()) for _ in range(H)]
    for r in range(H):
        for c in range(W):
            if ss[r][c] == "#":
                if not check(ss, r, c):
                    print("No")
                    return
    print("Yes")


resolve()


Measured memory_bytes: 9124
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static int N,K =0;
static int INF = (int) (1e9+5);
    public static void main(String[] args) throws IOException {
	// write your code here
        //st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(br.readLine());
        //K = Integer.parseInt(st.nextToken());
        ArrayList<Integer> dp = new ArrayList<>();
        dp.add(0);
        dp.add(0);
        dp.add(0);
        for (int day =0;day<N;day++){
            st = new StringTokenizer(br.readLine());
            ArrayList<Integer> newDp = new ArrayList<>();
            ArrayList<Integer> cost = new ArrayList<>();
            for (int i=0;i<3;i++) {
                cost.add(Integer.parseInt(st.nextToken()));
                newDp.add(0);
            }
            for (int i=0;i<3;i++){
                for (int j=0;j<3;j++){
                    if (i!=j)
                    newDp.set(j,Math.max(newDp.get(j),dp.get(i)+cost.get(j)));
                }
            }
            dp.clear();
           for (int i=0;i<3;i++)
               dp.add(newDp.get(i));
        }




        pw.println(Math.max(Math.max(dp.get(0),dp.get(1)),dp.get(2)));
        pw.flush();
    }
}


Measured memory_bytes: 47492
use std::borrow::{Borrow, BorrowMut};
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_m: i64 = input.next().unwrap().parse().unwrap();
    let xy: Vec<_> = (0..in_m)
        .map(|_| {
            let r: Vec<i64> = input
                .borrow_mut()
                .take(2 as usize)
                .map(|s| s.parse().unwrap())
                .collect();
            (r[0], r[1])
        })
        .collect();

    let mut counts = vec![1; in_n as usize];
    let mut ok = vec![false; in_n as usize];
    ok[0] = true;

    for &(x, y) in xy.iter() {
        let x = x as usize - 1;
        let y = y as usize - 1;
        counts[y] += 1;
        counts[x] -= 1;
        ok[y] |= ok[x];
        if counts[x] == 0 {
            ok[x] = false;
        }
    }
    let ans: i64 = ok
        .iter()
        .filter_map(|&ok| if ok { Some(1) } else { None })
        .sum();
    writeln!(out, "{}", ans).ok();
}


Measured memory_bytes: 12540
#include <cstdio>
typedef long long lld;
const int MAXN = 51;
const int MAXS = MAXN*(MAXN+2);
int array[MAXN]{ };
lld    dp[MAXN][MAXS]{ }; // [Len][Sum]
int A, N;

int main()
{
	scanf(" %d%d", &N, &A);
	for(int i = 1; i <= N; ++i)
		scanf("%d", &array[i]);
	dp[0][0] = 1; // Base Case
	for(int i = 1; i <= N; ++i)
		for(int len = N; len >= 0; --len)
			for(int sum = 0; sum < MAXS; ++sum)
				if(dp[len][sum]) // O(N^4)
					dp[len+1][sum+array[i]] += dp[len][sum];
	lld ret = 0;
	for(int len = 1; len <= N; ++len)
		ret += dp[len][len*A];
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[300000];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&a[i]);
	}
	multiset<P>se;
	rep(i,n){
		auto it=se.lower_bound(P(a[i],0));
		if(it==se.begin()){
			se.insert(P(a[i],1));
			continue;
		}
		it--;
		auto p=*it;
		se.erase(it);
		se.insert(P(a[i],p.second+1));
	}
	cout<<se.size()<<endl;
}

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

int cnt[200010];

int main(){
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		cnt[a]++;
	}
	sort(cnt,cnt+200001);
	reverse(cnt,cnt+200001);
	int ans=0;
	for(int i=K;i<200001;i++){
		ans+=cnt[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^11-1
#define P pair<int,int>
int n,a[200000],sum[200000],mid,tot=0,ans=0;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum[i]=a[i]-i-1;
    }
    sort(sum,sum+n);
    mid=sum[(n-1)/2];
    rep(i,n){
        ans+=abs(sum[i]-mid);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python  1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def int2ketanowa(No):
    result = 0
    noStr = str(No)
    nolen = len(noStr)
    for j in range(0,nolen):
        result = result + int(noStr[j])
    return result

def solver(maxNum, upperNum, lowerNum):
    result = 0
    for j in range(1,maxNum+1,+1):
        sumKeta = int2ketanowa(j)
        if upperNum <= sumKeta and sumKeta <= lowerNum:
            result = result + j
    return result


if __name__ == "__main__":
    N, A, B = MI()
    print("{}".format(solver(N, A, B)))


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

ll const mod =1e9+7;
int main() {
  int N,t; cin >> N;
  vector<int> e,o;
  rep(i,N) {
    cin >> t;
    if (i%2==0) o.push_back(t);
    else e.push_back(t);
  }
  if (o.size() > e.size()) {
    reverse(o.begin(),o.end());
    for (auto ans:o) cout << ans << ' ';
    for (auto ans:e) cout << ans << ' ';
  }
  else {
    reverse(e.begin(),e.end());
    for (auto ans:e) cout << ans << ' ';
    for (auto ans:o) cout << ans << ' ';
  }
  cout << endl;
}

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

int main(){
  int n;
  int h,m1,m2;
  int l,d,m,tl,td,tm;
  char tmp;

  while(1){
    cin >> n;
    if(!n)break;

    l = tl = 0;
    d = td = 0;
    m = tm = 0;

    getchar();
    for(int i=0;i<n;i++){
      h = 0;
      tmp = getchar();
      h += 10 * (tmp - '0');
      tmp = getchar();
      h += tmp -'0';
      getchar();

      m1 = 0;
      tmp = getchar();
      m1 += 10 * (tmp - '0');
      tmp = getchar();
      m1 += tmp -'0';
      getchar();

      m2 = 0;
      tmp = getchar();
      m2 += 10 * (tmp - '0');
      tmp = getchar();
      m2 += tmp -'0';
      getchar();

      if(m2<m1)m2+=60;

      if(h<2)tm++;
      else if(h>=11 && h<15)tl++;
      else if(h>=18 && h<21)td++;
      else if(h>=21)tm++;

      if(m2-m1 <= 8){
	if(h<2)m++;
	else if(h>=11 && h<15)l++;
	else if(h>=18 && h<21)d++;
	else if(h>=21)m++;
      }
    }

    cout << "lunch ";
    if(tl)cout << l*100/tl << endl;
    else cout << "no guest" << endl;

    cout << "dinner ";
    if(td)cout << d*100/td << endl;
    else cout << "no guest" << endl;

    cout << "midnight ";
    if(tm)cout << m*100/tm << endl;
    else cout << "no guest" << endl;
  }
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by AMK on 8/27/2019.
 * Life is nice :)
 * Enjoy coding :D
 */
public class Main {
    static int n;
    private static int memo[] = new int[100005];
    private static int arr[];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.fill(memo, -1);
        memo[1] = 0;
        memo[2] = Math.abs(arr[1] - arr[2]);
        for (int i = 3; i <= n; i++) {
            memo[i] = Math.min(memo[i - 2] + Math.abs(arr[i] - arr[i - 2]),
                    memo[i - 1] + Math.abs(arr[i] - arr[i - 1]));
        }
        System.out.println(memo[n]);
    }

    private static int Calc(int i, int cost) {
        if (i == 0) {
            return cost;
        }
        if (i < 0) {
            return Integer.MAX_VALUE;
        }
//        if (memo[i] != -1) {
//            return memo[i];
//        }
        int res = Math.min(Calc(i - 1, i >= 1 ? cost + Math.abs(arr[i] - arr[i - 1]) :
                        Integer.MAX_VALUE),
                Calc(i - 2, i >= 2 ? cost + Math.abs(arr[i] - arr[i - 2]) : Integer.MAX_VALUE));
        memo[i] = res;
        if (i > 0)
            System.out.println(i + " " + res);
        return res;
    }
}


Measured memory_bytes: 50764
n = 10 ** 5 + 1
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False

a = [0] * n
s = [0] * (n + 1)

for i in range(2, int(n ** 0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = False

for i in range(n):
    if i % 2 == 0:
        continue
    if is_prime[i] and is_prime[int((i + 1) / 2)]:
        a[i] = 1

for i in range(n):
    s[i + 1] = s[i] + a[i]

q = int(input())

l = [0] * q
r = [0] * q

for i in range(q):
    l[i], r[i] = map(int, input().split())
    r[i] += 1

for i in range(q):
    print(s[r[i]] - s[l[i]])


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> pii;
typedef long long ll;

int n , m, dist[1001][1001];
char g[1002][1002];
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

queue< pii > q;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		scanf("%s",g[i]);
	memset(dist,-1,sizeof dist);
	for (int i = 0; i < n; ++i){
		for(int j = 0 ; j < m ; ++j){
			if(g[i][j]=='#'){
				dist[i][j] = 0;
				q.push(make_pair(i,j));
			}
		}
	}
	int mx = 0;
	while(q.size()){
		pii src = q.front();
		q.pop();
		mx = max(mx,dist[src.x][src.y]);
		for(int j = 0 ; j < 4 ; ++j){
			int newX = dx[j] + src.x;
			int newY = dy[j] + src.y;
			if(newX < 0 || newY < 0 || newX >= n || newY >= m)continue;
			if(dist[newX][newY] != -1)continue;
			dist[newX][newY] = dist[src.x][src.y] + 1;
			q.push(make_pair(newX,newY));
		}
	}
	cout << mx << endl;
	
	return 0;
}

Measured memory_bytes: 13328
N = int(input())
R = [0] * 10001
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            res = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if res<=10000:
                R[res] += 1
for n in range(1,N+1):
    print(R[n])

Measured memory_bytes: 69124
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

int main()
{
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A), q(B), r(C);
  for (int i = 0; i < A; i++)
  {
    cin >> p[i];
  }
  for (int i = 0; i < B; i++)
  {
    cin >> q[i];
  }
  for (int i = 0; i < C; i++)
  {
    cin >> r[i];
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());

  vector<int> sub_p = vector<int>(p.begin(), p.begin() + X);
  vector<int> sub_q = vector<int>(q.begin(), q.begin() + Y);
  vector<int> s = {};
  s.insert(s.end(), sub_p.begin(), sub_p.end());
  s.insert(s.end(), sub_q.begin(), sub_q.end());
  s.insert(s.end(), r.begin(), r.end());
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  ll ans = 0;
  for (int i = 0; i < X + Y; i++)
  {
    ans += s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4000
#ifdef boost
	#pragma GCC target ("avx2")
	#pragma GCC optimization ("O3")
	#pragma GCC optimization ("unroll-loops")
#endif
#include<bits/stdc++.h>
#define int long long
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
#define __ read()
using namespace std;
const int maxn(1e5+5);
void rda(int *a,int n){for(int i=1;i<=n;++i)a[i]=__;}
void print(int *a,int n){for(int i=1;i<=n;++i)printf("%lld ",a[i]);puts("");}
int n,x,t;
signed main()
{
	n=__,x=__,t=__;
	printf("%lld",(n%x==0)?n/x*t:(n/x+1)*t);
}




Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int main() {
    int N, T, c, t;
    cin >> N >> T;
    int min = 1001;
    for (int i = 0; i < N; i++) {
        cin >> c >> t;
        if (t > T) continue;
        if (c < min) min = c;
    }
    if (min == 1001) cout << "TLE" << endl;
    else cout << min << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, k int

	fmt.Scan(&a, &b, &c, &k)

	data := []int{a, b, c}
	i := maxIndex(data)

	for j := 0; j < k; j++ {
		data[i] *= 2
	}

	fmt.Println(arraySum(data))
}

func maxIndex(a []int)int {
	var max int
	var r int
	for i := range a {
		if max < a[i] {
			max = a[i]
			r = i
		}
	}

	return r
}

func arraySum(a []int)int {
	sum := 0
	for i := range a {
		sum += a[i]
	}

	return sum
}

Measured memory_bytes: 512
from math import gcd

N = int(input())
A = list(map(int, input().split()))

# setwise validation
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)

# pairwise validation
M = 10 ** 6
sieve = [0] * (M + 1)
for a in A:
    sieve[a] += 1

cnt = 0
isPairwise = True
for i in range(2, M + 1):
    isPairwise &= (sum(sieve[j] for j in range(i, M + 1, i)) <= 1)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)

Measured memory_bytes: 194636
N = int(input())
h = list(map(int,input().split()))
ans = 0
while True:
    flag = False
    for i in range(N):
        if not flag and h[i] > 0:
            h[i] -= 1
            flag = True
        elif flag and h[i] > 0:
            h[i] -= 1
        elif flag and h[i] == 0:
            flag = False
            ans += 1
        else:
            pass
        if i == N-1 and flag:
            ans += 1
        
    if sum(h) == 0:
        break
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
//	"strconv"
//	"sort"
	"math"
//	"regexp"
)

var mod int = 1000000007
var N,M int
var ans int =1

func main(){
	fmt.Scan(&N,&M)

	if int(math.Min(float64(N),float64(M)))+1 == int(math.Max(float64(N),float64(M))){
		for i:=1;i<=N;i++{
			ans *= i	
			ans %=mod
		}
		for i:=1;i<=M;i++{
			ans *= i
			ans %=mod
		}
	}else if N == M{
		for i:=1;i<=N;i++{
			ans *= i	
			ans %=mod
		}
		for i:=1;i<=M;i++{
			ans *= i
			ans %=mod
		}
		ans *=2
		ans %=mod
	}else{
		ans = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#test

N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort()
F.sort(reverse=True)
AF = [A[i]*F[i] for i in range(N)]

l = -1
r = max(AF)

while r-l > 1:
    x = (l+r)//2
    k =0
    #スコアをx以下にするのに必要な最小コストを算出
    for i in range(N):
        if AF[i]<=x:
            continue
        else:
            k += A[i]-x//F[i]
    if k <= K:
        r = x
    else:
        l=x

print(r)

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

using namespace std;

int main()
{
	long long int n, k;
	cin >> n >> k;

	vector<pair<int, int>>pairs(n);
	int wka, wkb;
	for (int i = 0; i < n; i++) {
		cin >> wka >> wkb;
		pairs[i] = make_pair(wka, wkb);
	}
	
	sort(pairs.begin(), pairs.end());
	
	int ans;
	for (int i = 0; i < n; i++) {
		k -= pairs[i].second;

		if (k <= 0) {
			ans = pairs[i].first;
			break;
		}
	}

	cout << ans << endl;
	


	return 0;



}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
ll n, m;

int main(){
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m;
		if (m % 2 == 1) kill("first");
	}
	kill("second");
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        String ans = "";
        if(a.length>b.length){
            ans = "GREATER";
        } else if(a.length<b.length){
            ans = "LESS";
        } else {
            for(int i =0;i<a.length;i++){
                if(a[i]>b[i]){
                    ans = "GREATER";
                    break;
                } else if(a[i]<b[i]){
                    ans = "LESS";
                    break;
                }
                ans = "EQUAL";
            }
        }
        System.out.println(ans);
}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, a, b, dp[100100], res;
vector<int> e[100100];

int rec(int v) {
	if (dp[v]!=-1) return dp[v];
	int res = 0;
	each(i,e[v]) chmax(res, rec(i)+1);
	return dp[v] = res;
}

signed main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> a >> b;
		e[a-1].push_back(b-1);
	}
	rep(i,n) dp[i] = -1;
	rep(i,n) chmax(res, rec(i));
	cout << res << endl;
}

Measured memory_bytes: 8192