akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


bool dp[100][100][26000];
int h, w;
int a[90][90], b[90][90];
signed main() {
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j];
	rep(i, h)rep(j, w)cin >> b[i][j];
	dp[0][0][13000] = true;
	rep(i, h)rep(j, w) {
		rep(k, 26000) {
			if (!dp[i][j][k])continue;
			dp[i + 1][j][k + a[i][j] - b[i][j]] = true;
			dp[i + 1][j][k - a[i][j] + b[i][j]] = true;
			dp[i][j + 1][k + a[i][j] - b[i][j]] = true;
			dp[i][j + 1][k - a[i][j] + b[i][j]] = true;
		}
	}
	int ans = inf;
	rep(i, 26000) {
		if (!dp[h][w - 1][i])continue;
		chmin(ans, abs(i - 13000));
	}
	cout << ans << endl;
}


Measured memory_bytes: 205952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans=0;
  cin >> N;
  vector<int> A(N),B(N);
  for (int i = 0; i < N-1; i++) {
    cin >> B.at(i);
  }
  A.at(N-1) = B.at(N-2);
  
  for (int i = N-2; i>0 ; i--) {
    
    if( B.at(i) < B.at(i-1) ){
      A.at(i) = B.at(i);
    }
    else{
      A.at(i) = B.at(i-1);
    }
  }
  
  if(B.at(0) > B.at(1)){
    A.at(0) = B.at(0);
  }else{
    A.at(0) = A.at(1);
  }
  
  
  for (int i = 0; i < N; i++) {   
    ans += A.at(i);
  }

  cout << ans << endl;
}

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

int main() {
  int n, i, check = 1;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  for (i = 0; i <= n; i++) {
    if (t[i] % 2 != (x[i] + y[i]) % 2) {
      check = 0;
      break;
    }
  }
  if (check) {
    for (i = 0; i < n; i++) {
      if (t[i + 1] < x[i + 1] + y[i + 1] - x[i] - y[i]) {
        check = 0;
        break;
      }
    }
  }
  if (check) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 1408
n,m=map(int,input().split())
d=[0 for i in range(m)]
for i in range(n):
    k=list(map(int,input().split()))
    for i in range(len(k)-1):
        d[k[i+1]-1]+=1
ans=0
for i in d:
    if i==n:
        ans+=1
print(ans)

Measured memory_bytes: 9140
(defparameter *n* (read))

(defun count-2-div-inner (n cnt)
  (let ((n%2 (mod n 2)))
    (if (not (= n%2 0))
        cnt
        (count-2-div-inner (/ n 2) (1+ cnt)))))

(defun count-2-div (n)
  (count-2-div-inner n 0))

(defun max-position (lst)
  (let ((max-value (apply #'max lst)))
    (position-if (lambda (x)
		   (= x max-value)) lst)))

(format t "~A~%"
        (1+ (max-position
             (mapcar #'count-2-div (loop for i from 1 to *n* collect i)))))


Measured memory_bytes: 16480
#include<stdio.h>

int main(){
  int N,a,div_4=0,div_odd=0,div_2=0;
  scanf("%d",&N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&a);
    if (a%4==0){
      div_4++;
    }else if (a%2!=0){
      div_odd++;
    }else{
      div_2++;
    }
  }

  div_odd+=div_2%2;

  if (div_4 >= div_odd-1){
    puts("Yes");
  }else{
    puts("No");
  }

  return 0;
}


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

int main(){
	int x;
	cin >> x;
	
	while(1){
		bool ok = true;
		for (int i = 2 ;i <= x-1 ; ++i) {
			if(x % i == 0){
				ok = false;
			}
		}
		if(ok == true){
			cout << x << endl;
			break;
		}else{
			x++;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<unordered_map>
#include<queue>

using namespace std;
class CompareDist
{
public:
    bool operator()(pair<int,int> n1,pair<int,int> n2) {
        return n1.first>n2.first;
    }
};

int main(){

string s;
int a,b,c,i,j,k,n,m,ans=0,max,index;
vector<string> lst;
vector<int> cnt;

unordered_map<string,int> mp;

priority_queue<int> maxpq; // default 大きい順
priority_queue<pair<int,int>,vector<pair<int,int>>,CompareDist> pq;

cin >> n >> m;

vector<pair<int,int>> pairs(n);
int flg_delete[n]={0};

for(i=0;i<n;i++){
  cin >> a >> b;
//  pairs[i] = make_pair(a,b);
  pq.push(make_pair(a,b));
}

//sort(pairs.begin(),pairs.end());

for(i=1;i<=m;i++){
  while(pq.top().first == i && !pq.empty()){
    maxpq.push(pq.top().second);
//cout << i << pq.top().second << endl;
    pq.pop();
  }
//  for(j=0;j<n;j++){
//    if(i == pairs[j].first)maxpq.push(pairs[j].second);
//  }
  if(!maxpq.empty()){
    ans += maxpq.top();
    maxpq.pop();
  }
}

cout << ans << endl;

return 0;

}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 char name[1000];
int main() {
	// your code goes here
	scanf("%s",name);
	int len = strlen(name);
	bool H = false;
	bool F = false;
	for(int i=0;i<len;i++){
		if(!H&&name[i]=='C')H = true;
		if(H&&name[i]=='F')F = true;
	}
	if(F)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000001

void maxHeapify(int);
int A[MAX], n;

int main(){
  int i;
  scanf("%d", &n);
  for(i = 1 ; i <= n ; i++) scanf("%d", &A[i]);
  for(i = n / 2 ; i >= 1 ; i--) maxHeapify(i);
  for(i = 1 ; i <= n ; i++) printf(" %d", A[i]);
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int l, r, large, t;
  l = i *2;
  r = i * 2 + 1;
  if(l <= n && A[l] > A[i]) large = l;
  else large = i;
  if(r <= n && A[r] > A[large]) large = r;
  if(large != i){
    t = A[i];
    A[i] = A[large];
    A[large] = t;
    maxHeapify(large);
  }
}



Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=15;
const int mod=998244353;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int C[MAXN][MAXN],bin[MAXN];
int row[MAXN][MAXN][3],col[MAXN][MAXN][3],n,m;
int ans=0;
int r[MAXN],c[MAXN];
void dp()
{
	for(int i=0;i<MAXN;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=C[i-1][j],ad(C[i][j],C[i-1][j-1]);
	}bin[0]=1;for(int i=1;i<MAXN;i++)bin[i]=bin[i-1]<<1;
	for(int j=1;j<=m;j++)row[n][j][2]=1LL*C[m][j]*bin[m-j]%mod;
	ans=bin[m];
	for(int i=n;i>=1;i--)for(int j=m;j>=1;j--)
	{
		row[i][j][0]=(row[i][j][1]+row[i][j][2])%mod;
		col[i][j][0]=(col[i][j][1]+col[i][j][2])%mod;
		for(int k=1;k<i;k++)
		{
			ad(col[k][j][1],(2LL*row[i][j][2]*C[i][k]%mod+1LL*row[i][j][1]*C[i][k]%mod)%mod);
			ad(col[k][j][2],1LL*row[i][j][2]*C[i][k]%mod*(bin[i-k]-2)%mod);
		}
		ad(ans,1LL*row[i][j][2]*(bin[i]-2)%mod);
		for(int k=1;k<j;k++)
		{
			ad(row[i][k][1],(2LL*col[i][j][2]*C[j][k]%mod+1LL*col[i][j][1]*C[j][k]%mod)%mod);
			ad(row[i][k][2],1LL*col[i][j][2]*C[j][k]%mod*(bin[j-k]-2)%mod);
		}
		ad(ans,1LL*col[i][j][2]*(bin[j]-2)%mod);
	}
	for(int i=1;i<(1<<n);i++)for(int j=1;j<(1<<m);j++)
	{
		bool flag=true;
		for(int u=1;u<=n;u++)if((i&(1<<(u-1)))&&((r[u]&j)==j||(r[u]&j)==0)){flag=false;break;}
		for(int u=1;u<=m;u++)if((j&(1<<(u-1)))&&((c[u]&i)==i||(c[u]&i)==0)){flag=false;break;}
		if(!flag)continue;
		int fx=__builtin_popcount(i),fy=__builtin_popcount(j);
		ad(ans,1LL*(row[fx][fy][0]+col[fx][fy][0])*pow_mod(C[n][fx],mod-2)%mod*pow_mod(C[m][fy],mod-2)%mod);
	}
	pr2(ans);
}
char ch[MAXN][MAXN];
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(ch[i][j]=='#')r[i]|=(1<<(j-1));
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(ch[j][i]=='#')c[i]|=(1<<(j-1));
	dp();
	return 0;
}



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

typedef long long  ll;

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

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

ll vatical[1010];
ll horizontal[1010];

int main(){
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  for(int i = 0;i < N;i++){
    int n = S[i] - 'a';
    if(i == N-1){
      S[i] = 'a' + (n+K) % 26;
      break;
    }
    if(S[i] == 'a') continue;
    if(K >= 26 - n){
      S[i] = 'a';
      K -= (26-n);
    }else{
      continue;
    }
  }
  cout << S << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 A, B;

int main() {
  cin >> A >> B;
  i64 cnt = 0;
  i64 n = 1;
  while (n < B) {
    n--;
    n += A;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int H, W;
vstr a;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

bool bfs() {
  queue<pair<int, int>> q;  // (h, w)
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    auto p = q.front(); q.pop();
    int y = p.first, x = p.second;
    a[y][x] = '.';
    int cnt = 0;
    rep(i, 4) {
      int yy = y + dy[i], xx = x + dx[i];
      if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue;
      if (a[yy][xx] == '#') {
        if (cnt > 0) return false;
        if (yy < y || xx < x) return false;
        cnt++;
        q.push(make_pair(yy, xx));
      }
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cin >> H >> W;
  a = vstr(H);
  rep(i, H) cin >> a[i];
  if (bfs()) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#define long long int int
using namespace std;

const int maxk = 18;

int dist[100005];

class edge{
public:
  int t,c,l;

  edge(int to, int color, int length) : t(to),c(color),l(length) {}
};

int depth[100005];
int parent[maxk + 1][100005];
vector<edge> g[100005];

void dfs(int v, int prev, int d) {
  depth[v] = d;
  parent[0][v] = prev;
  
  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].t;
    if(u != prev) dfs(u,v,d+1);
  }
  
  return;
}

  

void init(int V) {
  dfs(0,-1,0);
  
  for(int k = 0; k < maxk; k++) {
    for(int i = 0; i < V; i++) {
      if(parent[k][i] < 0) parent[k+1][i] = -1;
      else parent[k+1][i] = parent[k][parent[k][i]];
    }
  }
  return;
}

int lca(int u, int v) {
  if(depth[u] > depth[v]) swap(u,v);
  for(int k = 0; k < maxk; k++) {
    if((depth[v] - depth[u]) >> k & 1) {
      v = parent[k][v];
    }
  }
  if(u == v) return u;
  for(int k = maxk - 1; k >= 0; k--) {
    if(parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}


int n,q;

typedef pair<int,int> P;
map<int,P> s[100005];

int C[100005];
int D[100005];

void dfs2(int v, int prev) {
 
  for(auto itr = s[v].begin(); itr != s[v].end(); ++itr) {
    int u = itr->first;
    itr->second.first = C[u];
    itr->second.second = D[u];
    
  }

  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].t;
    if(u != prev) {
      C[g[v][i].c]++;
      D[g[v][i].c] += g[v][i].l;
      dist[u] = dist[v] + g[v][i].l;
      dfs2(u,v);
      C[g[v][i].c]--;
      D[g[v][i].c] -= g[v][i].l;
    }
  }
  
}

int x[100005];
int y[100005];
int u[100005];
int v[100005];

signed main() {
  cin >> n >> q;



  for(int i = 0; i < n - 1; i++) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--,b--;
    g[a].push_back(edge(b,c,d));
    g[b].push_back(edge(a,c,d));
  }

  init(n);

  for(int i = 0; i < q; i++) {
    cin >> x[i] >> y[i] >> u[i] >> v[i];
    u[i]--,v[i]--;
   
    s[u[i]][x[i]] = P(0,0);
    s[v[i]][x[i]] = P(0,0);
    int t = lca(u[i],v[i]);
    s[t][x[i]] = P(0,0);
  }
  dfs2(0,-1);

  for(int i = 0; i < q; i++) {
    int tmp = s[u[i]][x[i]].first * y[i];
    int tmp2 = s[v[i]][x[i]].first * y[i];
    int tmp3 = s[lca(u[i],v[i])][x[i]].first * y[i];

    int tmp4 = s[u[i]][x[i]].second;
    int tmp5 = s[v[i]][x[i]].second;
    int tmp6 = s[lca(u[i],v[i])][x[i]].second;
    
    int di = dist[u[i]] + dist[v[i]] - 2 * dist[lca(u[i],v[i])];
    int di2 = tmp4 + tmp5 - 2 * tmp6;
    int di3 = tmp + tmp2 - 2 * tmp3;
    
    
    cout << di - di2 + di3 << endl;
    
  }
}
			      


Measured memory_bytes: 40120
#                               #
    # author : samars_diary #
    # 13-09-2020 │ 11:26:57 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    d,t,s=mii()
    if d/s<=t:
        print('Yes')
    else: print('No')
solve()

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,m;
	cin>>n;
	vector<unsigned long long>A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	unsigned long long sum[n][n];
	memset(sum,0,sizeof(sum));
	for(int i=0;i<n;i++) sum[i][i]=A[i];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++) sum[i][j]=sum[i][j-1]+A[j];
	}
	unsigned long long dp[n][n]; //dp[i][j] means from i to j
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n-1;i++) dp[i][i+1]=A[i]+A[i+1];
	for(int k=2;k<n;k++){
		for(int i=0;i<n-k;i++){
			int j=i+k;
			dp[i][j]=dp[i][j-1]+sum[i][j]; //jb j end m pure k sath add hoga
			for(int p=j-1;p>i;p--){
				dp[i][j]=min(dp[i][j], dp[p][j]+dp[i][p-1]+sum[i][j]);
			}
		}
	}
	cout<<dp[0][n-1]<<"\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

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


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        int numa = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        int numc = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += 1LL * numa * numc;
    }
    cout << ans << endl;

    return 0;
}


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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	ll a,b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;
	
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	vl A(N);
	rep(i, N)
		cin >> A[i];
	ll ans = -InfLL;
	if (N % 2 == 0) {
		vl Asum(N + 2, 0);
		rep(i, N) {
			Asum[i + 2] = Asum[i] + A[i];
		}
		rep(i, N + 1) {
			if (i % 2 == 0)
				ans = max(ans, Asum[i] + Asum[N + 1] - Asum[i + 1]);
		}
	}
	else {
		vl Asum(N + 2, 0);
		rep(i, N) {
			Asum[i + 2] = Asum[i] + A[i];
		}
		vl ansL(N, 0);
		vl ansR(N, 0);
		rep(i, N) {
			if (i % 2 == 1)
				ansL[i] = Asum[i + 1] - Asum[i + 2];
		}
		rep(i, N) {
			if (i % 2 == 1) {
				ansR[i] -= Asum[N] - Asum[i];
				ansR[i] += (Asum[N + 1] - Asum[i + 1]);
			}
		}
		vl ansLmax(N + 2, 0);
		vl ansRmax(N + 2, 0);
		rep(i, N) {
			if (i % 2 == 1) {
				ansLmax[i + 2] = max(ansLmax[i], ansL[i]);
			}
		}
		rrep(i, N) {
			if (i % 2 == 1) {
				ansRmax[i] = max(ansRmax[i + 2], ansR[i]);
			}
		}
		rep(i, N + 1) {
			if (i % 2 == 1) {
				ll anstmp = Asum[N];
				anstmp += ansLmax[i];
				anstmp += ansRmax[i];
				ans = max(ans, anstmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

void qsort(int[] ,int ,int );

int main(void)
{
    int n,q,result=0;
    cin>>n;
    int S[n];
    for(int i=0;i<n;i++)
    {
        cin>>S[i];
    }
    cin>>q;
    int T[q];
    for(int i=0;i<q;i++)
    {
        cin>>T[i];
    }
    qsort(S,0,n-1);
    qsort(T,0,q-1);
    for(int i=0;i<n;i++)
    {
        if(i>0&&S[i]==S[i-1])continue;
        if(*(lower_bound(T, T+q, S[i]))==S[i])result++;
    }
    cout<<result<<endl;
    return 0;
}

void qsort(int a[],int low,int high)
{
    int mid=a[(low+high)/2];
    int i=low,j=high;
    do{
        while(a[i]<mid) i++;
        while(a[j]>mid) j--;
        if(i<=j)
        {
            int temp=a[i];
            a[i]=a[j];
            a[j]=temp;
            i++;
            j--;
        }
    }while(i<=j);
    if(low<j) qsort(a,low,j);
    if(i<high) qsort(a,i,high);
}




Measured memory_bytes: 3656
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

char S[SIZE];
map<ll,ll> MAP;


int main(){

	scanf("%s",S);

	int len;
	for(len = 0; S[len] != '\0'; len++);

	ll num = 0,mult = 1;
	ll ans = 0;

	for(int i = len-1; i >= 0; i--){

		MAP[num]++;
		num += mult*(S[i]-'0');
		num %= 2019;

		ans += MAP[num];
		mult *= 10;
		mult %= 2019;
	}

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

	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

int64 N;
int64 dp[64][2];
int64 dp2[64][2];

int64 ways(int idx, bool less) {
  if(idx == -1) return 1;
  if(~dp2[idx][less]) return dp2[idx][less];
  int ret = ways(idx - 1, less | ((N >> idx) & 1));
  if(less || ((N >> idx) & 1)) ret ^= ways(idx - 1, less);
  return dp2[idx][less] = ret;
}

int64 rec(int idx, bool less) {
  if(idx == -1) return 0;
  if(~dp[idx][less]) return dp[idx][less];
  int64 ret = rec(idx - 1, less | ((N >> idx) & 1));
  if(less || ((N >> idx) & 1)) {
    ret ^= rec(idx - 1, less);
    ret ^= (ways(idx - 1, less) << idx);
  }
  return dp[idx][less] = ret;
}

int main() {
  int64 A, B;
  cin >> A >> B;
  --A;

  N = A;
  memset(dp, -1, sizeof(dp));
  memset(dp2, -1, sizeof(dp2));
  int64 v = 0;
  if(A > 0) v = rec(62, false);

  N = B;
  memset(dp, -1, sizeof(dp));
  memset(dp2, -1, sizeof(dp2));


  cout << (v ^ (rec(62, false))) << endl;
}



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

using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  vector<double> a(n);

  for(int i=0;i<n;i++){
    int tmp;
    scanf("%d",&tmp);
    a[i] = (double)tmp;
  }

  double sum = 0;
  for(int i=0;i<n;i++){
    sum += 1.0 / a[i];
  }

  double result = 1.0 / sum;

  cout << result << endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int x1 = x;
        int y1 = y;
        while (x1 != y1){
            if(x1 < y1)y1 -= x1;
            else x1 -= y1;
        }
        System.out.println(x + y + 1 - x1);



    }







}


Measured memory_bytes: 26372
//Created by:Coding_lover(27-07-2020 07:46:52)
#include <bits/stdc++.h>
#define ll long long
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define INF LLONG_MAX
#define f first
#define s second
#define LB lower_bound
#define UB upper_bound
#define pi pair<long long,long long>
#define pii pair<long long,pi>
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define vc vector
#define vll vector<long long>
#define rep(i, a, n) for (ll i = a; i < (long long)n; ++i)
#define repe(i, a, n) for (ll i = a; i <= (long long)n; ++i)
#define repr(i, n, a) for (ll i = n; i > (long long)a; --i)
#define repre(i, n, a) for (ll i = n; i >= (long long)a; --i)
#define dbg(x) cout<<"Debugging "<<#x<<":"<<endl;cout<<#x<<" = "<<x<<endl
#define dbgv(v) cout<<"Debugging "<<#v<<":"<<endl; for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
using namespace std;
const ll MAXA=1e5+10;
vector<vll> adj(MAXA);
vector<int> dia(MAXA);
vector<bool> vis(MAXA);
ll max_dist=0;
void dfs(ll v)
{
	vis[v]=true;
	dia[v]=0;
	for(auto i:adj[v])
	{
		if(!vis[i])
		{
			dfs(i);
			dia[v]=max(dia[v],dia[i]+1);
		}
		else dia[v]=max(dia[v],dia[i]+1);
	}
}
int main() {
  FASTER;
  ll t=1;
  //cin >> t;
  while (t--) {
  	ll n,m;
  	cin>>n>>m;
  	rep(i,0,m)
  	{
  		ll u,v;
  		cin>>u>>v;
  		adj[u].pb(v);
  	}
  	repe(i,1,n)
  	{
  		if(!vis[i])dfs(i);
  	}
  	max_dist=*max_element(all(dia));
  	cout<<max_dist<<endl;
  }
  return 0;
}

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

int A,B,C,D;

int main()
{
	cin >> A >> B >> C >> D;
	while(1)
	{
		C -= B;
		if(C <= 0)
		{
			cout << "Yes";
			return 0;
		}
		
		A -= D;
		if(A <= 0)
		{
			cout << "No";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3596
N = int(input())
V = [float(v) for v in input().split()]
V.sort(reverse=True)
for i in range(N):
    if len(V) == 1:
        print(V[0])
        exit()
    v1 = V.pop()
    v2 = V.pop()
    V.append((v1 + v2) / 2)



Measured memory_bytes: 2940
def print_list(l):
    for i, n in enumerate(l):
        if i == N - 1:
            print(l[i])
        else:
            print(l[i], end=' ')

N = int(input())
A = input().split()
B = list(A)
for i in range(N):
    for j in range(N-1, i, -1):
        if int(A[j][1]) < int(A[j-1][1]):
            w = A[j]; A[j] = A[j-1]; A[j-1] = w
print_list(A)
print('Stable')

for i in range(N):
    min_j = i
    for j in range(i, N):
        if int(B[j][1]) < int(B[min_j][1]):
            min_j = j
    w = B[i]; B[i] = B[min_j]; B[min_j] = w
print_list(B)
if A == B:
    print('Stable')
else:
    print('Not stable')



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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int X = A, Y = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      for (int k = 0; k < 100; k++) {
        for (int l = 0; l < 100; l++) {
          int x = 100 * A * i + 100 * B * j;
          int y = C * k + D * l;
          if (x + y <= F && y * 100 <= x * E &&
              (double)y * (X + Y) >= (double)Y * (x + y)) {
            X = x;
            Y = y;
          }
        }
      }
    }
  }
  cout << X + Y << ' ' << Y << endl;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0;
  for(int i = 0; i < sz(s); i++){
    if(s[i] == 'R')r++;
  }
  if(r > sz(s) - r)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    S = S.replace('2017','2018')
    print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9012
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>

using namespace std;
using LL = long long;
LL sum = 0;
int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; j += i)
			sum += j;

	printf("%lld\n", sum);

	return 0;
}

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

ll powmod(ll x, ll y) {
  ll res = 1;
  rep(i, y) res = res * x % mod;
  return res;
}

int main() {
  ll N;
  cin >> N;
  // (全事象) - (0を含まない) - (9を含まない) + (0も9も含まない)
  ll ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3588
n = int(input())
a = input()
b = input()
c = input()

changeCount = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
      continue  
    elif (a[i] != b[i]) and (a[i] != c[i]) and (b[i] != c[i]):
        changeCount += 2
    else:
        changeCount += 1

print(changeCount)

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



int main()
{
	int N, A, B, passed = 0, Bs = 0, i;
	string S;
	cin >> N >> A >> B;
	cin >> S;
	for (i = 0; i < N; i++)
	{
		if (S[i] == 'c' || passed >= A + B)
		{
			cout << "No" << endl;
			continue;
		}
		if (S[i] == 'a')
		{
			cout << "Yes" << endl;
			passed++;
		}
		else //'b'
		{
			if (Bs >= B)
				cout << "No" << endl;
			else
			{
				cout << "Yes" << endl;
				passed++;
			}
			Bs++;
		}
	}
	return 0;
}

Measured memory_bytes: 896
<?php
list($N)=sscanf(trim(fgets(STDIN)),"%d");
list($S)=sscanf(trim(fgets(STDIN)),"%s");
for($i=0;$i<strlen($S);$i++){
    $num = (ord($S[$i])+$N);
    if($num > ord('Z')) $num = $num - ord('Z') + ord('A') - 1;
    $S[$i] = chr($num);
}
printf($S);

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

int main() {
  int count[4][3][10] = {};
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;

    count[b - 1][f - 1][r - 1] += v;
  }
  for(int i = 0; i < 4; ++i) {
    for(int j = 0; j < 3; ++j) {
      for(int k = 0; k < 10; ++k) {
        cout << " " << count[i][j][k] << flush;
      }
      cout << endl;
    }
    if(!(i == 3)) {
      cout << "####################" << endl;
    }
  }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  // vector<int32> a(n);
  // REP(i,n)cin >> a[i];
  // vector<int32> asum(n+1,0);
  // REP(i,n)asum[i+1] = (asum[i] + a[i] - 1 + k) % k;
  vector<int32> asum(n+1,0);
  REP(i,n){
    int32 a;
    cin >> a;
    asum[i+1] = (asum[i] + a - 1 + k) % k;
  }
  // vector<int32> cnt(k,0);
  map<int32,int32> cnt;
  int64 ans = 0;
  REP(i,n+1){
    ans += cnt[asum[i]];
    cnt[asum[i]]++;
    if(i-k+1 >= 0)
      cnt[asum[i-k+1]]--;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 14336
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0

for i in range(N - 1):
	for j in range(i + 1, N):
		dist = 0
		for k in range(D):
			dist += (X[i][k] - X[j][k]) ** 2
			
		if dist == int(dist ** 0.5) ** 2:
			count += 1
		
print(count)

Measured memory_bytes: 38256
import java.util.Scanner;

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

		System.out.print(c + " ");
		System.out.print(a + " ");
		System.out.print(b);
		sc.close();
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

struct edge
{
  int to;
  int from;
  int cap;
  int rev;
};
const int max_v= 1010;
int s=0, t;
bool visited[max_v];
vector<edge> g[max_v];
int red_card[510], blue_card[510];

int max_flow();
int get_card();
void print_g();
int dfs(int node, int f);

void clear()
{
  for(int i=0;i<max_v;i++)
    {
      g[i].clear();
    }
}

int main()
{
  while(true)
    {
      clear();
      if(get_card()==-1)
	{
	  break;
	}
  cout << max_flow() << endl;
  //print_g();
    }
  return 0;
}
  
void print_g()
{
  for(int i=0;i<=t;i++)
    {
      for(int j=0;j<g[i].size();j++)
	{
	  if(g[i][j].cap!=0)
	    {
	  cout << "{" << g[i][j].from << g[i][j].to << g[i][j].cap << g[i][j].rev << "}";
	    }
	}
      cout << endl;
    }
}

int max_flow()
{
  int sum = 0, f=0;
  
  while(1)
    {
      fill(visited ,visited+max_v, false);
      f = dfs(s, INT_MAX/3);
      
      if(f==0)
	{
	  break;
	}
      sum += f;
    }
  return sum;
}


int dfs(int node, int f)
{
  //  cout << "node:" <<node << " f:" << f;
  int d = 0;
 
  if(node == t)//goal
    {
      //  cout <<"f:"<< f << endl;
      return f;
    }
  else if(visited[node]==true)// if visited
    {
      return -1;
    }
  else
    {
      visited[node]=true;//visited
    }

  for(int i=0;i<g[node].size();i++)//root form node
    {
      edge& e = g[node][i];
      // cout <<" e,to:"  <<e.to <<endl;
      if(e.cap != 0)
	{
	  d = dfs(e.to, min(f, e.cap));
	  /*if(dfs(g[node][i].to, f) == 1)
	    {
	    return 1;
	    }*/
	  //   cout << "node:" << node << " f:" << f << " d:" << d << endl;      
	  if(d>0)
	    {
	      e.cap -= d;
	      g[e.to][e.rev].cap += d;
	      
	      return d;
	    }
	}

    }
  return 0;
}


void add_edge(int i, int j)
{
  g[i].push_back({j, i, 1, (int)g[j].size()});
  g[j].push_back({i, j, 0, (int)g[i].size()-1});
}

int get_card()
{
  int red, blue;
  cin >> blue >> red;
  if(blue == 0)
    {
      return -1;
    }
  for(int i=0;i<blue;i++)
    {
      cin >> blue_card[i];
    }
  for(int i=0;i<red;i++)
    {
      cin >> red_card[i];
    }
  
  
  for(int i=0;i<blue;i++)
    {
      for(int j=0;j<red;j++)
	{
	  if(__gcd(blue_card[i], red_card[j])!=1)
	    {// to from cap rev
	      add_edge(i+1, j+blue+1);
	    }
	}
    }

   for(int i=1;i<=blue;i++)
    {
      add_edge(0, i);
    }

   t = blue+red+1;
   for(int i=blue+1;i<t;i++)
     {
       add_edge(i, t);
     }

   /*     for(int i=0;i<=t;i++)
    {
      for(int j=0;j<g[i].size();j++)
	{
	  cout << "{" << g[i][j].from << g[i][j].to << g[i][j].cap << g[i][j].rev << "}";
	}
      cout << endl;
      }*/
   return 0;
}

Measured memory_bytes: 9792
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int t,n;
long long a[205],p[65];
char s[205];
bool insert(long long v)
{
	for(int i=62;i>=0;i--)
	{
		if((v>>i)&1)
		{
			if(!p[i])
			{
				p[i]=v;
				return 1;
			}
			else v^=p[i];
		}
	}
	return 0;
}
bool check(long long v)
{
	for(int i=62;i>=0;i--)
	{
		if((v>>i)&1)
		{
			if(!p[i]) return 1;
			else v^=p[i];
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		memset(p,0,sizeof(p));
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		scanf("%s",s+1);
		bool flag=0;
		for(int i=n;i>=1;i--)
		{
			if(s[i]=='0') insert(a[i]);
			else if(check(a[i])) flag=1;
		}
		if(flag) puts("1");
		else puts("0");
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5 + 1;
const lli mod = 1e9 + 7;
lli n, a, b;

lli fat[maxN];
lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = (ans * x) % mod;
    x = (x * x) % mod, y >>= 1LL;
  }
  return ans;
}
lli inv(lli x)
{
  return modPow(x, mod - 2);
}
lli choose(lli nn, lli k)
{
  lli res = 1;
  for (lli i = nn; i > nn - k; i --)
    res = (res * i) % mod;
  return res * inv(fat[k]) % mod;
}

int main()
{
  fat[0] = 1;
  for (lli i = 1; i < maxN; i ++)
    fat[i] = fat[i - 1] * i % mod;

  while (scanf("%lld %lld %lld", &n, &a, &b) != EOF)
  {
    lli ans = (modPow(2, n) - choose(n, a) - choose(n, b) - 1LL + mod + mod) % mod;
    if (ans < 0)
      while (1);
    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

const LL INF = 1e18 + 2137;
const int N = 51 * 5002 + 2137;
vector<pair<int, LL>> V[N];
LL odl[N];

void djikstra(int src) {
	odl[src] = 0;
	set<pair<LL, int>> S;
	S.insert(make_pair((LL) 0, src));
	while(!S.empty()) {
		pair<LL, int> tmp = *(S.begin());
		S.erase(S.begin());
		int v = tmp.second;
		for(int i=0; i<V[v].size(); i++) {
			int u = V[v][i].first;
			LL waga = V[v][i].second;
			if(odl[u] > odl[v] + waga) {
				if(odl[u] != INF)
					S.erase(S.find(make_pair(odl[u], u)));
				odl[u] = odl[v] + waga;
				S.insert(make_pair(odl[u], u));
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, s;
	cin>>n>>m>>s;
	s = min(s, 5000);
	int u, v, a, b;
	for(int i=0; i<m; i++) {
		cin>>u>>v>>a>>b;
		for(int j=a; j<=5000; j++) {
			V[j*n+u].push_back({(j-a)*n+v, b});
			V[j*n+v].push_back({(j-a)*n+u, b});
		}
	}
	int c, d;
	for(int i=1; i<=n; i++) {
		cin>>c>>d;
		for(int j=0; (j+c) <= 5000; j++) {
			V[j*n+i].push_back({(j+c)*n+i, d});
		}
	}
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=5000; j++)
			odl[j*n+i] = INF;
	}
	int nrstartowy = s*n + 1;
	djikstra(nrstartowy);
	for(int i=2; i<=n; i++) {
		LL odlx = INF;
		for(int j=0; j<=5000; j++) {
			odlx = min(odlx, odl[j*n+i]);
		}
		cout<<odlx<<"\n";
	}
}


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

int main(){
	char b,a;
	cin >> b;
	if(b=='A')a='T';
	if(b=='C')a='G';
	if(b=='G')a='C';
	if(b=='T')a='A';
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int a[110000];
struct lll
{
    int x,y,weizhi;
}sx[110000],sy[110000];
struct llll
{
    int x,y,cha;
}s1[110000*4];

int cmp1(lll x,lll y)
{
    return x.x<y.x;
}
int cmp2(lll x,lll y)
{
    return x.y<y.y;
}
int cmp3(llll x,llll y)
{
    return x.cha<y.cha;
}

int find(int n)
{
    if(n==a[n])
        return n;
    return find(a[n]);
}
int panduan(int n,int m)
{
    int n1=find(n);
    int m1=find(m);
    if(n1==m1)
        return 0;
    a[n1]=min(n1,m1);
    a[m1]=min(n1,m1);
    return 1;
}
int  main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        a[i]=i;
        cin>>sx[i].x>>sx[i].y;
        sx[i].weizhi=i;
        sy[i]=sx[i];
    }
    sort(sx+1,sx+1+n,cmp1);
    sort(sy+1,sy+n+1,cmp2);
    for(int i=1;i<n;i++)
    {
        s1[i].x=sx[i].weizhi;
        s1[i].y=sx[i+1].weizhi;
        s1[i].cha=sx[i+1].x-sx[i].x;
        s1[i+n-1].x=sy[i].weizhi;
        s1[i+n-1].y=sy[i+1].weizhi;
        s1[i+n-1].cha=sy[i+1].y-sy[i].y;
    }
    sort(s1+1,s1+1+2*n-2,cmp3);
    int sum=0;
    for(int i=1;i<=2*n-2;i++)
    {
        //cout<<s1[i].x<<"_"<<s1[i].y<<"_"<<s1[i].cha<<endl;
        if(panduan(s1[i].x,s1[i].y))
            sum+=s1[i].cha;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main()
{
    int n, dif=0, sum=0, i;
    cin>>n;

    int x[n], y[n];

    for(i=0; i<n; i++){
        cin>>x[i];
    }
    for(i=0; i<n; i++){
        cin>>y[i];
    }

    for(i=0; i<n; i++){
        dif = x[i]-y[i];
        if(dif>0)
            sum = sum + dif;
    }

    cout<<sum;
}


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

using namespace std;

typedef long long int lli;

int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    a+=b;
    c+=d;
    if(a>c)cout<<"Left";
    else if(c>a)cout<<"Right";
    else cout<<"Balanced";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        boolean flag = true;

        while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 1) flag = false;
                else a[i] /= 2;
            }

            if (flag) count++;
            else break;
        }

        System.out.println(count);
    }
}


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

 int main() {
   int N, X, Y;
   cin >> N >> X >> Y;

   vector<vector<int>> Graph(N);
   vector<int> ans(N, 0);

   Graph.at(0).push_back(1);
   rep(i, 1, N - 1) {
     Graph.at(i).push_back(i - 1);
     Graph.at(i).push_back(i + 1);
   }
   Graph.at(N - 1).push_back(N - 2);

   Graph.at(X - 1).push_back(Y - 1);
   Graph.at(Y - 1).push_back(X - 1);

   rep(i, 0, N) {
     vector<int> dist(N, -1);
     queue<int> que;
     dist.at(i) = 0;
     que.push(i);

     while (!que.empty()) {
          int v = que.front();
          que.pop();
          for (int nv : Graph.at(v)) {
              if (dist.at(nv) != -1) continue;
              dist.at(nv) = dist.at(v) + 1;
              que.push(nv);
          }
      }

      rep(i, 0, N) ans.at(dist.at(i))++;
   }

   rep(i, 1, N) cout << ans.at(i) / 2 << endl;
 }


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

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

	return 0;
}



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

using namespace std;

using int64 = long long;

int main()
{
  int64 N, X[200000], S[200000];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> S[i];
  }

  // ∑_{i=L}^{R} S[i] - (X[R]-X[L])
  // ∑_{R} S[i] - ∑_{L-1} S[i] + (X[L] - X[R])
  // Z[i] = ∑_{i} S[i]
  // Z[R]-Z[L-1]+X[L]-X[R]
  // (X[L]-Z[L-1]) + (Z[R]-X[R])

  int64 ret = 0;
  int64 beet = 0, sum = 0;
  for(int i = 0; i < N; i++) {
    beet = max(beet, X[i] - sum);
    sum += S[i];
    ret = max(ret, beet + sum - X[i]);
  }
  cout << ret << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        string si;
        cin >> si;
        for (int j = 0; j < w; j++) {
            c[i][j] = si[j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (c[i][j] == '#') {
                cout << '#';
                continue;
            }
            int count = 0;
            for (int y = max(0, i - 1); y <= min(h - 1, i + 1); y++) {
                for (int x = max(0, j - 1); x <= min(w - 1, j + 1); x++) {
                    if (c[y][x] == '#') {
                        count++;
                    }
                }
            }
            cout << count;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
 
#define DEBUG
#define NMAX 100000
 
using namespace std;
 
typedef struct s{
    int y,c;
} S;
 
double p;
double AddC;
double sum2=0;
int N;

vector<S> v[NMAX+1];
bool f[NMAX+1];

double dfs(int n,double P,int C){
    //cout<<n<<","<<P<<","<<C<<endl;
    double sum=0;
    for(int i=0;i<v[n].size();i++){
        if(f[v[n][i].y]==false){
            f[v[n][i].y]=true;
            sum+=dfs(v[n][i].y,P*p,v[n][i].c);
        }
    }
    //cout<<"ret:"<<sum<<endl;
    return (double)C+sum*p;
}
 
double dfs2(int n,double P,int C){
    double sum=0;
    for(int i=0;i<v[n].size();i++){
        if(f[v[n][i].y]==false){
            f[v[n][i].y]=true;
            sum+=dfs2(v[n][i].y,P*p,v[n][i].c);
        }
    }
    return (double)C+sum*p+AddC;
}
 
int main(){
    int x,y,c;
 
    cin>>p;
    cin>>N;
     
    for(int i=0;i<N-1;i++){
        cin>>x>>y>>c;
        S SS;
        SS.y=y;
        SS.c=c;
        v[x].push_back(SS);
        SS.y=x;
        v[y].push_back(SS);
    }

    for(int i=0;i<=N;i++) f[i]=false;
    f[1]=true;
    AddC=dfs(1,1,0);
    //cout<<AddC<<endl;
    for(int i=0;i<=N;i++) f[i]=false;
    f[1]=true;
    printf("%.8f\n",dfs2(1,1,0));
}



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

int main() {
  string s;
  cin >> s;
  
  if (s.size() == 2) {
    cout << s << endl;
    return 0;
  }
  
  reverse(s.begin(),s.end());
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i,count=0;
  for(i=0;i<s.size();i++){
    if(i%2==0 && s.at(i)=='L'){
      count++;
    }
    if(i%2==1 && s.at(i)=='R'){
      count++;
    }
  }
  if(count>0){
    cout << "No";
  }else{
    cout << "Yes";
  }
  
}
 
 

Measured memory_bytes: 256