akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(1000000);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    mint ans = c.frac[m]/c.frac[m-n];
    ans *= ans;
    for(int i = 1; i <= n; ++i) {
        mint now = 1;
        if(i%2) now = -1;
        now *= c.frac[m]*c(n, i)*c.frac[m-i]/c.frac[m-n]/c.frac[m-n];
        ans += now;
    }
    cout << ans << endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


// 競技プログラミングを引退します
// いままでありがとうございました

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
  string S;

  int N;
  cin >> N;
  cin >> S;

  for(auto &p : S) {
    int v = p - 'A';
    v += N;
    v %= 26;
    cout << (char) (v + 'A');
  }
  cout << endl;

}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void)
{
    int a, b;

    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int K, T;
    int a[100];
    cin >> K >> T;
    for(int i=0; i<T; i++) cin >> a[i];

    sort(a, a+T);

    int rest = 0;
    for(int i=0; i<T-1; i++) rest += a[i];
    cout << max(0, a[T-1] - rest - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#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 <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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, res = 10001;
  cin >> n;
  vector<int> w(n);
  REP(i,n) cin >> w[i];
  int all = accumulate(w.begin(), w.end(),0);
  REP(i,n+1) {
    int sum1 = accumulate(w.begin(), w.begin()+i,0);
    int sum2 = all - sum1;
    int diff = abs(sum2 - sum1);
    res = min(res, diff);
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.substring(0, s.length() - 1);
        int n = s.length();
        String[] array = new String[n];
        for (int i = 1; i < n; i++) {
            array[i] = s.substring(0, i);
        }
        int max = 1;
        
        for (int i = 1; i < n / 2 + 1; i++) {
            if (s.substring(i, i * 2).equals(array[i])) {
                max = Math.max(max, i * 2);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007


#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  string str;cin>>str;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] =='?')
    {
      str[i] = 'D';
    }
  }
  
  cout<<str<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3776
N, Z, W = map(int, input().split())
if N == 1:
    a = int(input())
    print(abs(a - W))
else:
    a = list(map(int, input().split()))
    print(max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])))


Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  int len = s.length();
  int cond0 = 0;
  int cond1 = 0;
  if (len % 2 == 1) {
    cond0 = 1;
  }
  if (s[0] == s[len-1]) {
    cond1 = 1;
  }
  if (cond0 + cond1 == 1) {
    printf("First\n");
    return 0;
  }
  printf("Second\n");

  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();

        if(A <= X && X <= A + B){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}
 

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

ll gcd(ll a,ll b)
{
  if(a < b) return gcd(b,a);
  ll A;
  while(1)
  {
    if(a%b == 0) break;
    A = a%b;
    a = b;
    b = A;
    // cout << b << " ";
  }
  return b;
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> a;
  for(ll i = 0;i < n;i++)
  {
    ll A;
    cin >> A;
    a.push_back(A);
  }
  sort(a.begin(),a.end());
  ll ans = a[0];
  for(ll i = 1;i < n;i++)
  {
    ans = gcd(ans,a[i]);
    // cout << ans << endl;
  }
  // cout << endl;
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    string a,b,c;
    cin >> a >> b >> c;

    cout << a[0] << b[0] << c[0] << endl;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	map<long long int, int> d_map;
	for(int i = 0; i < n; i++){
		long long int tmp;
		cin >> tmp;
		d_map.insert(make_pair(tmp, i));
	}
	vector<long long int> s(n, 1);
	vector<long long int> dps(n, 0);
	set<pair<int, int> > ans;
	for(auto i = d_map.rbegin(); i != d_map.rend(); i++){
		int now = i->second;
		long long int nowd = i->first;
		long long int nextd = nowd + 2 * s[now] - n;
		if(nextd >= nowd || d_map.find(nextd) == d_map.end()) continue;
		int next = d_map[nextd];
		s[next] += s[now];
		dps[next] += s[now] + dps[now];
		ans.insert(make_pair(min(now, next), max(now, next)));
	}
	if(ans.size() != n - 1 || dps[(*d_map.begin()).second] != (*d_map.begin()).first){
		cout << -1 << endl;
		return 0;
	}
	for(auto i = ans.begin(); i != ans.end(); i++){
		cout << i->first + 1 << " " << i->second + 1 << endl;
	}
}

Measured memory_bytes: 13952
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;



int main()
{
	char ch;
	scanf("%c", &ch);
	ch++;
	printf("%c\n", ch);
	
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll i,j,k;
	ll N;
	cin >> N;
	ll L[N];
	ll l,r,t;
	for(i=0;i<N;i++){
		cin >> L[i];
	}
	sort(L,L+N);
	ll cnt=0;
	for(i=0;i<N-2;i++){
		for(j=i+1;j<N-1;j++){
			l=j;
			r=N;
			while(r-l>1){
				t=(r+l)/2;
				if(L[i]+L[j]>L[t])l=t;else r=t;
			}
			cnt+=l-j;
		}
	}
	cout << cnt;
    return 0;
}


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

int ans(0);
void merge(int A[],int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1],R[n2];
    for(int i=0;i<=n1-1;i++){
        L[i] = A[left+i];
    }
    for(int i=0;i<=n2-1;i++){
        R[i] = A[mid+i];
    }
    L[n1] = 2147483646;
    R[n2] = 2147483646;
    int i(0),j(0);
    for(int k=left;k<=right-1;k++){
        ans++;
        if(L[i]<=R[j]){
            A[k] = L[i];
            i += 1;
        }else{
            A[k] = R[j];
            j += 1;
        }
    }
}

void mergeSort(int A[],int left,int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    mergeSort(A,0,n);
    for(int i=0;i<n;i++){
        if(i+1==n){
            cout << A[i] << endl;
        }else
            cout << A[i] << " ";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6892
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, X, Y = read_values()
    X -= 1
    Y -= 1
    res = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            d = min(
                j - i,
                abs(X - i) + 1 + abs(Y - j),
                abs(Y - i) + 1 + abs(X - j),
            )

            res[d] += 1

    for r in res[1:]:
        print(r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46040
#include<stdio.h>

int main(){
  int N, i, flag = 0;
  scanf("%d", &N);
  
  for(i = 0; i <= N/7; i++){
    if((N - 7*i)%4 == 0){
      flag = 1;
    }
  }
  
  if(flag == 1){
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  
  return 0;
}
    

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

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, x;
	cin >> n;
	vector<int> A;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		A.pb(x);
	}
	sort(A.begin(), A.end());
	ll answer = -A[0] + A[n - 1];
	for (int i = 0; i < n - 2; ++i)
		answer += abs(A[i + 1]);
	cout << answer << '\n';
	int ptr = n - 2;
	ll minLowSum = A[0];
	while (ptr > 0 && A[ptr] > 0)
	{
		cout << minLowSum << ' ' << A[ptr] << '\n';
		minLowSum -= A[ptr];
		ptr--;
	}
	cout << A[n - 1] << ' ' << minLowSum << '\n';
	minLowSum = A[n - 1] - minLowSum;
	while (ptr > 0)
	{
		cout << minLowSum << ' ' << A[ptr] << '\n';
		minLowSum -= A[ptr];
		ptr--;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 2424
#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++)

ll GCD(ll x,ll y){
  if(y == 0) return x;
  return GCD(y,x%y);
}

int main() {
  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d;
  f = c*d/GCD(c,d);
  e = b/c-a/c+b/d-a/d-(b/f-a/f);
  if(a%c == 0) e++;
  if(a%d == 0) e++;
  if(a%f == 0) e--;
  cout << b-a+1-e << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 0;
    cin >> n;
    ans += (n / 11) * 2;
    ans += (n % 11 > 6) ? 2 : (n % 11) ? 1 : 0;
    cout << ans << "\n";
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N, M, X; cin >> N >> M >> X;
	vll CS (N);
	vector<vll> improv (N, vll (M));
	F0R(i, N) {
		cin >> CS[i];
		F0R(j, M) cin >> improv[i][j];
	}

	ll best = INF;
	for (int bm = 0; bm < (1 << N); ++bm) {
		vll tot (M);
		ll cost = 0;
		F0R(i, N) if (bm & (1 << i)) {
			cost += CS[i];
			F0R(j, M) tot[j] += improv[i][j];
		}

		bool bad = false;
		F0R(j, M) if (tot[j] < X) bad = true;

		if (!bad) best = min(best, cost);
	}

	if (best == INF) {
		print(-1);
	} else {
		print(best);
	}
}

Measured memory_bytes: 3660
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int ki = 0;
        int gu = 0;

       while(a>0){
         if(a%2==0){
           gu++;
         }else{
          ki++;
         }
         a--;
       }
         System.out.println(ki*gu);
      }
}

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll cnt = n / (a+b);
    ll out = cnt * a + min(n - cnt*(a+b), a);
    cout << out << endl;
    return 0;
}


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

int main(){
  int x,y;
  cin>>x>>y;
  
  int t = y-2*x;
  int c = 4*x-y;
  if(t>=0 && c>=0 && (t%2==0) && (c%2==0))
    cout<<"Yes";
  else
    cout<<"No";    
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
void X(int *A,int N)
{
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}


void Sort(int *A,int N)
{
  
  int i,j,k;

  for(i=1;i<N;i++){
    k=A[i];
    j=i-1;
    
    while(j>=0&&A[j]>k){
      A[j+1]=A[j];
    j--;
    }
    A[j+1]=k;
    X(A,N);
  }
}



int main()
{
  
  int i,n,A[1000];

  scanf("%d",&n);
    
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  X(A,n);
 Sort(A,n);
    
  return 0;
}





Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod=1e9+7;
#define N 2005
int n,m,a[N],b[N];
ll dp[N][N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]);

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {   
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
        if(a[i]==b[j])
            dp[i][j]+=(dp[i-1][j-1]+1),dp[i][j]%=mod;
    }
    printf("%lld\n",(dp[n][m]%mod+1+mod)%mod);
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define mod 1000000007

int main(){
  ll n,k;
  cin >> n >>k;
  ll a[100100]={0};
  ll buc[50]={0};
  rep(i,n){
    cin >> a[i];
    rep(j,40){//2^40>=10^12
      if(a[i]&(1ll<<j)){//j_ketame
        buc[j]++;
      }
    }
  }

  ll x=-1,ans=-1,res=-1;
  ll p=-1,answer=-1;

 //when x < k;
  rep(i,40){
    if(k&(1ll<<i)){
      //k no iketame 2^i==1=>
      //x no iketame 2^i==0
      //p=ans;
      res=0;
      ans=0;
      rep(j,i){
        if((n-buc[j])>buc[j]){
          res+=(1ll<<j);
        }
      }
      for(ll j=i+1;j<40;j++){
        if(k&(1ll<<j))res+=(1ll<<j);
      }
      rep(i,n){
        ans+=res^a[i];
      }
      answer=max(ans,answer);
      //cout << ans << endl;
      /*
      if(ans>=p){
        //cout << "p:" << p << "ans:" << ans<< endl;;
        p=ans;
        x=res;
        answer=ans;
      }*/
    }
  }
  // when x=k;
  ans=0;
  rep(i,n){
    ans+=k^a[i];
  }
  answer=max(answer,ans);
  //cout << x << endl;
  if(k==0){
    answer=0;
    rep(i,n)answer+=a[i];
  }

  cout << answer <<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int len = S.length();
    if(S[len-1] == 's'){
        S.append("es");
    }else{
        S.append("s");
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3040
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
long long a[100050];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    long long m=0,c=0,d;
    for(int i=(n-1); i>=0; i--)
    {
        if(a[i]==a[i-1])
        {
            i--;
            if(c==0)
            {
                c++;
                c=a[i];
            }
            m++;
            if(m==2)
            {
                d=a[i];
                break;
            }
        }
    }
    if(m==0)
        printf("0");
    else
        printf("%lld\n",c*d);
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, M, ans = 1;
ll cnt = 1;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    M = N << 1;
    fread_unlocked(S, 1, M, stdin);
    if(S[0] == 'B' && S[M-1] == 'B') {
        bool f = false;
        for(ll i = 1; i < M; i++) {
            if(S[i] == S[i-1]) f ^= true;
            if(f) {
                ans *= (cnt << 1) - i;
                if(ans > 1LL<<45) ans %= MOD;
            }
            else if(++cnt > N) break;
        }
        if(cnt != N) ans = 0;
        else ans = ((ans % MOD) * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))

#define mt make_tuple

string s = "RGBY";
int main(){
  int h,w,d; cin >> h >> w >> d;
  
  int x = 0;
  rep(i,h){
    rep(j,w)
      cout <<s[(i+j)/d % 2 + 2*((i-j+1000*d)/d%2)];
    cout << endl;
  }
}

Measured memory_bytes: 512
import Debug.Trace



main :: IO ()
main = do
    n <- read <$> getLine
    let num = length $ filter (\(a, b) -> a * 4 + b * 7 == n) [(a, b) | a <- [0..n], b <- [0..n]]
    putStrLn (if num == 0 then "No" else "Yes")


Measured memory_bytes: 764
#include <iostream>

using namespace std ;

int mod(int x){
    if (x<0)
        x = -x ;
    return x ;
}

int min(int a, int b){
    if (a<b)
        return a ;
    else
        return b ;
}

void print_array(int a[], int n){
    for (int i=0 ; i<n ; i++)
        cout << a[i] << " " ;
    cout << endl ;
}

int frog1(int h[], int n){
    int cost[n] ;
    
    cost[0] = 0 ;
    cost[1] = mod(h[1] - h[0]) ;
    for(int i=2 ; i<n ; i++){
        cost[i] = min(mod(h[i] - h[i-1]) + cost[i-1], mod(h[i]-h[i-2]) + cost[i-2]) ;
    }
    
    return cost[n-1] ;
}

int main(){
    int n ;
    cin >> n ;
    int h[n] ;
    
    for (int i=0 ; i<n ; i++)
        cin >> h[i] ;
    
    cout << frog1(h, n) << endl ;
    
    return 0 ;
}


Measured memory_bytes: 1024
a = input().split()
b = input().split()
c = [int(i) for i in b] 
outPut = 0
outPut2 = 0

for i in range(int(a[0])):
  if outPut2 < outPut:
    outPut2 = outPut
  if i+1 == int(a[0]):
    break
  if c[i] - c[i+1] >=0:
    outPut += 1
  else:
    outPut = 0
print(outPut2)

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long n;
  scanf("%lld", &n);
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }

  rep(i, 0, n - 1) {
    if (a[i] < 0) {
      a[i] *= -1;
      a[i + 1] *= -1;
      continue;
    }
  }

  if (a[n - 1] >= 0) {
    ll ans = accumulate(all(a), 0LL);
    put(ans);
    return 0;
  }

  a[n - 1] *= -1;
  ll ans = accumulate(all(a), 0LL);
  ll m = *min_element(all(a));
  ans -= (m * 2);
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n;
	cin>>n;
	rep(i,30) rep(j,30){
		if(i*4+j*7==n){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

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

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int a, b;
		std::cin >> a >> b;

		ans += b - a + 1;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b,c,x,ans=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(i*500+j*100+k*50==x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

int compr(const void *ax, const void *ay){
	unsigned long *x = *(unsigned long **)ax;
	unsigned long *y = *(unsigned long **)ay;

	if(x[0] > y[0]) return 1;
	if(x[0] < y[0]) return -1;
	if(x[0] = y[0]) return 0;
}

unsigned long answer(unsigned int N, unsigned long long K, unsigned long *a, unsigned long *b){
	unsigned long **list, rtn;
	unsigned int i;
	unsigned long long k;

	list  = (unsigned long **)malloc(sizeof(unsigned long *)*N);
	if(list == NULL) exit(1);
	for(i = 0; i < N; i++){
		list[i] = (unsigned long *)malloc(sizeof(unsigned long)*2);
		if(list[i] == NULL) exit(1);
		list[i][0] = a[i];
		list[i][1] = b[i];
	}

	qsort(list, N, sizeof(unsigned long *), compr);
	for(i = 0; i < N; i++){
		k += list[i][1];
		if(k >= K){
			rtn = list[i][0];
			break;
		}
	}
	
	for(i = 0; i < N; i++) free(list[i]);
	free(list);
	return rtn;
}

int main(){
	unsigned int N, i;
	unsigned long *a, *b;
	unsigned long long K;
	char line[32];

	fgets(line, 32, stdin);
	sscanf(line, "%ld %llu", &N, &K);

	a = (unsigned long *)malloc(sizeof(unsigned long)*N);
	b = (unsigned long *)malloc(sizeof(unsigned long)*N);
	if((a == NULL) || (b == NULL)) exit(1);

	for(i = 0; i < N; i++){
		fgets(line, 16, stdin);
		sscanf(line, "%lu %lu", &a[i], &b[i]);
	}

	printf("%lu\n", answer(N, K, a, b));

	free(a);
	free(b);
	return 0;
}



Measured memory_bytes: 6396
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll mod = 998244353;



int W, H,ans;
char F[1000][1000];
int cnt;
queue<pair<int, int>> que;

void bfs(int x,int y) {


}

int main() {
	
	cin >> H >> W;
	FOR(i, 0, H)FOR(j, 0, W) {
		char c;
		cin >> c;
		if (c == '#') {
			F[j][i] = true;
			cnt++;
			pair<int, int> cur = {j, i};
			que.push(cur);
		}
	}
	int Xv[4] = { 0,0,-1,1 };
	int Yv[4] = { -1,1,0,0 };

	while (cnt != H * W) {
		ans++;
		int S = que.size();

		FOR(i, 0, S) {
			pair<int, int> T = que.front();
			que.pop();
			FOR(k, 0, 4) {
				int Xn = T.first + Xv[k];
				int Yn = T.second + Yv[k];
				if (Xn >= 0 && Xn < W&&Yn >= 0 && Yn < H&&F[Xn][Yn]==false) {
					F[Xn][Yn] = true;
					cnt++;
					que.push({ Xn,Yn });
				}
			}

		}

	}

	ct(ans);

	return 0;
}

Measured memory_bytes: 9360
#include<stdio.h>

int main(){
    int x, y;
    while (1)
    {   
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0){
            break;
        }
        if (x <= y){
            printf("%d %d\n", x, y);
        }
        else{
            printf("%d %d\n", y, x);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    int n, m;
    cin >> n >> m;

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

    long long mod = 1000000000 + 7;
    long long ans = 1;
    if(abs(n - m) == 0) ans = 2;

    for(int i = 1; i <= n; i++){
        ans = ans* i % mod;
    }
    for(int i = 1; i <= m; i++){
        ans = ans* i % mod;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N; string S;

int main() {
    cin >> N >> S;
    for (int i = 0; i < S.size(); ++i) {
        cout << (char)(((S[i]-'A') + N) % 26 + 'A');
    }
    cout << endl;
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, k;
    cin >> a >> b >> k;


    rep(i, k/2){
        if(a%2) --a;
        b += a/2;
        a /= 2;

        if(b%2) --b;
        a += b/2;
        b /= 2;

    }
    if(k%2){
        if(a%2) --a;
        b += a/2;
        a /= 2;
    }
    cout << a << sp << b << endl;



    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string x = to_string(n);
  for (int i = 0; i < x.size(); i++) {
    if (x.at(i) == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL x,y;
  cin>>x>>y;
  int i = 0;
  while(1){
    LL p = x*pow(2,i);
    
    if(p>y) {
      --i;
      break;
    }
    ++i;
  }
  cout<<i+1<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>
 
using namespace std;
 
int main(){
  int N,K,X,Y;
  
  cin >> N >> K >> X >> Y;
  
  if(N > K){
    cout << X*K + Y*(N-K) << endl;
  }else{
    cout << X*N << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while((line = r.readLine())!=null){
				if(line.length()<1) break;
				int N = Integer.parseInt(line);
				String[] pline = r.readLine().split(" ");
				int[] p = new int[N];
				for(int i=0;i<N;i++){
					p[i] = Integer.parseInt(pline[i]);
				}
				
				Arrays.sort(p);
				
				int time = 0;
				
				for(int i=0;i<N;i++){
					time += p[i]*(N-i);
				}
				
				System.out.println(time);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<int,int> P;
struct Mo{
   const int n,w; vector<P> qs;
   Mo(int _n):n(_n),w(sqrt(n)){}
   void add(int lb,int rb){qs.push_back({lb,rb});}
   void addl(int i);
   void addr(int i);
   void dell(int i);
   void delr(int i);
   void out(int i);
   void run(){
      const int q=qs.size();
      vector<int> ord(q); iota(ALL(ord),0);
      sort(ALL(ord),[&](int i,int j){
         if(qs[i].first/w!=qs[j].first/w)return qs[i].first<qs[j].first;
         else return qs[i].second<qs[j].second;
      });
      int lb=0,rb=0;
      for(int i:ord){
         auto [li,ri]=qs[i];
         while(lb>li)addl(--lb);
         while(rb<ri)addr(rb++);
         while(lb<li)dell(lb++);
         while(rb>ri)delr(--rb);
         out(i);
      }
   }
};

int kind[501010]={},a[501010],cur=0;
ll res[501010];

void Mo::addl(int i){
   if(!kind[a[i]])cur++;
   kind[a[i]]++;
}
void Mo::addr(int i){
   if(!kind[a[i]])cur++;
   kind[a[i]]++;
}
void Mo::dell(int i){
   if(kind[a[i]]==1)cur--;
   kind[a[i]]--;
}
void Mo::delr(int i){
   if(kind[a[i]]==1)cur--;
   kind[a[i]]--;
}
void Mo::out(int i){
   res[i]=cur;
}

template<typename T=int>inline T get(){
   char c=getchar(); bool neg=(c=='-');
   T res=neg?0:c-'0'; while(isdigit(c=getchar()))res=res*10+(c-'0');
   return neg?-res:res;
}
template<typename T=int>inline void put(T x,char c='\n'){
   int d[20],i=0; if(x<0)putchar('-'),x*=-1;
   do{d[i++]=x%10;}while(x/=10); while(i--)putchar('0'+d[i]);
   putchar(c);
}

int main(){
   int n=get(),q=get();
   rep(i,0,n)a[i]=get();
   Mo mo(n);
   rep(i,0,q){
      int lb=get(),rb=get(); lb--;
      mo.add(lb,rb);
   }
   mo.run();
   rep(i,0,q)put<ll>(res[i]);
   return 0;
}

Measured memory_bytes: 17360