akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n;
    cin >> n;
    long double ans = 0.0;
    long double t = 0.0;
    rep(i,n){
        ld d; string s;
        cin >> d >> s;
        if(s == "JPY") ans += d;
        else t += d;
    }
    printf("%.10Lf",ans + t * 380000.0);
    cout << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26), t(D+1);
    std::vector<std::set<int>> days(26);
    for(int i(0); i < 26; ++i){
        days[i].emplace(0);
        days[i].emplace(D+1);
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26));
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    for(int i(1); i <= D; ++i){
        int mx(0), id(-1);
        for(int j(0); j < 26; ++j){
            std::cin >> s[i][j];
            if(chmax(mx, s[i][j])) id = j;
        }
        t[i] = id;
        days[t[i]].emplace(i);
    }

    long long v(0);
    for(int i(1); i <= D; ++i){
        long long dcr(0);
        for(int j(0); j < 26; ++j){
            auto itr(std::upper_bound(std::begin(days[j]), std::end(days[j]), i));
            dcr += c[j] * (i - *(--itr));
        }
        v += s[i][t[i]] - dcr;
    }
    int M(1000000);
    srand((unsigned int)time(NULL));
    {
        int d, q;
        for(int qq(0); qq < M; ++qq){
            d = rand() % D + 1;
            q = rand() % 25;
			if(q >= t[d]) ++q;
            long long oldv(v);

            auto itr(days[t[d]].find(d));
            long long d1(*(--itr));
            itr = std::upper_bound(std::begin(days[t[d]]), std::end(days[t[d]]), d);
            long long d2((*itr)-1);
            v -= c[t[d]] * ((d1-d)*(d-d2) + d - d1);

            itr = std::lower_bound(std::begin(days[q]), std::end(days[q]), d);
            d1 = *(--itr);
            itr = std::upper_bound(std::begin(days[q]), std::end(days[q]), d);
            d2 = (*itr)-1;
            v += c[q] * ((d1-d)*(d-d2) + d - d1);

            v += s[d][q] - s[d][t[d]];
            if(oldv <= v){
                days[t[d]].erase(d);
                days[q].emplace(d);
                t[d] = q;
            }else{
                v = oldv;
            }
        }
    }
    for(int i(1); i <= D; ++i){
        std::cout << t[i] + 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3704
n, w = [int(_) for _ in input().split()]

ans = [[-1 for i in range(w+1)]for i in range(2)]

ans[0][0] = 0
ans[1][0] = 0
c = 0
for i in range(n):
    s, t = [int(_) for _ in input().split()]
    for j in range(w-t+1):
        if ans[c][j] > -1:
            ans[not(c)][t+j] = max(ans[c][t+j], ans[c][j]+s)
    for j in range(w):
        ans[c][j] = ans[not(c)][j]
    c = not(c)
print(max(ans[c]))
# print(ans)



Measured memory_bytes: 6356
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


A, B = tuple(map(int, input().split()))
print(lcm(A, B))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
  int N, D;
  cin >> N >> D;
  long long dist = (long long)D*D;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    long long X, Y;
    cin >> X >> Y;
    if ((X*X+Y*Y) <= dist) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int c[][] = new int [3][3];
        for(int i=0;i<3;i++){
          for(int j=0;j<3;j++){
            c[i][j] = sc.nextInt();
          }
        }
        if(c[0][0]-c[1][0]==c[0][1]-c[1][1] && c[0][1]-c[1][1]==c[0][2]-c[1][2] && c[2][0]-c[1][0]==c[2][1]-c[1][1] && c[2][1]-c[1][1]==c[2][2]-c[1][2])
          System.out.println("Yes");
        else
          System.out.println("No");
   
      
	}

}


Measured memory_bytes: 23892
n = int(input())
a = list(map(int, input().split()))
rem = [0]*(n+1)
for i in range(1, n+1)[::-1]:
    Sum = 0
    for j in range(i, n+1, i):
        Sum += rem[j]
    if Sum % 2 != a[i-1]:
        rem[i] = 1

print(sum(rem))

if sum(rem):
    ans = []
    for i, ele in enumerate(rem):
        if ele:
            ans.append(i)
    print(*ans)

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

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

    if (N%2 == 0){
        if(S.substr(0,N/2)==(S.substr(N/2))){
            cout << "Yes" << endl;
        }else
        {
            cout << "No" << endl;
        }
        


    } else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_eng) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B';
    } else if (mean3(p_math, p_eng, p_jpn) >= 50.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    while (1) {
        scanf("%d", &n_iteration);

        if (n_iteration == 0) {
            break;
        }

        for (i = 0; i < n_iteration; i++) {
            scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
            grade = grading(p_math, p_eng, p_jpn);
            printf("%c\n", grade);
        }
    }
    return 0;
}    

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define lli long long int
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    while(b<=a && k>0)
    {
        b=b*2;
        k--;
    }
    while(c<=b && k>0)
    {
        c=c*2;
        k--;
    }
    if(c>b && b>a)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
 }

Measured memory_bytes: 3640
N = int(input())

ans = N
for v9 in range(N + 1):
    cnt = 0
    t = v9
    w = 9 ** 5
    while t >= 9:
        if t >= w:
            cnt9, t = divmod(t, w)
            cnt += cnt9
        w //= 9
    t = N - (v9 - t)
    w = 6 ** 7
    while t >= 6:
        if t >= w:
            cnt6, t = divmod(t, w)
            cnt += cnt6
        w //= 6
    ans = min(ans, cnt + t)

print(ans)


Measured memory_bytes: 41708
while True:
    try:
        strings=input()

        for i in range(26):
            _strings=""
            for s in strings:
                if ord('a')<=ord(s) and ord(s)<=ord('z'):
                    _strings+=chr((ord(s)-ord('a')+1)%26+ord('a'))
                else:
                    _strings+=s
            strings=_strings
            if "the" in strings or "this" in strings or "that" in strings:
                print(strings)
                break
    except EOFError:
        break



Measured memory_bytes: 5560
n, k, q = gets.chomp.split(" ").map(&:to_i)
person = Array.new(n, k-q)
q.times do
    num = gets.chomp.to_i
    person[num-1] += 1
end

person.each do |p|
    if p <= 0
        puts "No"
    else
        puts "Yes"
    end
end


Measured memory_bytes: 3196
result = []

while True:
    indata = input().split()
    a = int(indata[0])
    b = int(indata[2])
    op = indata[1]

    if op == "+":
        result.append(a + b)
    elif op == "-":
        result.append(a - b)
    elif op == "*":
        result.append(a * b)
    elif op == "/":
        result.append(a // b)
    elif op == "?":
        break
    else:
        pass

for i in range(len(result)):
    print("{0:.0f}".format(result[i]))

Measured memory_bytes: 7704
#include<bits/stdc++.h>
using namespace std;
const int N = 205;
const int maxS = 40005;
long long f[2][2*maxS],n,m,a[N];
const int MOD =1e9+7;
void init()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void nhap()
{
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        a[i] -= m;
    }
}
void xuli()
{
    memset(f,0,sizeof(f));
    f[0][maxS] = 1;
    for (int i = 1; i<=n; i++) {
        for (int j = 0; j<2*maxS; j++) {
             f[1][j] = f[1][j] + f[0][j];
             f[1][j+a[i]] = f[1][j+a[i]] + f[0][j];
        }
        for (int j = 0; j<2*maxS; j++) {
            f[0][j] = f[1][j];
            f[1][j] = 0;
        }
    }
    cout << f[0][maxS] - 1  << '\n';
}
int main()
{
    init();
        nhap();
        xuli();

}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define N int(5e5)+5
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

struct node{
    node *l, *r;
    int v;

    node(int x=0){
        l = r = NULL;
        v = x;
    }
};

void build(node *p, int l, int r){
    if(l==r)
        return;
    int med = l + (r-l)/2;
    p->l = new node();
    p->r = new node();
    build(p->l,l,med);
    build(p->r,med+1,r);
}

void update(node *last, node *curr, int l, int r, int i, int v){
    if(l==r){
        curr->v+=v;
        return;
    }
    int med = (l+r)/2;
    if(i<=med){
        curr->r = last->r;
        curr->l = new node(last->l->v);
        update(last->l,curr->l,l,med,i,v);
    }
    else{
        curr->l = last->l;
        curr->r = new node(last->r->v);
        update(last->r,curr->r,med+1,r,i,v);
    }
    curr->v = curr->l->v + curr->r->v;
}

int get(node *last, node *curr, int l, int r, int i, int j){
    if(j<l || r<i)
        return 0;
    else if(i<=l && r<=j){
        return curr->v-last->v;
    }
    int med = l + (r-l)/2;
    return get(last->l,curr->l,l,med,i,j)+get(last->r,curr->r,med+1,r,i,j);
}

int n, arr[N], nxt[N];
vector<node*> roots;

int main(){
    fastIO();
    int q, l, r;
    map<int,int> cnt;

    cin >> n >> q;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }

    for(int i=n;i;i--){
        nxt[i] = cnt[arr[i]];
        if(nxt[i]==0) nxt[i] = n+1;
        cnt[arr[i]] = i;
    }

    roots.push_back(new node());
    build(roots[0],0,n+1);
    for(int i=1;i<=n;i++){
        roots.push_back(new node());
        update(roots[i-1],roots[i],0,n+1,nxt[i],1);
    }

    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << get(roots[l-1],roots[r],0,n+1,r+1,n+1) << '\n';
    }

    return 0;
}

Measured memory_bytes: 363768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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(ll 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) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
    int N, K;
    cin >> N >> K;
    mint ans = 0;
    mint sum1 = 0;
    mint sum2 = 0;
    for(ll i = 1;i < N+2; ++i)
    {
        sum1 += i-1;
        sum2 += N-i+1; 
        if(i >= K){
            ans += sum2-sum1+1;
        }      
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
const int INF = 1e9;

signed main(){
  int N; cin >> N;
  string s; cin >> s;
  int Q; cin >> Q;
  vector<set<int> > alp(26, set<int> {INF});
  for(int i = 0; i < N; i++) alp[s[i] - 'a'].insert(i);
  
  for(int i = 0; i < Q; i++){
    int t; cin >> t;
    if(t == 1){
      int i; char c; cin >> i >> c; --i;
	  if(s[i] != c) alp[s[i] - 'a'].erase(i);
		s[i] = c;
		alp[c - 'a'].insert(i);
    }
    if(t == 2){
      int ans = 0;
      int l, r; cin >> l >> r; --l;
      for(int c = 0; c < 26; c++){
        if(alp[c].empty()) continue;
        if(*alp[c].lower_bound(l) < *alp[c].lower_bound(r)) ans++;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 26244
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define swap(a,b) ((*a!=*b)&&(*a+=*b,*b=*a-*b,*a-=*b))
const int IMIN=(1<<31);
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define array(N,t) (t*)calloc(N,sizeof(t))
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Sort(unsigned *from,unsigned *to,unsigned bit)
{
  if(!bit||to<from+1)return;
  unsigned *left=from,*right=to-1;
  for(;;)
  {
    while(left<right&&!(*left&bit))left++;
    while(left<right&&(*right&bit))right--;
    if(left>=right)break;
    swap(left,right);
  }
  if(!(bit&*left)&&left<to)left++;
  bit>>=1;
  Sort(from,left,bit);
  Sort(left,to,bit);
}
static inline void Radix32(int *array,const int len)
{
  unsigned *x=(unsigned*)array;
  rep(i,len)x[i]^=IMIN;
  Sort(x,x+len,IMIN);
  rep(i,len)x[i]^=IMIN;
}
int main(void)
{
  int N=IN(),c=CH(),i=0,m=0,p=0,z=0,temp,*A=array(N,int);
  long K=0,low=-1e18,mid,high=-low,count;while(c>47&&c<58){K=K*10+c-48,c=CH();}
  rep(j,N){A[j]=IN();if(A[j]<0)m++;else if(A[j]>0)p++;else z++;}
  Radix32(A,N);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;else temp=0;
  if(K<=1l*m*p)high=1l;else low=-1l;
  while(high-low>1)
  {
    mid=(low+high)/2,count=0;
    if(!mid)count=1l*m*p;
    else if(mid>0)
    {
      count=1l*m*p+1l*z*(m+p)+1l*z*(z-1)/2;temp=N-1;i=m+z;if(count>=K){high=mid;continue;}
      while(i<N){while(1l*A[temp]*A[i]>=mid){temp--;}if(temp>i)count+=1l*temp-i,i++;else break;}
      temp=0;i=m-1;if(count>=K){high=mid;continue;}
      while(i>=0){while(1l*A[temp]*A[i]>=mid){temp++;}if(temp<i)count+=1l*i-temp,i--;else break;}
    }
    else
    {
      temp=m-1;i=N-1;
      while(i>=m+z){while(temp>=0&&1l*A[temp]*A[i]>=mid){temp--;}if(temp>=0){count+=1l*temp+1;}i--;}
    }
    if(count<K)low=mid;else high=mid;
  }
  free(A);return OUT(low),0;
}

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

#define BR "\n"
#define SP " "

int main() {
  ll N;
  cin >> N;

  vector<ll> S(14, 1);
  vector<ll> H(14, 1);
  vector<ll> C(14, 1);
  vector<ll> D(14, 1);
  for (int i = 0; i < N; i++) {
    string s;
    int a;
    cin >> s >> a;
    if (s == "S") S[a] = 0;
    if (s == "H") H[a] = 0;
    if (s == "C") C[a] = 0;
    if (s == "D") D[a] = 0;
  }

  for (int i = 1; i < 14; i++) { if (S[i]) cout << "S " << i << BR; }
  for (int i = 1; i < 14; i++) { if (H[i]) cout << "H " << i << BR; }
  for (int i = 1; i < 14; i++) { if (C[i]) cout << "C " << i << BR; }
  for (int i = 1; i < 14; i++) { if (D[i]) cout << "D " << i << BR; }

  return 0;
}


Measured memory_bytes: 3140
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


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;
}

bool cmp(pint a, pint b) { return a.second < b.second; }
vector<ll> g[100010];
vector<ll> value(100010,0);
vector<pint> pp;
map<pint,ll> mp;
ll cnt=0;

void dfs(ll p,ll v){
    ll ans=value[v];
    for(auto c:g[v]){
        if(c==p) continue;
        ans++;
        if(p!=-1 && ans==value[v]) ans++;
        value[c]=ans%cnt;
        pp.push_back(pint(value[c],mp[pint(v,c)]));
        dfs(v,c);
    }
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  rep(i,n-1){
      ll a,b;cin>>a>>b;a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
      mp[pint(a,b)]=i;
      mp[pint(b,a)]=i;
  }
  rep(i,n) chmax(cnt,(ll)(g[i].size()));
  ll res=0;
  dfs(-1,0);
  sort(ALL(pp),cmp);
  cout<<cnt<<endl;
  rep(i,n-1) cout<<pp[i].first+1<<endl;
}

Measured memory_bytes: 23540
/*
 * A.cpp
 *
 *  Created on: 2017/06/18
 *      Author: jin
 */

#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
const int MOD = 1000000007;
int n, m;
int a[2];
ll ans = 1;
bool f;
void solve() {
  cin >> n >> m;
  if (abs(n - m) >= 2) {
    cout << 0 << endl;
    return;
  }
  int a = n, b = m;
  if (a > b) {
    swap(a, b);
  }
  while (a > 0) {
    ans = (ans * a) % MOD;
    a--;
  }
  while (b > 0) {
    ans = (ans * b) % MOD;
    b--;
  }
  if (n == m) {
    ans = (ans * 2) % MOD;
  }
  cout << ans << endl;
}

int main() {
  solve();
}



Measured memory_bytes: 256
solve :: Int -> Int -> Int
solve n m
  | n == 1 && m == 1 = 1
  | min n m == 1 = max n m - 2
  | otherwise = (n - 2) * (m - 2)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  print $ solve n m

Measured memory_bytes: 508
local min = math.min

local s = io.read()
local t = io.read()

local s_byte_t = {}
for i = 1, s:len() do
	s_byte_t[i] = s:byte(i)
end
local t_byte_t = {}
for i = 1, t:len() do
	t_byte_t[i] = t:byte(i)
end

local out = math.maxinteger
for i = 0, #s_byte_t - #t_byte_t do
	local count = 0
	for j = 1, #t_byte_t do
		if s_byte_t[i + j] ~= t_byte_t[j] then
			count = count + 1
		end
	end
	out = min(out, count)
end

print(out)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll 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) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  string s; cin >> s;
  int ans = 0;
  for(auto c : s) {
    if(c == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef queue<int> Q;

int main(){
    int n;
    cin >> n;
    V a(n+1);
    a[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        int tmp;
        cin >> tmp;
        a[i] = a[i-1] + tmp;
    }
    ll ans = 100000000000000;
    for (int i = 1; i < n; i++)
    {
        ans = min(ans, abs(a[i]*2 - a[n]));
    }
    OUT(ans);
}

Measured memory_bytes: 1792
t=int(input())
for i in range(t):
        n,k=[int(j) for j in input().split(" ")]
        x=[int(j) for j in input().split(" ")]
        if n<=k:
                print(0)
        else:
                distance=x[-1]-x[0]
                dis_list=[]
                for j in range(n-1):
                        dis_list.append(x[j+1]-x[j])
                dis_list.sort()
                dis_list.reverse()
                for j in range(k-1):
                        distance-=dis_list[j]
                print(distance)
	

Measured memory_bytes: 23136
N=int(input())
P=tuple(list(map(int,input().split())))
Q=tuple(list(map(int,input().split())))

# P=tuple([7, 3, 5, 4, 2, 1, 6, 8])
# Q=tuple([3 ,8 ,2 ,5 ,4 ,6 ,7 ,1])
# P=tuple([1 ,3 ,2])
# Q=tuple([3 ,1 ,2])

import itertools
# N=3
s=[i for i in range(1,N+1)]
number_id=0
id_p=0
id_q=0
for v in itertools.permutations(s):
    number_id+=1
#     print(number_id)
#     print(v)
    if v==P:
        id_p=number_id
    if v==Q:
        id_q=number_id
        
print(abs(id_p-id_q))
    
    


Measured memory_bytes: 39024
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	string s, t, r;
	cin >> s;
	t = s.substr(0, (s.length() - 1) / 2);
	r = s.substr((s.length() + 1) / 2, s.length() - (s.length() + 1) / 2);
	
	bool ans = true;
	rep(i, s.length()) {
		if (s[i] != s[s.length() - 1 - i]) {
			ans = false;
			break;
		}
	}
	rep(i, t.length()) {
		if (t[i] != t[t.length() - 1 - i]) {
			ans = false;
			break;
		}
	}
	rep(i, r.length()) {
		if (r[i] != r[t.length() - 1 - i]) {
			ans = false;
			break;
		}
	}

	if (ans) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    vector<int> a(n);
    For(i, 0, n){
        cin>>a[i];
    }
    sort(all(a));
    reverse(all(a));
    int ans = 0;
    ans += a[0];
    int cur = 2;
    For(i, 1, n){
        if(cur < n){
            cur++;
            ans += a[i];
        }
        if(cur < n){
            cur++;
            ans += a[i];
        }
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 4764
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N, tmp, ans;
  ll A[200010];
  
  cin >> N;
  rep(i,N){
    cin >> A[i];
  }

  tmp = A[0];
  ans = 0;

  rep(i,N-1){
    if(tmp > A[i+1]){
      ans += (tmp-A[i+1]);
    }else{
      tmp = A[i+1];
    }
  }


  cout << ans << endl;
  
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

    ll n;
    cn n;

    if(n==2){
    	ct 1;nl;
    	return 0;
    }

    set<ll>st;

    for(int k=1; k<=sqrt(n); k++){
        
        if(n%k==0){st.insert(k),st.insert(n/k);}
    
    }

    int cnt=0;

    for(ll x:st){
     
     ll p=n/x;

     int pw=1;

     while(1) {
         
          ll y=pow(x,1.00/pw)+.01;
           
          ll tmp=pow(y,pw)+.01;


          
          if(tmp==x){

          	if( p%y==1)cnt++;
          }
         if(y==1)break;

          pw++; 



     }
    }


    ll nn=n-1;
    ll lm=sqrt(nn);
    set<ll>st2;
    for(int k=2; k<=lm; k++){
        
        if(nn%k==0){st2.insert(k);st2.insert(nn/k);}
    
    }

    ct cnt+st2.size()+1;nl;







    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	vector<int> a(26, -1), b(26, -1);
	rep(i, n) {
		a[s[i] - 'a'] = t[i] - 'a';
		b[t[i] - 'a'] = s[i] - 'a';
	}
	bool ch = 0;
	rep(i, n) {
		if (t[i] != a[s[i] - 'a'] + 'a') ch = 1;
		if (s[i] != b[t[i] - 'a'] + 'a') ch = 1;
	}
	rep(i, 26) {
		if (a[i] == -1) continue;
		if (i != b[a[i]]) ch = 1;
	}
	if (ch)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi vA(N);
  rep(i,N) {
    int a;
    cin >> a;
    if(a % 4 == 0) {
      vA[i] = 2;
    } else if(a % 2 == 0) {
      vA[i] = 1;
    } else {
      vA[i] = 0;
    }
  }
  sort(rng(vA));
  deque<int> A;
  rep(i,N) {
    A.push_back(vA[i]);
  }
  vi ans(N);
  ans[0] = A.front();
  A.pop_front();
  srep(i,1,N) {
    if(i % 2 == 1) {
      ans[i] = A.back();
      A.pop_back();
    } else {
      ans[i] = A.front();
      A.pop_front();
    }
    if(ans[i] + ans[i-1] < 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
S = [int(s) for s in list(input())]
n = len(S)
ans = 0
for bit in range(1 << (n-1)):
    total = 0
    tmp = S[0]
    for i in range(n-1):
        if (bit >> i) & 1:
            total += tmp
            tmp = S[i+1]
        else:
            tmp = tmp*10 + S[i+1]
    total += tmp
    ans += total
print(ans)


Measured memory_bytes: 39152
from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  G[a].append(b)
  G[b].append(a)
V=[0]*n
V[0]=1
P=[0]*n
P[0]=-1
C=[1]*n
D=deque([0])
DD=deque([0])
GG=[[] for i in range(n)]
while len(D)>0:
  v=D[0]
  D.popleft()
  for i in range(len(G[v])):
    if V[G[v][i]]==0:
      V[G[v][i]]=1
      D.append(G[v][i])
      DD.append(G[v][i])
      P[G[v][i]]=v
DD=list(DD)[::-1]
for i in range(n):
  if DD[i]!=0:
    C[P[DD[i]]]+=C[DD[i]]
a=0
i=n-1
while i!=0:
  i=P[i]
  a=a+1
i=n-1
for _ in range((a-1)//2):
  i=P[i]
s=C[i]
f=n-C[i]
if f>s:
  print("Fennec")
else:
  print("Snuke")

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define IT(s) s.begin(), s.end()
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD 1000000007

int a;

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

    cin >> a;
    cout << a + a * a + a * a * a << "\n";

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>

using namespace std;

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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int N = 4;
const int INF = 1e9 + 123;
const double EPS = 1e-9;

int a[N], mx;

int main () {
    ios_base :: sync_with_stdio(0);
    for(int i = 1; i <= 3; ++i) {
        cin >> a[i];
    }
    for(int i = 1; i <= 3; ++i) {
        for(int j = i + 1; j <= 3; ++j) {
            mx = max(mx, (a[i] * 10 + a[j] + a[6 - i - j]));
            mx = max(mx, (a[j] * 10 + a[i] + a[6 - i - j]));
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long gcd(long long a,long long b)
{
	if(a%b==0)
	{
		return b;
	}
	else
	{
		return gcd(b,a%b);
	}
}
int main(void)
{
    long long n,x;
    cin>>n>>x;
    a[0]=x;
    for(long long i=1;i<=n;++i)
    {
        cin>>a[i];
    }
    sort(a,a+n+1);
    long long t=a[1]-a[0];
    if(n==1)
    {
        cout<<t<<endl;
    }
    else
    {
        for(long long i=2;i<=n;++i)
        {
            t=gcd(t,a[i]-a[i-1]);
        }
        cout <<t<<endl;
    }

    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main ()
{
    int arr[5], i, j, w, e, temp;
    for(i=0; i<3; i++)
    {
        scanf("%d", &arr[i]);
    }
    for(i=0; i<3-1; i++)
    {
        for(j=0; j<3-i-1; j++)
        {
            if(arr[j]>arr[j+1])
            {
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }
    w = arr[2] - arr[1];
    e = arr[1] - arr[0];
    printf("%d\n", w+e);
        return 0;
}


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

int main() {
    int N; cin >> N;
    int tuyoi = 0;
    vector<int> C(8);
    rep(i, N){
        int a; cin >> a;
        int x = a / 400;
        if(x < 8){
            C[x]++;
        } else {
            tuyoi++;
        }
    }

    int ans = 0;
    rep(i, 8){
        if(C[i] != 0)ans++;
    }
    if(ans == 0){
        ans = 1;
        tuyoi--;
    }

    cout << ans << " " << ans + tuyoi << endl;


    return 0;
}

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

int main()
{
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        if(sqrt(x * x + y * y) <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3836
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var s = input.ReadLine();

        Func<int, bool> isok = (x) => {
            var xx = new int[3];
            xx[0] = x / 100;
            xx[1] = (x % 100) / 10;
            xx[2] = (x % 10);

            var p = 0;
            for(int i=0; i<n; i++) {
                var c = s[i] - '0';
                if(c == xx[p]) {
                    if (p == 2) return true;
                    else p++;
                }
            }
            return false;
        };

        long count = 0;
        for(int i=0; i<=999; i++) {
            if (isok(i)) {
                //Debug.WriteLine(i);
                count++;
            }
        }
        //Debug.WriteLine("");

        return count;
    }
}


Measured memory_bytes: 13140
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    let ans = n * (n - 1) / 2;
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)<abs(b-x))puts("A");
	else puts("B");
}
		
		

		
		


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

int main() {
    int n, k;
    std::cin >> n >> k;
    long long a = n / k, b = 0;
    if (k % 2 == 0) {
        b = a + (n % k >= k / 2);
    }
    std::cout << a * a * a + b * b * b << std::endl;
    
    return 0;
}

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

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

	std::string S;
	std::cin >> S;

	int num = 0;
	for(auto itr = S.begin(); itr != S.end(); itr++) {
		if(*itr == 'E') {
			num++;
		}
	}
	
	int min = num;
	for(auto itr = S.begin(); itr != S.end(); itr++) {
		switch(*itr) {
		case 'W':
			num++;
			break;
		case 'E':
			num--;
			break;
		}
		if(num < min) {
			min = num;
		}
	}

	std::cout << min << std::endl;

	return 0;
}

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

const int MAXN = 2 * 1e5 + 5;
int n;
int a, _max = -1;
long long ans;

int main () {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a <= _max) ans += _max - a;
		if (a > _max) _max = a;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    bool has0 = false;
    int minus = 0;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> v[i];
        if(v[i] == 0) has0 = true;
        if(v[i] < 0) {
            minus++;
            v[i] *= -1;
        }
        ans += v[i];
    }
    if(has0 || minus % 2 == 0)
        cout << ans;
    else {
        sort(v.begin(), v.end());
        ans -= v[0] * 2;
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<int> G[SIZE];
int color[SIZE];

int main(){
  int N;

  scanf("%d", &N);

  for (int i=0; i<N-1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> que[2], next;
  int counter[2] = {};

  for (int i=0; i<N; i++)
    color[i] = -1;

  que[0].push(0);
  que[1].push(N-1);

  while(que[0].size() || que[1].size()) {
    for (int i=0; i<2; i++) {
      while(que[i].size()) {
        int p = que[i].front();
        que[i].pop();

        if (color[p] >= 0) continue;
        color[p] = i;
        counter[i]++;

        for (int to : G[p]) {
          next.push(to);
        }
      }
      swap(next, que[i]);
    }
  }

  if (counter[0] <= counter[1]) {
    puts("Snuke");
  } else {
    puts("Fennec");
  }

  return 0;
}


Measured memory_bytes: 8704
function main(input) {
  const d = Number(input.trim());
  let result = "";
  if (d === 22) {
    result = "Christmas Eve Eve Eve";
  } else if (d === 23) {
    result = "Christmas Eve Eve";
  } else if (d === 24) {
    result = "Christmas Eve";
  } else if (d === 25) {
    result = "Christmas";
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            X -= A;

            int num = X / B;

            Console.WriteLine(X - num * B);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

















int main(){
    ll n;
    string s;
    cin >> n >> s;
    vector<vector<ll>> cnt(3, vector<ll>(n + 1));
    REP(i, n){
        if(s[i] == 'R'){
            cnt[0][i]++;
        }
        else if(s[i] == 'G'){
            cnt[1][i]++;
        }
        else{
            cnt[2][i]++;
        }
        REP(j, 3){
            cnt[j][i + 1] = cnt[j][i];
        }
    }
    ll ans = 0;
    REP(i, n - 2){
        for(ll j = i + 1; j < n - 1; j++){
            if(s[i] == 'R' && s[j] == 'G'){
                ans += cnt[2][n - 1] - cnt[2][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'B'){
                    ans--;
                }
            }
            if(s[i] == 'R' && s[j] == 'B'){
                ans += cnt[1][n - 1] - cnt[1][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'G'){
                    ans--;
                }
            }
            if(s[i] == 'G' && s[j] == 'B'){
                ans += cnt[0][n - 1] - cnt[0][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'R'){
                    ans--;
                }
            }
            
            if(s[i] == 'G' && s[j] == 'R'){
                ans += cnt[2][n - 1] - cnt[2][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'B'){
                    ans--;
                }
            }
            if(s[i] == 'B' && s[j] == 'R'){
                ans += cnt[1][n - 1] - cnt[1][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'G'){
                    ans--;
                }
            }
            if(s[i] == 'B' && s[j] == 'G'){
                ans += cnt[0][n - 1] - cnt[0][j];
                if((j + (j - i)) < n && s[j + (j - i)] == 'R'){
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656