akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //?????±?????????????????????
	ios::sync_with_stdio(false); //printf??¨??±??????????????????

	
	int n = nextInt();
	vector<string> m;
	vector<set<string>> cn(n);
	string fr,ba;
	int s;
	for(int i=0;i<n;i++){
		m.push_back(nextString());
		cn.push_back(set<string>());
		for(int j=1;j<m[i].size();j++){
			fr = m[i].substr(0,j);
			ba = m[i].substr(j,m[i].size() - j);
			s=2;
			while(s--)
			for(int k=0;k<4;k++){
			  if(s)cn[i].insert(fr+ba);
			  else cn[i].insert(ba+fr);
			  if(k==1)reverse(fr.begin(),fr.end());
			  reverse(ba.begin(),ba.end());
			}
			//4??????????????\???fr??¨br??\????????????????????????????????§??????
		}
		cout << cn[i].size() << endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int N = s.size();
  int ans = 999;
  for(int i = 0; i <= N - 3; i++){
    int num = (s[i] - '0')*100 + (s[i+1] - '0')*10 + (s[i+2] - '0');
    ans = min(ans, abs(num - 753));
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/************************************************
 *Author*        :skyNebula
 *Created Time*  : 一  4/23 22:44:15 2018

*********************************************/

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int mod = 1e9 + 7;
const int MaxN = 1e6;

int a,b,c,x,y,s,minn,maxn,z,ans;

int main()
{
	cin >> a >> b >> c >> x >> y;
	s = a + b;
	minn = min(x,y);
	maxn = max(x,y);
	z = maxn - minn;

	if(s >= 2 * c)
	    ans += minn * 2 * c;
	else 
	    ans += minn * s;
	if(a <= 2 * c && x == maxn)
	{
		ans += z * a;
	}
	else if(a > 2 * c && x == maxn)
	{
		ans += z * 2 * c;
	}
	else if(b > 2 * c && y == maxn)
	{
		ans += z * 2 * c;
	}
	else if(a <= 2 * c && y == maxn)
	{
		ans += z * b;
	}	
	cout << ans << endl;;
	return 0;
	
} 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define MP make_pair

inline int gn(){
    int s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

inline ll gl(){
    ll s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

const int N=2e5+100;
int h[N];
int f[N];

void solve(){
    int n=gn(),m=gn();
    for(int i=1;i<=n;++i){
        h[i]=gn();
        f[i]=i;
    }
    for(int i=0;i<m;++i){
        int a=gn(),b=gn();
        if(h[a]>h[b]){
            f[b]=a;
        }
        else if(h[a]==h[b]){
            f[a]=b;
            f[b]=a;
        }
        else f[a]=b;
    }
    int cnt=0;
    for(int i=1;i<=n;++i){
        //cout<<i<<" "<<f[i]<<endl;
        if(f[i]==i){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    // int t;
    // t=gn();
    // while(t--)
        solve();
}

/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/


Measured memory_bytes: 4424
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int cuE[300030];
int cuW[300030];

int main() {
    int N;
    string S;
    cin >> N >> S;

    cuW[0] = 0;
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == 'W')cuW[i] = cuW[i - 1] + 1;
        else cuW[i] = cuW[i - 1];
    }
    cuE[N - 1] = 0;
    for (int i = N - 2; i >= 0; i--) {
        if (S[i + 1] == 'E')cuE[i] = cuE[i + 1] + 1;
        else cuE[i] = cuE[i + 1];
    }
    int mi = INF;
    rep(i, N) {
        mi = min(mi, cuE[i] + cuW[i]);
    }

    cout << mi << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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

    ll maxv = LONG_MIN, minv = a[0];

    for (int i = 1; i < n; i++)
    {
        maxv = max(maxv, a[i] - minv);
        minv = min(minv, a[i]);
    }

    OP(maxv);
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    int dp[k + 1];
    for (int i = 0;i < k + 1;i++) {
        dp[i] = 0;
    }
    for (int i = 1;i <= k;i++) {
        for (int j = 0;j < n;j++) {
            if (i - a[j] >= 0) {
                if (dp[i - a[j]] == 0) {
                    dp[i] = 1;
                }
            }
        }
    }
    if (dp[k]) {
        cout << "First";
    }else {
        cout << "Second";
    }

    return 0;
}


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

using namespace std;

int main(){
  int N; cin>>N;
  string str="";
  while(N!=0){
    int r=N%2;
    if(r<0)r+=2;
    N=(N-r)/(-2);

    str+=(char)('0'+r);
  }

  reverse(str.begin(),str.end());
  if(str=="")str="0";
  cout<<str<<endl;

  return 0;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main()
{
  int w, a, b;
  cin >> w >> a >> b;

  if((a <= b && b <= a+w) || (b <= a && a <= b+w)){
    cout << '0' << endl;
  }

  else if(a < b) cout << b - (w+a) << endl;

  else cout << a - (w+b) << endl;

  return 0;

}


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

int main()
{	
	int ans=0, i, j, k;
	int n, d, x[10][10] = {0};
	cin >> n >> d;
	for (i = 0; i < n;i++){
		for (j = 0; j < d;j++){
			cin >> x[i][j];
		}
	}
	
	for (i = 0; i < n-1; i++){
		for (j = i+1; j < n; j++){
			double dis = 0;
			for (k = 0; k < d;k++){
				dis += pow(x[i][k] - x[j][k], 2);
			}
			dis = sqrt(dis);
			if(dis-int(dis)==0)
				ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def enqueue(Q,t,x):
    Q[t].append(x)
    return Q

def front(Q,t):
    count=len(Q[t])
    if count!=0:
        print(Q[t][0])

def dequeue(Q,t):
    count=len(Q[t])
    if count!=0:
        del Q[t][0]
    return Q

n,q=(int(x) for x in input().split())
Q=[[] for i in range(n)]
for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        Q=enqueue(Q,query[1],query[2])
    elif query[0]==1:
        front(Q,query[1])
    else:
        Q=dequeue(Q,query[1])



Measured memory_bytes: 13700
import math

a,b,x = map(int, input().split())

capacity = a * b

if x / a > capacity * 0.5:
    tan = 2 * (b / a - x / pow(a, 3)) 
    print(math.degrees(math.atan(tan)))
else:
    tan = 2 * x / (a * pow(b, 2))
    print(90 - math.degrees(math.atan(tan)))

Measured memory_bytes: 3060
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Mame = Tuple!(long, "point", long, "number");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    bool easy = true;
    foreach (i; iota(s.length))
    {
        if (i % 2)
        {
            if (s[i] == 'R')
                easy = false;
        }
        else
        {
            if (s[i] == 'L')
                easy = false;
        }
        // (i + 1).writeln(" ", s[i]);
    }
    if (easy)
        writeln("Yes");
    else
        writeln("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k, d, tmp;
    cin >> n >> k;
    set<int> S;
    set<int> S1;
    for (int i = 1; i <= n; i++)
    {
        S.insert(i);
    }
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> tmp;
            S1.insert(tmp);
        }
    }
    vector<int> res;
    set_difference(S.begin(), S.end(), S1.begin(), S1.end(), back_inserter(res));
    cout << res.size() << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#define R 1000
#define TMAX 1261
using namespace std;
int main(){
  int N,M,r,q,t[R],n[R],m[R],s[R],end[R],ts,te,m1,cnt,lim,time[TMAX];
  while(1){
    cin >> N >> M;
    if(N==0&&M==0) break;
    cin >> r;
    for(int i=0;i<r;i++){
      cin >> t[i] >> n[i] >> m[i] >> s[i];
    }
    cin >> q;
    for(int i=0;i<q;i++){
      cin >> ts >> te >> m1;
      for(int j=ts;j<=te;j++){
    time[j]=0;
      }
      for(int j=0;j<r;j++) end[j]=0;
      cnt=0;
      for(int j=0;j<r;j++){
    if(end[j]==0){
      end[j]=1;
      if(m1==m[j]){
        for(int k=j+1;k<r;k++){
          if(m1==m[k]&&n[j]==n[k]&&end[k]==0){
        end[k]=1;
        for(int l=t[j]+1;l<=t[k];l++){
          if(time[l]==0&&ts<l&&l<=te){
            time[l]=1;
            cnt++;
          }
        }
        break;
          }
        }
      }
    }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1180
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <sstream>
#include <cstring>
#include <bitset>
#include <climits>
 
using namespace std;
#define  AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;
int main(void){
    // Here your code !
    bool s = false,w = false,e = false,n = false;
    string S;
    cin >> S;
    for(char c : S)
    {
        switch(c)
        {
            case 'N': n = true; break;
            case 'E': e = true; break;
            case 'S': s = true; break;
            case 'W': w = true; break;
        }
    }
    if(n && !s) cout << "No" << endl;
    else if(!n && s) cout << "No" << endl;
    else if(e && !w) cout << "No" << endl;
    else if(!e && w) cout << "No" << endl;
    else cout << "Yes" << endl;
    
}


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

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    string s;
    cin >> s;

    cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
    int n;
    cin >> n;
    int ans = 0 , bf = 0;
    rep(i,1,n+1){
        int x;
        cin >> x;
        if(x == i && bf == 0) ans++ , bf = 1;
        else bf = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//diverta2019_a.cpp
//Sat May 11 20:39:31 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	cout << n-k+1 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int i;
  int N;
  long long A[100010], B[100010], C[100010];
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for (i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }
  for (i = 0; i < N; i++) {
    scanf("%lld", &C[i]);
  }
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  int num_B[100010], num_A[100010];
  int ruiseki[100010];
  long long ans = 0;
  for (i = 0; i < N; i++) {
    long long* it_A = (long long*)lower_bound(A, A+N, B[i]);
    long long* it_C = (long long*)upper_bound(C, C+N, B[i]);
    ans += (long long)(it_A - A) * (N - (long long)(it_C - C));
    //printf("%d %d ", (int)(it_A - A), N - (int)(it_C - C));
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

}


Measured memory_bytes: 29576
import java.lang.Math

fun main(args: Array<String>) {
    val (N, A, B) = readInputLine().split(" ").map { it.toLong() }
    val diff = A - B
    val monsters = LongArray(N.toInt())

    repeat(N.toInt()) {
        monsters[it] = readInputLine().toLong()
    }

    var r = 1000000000L
    var l = 0L

    while (r - l > 1) {
        val m = (r + l) / 2L
        var rest = m

        for (monster in monsters) {
            rest -= Math.max(0L, (monster - B * m + diff - 1L) / diff)
            if (rest < 0) {
                break
            }
        }

        if (rest < 0) {
            l = m
        } else {
            r = m
        }
    }

    println(r)
}

fun readInputLine(): String {
    return readLine()!!
}


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

bool sort1(int a, int b)
{
    int ta = a%10;
    int tb = b%10;
    if(ta>0&&tb>0)return ta>tb;
    if(ta==0)return true;
    if(tb==0)return false;
}

int main()
{
    int a[10];
    for(int i = 1; i <= 5; i++)cin>>a[i];
    sort(a+1,a+6,sort1);
    int sum = 0;
    for(int i = 1; i <= 4; i++)
    {
        int t = a[i]%10;
        if(t)
        {
            sum += a[i] + 10-t;
        }else
        {
            sum+=a[i];
        }
    }
    sum+=a[5];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;

int main(){
    cin>>a>>b;
    for(int i=0;i<4;i++){
        if((a*b*i)%2==1)c++;
        }
        if(c!=0)cout<<"Yes"<<endl;
        if(c==0)cout<<"No"<<endl;
}


Measured memory_bytes: 256
// Kab khoon khaulega re tera?

#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;


const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    long long n;
    cin >> n;
    vector<pair<long long, long long> > v;
    for(long long i = 0; i < n; i++){
        long long x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    vector<long long> u;
    for(long long i = 0; i < n; i++){
        u.push_back(v[i].F);
    }
    sort(u.begin(), u.end());
    vector<long long> uu;
    for(long long i = 0; i < n; i++){
        uu.push_back(v[i].S);
    }
    sort(uu.begin(), uu.end());

    if(n & 1){
        ll median1 = u[n / 2];
        ll median2 = uu[n / 2];
        cout << median2 - median1 + 1;
    }
    else{
        ll median1 = u[(n - 1) / 2] + u[(n - 1) / 2 + 1];
        ll median2 = uu[(n - 1) / 2] + uu[(n - 1) / 2 + 1];
        cout << median2 - median1 + 1;
    }
return 0;
}


Measured memory_bytes: 11616
import qualified Data.ByteString.Lazy.Char8 as B
import Data.ByteString.Lazy.Char8 (ByteString)
import Control.Monad.Trans.State.Strict
import Control.Applicative (many)
import Data.Char (isSpace)

main :: IO ()
main = B.interact $ output . solve . input

output :: Int -> ByteString
output = B.pack . show
{-# INLINE output #-}

solve :: [Int] -> Int
solve = foldr ((+) . pred) 0
{-# INLINE solve #-}

input :: ByteString -> [Int]
input = maybe (error "parse error") fst . runStateT (parseInt *> many parseInt)
{-# INLINE  input #-}

parseInt :: StateT ByteString Maybe Int
parseInt = StateT $ B.readInt . B.dropWhile isSpace
{-# INLINE parseInt #-}


Measured memory_bytes: 1148
#include <iostream>

using namespace std;

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

int dp[100010];
int a[110];

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

    REP(i, n) {
        cin >> a[i];
    }

    REP(i, k+1) {
        dp[i] = 0;
    }

    REP(i, k) {
        if (i < a[0]) {
            dp[i] = -1;
        }

        REP(j, n) {
            if (i+a[j] > k) continue;
            if (dp[i+a[j]] != 1) {
                dp[i+a[j]] = -dp[i];
            }
        }
    }

    if(dp[k] == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = 0;
	for (int i = 1; i*i <= N; i++) {
		if (N / (i + 1) + 1 < N / i) {
			//商がi -> [N/(i + 1) + 1 , N/i]
			int X = N / i;

			int M = N % X;
			if (i - M >= 0) {
				if ((i - M) % i == 0) {
				//	cerr << X - ((i - M) / i) << endl;
					res += X - ((i - M) / i);
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
#define nn 50004
#define lf double
ll a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0 or b%2==0 or c%2==0)
	{
		puts("0");
		exit(0);
	}
	printf("%lld\n",min(a*b,c*min(a,b)));
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[10];
int n,ans;
int main(){
    scanf("%s",s);
    n=strlen(s);
    for(int i=n-1;i>=1;i--) ans+=s[i]-'0';
    if(ans == 0 && s[0] == '1') ans=10;
    else ans+=s[0]-'0';
    printf("%d",ans);
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(true){
    C -= B;
    if (C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3528
# D
# Teleporter

import numpy as np

def next_town(_list,idx):
    return _list[idx]

n, k = map(int, input().split())
a_list = np.array([int(x) for x in input().split()])

t_list = np.zeros(n, dtype=int)

i = 1
count = 0
flag = True
while count < k:
    i = next_town(a_list,i-1)
    count += 1
    if t_list[i-1] == 0:
        t_list[i-1] = count
    elif flag:
        _roop = count - t_list[i-1]
        _tmp = k - count
        count = k - _tmp % _roop
        flag = False

print(i)

Measured memory_bytes: 51072
while True:
    n, m = map(int, input().split())
    if n == m == 0:
        break

    li = list()
    total = 0
    for i in range(n):
        d, p = map(int, input().split())
        li.append((p, d))
        total += p * d

    li.sort(reverse = True)
    for p, d in li:
        if d <= m:
            total -= p * d
            m -= d
        else:
            total -= p * m
            break

    print(total)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a, b, c, d;
const ll mod = 998244353;
vvl dp(3123, vl(3123, -1));

ll f(ll x, ll y) {
  if (dp[x][y] != -1) return dp[x][y];
  if (x==a and y==b) return 1;
  if (x>a and y>b) {
    ll ans = f(x-1,y)*y + f(x,y-1)*x - f(x-1, y-1)*(x-1)*(y-1);
    ans %= mod;
    return dp[x][y] = ans;
  }
  if (x > a) return dp[x][y] = f(x-1, y) * y % mod;
  if (y > b) return dp[x][y] = f(x, y-1) * x % mod;
  return dp[x][y] = 1;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  cin >> a >> b >> c >> d;

  ll ans = f(c,d);
  ans %= mod;
  ans += mod;
  ans %= mod;
  cout << ans << '\n';
}

Measured memory_bytes: 80292
n, x, m = map(int, input().split())

mod = [x]
app = {}
cnt = 1
app[x] = cnt
i = x*x
i %= m
cnt += 1
while not i in app:
  mod.append(i)
  app[i] = cnt
  i *= i
  i %= m
  cnt += 1

# print(mod)
# num = n // len(mod)
# if mod[-1] == 0:
#   ans = sum(mod)
# else:
#   ans = sum(mod) * num + sum(mod[:n % len(mod)])

# print(ans)
# print(mod)
# print(len(mod))
# print(app[i])

if n <= len(mod):
  ans = sum(mod[:n])
else:
  ans = sum(mod)
  if mod[-1] != 0:
    # print(mod)
    n -= len(mod)
    mod = mod[app[i]-1:]
    # print(mod)
    num = n // len(mod)
    ans += sum(mod) * num + sum(mod[:n % len(mod)])

print(ans)

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

using namespace std;

int a[200000], b[200000];

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

	string c[3];
	cin >> c[0] >> c[1] >> c[2];
	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;


int main(){
 int A,B,C,X,Y;
 cin >> A >> B >> C >> X >> Y;
 int d = A * X + B * Y,e = 2 * C * X + max(0,Y-X) * B,f = 2 * C * Y + max(0,X-Y) * A;
 //cout <<  d << ' ' << e << ' ' << f << endl;
 cout << min({d,e,f}) << endl;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int e = 0;
  while(a > 0 && c > 0){
    e += 1;
    if(e % 2 == 1){
      c = c - b;
    }else{
      a = a - d;
    }
  }
  if(e % 2 == 1){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> l;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >>  tmp;
        l.push_back(tmp);
    }

    sort(all(l), greater<int>());

    int a, b, c;
    int ret = 0;
    for (int i = 0; i < l.size(); ++i) {
        a = l[i];
        for (int j = i + 1; j < l.size(); ++j) {
            b = l[j];
            for (int k = j + 1; k < l.size(); ++k) {
                c = l[k];
                if (a < b + c) {
                    if (b < c + a) {
                        if (c < a + b) {
                            ret++;
                        }
                    }
                } else {
                    break;
                }
            }
        }
    }

    cout << ret << endl;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;

Graph G;

vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (abs(b - a) > 1000000000000000000)
    {
        cout << "Unfair" << endl;
    }
    if (k % 2 == 0)
    {
        cout << a - b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int seg[200005], n;
inline void modify(int pos, int x)
{
	for (; pos <= n; pos += pos & -pos)
		(seg[pos] += x) %= MOD;
}
inline int query(int pos)
{
	int res = 0;
	for (; pos; pos -= pos & -pos)
		(res += seg[pos]) %= MOD;
	return res;
}
int app[200005], pre[200005], val[200005], arr[200005];
int main()
{
	// freopen("AGC023-E.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		app[arr[i]]++;
	}
	for (int i = n - 1; i; i--)
		app[i] += app[i + 1];
	ll cur = 1, ans = 0;
	for (int i = 1; i <= n; i++)
	{
		app[i] -= n - i;
		if (app[i] <= 0)
		{
			puts("0");
			return 0;
		}
		if (app[i] == 1)
			pre[i] = i;
		else
		{
			val[i] = (ll)(app[i] - 1) * quick_pow(app[i], MOD - 2) % MOD;
			if (val[i - 1])
				val[i] = (ll)val[i] * val[i - 1] % MOD;
			pre[i] = pre[i - 1];
		}
		cur = cur * app[i] % MOD;
	}
	for (int i = 0; i < n; i++)
	{
		(ans += cur * (query(arr[i]) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
		modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
	}
	memset(seg, 0, sizeof(seg));
	for (int i = 0; i < n; i++)
	{
		(ans += cur * (i - query(arr[i])) * 2) %= MOD;
		modify(arr[i], 1);
	}
	memset(seg, 0, sizeof(seg));
	for (int i = n - 1; i >= 0; i--)
	{
		(ans -= cur * (query(arr[i] - 1) - query(pre[arr[i]])) % MOD * val[arr[i]]) %= MOD;
		modify(arr[i], quick_pow(val[arr[i]], MOD - 2));
	}
	printf("%lld\n", (ans + MOD) * (MOD + 1) / 2 % MOD);
	return 0;
}


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

int findsum(int n){
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int X;
  cin >> X;
  int sum = findsum(X);
  if(X%sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
ac = 0

wa = 0
tle = 0
re = 0
while (N) :
    x = input()
    if x == 'AC':
        ac+=1
    if x == 'WA':
        wa +=1
    if x == 'TLE':
        tle += 1
    if x == 'RE':
        re += 1
    N-=1
print('AC' + " " + "x" + " " + str(ac))
print('WA' + " " + "x" + " " + str(wa))
print('TLE' + " " + "x" + " " + str(tle))
print('RE' + " " + "x" + " " + str(re))


Measured memory_bytes: 9220
#include<stdio.h>

int main(void)
{
	int i,a[100],N,answer;
	static int min=0,max=0;
	scanf("%d",&N);
	for (i = 1; i <= N; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= N; i++)
	{
		if (max < a[i])
			max = a[i];
	}
	min = max;
	for (i = 1; i <= N; i++) {
		if (min > a[i])
			min = a[i];
	}
	answer = max - min;
	printf("%d", answer);
	return 0;
}


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

int main() {
    int num_of_entries;

    scanf("%d", &num_of_entries);

    for (int i = 0; i < num_of_entries; i++) {
        int entry;
        scanf("%d", &entry);

        if (entry % 2 == 0) {
            if (entry % 3 != 0 && entry % 5 != 0) {
                printf("DENIED\n");
                return 0;
            }
        }
    }

    printf("APPROVED\n");
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <string.h>
#include <stdio.h>
using namespace std;
using std::cout;
#include <algorithm>
#include <map>
int main(){
long long n,m=0;
cin>>n;
map<string,long long>freq;
string x[n];
for(long long i=0;i<n;i++)
                    {
cin>>x[i];
sort(x[i].begin(),x[i].end());
                    }
                    for(long long i=0;i<n;i++){
                        freq[x[i]]++;
                    }
for(auto i=freq.begin();i!=freq.end();i++)
    m+=(i->second)*((i->second)-1)/2;
                     cout<<m<<endl;

return 0;
            }

Measured memory_bytes: 14488
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K = int(read().rstrip())

runrun = [None for _ in range(1, 20)] # 20は十分な値
runrun[1] = (1, 2, 3, 4, 5, 6, 7, 8, 9)

def gen_runrun(keta):
    for x in runrun[keta-1]:
        r = x % 10

        if r > 0:
            yield x * 10 + r - 1
        yield x * 10 + r
        if r < 9: 
            yield x * 10 + r + 1

# 10桁以下のrunrun数の列挙
for keta in range(2, 11):
    runrun[keta] = tuple(gen_runrun(keta))

for keta in range(1, 11):
    if K < len(runrun[keta]):
        answer = runrun[keta][K-1]
        break
    K -= len(runrun[keta])

print(answer)

Measured memory_bytes: 11816
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

// 文字列を圧縮する。first に文字、second に個数
map<char, int> run_length(string &s) {
    map<char, int> ans;
    for (int i = 0; i < s.size(); i++) {
        ans.count(s[i]) ? ans[s[i]]++ : ans[s[i]] = 1;
    }
    return ans;
}

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

    string s;
    cin >> s;
    auto run = run_length(s);
    int N    = s.size();
    int a    = run['a'];
    int b    = run['b'];
    int c    = run['c'];

    int mx  = max({a, b, c});
    int mn  = min({a, b, c});
    int ot  = N - mx - mn;
    auto no = []() {
        print("NO");
        exit(0);
    };
    auto yes = []() {
        print("YES");
        exit(0);
    };
    if (mx - mn <= 1)
        yes();
    no();

    return 0;
}

Measured memory_bytes: 512
import numpy as np

N = int(input())

hyo = np.zeros((N,2))

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")

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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

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

typedef vector<LL> V;
typedef vector<V> VV;
typedef pair<LL,LL> P;
int N,N2;

LL x[21234];
LL d;
V comp,vs;
set<P> X;

LL get_nxt(int v){
    auto nxt=X.upper_bound(P(x[v]-d,114514));
    if(nxt==X.end()||nxt->fi>=x[v]+d)return -1;
    if(nxt->se%N==v%N)nxt++;
    if(nxt==X.end()||nxt->fi>=x[v]+d)return -1;
    LL ret=(nxt->se+N)%N2;
    X.erase(nxt);
    return ret;
}
LL get_nxt_r(int v){
    v=(v+N)%N2;
    auto nxt=X.upper_bound(P(x[v]-d,114514));
    if(nxt==X.end()||nxt->fi>=x[v]+d)return -1;
    if(nxt->se%N==v%N)nxt++;
    if(nxt==X.end()||nxt->fi>=x[v]+d)return -1;
    LL ret=nxt->se;
    X.erase(nxt);
    return ret;
}

void dfs(int v){
    comp[v]=0;
    for(int u=get_nxt(v);u!=-1;u=get_nxt(v))
        if(comp[u]==-1)dfs(u);
    vs.push_back(v);
}
void rdfs(int v,int k){
    comp[v]=k;
    for(int u=get_nxt_r(v);u!=-1;u=get_nxt_r(v))
        if(comp[u]==-1)rdfs(u,k);
}
void decomposition(){
    comp.resize(N2);
    fill(comp.begin(),comp.end(),-1);
    vs.clear();
    REP(i,N2)X.insert(P(x[i],i));
    for(int v = 0; v < N2; v++)
        if(comp[v]==-1){
            int rv=(v+N)%N2;
            X.erase(P(x[rv],rv));
            dfs(v);
        }
    reverse(vs.begin(),vs.end());
    fill(comp.begin(),comp.end(),-1);
        REP(i,N2)X.insert(P(x[i],i));
    int k=0;
    for(auto& v : vs)if(comp[v]==-1){
            X.erase(P(x[v],v));
            rdfs(v,k++);
        }
}
bool isSame(int a,int b){
    return comp[a]==comp[b];
}


bool f(LL mid){
    d=mid;
    decomposition();
    REP(i,N)if(isSame(i,i+N))return false;
    return true;
}
int main(){
    cin>>N;
    N2=N<<1;
    REP(i,N){
        cin>>x[i]>>x[i+N];
    }
    LL ok=0;
    LL ng=1e10;
    while(ng-ok>1){
        const LL mid=(ok+ng)/2;
        //cout<<"mid="<<mid<<endl;
        if(f(mid)){
            ok=mid;
        }
        else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 2968
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N % 2 == 0) {
    ll p = A[N/2 - 1] + A[N/2];
    ll q = B[N/2 - 1] + B[N/2];
    cout << q - p + 1 << endl;
  }else {
    ll p = A[N/2];
    ll q = B[N/2];
    cout << q - p + 1 << endl;
  }

  return 0;
}



Measured memory_bytes: 6284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,m;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0;
    return 0;
  }
  ll c=1;
  for(int i=1;i<=n;i++){
    c*=i;
    c%=1000000007;
  }
  for(int i=1;i<=m;i++){
    c*=i;
    c%=1000000007;
  }
  if(n==m){
    c*=2;
    c%=1000000007;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    string ans = "";
    for(int i = 0; i < S.length(); i++){
        if(S[i]=='1'){
            ans+="1";
        }else if(S[i]=='0'){
            ans+="0";
        }else{
            if(ans.size()>0){
                ans.pop_back();
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
module module1
sub main()
    dim number as string
    dim takoyaki as string
    number = console.readline()
    takoyaki = console.readline()
    dim a as string()
    a = split(takoyaki)
    dim b as string
    dim c as string
    c = number * (number - 1) / 2
    dim i as integer
    dim n as integer
    dim d as integer
    for i = 0 to number - 1
        for n = i + 1 to number - 1
            b = b + a(i) * a(n)
        next
        d = d + b
        b = 0
    next
    console.writeline(d)
End sub
end module


Measured memory_bytes: 11488
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [a-b for a,b in zip(A,B)]
A.sort()
if sum(A)<0:
    print(-1)
else:
    cnt = sum([a<0 for a in A])
    max_i = -1
    for i in range(n):
        while A[i]<0:
            if A[max_i] > abs(A[i]):
                A[max_i] += A[i]
                A[i] = 0
            else:
                A[i] += A[max_i]
                A[max_i] = 0
                max_i -= 1
    print(cnt-max_i if cnt!=0 else 0)

Measured memory_bytes: 24240
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
d = {}
ans = 0
for c in s:
    if c not in d:
        d[c] = 1
    else:
        d[c] += 1
for c in t:
    if c in d:
        d[c] -= 1
for c in d:
    ans = max(ans,d[c])
print(ans)
        

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#include<fstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int a[25 * 25][25 * 25 + 1];

int manhattan(int x1, int y1, int x2, int y2){
  return abs(x1 - x2) + abs(y1 - y2);
}

int main(){
  int n, m, d;

  while(scanf("%d%d%d", &m, &n, &d), n + m + d){
    int s[25][25];
    const int N = n * m;
    REP(i,n) REP(j,m) scanf("%d", &s[i][j]);

    REP(i,N){
      REP(j,N){
        a[i][j] = 0;
      }
      a[i][N] = s[i / m][i % m];
    }

    REP(i1,n) REP(j1,m){
      a[i1 * m + j1][i1 * m + j1] = 1;
      REP(i2,n) REP(j2,m){
        if(manhattan(i1, j1, i2, j2) == d){
          a[i1 * m + j1][i2 * m + j2] = 1;
        }
      }
    }

    int ans = 1;

    REP(i, N){
      if(a[i][i] == 0){
        for(int j = 0; j < N; j++){
          if(j < i && a[j][j]) continue;
          if(a[j][i] > 0){
            for(int k = 0; k < N + 1; k++){
              swap(a[i][k], a[j][k]);
            }
            break;
          }
        }
        if(a[i][i] == 0){
          continue;
        }
      }

      for(int j = 0; j < N; j++){
        if(i != j){
          if(a[j][i] == 1){
            for(int k = i; k < N + 1; k++){
              a[j][k] = (a[j][k] + a[i][k]) % 2;
            }
          }
        }
      }
    }

    REP(i,N) if(a[i][i] == 0 && a[i][N] == 1) ans = 0;

    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 2416
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#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 <utility>
#include <vector>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define print(x) (cout << x << endl)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int n, k;
  string s;
  cin >> n >> k >> s;
  k--;
  s[k] = tolower(s[k]);

  cout << s << endl;
  
  // cout << "Case #" << C++ << ": " << cur_max << endl;  


}



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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  vector<long long> Side(2);
  int cnt=0;
  int temp=0;
  for(int i=0; i<N-1; i++){
    if(cnt==1){
      cnt=0;
      continue;
    }
    if(temp==2) break;
      if(cnt==0 && A.at(i)==A.at(i+1)){
      Side.at(temp)=A.at(i);
      temp++;
      cnt++;
    }
  }
  long long ans = Side.at(0)*Side.at(1);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int h, w;
  int ans[55][55] = {};
  cin >> h >> w;
  char s;
  reps(i, h){
    reps(j, w){
      cin >> s;
      if(s == '#'){
	ans[i - 1][j - 1] ++;
	ans[i - 1][j] ++;
	ans[i - 1][j + 1] ++;
	ans[i][j - 1] ++;
	ans[i][j + 1] ++;
	ans[i + 1][j - 1] ++;
	ans[i + 1][j] ++;
	ans[i + 1][j + 1] ++;
	ans[i][j] = 1e9;
      }
    }
  }
  reps(i, h){
    reps(j, w){
      if(ans[i][j] >= 1e9){
	cout << '#';
      } else {
	cout << ans[i][j];
      }
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256