akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> X(1010, 0);
  for (ll i = 0; i < N; i++)
  {
    ll L;
    cin >> L;
    X.at(L)++;
  }

  ll ans = 0;
  for (ll a = 1; a <= 1000; a++)
  {
    for (ll b = a; b <= 1000; b++)
    {
      for (ll c = b; c <= 1000; c++)
      {
        if (a < b + c && b < c + a && c < a + b)
        {
          if (a == b && b == c)
            ans += X.at(a) * (X.at(b) - 1) * (X.at(c) - 2) / 6;
          else if (a == b)
            ans += X.at(a) * (X.at(b) - 1) * X.at(c) / 2;
          else if (b == c)
            ans += X.at(a) * X.at(b) * (X.at(c) - 1) / 2;
          else
            ans += X.at(a) * X.at(b) * X.at(c);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b ,c;
    cin >> a>> b >> c;
    if(a + b == c || a + c == b || b+ c == a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n, m, X, Y;
    int xWest, xEast, yWest, yEast;
    int x[100], y[100];
    cin >> n >> m >> X >> Y;
    xWest = xEast = X;
    yWest = yEast = Y;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];
    for (int i = 0; i < n; i++) {
        xWest = min(xWest, x[i]);
        xEast = max(xEast, x[i]);
    }
    for (int i = 0; i < m; i++) {
        yWest = min(yWest, y[i]);
        yEast = max(yEast, y[i]);
    }
    cout << (xEast < yWest ? "No " : "") << "War" << endl;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(n==2){
    if(s.at(0)==s.at(1)){
      cout << 1 << " " << 2 << endl;
    }else{
      cout << -1 << " " << -1 << endl;
    }
    return 0;
  }
  for (int i = 0; i <= n - 3;i++){
    if(s.at(i)==s.at(i+1) || s.at(i+1)==s.at(i+2) || s.at(i+2)==s.at(i)){
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
n=int(input())
lists=[]
if n>=2:
    for i in range(n):
        a,b=map(int,input().split())
        lists.append([a,b])
    diflist=[]
    for i in range(n):
        for j in range(n):
            if i!=j:
                add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
                diflist.append(add)
            else:
                continue
    import collections
    dic=collections.Counter(diflist)
    value=dic.values()
    a=max(value)
    print(n-a)
else:
    print(1)

Measured memory_bytes: 3828
from itertools import accumulate
from bisect import bisect, bisect_left
from functools import reduce
from itertools import accumulate, product
from operator import itemgetter, xor, mul
from math import sqrt
from random import randint, random
from heapq import heappop, heappush

from fractions import gcd
from collections import Counter, deque, defaultdict

import sys
input = sys.stdin.readline
from sys import setrecursionlimit
setrecursionlimit(10**9)

def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
l = bisect_left(A, 0)
if l == 0:
    ans = []
    for i in range(N-2, 0, -1):
        ans.append("{} {}".format(str(A[0]), str(A[i])))
        A[0] -= A[i]
    ans.append("{} {}".format(str(A[-1]), str(A[0])))
    score = A[-1] - A[0]

elif l == N:
    ans = []
    for i in range(N-1):
        ans.append("{} {}".format(str(A[-1]), str(A[i])))
        A[-1] -= A[i]
    score = A[-1]

else:
    ans = []
    for i in range(l, N-1):
        ans.append("{} {}".format(str(A[0]), str(A[i])))
        A[0] -= A[i]
    for i in range(l):
        ans.append("{} {}".format(str(A[-1]), str(A[i])))
        A[-1] -= A[i]
    score = A[-1]
print(score)
print(*ans, sep="\n")


Measured memory_bytes: 99948
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

int main(int argc, char const *argv[]){
    int n,k;
    cin >> n >> k;

    vector<int> h;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        h.push_back(a);
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (h[i] >= k)
        {
            cnt += 1;
        }
    }
    
    cout << cnt ;
       
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f;
  long long min,max,sum;
  //vector<vector<int>> A(n, vector<int>(m, 0));
  vector<int> B(26, 0);
  string s,g;
  string s1,s2;
  int n1,n2;
  
  n1 = 0;
  n2 = 0;

  cin >> s;
    cin >> n;
    for(int i=0;i<n;++i){
      cin >> g;
      if(g == "print"){
        cin >> n1 >> n2;
        for(int i=n1; i <= n2; i++){
        	cout << s[i];
        }
        cout << endl;
      } else if(g == "reverse"){
        cin >> n1 >> n2;
		string rs;
        for(int i=n2; i >= n1; i--){
			rs += s[i];
        }
        sum = 0;
      	for(int i=n1; i <= n2; i++){
			s[i ]= rs[sum];
          sum++;
        }
      } else {
        cin >> n1 >> n2;
        cin >> s1;
        sum = 0;
        for(int i=n1; i <= n2; i++){
			s[i]= s1[sum];
          sum++;
        }
      }
      
    }

}


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

int main() {
  int a, b, c, d = 0;
  cin >> a ;
  if(a % 10 == 1){d++;}
  a  /= 10;
  if(a % 10 == 1){d++;}
  a  /= 10;
  if(a % 10 == 1){d++;}
  cout << d << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

int main(){fastio
    
    ll n,m;cin>>n>>m;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    ll s[n+1];s[0]=0;
    rep(i,1,n)s[i]=(s[i-1]+a[i])%m;
    sort(s,s+n+1);
    ll ans=0;
    rep(i,0,n){
        ll c=1;
        while(i<=n-1&&s[i]==s[i+1]){
            c++;i++;
        }
        ans+=c*(c-1)/2;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
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) {
		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;
}
struct edge { int to, cost; };
signed main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	rep(i, n)cout << s[i] << t[i];
	cout << endl;
	ggr
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int unsigned __int128
//#define ll unsigned __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);

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

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef RUS_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#else
    //freopen("dictionary.in", "r", stdin);
    //freopen("dictionary.out", "w", stdout);
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int N = 2e3 + 100, oo = 1e9;


void smain() {
    int n, x;
    cin >> n >> x;
    cout << 3 * (n - __gcd(n, x));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=2e5+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int n,h[mxN],v[mxN],bit[mxN];
void upd(int pos,int val){
    while(pos<mxN){
        bit[pos]=max(bit[pos],val);
        pos+=(pos&-pos);
    }
}
int query(int pos){
    int ans=0;
    while(pos>0){
        ans=max(ans,bit[pos]);
        pos-=(pos&-pos);
    }
    return ans;
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];h[i]++;
    }
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<n;i++){
        int temp=query(h[i]-1)+v[i];
        upd(h[i],temp);        
    }
    cout<<query(mxN-1);
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{

    final static Scanner sc = new Scanner(System.in);
    static int res = 0;
    public static void main(String[] args) {
        System.out.println(C());
    }

    public static int C(){
        int N = sc.nextInt();
        for (int i = 1; i <= N; i++) {
            res = (res*10+7)%N;
            if (res == 0) {
                return i;
            }
        }
        return -1;
    }
}


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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))

using namespace std;

string s;
int word[30];


ll solve() {
	int n = sz(s);
	if(n == 1) return 1;
	rep(i, 0, n) word[s[i]-'a']++;
	ll num = 1LL * (n-1) * n / 2;
	rep(i, 0, 30) if(word[i] > 1) {
		ll k = 1LL * (word[i]-1) * word[i] / 2;
		num -= k;
	}
	return num+1;
}

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> s;
	zero(word);
	cout << solve() << endl;

	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


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

int main(){
    unsigned long x, y;
    cin >> x >> y;
    bitset<32> a(x), b(y);

    cout << (a&b) << endl;
    cout << (a|b) << endl;
    cout << (a^b) << endl;

    return 0;
}


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

void solve(){
    
}

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

    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0; i<s.length(); i++){
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt<<"\n";
      
    return 0;
}

Measured memory_bytes: 3796
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int h[] = new int[n];

		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
		}

		Arrays.sort(h);
		int minDiff = Integer.MAX_VALUE;

		for(int i = 0; i + k - 1 < n; i++){
			minDiff = Math.min(minDiff, h[i + k - 1] - h[i]);
		}
		System.out.println(minDiff);
	}
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  //cout<<<<endl;

  
  set<ll> a;
  for(i=0;i<n;i++){
    cin >> buf;
    a.insert(buf);
  }
  /*for(i=0;i<n;i++){

  }*/
  cout<<a.size()<<endl;
  

  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp;

#[allow(dead_code)]
fn readval<T: FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    
    buf.trim().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn readvec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();

    buf.trim().split(" ")
              .map(|c| c.parse::<T>().ok().unwrap())
              .collect::<Vec<T>>()
}

fn find_mp(a: usize, b: usize, c: usize, abc: &Vec<usize>) -> usize {
    if a == 0 || b == 0 || c == 0 {
        return 10_usize.pow(9);
    }
    
    let mut res = vec![a,b,c];
    let mut ans = 0;

    res.sort();

    for i in 0..3 {
        ans += ((res[i] as isize) - (abc[i] as isize)).abs();
    }

    return ans as usize
}

fn find_minmp(l: &Vec<usize>,
              depth: usize,
              a: usize, 
              b: usize, 
              c: usize, 
              abc: &Vec<usize>) -> usize {
    
    //println!("a:{} b:{} c:{}", a,b,c);

    if depth == l.len() {
        return find_mp(a, b, c, abc);
    }
    
    else {
        let mut ans = 10usize.pow(9);
        ans = cmp::min(ans, find_minmp(l, depth+1, a+l[depth], b, c, abc) + 10);
        ans = cmp::min(ans, find_minmp(l, depth+1, a, b+l[depth], c, abc) + 10);
        ans = cmp::min(ans, find_minmp(l, depth+1, a, b, c+l[depth], abc) + 10);
        
        ans = cmp::min(ans, find_minmp(l, depth+1, a, b, c, abc));
        return ans
    }
}

fn main() {
    //println!("Hello, world!");
    let nabc: Vec<usize> = readvec();
    let mut abc = vec![];
    for i in 1..4 {
        abc.push(nabc[i]);
    }
    abc.sort();

    let mut l: Vec<usize> = vec![];
    for _ in 0..nabc[0] {
        l.push(readval());
    }
    let ans = find_minmp(&l, 0, 0, 0, 0, &abc);

    println!("{}", ans-30);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define CVector CPoint
#define INF 0x3f3f3f3f
#define MAXN 1e5
const LL mod=1e9+7;
const double PI=acos(-1.0);
const double EPS=1e-10;

inline int readint(){
  int sum=0;char c=getchar();bool f=0;
  while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}
  while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}
  if(f) return -sum;
  return sum;
}

inline LL readLL(){
  LL sum=0;char c=getchar();bool f=0;
  while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}
  while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}
  if(f) return -sum;
  return sum;
}

const int maxn=1e5+5;
LL inv[maxn],p[maxn];
void init(int n,LL mod){
    inv[1]=inv[0]=1;
    p[0]=p[1]=1;
    for(int i=2;i<=n;i++){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        p[i]=p[i-1]*i%mod;
    }
    for(int i=2;i<=n;i++){
        inv[i]=inv[i-1]*inv[i]%mod;
    }
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    init(100002,mod);
    int n,m;
    cin>>n>>m;
    if(fabs(n-m)>1){
        cout<<"0"<<endl;
    }else if(n==m){
        LL ans=2;
        ans=ans*p[n]%mod*p[n]%mod;
        cout<<ans<<endl;
    }else{
        LL ans=p[n]*p[m]%mod;
        cout<<ans<<endl;
    }
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


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

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

    for(int i=n-1;i>=0;i-=2) printf("%d ",a[i]);
    for(int i=n%2;i<n;i+=2) printf("%d ",a[i]);
    
    return 0;
}


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

// 未AC
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> A(N), B(N, 0);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  for (int64_t i = 0; i < N; i++) {
    B.at(A.at(i))++;
  }
  int64_t C = 0;
  for (int64_t i = 0; i < N; i++) {
    if (B.at(i)>0 && B.at(i)%2==0) {
      C += B.at(i)/2*(B.at(i)-1);
    }
    else if (B.at(i)>0 && B.at(i)%2!=0) {
      C += (B.at(i)-1)/2*B.at(i);
    }
  }
  for (int i = 0; i < N; i++) {
    cout << C - (B.at(A.at(i))-1) << endl;
  }
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <set>
#include <deque>

using namespace std;


set<int> makeTable(int n, deque<int> a) {
    deque<int> sequence;
    sequence.push_back(0);
    sequence.push_back(a[0]);

    for (int i = 1; i < n; ++i) {
        deque<int> tmp(sequence);
        for (auto item : tmp) {
            sequence.push_back(item + a[i]);
        }
    }

    set<int> result;
    for (auto item : sequence) {
        result.insert(item);
    }

    return result;
}

int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    deque<int> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    set<int> table = makeTable(n, a);


    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int m;
        cin >> m;
        if (table.find(m) != table.end()) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }

    return 0;
}



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

using namespace std;

typedef long long ll;

#define MOD		(1000000007)

int main () {
	ll n, m;
	ll i, j;
	ll ret = 1;
	
	cin >> n;
	for (i=1;i<=n;i++) {
		ret = ret*i % MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[10];
    int i,j;
    while(~scanf("%s",s))
    {
        int n=4;
        char c;
        for(i=0;i<n-1;i++)
            for(j=0;j<n-1-i;j++)
                if(s[j]>s[j+1])
                {
                    c=s[j];
                    s[j]=s[j+1];
                    s[j+1]=c;
                }
        if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])
            printf("Yes\n");
        else
            printf("No\n");
    }
}


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

using namespace std;

int main() {
	int n, m, i, j,on, ans=0, count;
	string a;

	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m);
	vector<int> p(m);
	stringstream ss;
	for (i = 0; i < m; i++) {
		cin >> k[i];
		for (j = 0; j < k[i]; j++) {
			int x;
			cin >> x;
			s[i].push_back(x);
		}
	}
	for (i = 0; i < m; i++) {
		cin >> p[i];
	}
	for (i = 0; i < pow(2,n); i++) {
		count = 0;
		string b = bitset<10>(i).to_string();
		for (j = 0; j < m; j++) {
			on = 0;
			for (int h = 0; h < (int)s[j].size(); h++) {
				if (b[(10-s[j][h])] == '1') {
					on++;
				}
			}
			if ((on % 2) == p[j]) {
				count++;
			}
		}
		if (count == m) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,fix[200005];
string s;
int main() {
  cin>>n>>m;
  for(long long i=1;i<=m;i++) {
  	cin>>a;
  	while(a--){ 
  	cin>>b;
  	if(fix[b]==0) l++;
  	fix[b]=1;
	  }
  }
  cout<<n-l;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int DEFAULT = 0;

typedef long long ll;

//RSQ, RAQ
struct SegmentTree {
    int n;
    vector<ll> heap;
    vector<ll> lazy;
    
    SegmentTree(int n): n(n) {
        heap.assign(4 * n, DEFAULT);
        lazy.assign(4 * n, DEFAULT);
    }
    
    void add(int nodeId, int l, int r, int ql, int qr, int v) {
        if (qr < l || ql > r) {
            return;
        }
        else if (ql <= l && r <= qr) {
            lazy[nodeId] += v;
        }
        else {
            pushdown(nodeId, l, r);
            int m = l + (r - l)/2;
            add(nodeId * 2, l, m, ql, qr, v);
            add(nodeId * 2 + 1, m + 1, r, ql, qr, v);
            pushup(nodeId, l, r);
        }
    }
    
    void pushdown(int nodeId, int l, int r) {
        if (lazy[nodeId] > 0) {
            lazy[nodeId * 2] += lazy[nodeId];
            lazy[nodeId * 2 + 1] += lazy[nodeId];
            heap[nodeId] += lazy[nodeId] * (r - l + 1);
            lazy[nodeId] = 0;
        }
    }
      
      void pushup(int nodeId, int l, int r) {
          int m = l + (r - l)/2;
          heap[nodeId] = getSum(nodeId * 2, l, m) + getSum(nodeId * 2 + 1, m + 1, r);
      }
      
      ll getSum(int nodeId, int l, int r) {
           return lazy[nodeId] * (r - l + 1) + heap[nodeId];
        
      }
    
    ll query(int nodeId, int l, int r, int ql, int qr) {
        if (qr < l || ql > r) {
            return DEFAULT;
        }
        if (ql <= l && r <= qr) {
            return getSum(nodeId, l, r);
        } 
        else {
            pushdown(nodeId, l, r);
            int m = l + (r - l)/2;
            return query(nodeId * 2, l, m, ql, qr) + 
                   query(nodeId * 2 + 1, m + 1, r, ql, qr);
        }
    }  
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree st(n);
    for (int i = 0; i < q; i++) {
        int cmd;
        cin >> cmd;
        if (cmd == 0) {
            int ql, qr, v;
            cin >> ql >> qr >> v;
            st.add(1, 1, n, ql, qr, v);
            
        }
        else {
            int ql, qr;
            cin >> ql >> qr;
            cout << st.query(1, 1, n, ql, qr) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 9176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    VI a(n), b(m);
    REP(i,n) a[i] = in();
    REP(i,m) b[i] = in();

    VVL dp(n + 1, VL(m + 1));
    VL sum(m, 1);
    dp[0][0] = 1;
    REP(i,n){
        REP(j,m){
            if (a[i] == b[j]) dp[i + 1][j + 1] = sum[j];
        }
        ll tmp = 0;
        REP(j,m){
            tmp = (tmp + dp[i + 1][j]) % mod;
            sum[j] = (sum[j] + tmp) % mod;
        }
    }

    ll ans = 0;
    REP(i,n+1) REP(j,m+1) ans = (ans + dp[i][j]) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9


int main(){
    ll N,ans=0;
    cin >> N;
    for (ll i = 1 ; i <= N; i++)
    {
        if(i%3==0 || i%5==0){
            continue; // while,for文の中でこの後の操作を飛ばして次のループへとぶ
        }
        ans += i;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const long long INF = static_cast<long long>(1.05e18);
using namespace std;

const long long MAX_V = 5005;

class Edge{
    public:
        int to;
        long long cap;
        int rev;
};

vector<Edge> G[MAX_V];
bool used[MAX_V];

void addEdge(int from, int to, long long cap){
    G[from].emplace_back(Edge{to, cap, static_cast<int>(G[to].size())});
    G[to].emplace_back(Edge{from, 0, static_cast<int>(G[from].size() - 1)});
}

long long dfs(int v, int t, long long f){
    if(v == t) return f;
    used[v] = true;
    rep(i,G[v].size()){
        Edge &e = G[v][i];
        if(not used[e.to] && e.cap > 0){
            long long d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

long long maxFlow(int s, int t){
    long long flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        long long f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

void countNode(int current){
    used[current] = true;
    rep(i,G[current].size()){
        if(G[current][i].cap > 0 && not used[G[current][i].to]){
            countNode(G[current][i].to);
        }
    }
}

void solve(int n, int m){
    int a, b;
    long long c;
    rep(i,m){
    cin >> a >> b >> c;
    addEdge(a,b,c);
    }
    cout << maxFlow(0,n - 1) << endl;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    solve(n,m);
    return 0;
    const int source = n, sink = n + 1;
    long long c[MAX_V];
    rep(i,n){
        scanf("%lld",&c[i]);
        if(c[i] > 0) addEdge(source, i, c[i]);
        else if(c[i] < 0) addEdge(i,sink, -c[i]);
    }
    rep(i,m){
        int a, b;
        scanf("%d%d",&a,&b);
        a--; b--;
        addEdge(a,b,INF);
    }

    maxFlow(source,sink);
    memset(used, 0,sizeof(used));
    countNode(source);
    long long sum = 0,cnt = 0;
    rep(i,n){
        if(used[i]){
            sum += c[i];
            cnt++;
        }
    }
    printf("%lld %lld\n",cnt,sum);
}

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

const int mod = 1000000007;
struct mint {
    ll x;

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

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

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

  string s1, s2;
  cin >> s1 >> s2;

  mint answer = 1;
  for (int i = 0; i < n;) {
    if(i == 0) {
      if(s1[i] == s2[i]) {
        answer *= 3;
        i += 1;
      } else {
        answer *= 6;
        i += 2;
      }
    } else {
      if(s1[i] == s2[i]) {
        if(s1[i - 1] == s2[i - 1]) answer *= 2;
        else answer *= 1;

        i += 1;
      } else {
        if(s1[i - 1] == s2[i - 1]) answer *= 2;
        else answer *= 3;
        i += 2;
      }
    }
  }

  cout << answer.x << '\n';
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		Point r[] = new Point[n];
		Point b[] = new Point[n];
		
		for(int i=0;i<n;i++){
			r[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		for(int i=0;i<n;i++){
			b[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		
		Arrays.sort(r, new Comparator<Point>(){
			public int compare(Point o1, Point o2) {
				return o1.x - o2.x;
			}
		});
		
		Arrays.sort(b, new Comparator<Point>(){
			public int compare(Point o1, Point o2) {
				return o1.x - o2.x;
			}
		});
		
		boolean v[] = new boolean[n];
		int ans = 0;
		for(int i=0;i<n;i++){
			int max = -1;
			int idx = -1;
			for(int j=0;j<n && b[i].x > r[j].x;j++){
				if(!v[j] && b[i].y>r[j].y && r[j].y>max){
					max = r[j].y;
					idx = j;
				}
			}
			if(idx != -1){
				ans++;
				v[idx] = true;
			}
		}
		System.out.println(ans);
		
	}
}
class Point{
	int x, y;
	Point(int _x, int _y){
		x = _x;
		y = _y;
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,k,j;
	j = 0;
	int s[105] = {0};
	cin >> a>>b>>k;
	for (int i = min(a,b); i >= 1; i--) {
		if (a%i == 0 && b%i == 0) {
			j++;
			s[j] = i;
		}
	}
	cout << s[k] << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()
for na,a in enumerate(L[:N-2]):
    for nb_,b in enumerate(L[na+1:N-1]):
        nb = nb_+na+1
        nc = bisect_left(L,a+b)
        ans += nc-nb-1
print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
 
int main(){
    int a,b;scanf("%d%d",&a,&b);
    long long ret=0;
    for(int i=b+1;i<=a;i++){
        for(int j=0;j<=a/i;j++){
            int nd=j*i;
            int am=min(1+a-nd,i);
            int rm=max(0,am-b);
      //      printf("%d %d: %d\n",i,j,rm);
            ret+=rm;
            if(rm&&j==0&&b==0)ret--;
        }
    }
    printf("%lld\n",ret);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextLine()
	mm := map[string]string{
		"Sunny":  "Cloudy",
		"Cloudy": "Rainy",
		"Rainy":  "Sunny",
	}

	fmt.Println(mm[n])
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+2,0);
    for(int i=1;i<=N;i++) cin >> A[i];

    vector<int> S;
    int sum = 0;
    for(int i=1;i<=N+1;i++){
        S.push_back(abs(A[i]-A[i-1]));
        sum += S[i-1];
    }

    vector<int> ans;
    for(int i=1;i<=N;i++){
        ans.push_back(sum-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))+abs(A[i-1]-A[i+1]));
    }

    for(int x : ans){
        cout << x << endl;
    }
}


Measured memory_bytes: 2552
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}

void main() {
	auto N = readInt();
	while(true) {
		alias Tuple!(int, int, string) t;
		t[] s;
		foreach(i; 0..N) {
			auto l = readln().strip().split();
			s ~= t(-(to!int(l[1])*3+to!int(l[3])), i, l[0]);
		}
		s.sort();
		foreach(ss; s) {
			writeln(ss[2], ",", -ss[0]);
		}

		N = readInt();
		if(N == 0) {
			break;
		}
		writeln();
	}
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // *or+でnまでずっとひくいほうやってけばいいのでは？
  int N,K;
  cin >>N>>K;
   int a=1;
   int A=1,B=1;
  for(int i=0;i<N;i++){
    A=a*2;
    B=a+K;
    if(B>=A){
      a*=2;
  }
      if(B<A){
        a+=K;
      }
  }
  cout << a <<endl;

}


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

int main(){
	int k;
	cin >> k;
	
	int cnt = 0;
	
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			if(i == j) continue;
			if((i %2 == 1) && (j % 2 == 0)) cnt++;
		}
	}
	
	cout << cnt << endl;
	return 0;
}

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

int h, w;
string S;
char A[222][222];

int main ()
{
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		cin >> S;
		for (int j = 0; j < w; j++) A[i][j+1] = S[j];
	}

	for (int i = 1; i <= 2 * h; i++) {
		for (int j = 1; j <= w; j++) {
			cout << A[(i+1)/2][j];
		}
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
int a[500005];
vector <pair <int, int> > occ[1 << 20];
vector <int> dp;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", a + i);
	for (int i = 2; i <= n; ++ i) a[i] ^= a[i - 1];
	int cnt0 = 0;
	for (int i = 1; i <= n; ++ i) cnt0 += a[i] == 0;
	if (cnt0) {
		map <int, int> cnt;
		int cntr = 0;
		for (int i = 1; i <= n; ++ i) {
			cnt[a[i]] ++;
			if (a[i] == 0 || i == n) {
				for (map <int, int> :: iterator it = cnt.begin(); it != cnt.end(); ++ it) {
					occ[it -> first].push_back(make_pair(it -> second, cntr));
				}
				cnt.clear();
				cntr ++;
			}
		}
		int ans = 0;
		int cur = 1;
		for (int i = 1; i < cnt0; ++ i) cur = 2LL * cur % mod;
		ans = a[n] == 0 ? cur : 0;
		for (int i = 1; i < (1 << 20); ++ i) {
			if (occ[i].empty()) continue;
			if (a[n] != 0 && i != a[n]) continue;
			dp.resize(occ[i].size());
			int sum = 0, cur = 0;
			for (int j = 0; j < (int) occ[i].size(); ++ j) {
				if (j) cur = (cur + 1LL * sum * (occ[i][j].second - occ[i][j - 1].second) % mod) % mod;
				dp[j] = 1 + cur;
				if (a[n] == 0 || j != (int) occ[i].size() - 1) dp[j] = 1LL * dp[j] * occ[i][j].first % mod;
				if (a[n] == 0) ans = (ans + dp[j]) % mod;
				else if (j == (int) occ[i].size() - 1) ans = (ans + dp[j]) % mod;
				sum = (sum + dp[j]) % mod;
			}
		}
		printf("%d\n", ans);
	}
	else puts("1");
	return 0;
}

Measured memory_bytes: 37104
#include <bits/stdc++.h>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
 
int main() {
	int N; cin >> N;
	string s; cin >> s;
	int M = s.length();
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int t = 0; t < N; t++) {
		vector<int> _dp(N + 1);
		for (int x = 0; x <= t; x++) {
			_dp[x + 1] = (_dp[x + 1] + dp[x]) % MOD;
			if (x) _dp[x - 1] = (_dp[x - 1] + dp[x] * 2LL) % MOD;
			else _dp[x] = (_dp[x] + dp[x]) % MOD;
		}
/*		cout << "at " << t+1 << " phase:\n";
		cout << "dp: ";
		for(int j = 0 ; j <= N ; j ++) cout << dp[j] << " ";cout << endl;
		cout << "_dp: ";
		for(int j = 0 ; j <= N ; j ++) cout << _dp[j] << " ";cout << endl;
*/		dp = _dp;
	}
	cout << dp[M] << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
const int MOD = (int)1e6 + 3;

const int N = MOD;
ll fact[N];
ll inv_fact[N];

ll modPow(ll a, ll b) {
	if (b & 1) return a * modPow(a, b-1) % MOD;
	if (b == 0) return 1;
	return modPow(a*a % MOD, b / 2);
}

ll intProd(int a, int b) {
	if (a <= 0 || b >= MOD) return 0;
	return fact[b] * inv_fact[a-1] % MOD;
}

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

	fact[0] = 1;
	for (int i = 1; i < MOD; ++i) fact[i] = i * fact[i-1] % MOD;
	for (int i = 0; i < MOD; ++i) inv_fact[i] = modPow(fact[i], MOD-2);

	int q;
	cin >> q;
	for (int qi = 0; qi < q; ++qi) {
		int x, d, n;
		cin >> x >> d >> n;

		// \prod_{i = 0}^{n-1} (x + id)
		// = d^{n} \prod_{i = 0}^{n-1} (x/d + i)

		if (d == 0) {
			cout << modPow(x, n) << '\n';
		} else {
			int a = x * modPow(d, MOD-2) % MOD;
			int b = a + n-1;
			ll res = modPow(d, n) * intProd(a, b) % MOD;
			cout << res << '\n';
		}
	}
}


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

using namespace std;

using ll = long long;

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

    ll x;
    cin >> x;

    ll lb = -1, ub = x;
    while (1 < ub - lb) {
        ll mid = (ub + lb) >> 1;
        ll sum = mid * (mid + 1) / 2;
        if (x <= sum) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;

    return 0;
}


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

red_list=[]
for i in range(N):
  a,b=map(int,input().split())
  red_list.append((a,b))
red_list.sort()
  
blue_list=[]
for i in range(N):
  c,d=map(int,input().split())
  blue_list.append((c,d))
blue_list.sort()

#print(red_list)
#print(blue_list)

answer=0
selected_set=set()
for i in range(N):
  c,d=blue_list[i]
  max_y=-1
  maxarg_y=-1
  for j in range(N):
    a,b=red_list[j]
    if c<=a:
      break
    
    if b<d and b>max_y and not j in selected_set:
      max_y=b
      maxarg_y=j
      
  if maxarg_y!=-1:
    answer+=1    
    selected_set.add(maxarg_y)
    #print(red_list[maxarg_y],blue_list[i])
    
print(answer)

Measured memory_bytes: 3192
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    rep (i, m) cin >> b[i];
    vector<vector<int>> a(n);
    rep (i, n) a[i].resize(m);

    rep (i, n) {
        rep (j, m) cin >> a[i][j];
    }

    int ans = 0;
    rep (i, n) {
        int val = c;
        rep (j, m) {
            val += (a[i][j]*b[j]);
        }
        if (val > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int inf = 1e9;

int main(){
    int p=inf, j=inf;
    for(int i=0; i<3; i++){
        int a;
        cin >> a;
        p = min(p, a);
    }
    for(int i=0; i<2; i++){
        int a;
        cin >> a;
        j = min(j, a);
    }
    cout << p+j-50 << endl;
    return 0;
}



Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println((n * (n - 1)) / 2)
}


Measured memory_bytes: 640
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main() {

	cin>>N;



	cout<<N/3<<endl;

 	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int i1,i2;
        long l1 = 1;
        long l2 = 1;
        for (int k = 0;k < i - 2;++k){
            long l3 = l1;
            l1 = l2;
            l2 += l3;
        }
        if(i == 1){
            l1 = 0;
        }
        System.out.println(l1 * 2 + l2);
    }


}

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

int main(){
    int W, H, N;
    int x[101], y[101], a[101];
    int xmin, xmax, ymin, ymax;
    cin >> W >> H >> N;

    xmin = 0; xmax = W; ymin = 0; ymax = H;

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

    for(int i = 0; i < N; ++i){
        if(a[i] == 1){
            if(xmin < x[i])
            xmin = x[i];
        }else if(a[i] == 2){
            if(xmax > x[i])
            xmax = x[i];
        }else if(a[i] == 3){
            if(ymin < y[i])
            ymin = y[i];
        }else if(a[i] == 4){
            if(ymax > y[i])
            ymax = y[i];
        }
    }

    int ans;
    if(xmax > xmin && ymax > ymin){
        ans = (xmax - xmin) * (ymax - ymin);
    }else{
        ans = 0;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#define maxh 20
#define maxn 200005
using namespace std;
const long long mo=1e9+7;
long long h,n,p[maxn];
long long ans=0,tag[maxn*2];
void modify(long long x,long long data)
{
	if(!x) return;
	modify(x/2,data*x%mo);
	tag[x]=(tag[x]+data)%mo;
}
void qk(long long x,long long data)
{
	if(!x) return;
	qk(x/2,data*x%mo);
	tag[x]=(tag[x]-data)%mo;
}
long long que(long long x,long long data,long long a)
{
	if(!x) return 0;
	long long res=data*(tag[x]+mo-a)%mo;
	res+=que(x/2,data*(x/2)%mo,tag[x]*x%mo);
	return res%mo;
}
void work(long long x,long long data)
{
	if(x>=n)
	{
		modify(p[x-n+1]+n-1,data);
		return;
	}
	work(x*2,data*x*2%mo);
	work(x*2+1,data*(x*2+1)%mo);
}
void clear(long long x,long long data)
{
	if(x>=n)
	{
		qk(p[x-n+1]+n-1,data);
		return;
	}
	clear(x*2,data*x*2%mo);
	clear(x*2+1,data*(x*2+1)%mo);
}
long long calc(long long x,long long data)
{
	if(x>=n)  return que(p[x-n+1]+n-1,data*(p[x-n+1]+n-1)%mo,0);
	long long res=0;
	res+=calc(x*2,data*x*2%mo);
	res+=calc(x*2+1,data*(x*2+1)%mo);
	return res%mo;
}
int main()
{
	scanf("%lld",&h);
	n=(1<<(h-1));
	for(long long i=1;i<=n;i++) scanf("%lld",&p[i]);
	for(long long i=1;i<n;i++)
	{
		//memset(tag,0,sizeof(tag)); 
		work(i*2,i*2*i%mo);
		ans=(ans+calc(i*2+1,i*2+1))%mo;
		clear(i*2,i*2*i%mo);
	}
	printf("%lld",ans);
	return 0; 
} 

Measured memory_bytes: 6828