akhauriyash/Code-Regression huggingface dataset:
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}


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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int cnt=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if( 500*i + 100*j + 50*k == x ){
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

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

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


Measured memory_bytes: 3668
def solve():
    N, *sl = map(lambda x:''.join(sorted(x)), open(0).read().split())
    dic = {}
    ans = 0
    
    for s in sl:
        if s in dic:
            ans += dic[s]
            dic[s] += 1
        else:
            dic[s] = 1
    
    print(ans)


if __name__ == '__main__':
    solve()

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef unsigned long long ull;

mt19937_64 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());

ull const MASK30 = (1<<30)-1;
ull const MASK31 = INT_MAX;
ull const MOD = (1LL<<61)-1;
ull const MOD5 = MOD*5;
ull const base = r()%MOD;

struct RollingHash {
private:
    vector<ull> power,hash;
public:
    inline ull mul(ull a,ull b) {
        ull au = a>>31;
        ull ad = (a&MASK31);
        ull bu = b>>31;
        ull bd = (b&MASK31);
        ull mid = au*bd+ad*bu;
        return ((au*bu)<<1)+ad*bd+(mid>>30)+((mid&MASK30)<<31);
    }

    inline ull calcmod(ull a) {
        a = (a&MOD)+(a>>61);
        if (a > MOD) a -= MOD;
        return a;
    }

    RollingHash(string& s) {
        int n = s.size();
        power.resize(n+1);
        hash.resize(n+1);
        power[0] = 1;
        hash[0] = 0;
        for (int i = 0;i < n;++i) power[i+1] = calcmod(mul(power[i],base));
        for (int i = 0;i < n;++i) hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
    }

    ull get(int l, int r)  {
        if (l) return calcmod(hash[r]+MOD5-mul(hash[l],power[r-l]));
        return hash[r];
    }

    ull connect(ull h1,int l,int r) {
        ull h2 = get(l,r);
        return calcmod(mul(h1,power[r-l])+h2);
    }

    // [l,r)
    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (get(l1,l1+mid) == rh.get(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    RollingHash rh(s);
    int ok = 0,ng = n/2+1;
    while (ng-ok > 1) {
        // map<ull,int> mp;
        unordered_map<ull,int> mp;
        // mp.reserve(5000);
        int mid = (ok+ng)/2;
        bool f = false;
        for (int i = 0;i < n-mid+1;++i) {
            ull key = rh.get(i,i+mid);
            auto it = mp.find(key);
            if (it != mp.end()) {
                if (it->second < i+2-mid) {
                    f = true;
                    break;
                }
            } else mp[key] = i+1;
        }
        (f ? ok : ng) = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 652
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for c in range(M):
    L[c], R[c] = map(int, input().split())

L_max = max(L)
R_min = min(R)

ans = R_min - L_max
ans += 1

if ans < 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 16672
/*
* @Author: kabbo
* @Date:   2020-06-21 21:00:55
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-21 21:06:26
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
	int n, k;
	cin >> n >> k;
	vector<int>v(n);
	for (auto& x : v)
		cin >> x;
	sort(v.begin(), v.end());
	auto ans = 0;
	for (int i(0); i < k; ++i) {
		ans += v[i];
	}
	cout << ans << endl;
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    ll ans = -1e12;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);
    rep(i, N) cin >> x[i] >> y[i] >> z[i];

    rep(b, 8) {
        vector<ll> anss(N, 0);
        rep(i, N) {
            ll sm = 0;
            sm += (b & (1 << 0)) ? x[i] : -x[i];
            sm += (b & (1 << 1)) ? y[i] : -y[i];
            sm += (b & (1 << 2)) ? z[i] : -z[i];
            anss[i] = sm;
        }
        sort(all(anss), greater<ll>());
        ll tmp = 0;
        rep(m, M) tmp += anss[m];
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

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

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  int n,m,ans;
  cin >> n >> m;
  ans = n-1;
  UnionFind tree(n);
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    if(!tree.issame(a,b)){tree.merge(a,b);ans--;}
  }
  cout << ans << endl;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> gates(n+1);
    for(int i = 0; i < m; ++i)
    {
        int l,r;
        cin >> l >> r;
        --l;
        --r;
        ++gates[l];
        --gates[r+1];
    }

    int cnt = 0;
    for(int i = 0; i < n+1; ++i)
    {
        gates[i] += gates[i-1];
        if(gates[i] >= m)
        {
            ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
[k,x] = [int(i) for i in input().split()]
ls =[]
if x - k + 1 < -100000:
    for i in range(-100000,x+k):
        ls.append(i)
elif x + k - 1 > 100000:
    for i in range(x - k + 1, 100001):
        ls.append(i)
else:
    for i in range(x - k + 1,x + k):
        ls.append(i)
ans = ""
for i in range(len(ls)):
    ans += str(ls[i]) + " "
print(ans[:-1])


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return (n%mod)*(factorial(n-1)%mod);
    }
}

/* ユークリッドの互除法 最大公約数*/
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;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll m,n;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
        exit(0);
    }
    ll sum=1;
    if((n+m)%2==0){
        sum*=factorial(n)%mod;
        sum*=factorial(m)%mod;
        sum*=2%mod;
    }
    else{
        sum*=factorial(n)%mod;
        sum*=factorial(m)%mod;
    }
    cout<<sum%mod<<endl;
    


    
    
}


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

int main()
{
  int n;
  cin >> n;
  int a = n / 100;
  if(a * 100 + a * 10 + a >= n){
    cout << a * 100 + a * 10 + a << endl;
  }
  else{
    cout << (a + 1) * 100 + (a + 1) * 10 + a + 1 << endl;
  }
}

Measured memory_bytes: 256
goodlist = []
10.times do |n|
  str = /#{n}#{n}#{n}/
  goodlist.push(str)
end
check = true
s = gets.chomp
goodlist.each do |str|
  if(s =~ str)
    print "Yes\n"
    check = false
    break
  end
end
print "No\n" if check

Measured memory_bytes: 3836
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    A,B = cin.mapInt()
    print(Math.lcm(A,B))
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 38736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
	int n, m, tmp, tmp2;
	cin >> n >> m;
	vector<int> height(n);
	vector<vector<int>> load(n);
	rep(i, n)	cin >> height[i];
	rep(i, m) {
		cin >> tmp >> tmp2;
		tmp--;
		tmp2--;
		load[tmp].push_back(tmp2);
		load[tmp2].push_back(tmp);
	}
	int ans = 0;
	bool ok = false;
	rep(i, n) {
		ok = false;
		rep(j, load[i].size()) {
			if (height[i] <= height[load[i][j]]) {
				ok = true;
				break;
			}
		}
		if (!ok)	ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8424
import Data.Int
import Data.Bits
toi True = 1
toi False = 0
btoi xs = sum $ zipWith (*) xs $ map (2^) [0..]
-- f :: Int64 -> Int64 -> [Int64] -> Int64
f nn xx yys = go xx 41 urettat
  where
    tatteru = map (\a -> sum $ map (\y -> toi $ testBit y a) yys) [0..41]
    zakos = map (\a -> max a (nn - a)) tatteru
    urettat = reverse tatteru
    zako n = btoi $ take n zakos
    go :: Int64 -> Int -> [Int64] -> Int64
    go k n xs
      | n < 0 = 0
      | k < 2^n = 2^n*(head xs) + go k (n-1) (tail xs)
      | k >= 2^n = max (2^n*(head xs) + zako n) (2^n*(nn-head xs) + go (k-2^n) (n-1) (tail xs))

main = do
  [n,k] <- map (read::String->Int64) . words <$> getLine
  xs <- map (read::String->Int64) . words <$> getLine
  print $ f n k xs


Measured memory_bytes: 67964
MOD = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

MAX = 10**5 + 100
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


ans = 0
for i in range(n):
    # min
    ans -= a[i] * comb(n - 1 - i, k - 1)
    ans %= MOD
    # max
    ans += a[i] * comb(i, k - 1)
    ans %= MOD
    # print(comb(n - 1 - i, k - 1), comb(i, k - 1))

print(ans)


Measured memory_bytes: 19168
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int a[1005];

int main()
{
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << accumulate(a, a + k, 0) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, k; cin >> n >> k;
  vector<int> d(10, 0);
  for(int i = 0; i < k; i++){
    int x; cin >> x;
    d[x]++;
  }

  for(int i = n; ; i++){
    string s = to_string(i);
    int j = 0;
    for(; j < s.size(); j++){
      if(d[s[j] - '0'] == 1) break;
    }
    if(j == s.size()){
      cout << i << endl;
      return;
    }
  }

  return;
}

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


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    rep(i, N) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    string ans;
    rep(i, N) ans += s[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <list>
#include <iostream>
#include <vector>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <map>
#include <sstream>
#include <set>
#include <cmath>
#include <iomanip>
#include <queue>

#define endl "\n"
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rr return 0

using namespace std;


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,wg;
    cin >> n >> wg;
    int w[n + 1];
    int v[n + 1];
    for(int i = 1;i <= n;i++){
        cin >> w[i] >> v[i];
    }
    int dp[n + 1][wg + 1];
    for(int i = 0;i <= wg;i++){
        dp[0][i] = 0;
    }
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= wg;j++){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i]){
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i],dp[i][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0;i <= wg;i++){
        ans = max(ans,dp[n][i]);
    }
    cout << ans;
    rr;
}


Measured memory_bytes: 79232
N=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
x=[0]*(M-m+3)
for i in a:
  x[i-m]+=1
  x[i-m+1]+=1
  x[i-m+2]+=1
print(max(x))

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    cin>>n>>m>>k;
    ll a[n];
    ll b[m];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
            a[i]+=a[i-1];
    }
    for(i=0;i<m;i++)
    {
        cin>>b[i];
        if(i>0)
            b[i]+=b[i-1];
    }
    i=-1;
    j=m-1;
    ll mx=0;
    ll o;
    
    while(i<n)
    {   if(i==-1)
        o=0;
        else
        {
        if(a[i]>k)
            break;
        o=a[i];
        }
        while(j>=0 && b[j]>k-o)
            j--;
        mx=max(mx,i+j+2);
        i++;
    }
    cout<<mx<<"\n";
}





Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n;
  cin >> n;
  vector<vi> v1(0), v2(0);
  vi v1memo(100000, 0), v2memo(100000, 0);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      if (v1memo.at(v - 1) == 0) {
        v1.push_back({1, v});
        v1memo.at(v - 1) = 1;
      }
      else {
        for (int j = 0; j < v1.size(); j++) {
          if (v1.at(j).at(1) == v) {
            v1.at(j).at(0)++;
            break;
          }
        }
      }
    }
    else {
      if (v2memo.at(v - 1) == 0) {
        v2.push_back({1, v});
        v2memo.at(v - 1) = 1;
      }
      else {
        for (int j = 0; j < v2.size(); j++) {
          if (v2.at(j).at(1) == v) {
            v2.at(j).at(0)++;
            break;
          }
        }
      }
    }
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  int a = v1.size(), b = v2.size();
  if (v1.at(a - 1).at(1) != v2.at(b - 1).at(1))
    cout << n - v1.at(a - 1).at(0) - v2.at(b - 1).at(0) << endl;
  else {
    if (a == 1 && b == 1)
      cout << min(v1.at(0).at(0), v2.at(0).at(0)) << endl;
    else if (a == 1)
      cout << n - v1.at(a - 1).at(0) - v2.at(b - 2).at(0) << endl;
    else if (b == 1)
      cout << n - v1.at(a - 2).at(0) - v2.at(b - 1).at(0) << endl;
    else {
      cout << min(
        n - v1.at(a - 1).at(0) - v2.at(b - 2).at(0),
        n - v1.at(a - 2).at(0) - v2.at(b - 1).at(0)
      ) << endl;
    }
  }
}

Measured memory_bytes: 6504
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int D,T,S;
  cin >> D >> T >> S;
  if(T*S >= D){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[] dp = new bool[10001];
		dp[0] = true;
		for(int i=0;i<N;i++){
			for(int j=10000;j>=0;j--){
				if(dp[j]) dp[j + A[i]] = true;
			}
		}
		
		int max = 0;
		for(int i=10000;i>=0;i--){
			if(i % 10 == 0) continue;
			if(dp[i]){
				max = i;
				break;
			}
		}
		
		Console.WriteLine(max);
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    string s,t; cin >> s >> t;
    sort(all(s));
    sort(rall(t));
    if(s < t)out("Yes");
    else out("No");
}

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

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T;
  cin >> S;
  cin >> T;
  
  int  count=0;
  if(S[0] == T[0]) ++count;
  if(S[1] == T[1]) ++count;
  if(S[2] == T[2]) ++count;
  cout << count << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

int main() {
	cout << fixed << setprecision(15);
	int n;
	cin>>n;
	double sum1 = 0, sum2 = 0, sum3 = 0, ansinf=0;
	vector<double> x(n, 0);
	vector<double> y(n, 0);
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < n; i++) cin >> y[i];
	for (int i = 0; i < n; i++) {
		double d = abs(x[i] - y[i]);
		sum1 += d;
		sum2 += pow(d, 2);
		sum3 += pow(d, 3);
		ansinf = max(d, ansinf);
	}
	cout << sum1 << endl;
	cout << sqrt(sum2) << endl;
	cout << cbrt(sum3) << endl;
	cout << ansinf << endl;
}



Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

int32_t main()
{
    fast;
    int a,b,k,cnt=0,ans;
    cin>>a>>b>>k;
    repd(i,min(a,b),1)
    {
        if((a%i)==0 && (b%i)==0)
        {
            cnt++;
            ans=i;
        }
        if(cnt==k)
            break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
if(n%10==2 or n%10==4 or n%10==5 or n%10==7 or n%10==9):
  print("hon")
elif(n%10==0 or n%10==1 or n%10==6 or n%10==8):
  print("pon")
else:
  print("bon")

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N;
	cin >> N;
	vector<ll> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}

	string ans = "Yes";
	ll prev = H[N - 1];
	for (int i = N - 2; i >= 0; --i) {
		if (prev > H[i]) {
			prev = H[i];
		}
		else if (prev == H[i]) {
			prev = H[i];
		}
		else {
			if (prev == H[i] - 1) {
				prev = H[i] - 1;
			}
			else {
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m[10];
  for(int i=0;i<10;i++){
    cin>>m[i];
  }
  sort(m,m+10);
  reverse(m,m+10);
  cout<<m[0]<<endl;
  cout<<m[1]<<endl;
  cout<<m[2]<<endl;
  return 0;
}



Measured memory_bytes: 3064
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [usize; n]
    }
    let mut p: Vec<usize> = p;
    p.sort();
    let res: usize = p[0..k].iter().sum();
    println!("{}", res);
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int num[31];
  int temp;
  int ans=0;
  int ans2=0;
  int i;
  for(i=1;i<=30;i++){
      cin>>temp;
      num[temp]=1;
  }
  
  for(i=1;i<=30;i++){
      if(num[i]!=1&&ans==0){
          ans=i;
      }else if(num[i]!=1&&ans!=0){
          ans2=i;
      }
  }
  if(ans<=ans2){
      cout<<ans<<endl;
      cout<<ans2<<endl;
  }else{
      cout<<ans2<<endl;
      cout<<ans<<endl;
  }
  return 0;
  
}

Measured memory_bytes: 3056
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N, W = readi(2)
    vs, ws = zip(*readi(N, 2))
    dp = arr(N + 1, W + 1)
    for i in range(N):
        for j in range(W + 1):
            if j - ws[i] >= 0:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - ws[i]] + vs[i])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

    print(dp[N][W])


if __name__ == "__main__":
    main()



Measured memory_bytes: 43088
list1 = list(map(int,input().split()))
h = list1[0]
w = list1[1]
a = list()
i = 0
n = 0
ans = list()
while i <= h-1:
    a.append(list(map(int,input().split())))
    i += 1
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 != 0:
            a[i][j] -= 1
            a[i][j+1] += 1
            n+=1
            ans.append([i+1,j+1,i+1,j+2])
for i in range(h-1):
    if a[i][w-1] % 2 != 0:
        a[i][w-1] -= 1
        a[i+1][w-1] += 1
        ans.append([i+1, w, i+2, w])
        n+=1
print(n)
for i in range(n):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3])

Measured memory_bytes: 30264
package main
import(
  "fmt"
)
func main(){
  var n, i int
  fmt.Scan(&n)
  temp:=0
  ans:=0
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    if i!=0{
      if a[i-1]>=a[i]{
        temp++
      }else{
        if temp>ans{
          ans=temp
        }
        temp=0
      }
    }
    if temp>ans{
      ans=temp
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <iostream>
    #include <cmath>
    using namespace std;
    using ll = long long;
    using ull = unsigned long long;

    bool calc(ll a, ll b, ll c)
    {
        ull left = (c-b-a) * (c-b-a);
        ull right = 4 * a * b;
        return (left > right) && ((c-a-b) > 0);
    }

    int main()
    {
        ull a, b, c;
        cin >> a >> b >> c;
        if (calc(a, b, c))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n; cin >> n;

  int A[n+5], B[n+5];
  for(int i = 1; i <= n; i++) {
    cin >> A[i] >> B[i];
  }

  for(int i = 1; i <= n-2; i++) {
    if(A[i] == B[i] && A[i+1] == B[i+1] && A[i+2] == B[i+2]) {
      cout << "Yes\n"; return;
    }
  }
  cout << "No\n";
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1; // cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

ll dp[101][2][5];
int main() {
  string n;
  ll k;
  cin >> n >> k;
  ll nlen = n.size();
  dp[0][1][0] = 1;
  rep(i, nlen) {
    ll x = n[i] - '0';
    rep(j, 2) rep(k, 4) rep(l, 10) {
      if (j == 1 && l > x) continue;
      dp[i + 1][j == 1 && l == x][k + (l > 0)] += dp[i][j][k];
    }
  }
  cout << dp[nlen][0][k] + dp[nlen][1][k] << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
long long dp[101][4][4][4];
long long const p=1e9+7;

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                dp[3][i][j][k]=1;
            }
        }
    }
    dp[3][0][2][1]=0;
    dp[3][0][1][2]=0;
    dp[3][2][0][1]=0;
    for(int m=4;m<=n;m++){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                for(int k=0;k<4;k++){
                    dp[m][i][j][k]=0;
                    if(i==0&&j==2&&k==1)continue;
                    if(i==0&&j==1&&k==2)continue;
                    if(i==2&&j==0&&k==1)continue;
                    for(int l=0;l<4;l++){
                        dp[m][i][j][k]+=dp[m-1][l][i][j];
                    }
                    if(i==2&&k==1)dp[m][i][j][k]-=dp[m-1][0][i][j];
                    if(j==2&&k==1)dp[m][i][j][k]-=dp[m-1][0][i][j];
                    if(i==2&&j==2&&k==1)dp[m][i][j][k]+=dp[m-1][0][i][j];
                    dp[m][i][j][k]%=p;

                }
            }
        }
    }
    long long ans=0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                ans+=dp[n][i][j][k];
            }
        }
    }
    printf("%lld\n",ans%p);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
ans=min(a)+min(b)
for i in range(M):
  x,y,c=map(int, input().split())
  ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 18736
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;
#define MAX 100000

int main(){
  int n; cin >> n;
  int F[50];
  F[0]=F[1]=1;
  for(int i=2;i<=n;i++)F[i]=F[i-1]+F[i-2];
  cout << F[n] << endl;
  return 0;
}


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

int main() {
  int N,K,count = 0;// N人とK種類,100以下
  cin >> N >> K;
  
  vector<int> d(K);// お菓子1を持ってるのはd人,1〜K＝100以下種類あるよ
  vector<int> A(N);// お菓子1を持ってるのはA人目、d人,必ずN＝100以下だよ
  vector<int> v(100);// お菓子を持ってる人の管理配列、N＝100以下人分
  
  for(int i = 0; i < K; i++){
    cin >> d.at(i); //お菓子1は1人、お菓子2は1人、お菓子3は1人
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(j); //お菓子1は3人目、お菓子2は3人目、お菓子3は3人目
      v.at(A.at(j)-1) += A.at(j);
      //cout << v.at(A.at(j)-1) << " ";
      A.at(j) = 0;
    }
    //cout << endl;
  }
  
  
  
  for(int i = 0; i < 100; i++){
    //cout << v.at(i) << " ";
  	if(v.at(i) > 0)count++;
  }
  
  //cout << endl;
  //cout << count << endl;
  cout << (N-count) << endl;
  
}

Measured memory_bytes: 3596
l, r = [int(v) for v in input().split()]

if r - l > 2019:
    print(0)
    exit()

res = 2019
for i in range(l, r):
    for j in range(i + 1, r + 1):
        res = min(res, (i * j) % 2019)

        if res == 0: break

print(res % 2019)


Measured memory_bytes: 2940
#include <cstdio>

using namespace std;

int main()
{
	int a,b,c;
	scanf("%d %d", &a, &b);
	if(a==1 || a==3 || a==5 || a==7 || a==8 || a==10 ||a==12){
		if(b==1 || b==3 || b==5 || b==7 || b==8 || b==10 ||b==12){
			printf("Yes");
		}
		else {
			printf("No");
		}
	}
	else if (a==4 || a==6 || a==9 || a==11){
		if(b==4 || b==6 || b==9 || b==11){
			printf("Yes");
		}
		else {
			printf("No");
		}
	}
	else if (a==2) {
		if(b==2){
			printf("Yes");
		}
		else { 
		printf("No");
		}
	}
	
	
}



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

using namespace std;

int main()
{
    long N;
    cin >> N;
    vector<long> A(N);
    for (long i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    long ans = A.at(0);
    if (N == 3)
    {
        ans += A.at(1);
        
    } else if (N % 2 == 1)
    {
        for (long i = 1; i < N / 2; i++)
        {
            ans += A.at(i) * 2;
        }
        ans += A.at(N / 2);
        
    } else if (N % 2 == 0)
    {
        for (long i = 1; i < N / 2; i++)
        {
            ans += A.at(i) * 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"    [";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    set<int> s;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (s.find(a) == s.end()) {
            s.insert(a);
            ans++;
        } else {
            s.erase(a);
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>
int main(void) {
int a, b;
scanf("%d", &a);
scanf("%d", &b);
if ((a + b) % 2 == 0) { 
printf("%d\n", (a + b) / 2);
} else {
printf("%d\n", (a + b) / 2 + 1);
}
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

using ll = long long int;
# define MOD 1000000007
ll F[100010];

ll square(ll x){
    return (x*x) % MOD;
}

ll mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

void fact(int max){
    F[0] = 1;
    F[1] = 1;
    for( ll i = 2; i <= max; i++){
        F[i] = mul(F[i-1],i);
    }
}

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int N,M;
	cin >> N >> M;

	if (N>M){swap(M,N);}
	// N<=M の関係にする。
	int mulVal = 0;
	if (N==M){
		mulVal=2;
	}else if(N+1==M){
		mulVal=1;
	}else{
		printf("0\n");return 0;
	}

	fact(M);
	int64_t ans = mul(F[M],F[N]);
	if (mulVal != 1){
		ans = mul(2,ans);
	}

	printf("%ld\n",ans);

	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
n = int(input())
l = list(map(int, input().split()))
m = sum(l)
a = 0
for i in range(n):
    if l[i] >= m - l[i]:
        print("No")
        a = 1
        break
if a == 0:
    print("Yes")

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

signed main(){
    int n;
    cin>>n;
    int arr[n][3];
    int dp[n][3];
    memset(dp,0,sizeof(dp[0][0])*n*3);
    for(int i = 0;i<n;i++){
        for(int j = 0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    for(int i =0;i<3;i++){
        dp[0][i] = arr[0][i];
    }
    for(int i = 1;i<n;i++){
        for(int j = 0;j<3;j++){
            if(j==0){
                dp[i][j] = arr[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
            }
            else if(j==1){
                dp[i][j] = arr[i][j]+max(dp[i-1][j-1],dp[i-1][j+1]);
            }
            else{
                dp[i][j] = arr[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
            }
        }
    }
    int res = INT_MIN;
    for(int i=0;i<3;i++){
        if(dp[n-1][i]>res){
            res = dp[n-1][i];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (110)

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

int BS(vector<ll> &v, ll left, ll right, ll key){
  ll mid = (left + right) / 2;
  if(v[mid] <= key) left = mid;
  else right = mid;
  if(right - left == 1) return left;
  else return BS(v, left, right, key);
}

void chmin(ll &a, ll b) {if(a > b) a = b;}

void Main() {
  ll A, B, Q; cin >> A >> B >> Q;
  vector<ll> s(A), t(B), x(Q);
  rep(i, 0, A) cin >> s[i];
  rep(i, 0, B) cin >> t[i];
  rep(i, 0, Q) cin >> x[i];

  rep(i, 0, Q){
    ll res = INF;
    ll key = x[i];
    ll sl, sr, tl, tr;
    sl = BS(s, -1, A, key);
    sr = sl + 1;
    tl = BS(t, -1, B, key);
    tr = tl + 1;
    //sr tr
    if(sl >= 0 && tl >= 0) chmin(res, min(abs(key - s[sl]), abs(key - t[tl])) + abs(s[sl] - t[tl]));
    if(sl >= 0 && tr < B) chmin(res, min(abs(key - s[sl]), abs(key - t[tr])) + abs(s[sl] - t[tr]));
    if(sr < A && tl >= 0) chmin(res, min(abs(key - s[sr]), abs(key - t[tl])) + abs(s[sr] - t[tl]));
    if(sr < A && tr < B) chmin(res, min(abs(key - s[sr]), abs(key - t[tr])) + abs(s[sr] - t[tr]));
    cout << res << endl;
  }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


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

int main(void)
{
	char str[200], cpy[200];
	int i, j, len, cpyh, in;
	
	while (scanf("%s", &str) != EOF){
		len = strlen(str);
		cpyh = 0;
		for (i = 0; i < len; i++){
		//	printf("i = %d\n", i);
			if (str[i] == '@'){
				in = str[++i] - '0';
				i++;
				for (j = 0; j < in; j++){
					cpy[cpyh++] = str[i];
		//			printf("%c\n", cpy[cpyh - 1]);
				}
				
			}
			else cpy[cpyh++] = str[i];
		//	printf("%c\n", cpy[cpyh - 1]);
		}
		cpy[cpyh] = '\0';
		
		printf("%s\n", cpy);
	}
	
	return (0);
}

Measured memory_bytes: 524
// AOJ 3054 Tunnel
// 2019.3.31 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAGIC 305
#define INF   0x5f

int h[155];
double dp[155][310];

double area(int x, int y1, int y2)
{
	int d1 = y1 - h[x], d2 = y2 - h[x];
	if (d1 < 0) d1 = -d1;
	if (d2 < 0) d2 = -d2;
	if ((y1 - h[x])*(y2 - h[x]) >= 0) return 0.5 * (d1 + d2);
	return 0.5 * (d1*d1 + d2*d2) / (d1 + d2);
}

int main()
{
	int x, y1, y2, n;
	double s;

	scanf("%d", &n);
	for (x = 0; x < n; x++) scanf("%d", h + x);

	memset(dp, INF, sizeof(dp));
	dp[0][1] = 0;
	for (x = 0; x < n; x++) {
		for (y1 = 1; y1 < MAGIC; y1++) {
			for (y2 = 1; y2 < MAGIC; y2++) {
				s = dp[x][y1] + area(x, y1, y2);
				if (s < dp[x + 1][y2]) dp[x + 1][y2] = s;
			}
		}
	}
	s = 1e20;
	for (y1 = 1; y1 < MAGIC; y1++) {
		if (dp[n][y1] < s) s = dp[n][y1];
	}
	printf("%.12lf\n", s);
	return 0;
}


Measured memory_bytes: 2232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

int main() {
    llong n;
    llong x;

    cin >> n;

    for (x = 0; x <= n; x++) {
        if ((llong)(x * 1.08) == n) {
            cout << x << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e4+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	int n;
	cin>>n;
	int arr[n+1];
	int dp[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	memset(dp , 0 , sizeof(dp));
	dp[2]=abs(arr[1]-arr[2]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]), dp[i-1]+abs(arr[i]-arr[i-1]));
	
	cout<<dp[n];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef vector < ll > vll;
#define s second
#define f first
int main()
{   
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while (t-- )
	{	int v[5];
		for(int i=0;i<5;i++)
		{	cin>>v[i];
				if(v[i]==0)
					cout<<i+1<<endl;
		}
	}
	return 0;  
}

Measured memory_bytes: 3652
n = int(input()) 
a = [input() for i in range(n)] 

used = [a[0]]
pre = a[0]
for i in a[1:]:
    if i not in used and pre[-1] == i[0]:
        used.append(i)
        pre = i
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3060
#include<cstdio>

int p[4]={6000,4000,3000,2000};

int main(void){
	int t,n;
	for(int i=0;i<4;i++){
		scanf("%d%d",&t,&n);
		printf("%d\n",p[t-1]*n);
	}
	return 0;
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int K;
int main() {
    cin >> K;
    queue<ll> que;
    
    rep(i, 9)que.push(i+1);
    
    while(1){
        ll x = que.front();
        int a = x % 10;
        que.pop();
        K--;
        if (K == 0){
            cout << x;
            return 0;
        }
        if (a != 0)que.push(x * 10 + a - 1);
        que.push(x * 10 + a);
        if (a != 9)que.push(x * 10 + a + 1);
    }
    
    return 0;
}


Measured memory_bytes: 1792